Skip to content

Commit b13da17

Browse files
dwblaikieJDevlieghere
authored andcommitted
DebugInfo: Add parsing support for debug_loc base address specifiers
llvm-svn: 373278 (cherry picked from commit 5ca3066)
1 parent d488f78 commit b13da17

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class DWARFDebugLoc {
6868
/// Return the location list at the given offset or nullptr.
6969
LocationList const *getLocationListAtOffset(uint64_t Offset) const;
7070

71-
static Expected<LocationList>
71+
Expected<LocationList>
7272
parseOneLocationList(const DWARFDataExtractor &Data, uint64_t *Offset);
7373
};
7474

llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ DWARFDebugLoc::parseOneLocationList(const DWARFDataExtractor &Data,
101101

102102
if (Error Err = C.takeError())
103103
return std::move(Err);
104+
104105
// The end of any given location list is marked by an end of list entry,
105106
// which consists of a 0 for the beginning address offset and a 0 for the
106107
// ending address offset.
@@ -109,9 +110,12 @@ DWARFDebugLoc::parseOneLocationList(const DWARFDataExtractor &Data,
109110
return LL;
110111
}
111112

112-
unsigned Bytes = Data.getU16(C);
113-
// A single location description describing the location of the object...
114-
Data.getU8(C, E.Loc, Bytes);
113+
if (E.Begin != (AddressSize == 4 ? -1U : -1ULL)) {
114+
unsigned Bytes = Data.getU16(C);
115+
// A single location description describing the location of the object...
116+
Data.getU8(C, E.Loc, Bytes);
117+
}
118+
115119
LL.Entries.push_back(std::move(E));
116120
}
117121
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
2+
# RUN: llvm-dwarfdump --debug-loc %t.o | FileCheck %s
3+
4+
# CHECK: .debug_loc contents:
5+
# CHECK-NEXT: 0x00000000:
6+
# CHECK-NEXT: [0xffffffffffffffff, 0x000000000000002a):
7+
# CHECK-NEXT: [0x0000000000000003, 0x0000000000000007): DW_OP_consts +3, DW_OP_stack_value
8+
9+
.section .debug_loc,"",@progbits
10+
.quad 0xffffffffffffffff
11+
.quad 42
12+
.quad 3
13+
.quad 7
14+
.short 3 # Loc expr size
15+
.byte 17 # DW_OP_consts
16+
.byte 3 # 3
17+
.byte 159 # DW_OP_stack_value
18+
.quad 0
19+
.quad 0
20+
.section .debug_abbrev,"",@progbits
21+
.byte 1 # Abbreviation Code
22+
.byte 17 # DW_TAG_compile_unit
23+
.byte 0 # DW_CHILDREN_no
24+
.byte 0 # EOM(1)
25+
.byte 0 # EOM(2)
26+
.byte 0 # EOM(3)
27+
.section .debug_info,"",@progbits
28+
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
29+
.Ldebug_info_start0:
30+
.short 4 # DWARF version number
31+
.long .debug_abbrev # Offset Into Abbrev. Section
32+
.byte 8 # Address Size (in bytes)
33+
.byte 1 # Abbrev [1] DW_TAG_compile_unit
34+
.Ldebug_info_end0:

0 commit comments

Comments
 (0)