mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[llvm/DWARF] Return section offset from DWARFUnit::get{Loc,Rng}listOffset
Summary: Currently these function return the raw content of the appropriate table header, which means they are relative to the DW_AT_{loc,rng}list_base, and one has to relocate them in order to do anything. This changes the functions to perform the relocation themselves, which seems more clearer, particularly as they are sitting right next to the find{Rng,Loc}listFromOffset functions, but one *cannot* simply take the result of these functions and take pass them there. The only effect of this patch is to change what value is dumped for the DW_AT_ranges attribute, which I think is for the better, as previously the values appeared to point into thin air. (The main reason I am looking at this is because I was trying to implement equivalent functionality in lldb's DWARFUnit, and was stumped by this behavior. Reviewers: dblaikie, JDevlieghere, aprantl Subscribers: hiraditya, llvm-commits, SouraVX Tags: #llvm Differential Revision: https://reviews.llvm.org/D71006
This commit is contained in:
parent
41da9fac12
commit
c389de3c21
@ -427,14 +427,18 @@ public:
|
|||||||
/// an entry in the rangelist table's offset array and is supplied by
|
/// an entry in the rangelist table's offset array and is supplied by
|
||||||
/// DW_FORM_rnglistx.
|
/// DW_FORM_rnglistx.
|
||||||
Optional<uint64_t> getRnglistOffset(uint32_t Index) {
|
Optional<uint64_t> getRnglistOffset(uint32_t Index) {
|
||||||
if (RngListTable)
|
if (!RngListTable)
|
||||||
return RngListTable->getOffsetEntry(Index);
|
return None;
|
||||||
|
if (Optional<uint64_t> Off = RngListTable->getOffsetEntry(Index))
|
||||||
|
return *Off + RangeSectionBase;
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<uint64_t> getLoclistOffset(uint32_t Index) {
|
Optional<uint64_t> getLoclistOffset(uint32_t Index) {
|
||||||
if (LoclistTableHeader)
|
if (!LoclistTableHeader)
|
||||||
return LoclistTableHeader->getOffsetEntry(Index);
|
return None;
|
||||||
|
if (Optional<uint64_t> Off = LoclistTableHeader->getOffsetEntry(Index))
|
||||||
|
return *Off + getLocSectionBase();
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Expected<DWARFAddressRangesVector> collectAddressRanges();
|
Expected<DWARFAddressRangesVector> collectAddressRanges();
|
||||||
|
@ -91,7 +91,7 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue,
|
|||||||
FormValue.dump(OS, DumpOpts);
|
FormValue.dump(OS, DumpOpts);
|
||||||
|
|
||||||
if (auto LoclistOffset = U->getLoclistOffset(Offset))
|
if (auto LoclistOffset = U->getLoclistOffset(Offset))
|
||||||
Offset = *LoclistOffset + U->getLocSectionBase();
|
Offset = *LoclistOffset;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -629,7 +629,7 @@ DWARFUnit::findRnglistFromOffset(uint64_t Offset) {
|
|||||||
Expected<DWARFAddressRangesVector>
|
Expected<DWARFAddressRangesVector>
|
||||||
DWARFUnit::findRnglistFromIndex(uint32_t Index) {
|
DWARFUnit::findRnglistFromIndex(uint32_t Index) {
|
||||||
if (auto Offset = getRnglistOffset(Index))
|
if (auto Offset = getRnglistOffset(Index))
|
||||||
return findRnglistFromOffset(*Offset + RangeSectionBase);
|
return findRnglistFromOffset(*Offset);
|
||||||
|
|
||||||
if (RngListTable)
|
if (RngListTable)
|
||||||
return createStringError(errc::invalid_argument,
|
return createStringError(errc::invalid_argument,
|
||||||
|
@ -196,14 +196,14 @@ Range1_end:
|
|||||||
# CHECK-NOT: Compile Unit:
|
# CHECK-NOT: Compile Unit:
|
||||||
# CHECK: DW_TAG_compile_unit
|
# CHECK: DW_TAG_compile_unit
|
||||||
# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000014)
|
# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000014)
|
||||||
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000020
|
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000034
|
||||||
# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
|
# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
|
||||||
|
|
||||||
# CHECK: .debug_info.dwo contents:
|
# CHECK: .debug_info.dwo contents:
|
||||||
# CHECK: Compile Unit:
|
# CHECK: Compile Unit:
|
||||||
# CHECK-NOT: contents:
|
# CHECK-NOT: contents:
|
||||||
# CHECK: DW_TAG_compile_unit
|
# CHECK: DW_TAG_compile_unit
|
||||||
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000011
|
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000025
|
||||||
# CHECK-NEXT: [0x0000002a, 0x00000034))
|
# CHECK-NEXT: [0x0000002a, 0x00000034))
|
||||||
|
|
||||||
#ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
|
#ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
|
||||||
|
@ -192,14 +192,14 @@ Range1_end:
|
|||||||
# CHECK-NOT: Compile Unit:
|
# CHECK-NOT: Compile Unit:
|
||||||
# CHECK: DW_TAG_compile_unit
|
# CHECK: DW_TAG_compile_unit
|
||||||
# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
|
# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
|
||||||
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000018
|
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000024
|
||||||
# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
|
# CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
|
||||||
|
|
||||||
# CHECK: .debug_info.dwo contents:
|
# CHECK: .debug_info.dwo contents:
|
||||||
# CHECK: Compile Unit:
|
# CHECK: Compile Unit:
|
||||||
# CHECK-NOT: contents:
|
# CHECK-NOT: contents:
|
||||||
# CHECK: DW_TAG_compile_unit
|
# CHECK: DW_TAG_compile_unit
|
||||||
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000009
|
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000015
|
||||||
# CHECK-NEXT: [0x0000002a, 0x00000034))
|
# CHECK-NEXT: [0x0000002a, 0x00000034))
|
||||||
|
|
||||||
#ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
|
#ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
; CHECK: .debug_info contents:
|
; CHECK: .debug_info contents:
|
||||||
; CHECK: .debug_info.dwo contents:
|
; CHECK: .debug_info.dwo contents:
|
||||||
; CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000004
|
; CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010
|
||||||
; CHECK: [0x0000000000000001, 0x000000000000000c) ".text"
|
; CHECK: [0x0000000000000001, 0x000000000000000c) ".text"
|
||||||
; CHECK: [0x000000000000000e, 0x0000000000000013) ".text")
|
; CHECK: [0x000000000000000e, 0x0000000000000013) ".text")
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
## Ensure bogus empty section names are not printed when dumping
|
## Ensure bogus empty section names are not printed when dumping
|
||||||
## rnglists that reference debug_addr when it is not present (such as in .dwo files)
|
## rnglists that reference debug_addr when it is not present (such as in .dwo files)
|
||||||
|
|
||||||
# CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000004
|
# CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010
|
||||||
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000001)
|
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000001)
|
||||||
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000002))
|
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000002))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user