Browse Source

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

(addr attributes coming shortly)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349996 91177308-0d34-0410-b5e6-96231b3b80d8
David Blaikie 6 years ago
parent
commit
2260761a43

+ 2 - 0
include/llvm/DebugInfo/DWARF/DWARFFormValue.h

@@ -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);
 

+ 12 - 3
lib/DebugInfo/DWARF/DWARFFormValue.cpp

@@ -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;
   }

+ 1 - 1
test/DebugInfo/X86/debug_addr.ll

@@ -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: [