llvm-dwarfdump: Print the section name/number for addr_index attributes

(addr attributes coming shortly)

llvm-svn: 349996
This commit is contained in:
David Blaikie 2018-12-22 08:33:55 +00:00
parent da4066e34a
commit bc41705cbc
3 changed files with 15 additions and 4 deletions

View File

@ -75,6 +75,8 @@ public:
bool isFormClass(FormClass FC) const;
const DWARFUnit *getUnit() const { return U; }
void dump(raw_ostream &OS, DIDumpOptions DumpOpts = DIDumpOptions()) const;
void dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts,
SectionedAddress SA) const;
static void dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS,
DIDumpOptions DumpOpts, uint64_t SectionIndex);

View File

@ -331,6 +331,14 @@ bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
return true;
}
void DWARFFormValue::dumpSectionedAddress(raw_ostream &OS,
DIDumpOptions DumpOpts,
SectionedAddress SA) const {
OS << format("0x%016" PRIx64, SA.Address);
dumpAddressSection(U->getContext().getDWARFObj(), OS, DumpOpts,
SA.SectionIndex);
}
void DWARFFormValue::dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS,
DIDumpOptions DumpOpts,
uint64_t SectionIndex) {
@ -365,9 +373,10 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
AddrOS << format(" indexed (%8.8x) address = ", (uint32_t)UValue);
if (U == nullptr)
OS << "<invalid dwarf unit>";
else if (Optional<SectionedAddress> A = U->getAddrOffsetSectionItem(UValue))
AddrOS << format("0x%016" PRIx64, A->Address);
else
else if (Optional<SectionedAddress> A =
U->getAddrOffsetSectionItem(UValue)) {
dumpSectionedAddress(AddrOS, DumpOpts, *A);
} else
OS << "<no .debug_addr section>";
break;
}

View File

@ -32,7 +32,7 @@
; DWARF5-NOT: DW_TAG_{{.*}}
; DWARF5: DW_AT_GNU_dwo_name{{.*}}test.dwo
; DWARF5: DW_AT_addr_base{{.*}}0x00000008
; DWARF5: DW_AT_low_pc [DW_FORM_addrx] ( indexed (00000000) address = 0x0000000000000000)
; DWARF5: DW_AT_low_pc [DW_FORM_addrx] ( indexed (00000000) address = 0x0000000000000000 ".text")
; DWARF5: .debug_addr contents:
; DWARF5-NEXT: 0x00000000: Addr Section: length = 0x0000000c, version = 0x0005, addr_size = 0x04, seg_size = 0x00
; DWARF5-NEXT: Addrs: [