[llvm] r191050 - DebugInfo: llvm-dwarfdump support for gnu_pubnames section

David Blaikie dblaikie at gmail.com
Thu Sep 19 16:01:30 PDT 2013


Author: dblaikie
Date: Thu Sep 19 18:01:29 2013
New Revision: 191050

URL: http://llvm.org/viewvc/llvm-project?rev=191050&view=rev
Log:
DebugInfo: llvm-dwarfdump support for gnu_pubnames section

Modified:
    llvm/trunk/include/llvm/DebugInfo/DIContext.h
    llvm/trunk/include/llvm/Support/Dwarf.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/DebugInfo/DWARFContext.cpp
    llvm/trunk/lib/DebugInfo/DWARFContext.h
    llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll

Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=191050&r1=191049&r2=191050&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Thu Sep 19 18:01:29 2013
@@ -109,6 +109,7 @@ enum DIDumpType {
   DIDT_Loc,
   DIDT_Ranges,
   DIDT_Pubnames,
+  DIDT_GnuPubnames,
   DIDT_Str,
   DIDT_StrDwo,
   DIDT_StrOffsetsDwo

Modified: llvm/trunk/include/llvm/Support/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=191050&r1=191049&r2=191050&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Dwarf.h (original)
+++ llvm/trunk/include/llvm/Support/Dwarf.h Thu Sep 19 18:01:29 2013
@@ -821,19 +821,18 @@ StringRef GDBIndexEntryLinkageString(GDB
 /// offset of the cu within the debug_info section stored in those 24 bits.
 struct PubIndexEntryDescriptor {
   GDBIndexEntryKind Kind;
-  GDBIndexEntryLinkage Static;
-  PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Static)
-      : Kind(Kind), Static(Static) {}
+  GDBIndexEntryLinkage Linkage;
+  PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
+      : Kind(Kind), Linkage(Linkage) {}
   /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
-      : Kind(Kind), Static(GIEL_EXTERNAL) {}
+      : Kind(Kind), Linkage(GIEL_EXTERNAL) {}
   explicit PubIndexEntryDescriptor(uint8_t Value)
       : Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >>
                                             KIND_OFFSET)),
-        Static(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
-                                                 LINKAGE_OFFSET)) {}
-  uint8_t toBits() {
-    return Kind << KIND_OFFSET | Static << LINKAGE_OFFSET;
-  }
+        Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
+                                                  LINKAGE_OFFSET)) {}
+  uint8_t toBits() { return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET; }
+
 private:
   enum {
     KIND_OFFSET = 4,

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=191050&r1=191049&r2=191050&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Sep 19 18:01:29 2013
@@ -2404,7 +2404,7 @@ void DwarfDebug::emitDebugPubNames(bool
         dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity);
         Asm->OutStreamer.AddComment(
             "Kind: " + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
-            dwarf::GDBIndexEntryLinkageString(Desc.Static));
+            dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
         Asm->EmitInt8(Desc.toBits());
       }
 
@@ -2466,7 +2466,7 @@ void DwarfDebug::emitDebugPubTypes(bool
         dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity);
         Asm->OutStreamer.AddComment(
             "Kind: " + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
-            dwarf::GDBIndexEntryLinkageString(Desc.Static));
+            dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
         Asm->EmitInt8(Desc.toBits());
       }
 

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=191050&r1=191049&r2=191050&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Sep 19 18:01:29 2013
@@ -120,6 +120,27 @@ void DWARFContext::dump(raw_ostream &OS,
     }
   }
 
+  if (DumpType == DIDT_All || DumpType == DIDT_GnuPubnames) {
+    OS << "\n.debug_gnu_pubnames contents:\n";
+    DataExtractor pubNames(getGnuPubNamesSection(), isLittleEndian(), 0);
+    offset = 0;
+    OS << "Length:                " << pubNames.getU32(&offset) << "\n";
+    OS << "Version:               " << pubNames.getU16(&offset) << "\n";
+    OS << "Offset in .debug_info: " << pubNames.getU32(&offset) << "\n";
+    OS << "Size:                  " << pubNames.getU32(&offset) << "\n";
+    OS << "Offset     Linkage  Kind    Name\n";
+    while (offset < getGnuPubNamesSection().size()) {
+      uint32_t dieRef = pubNames.getU32(&offset);
+      if (dieRef == 0)
+        break;
+      PubIndexEntryDescriptor desc(pubNames.getU8(&offset));
+      OS << format("0x%8.8x ", dieRef)
+         << format("%-8s", dwarf::GDBIndexEntryLinkageString(desc.Linkage))
+         << ' ' << dwarf::GDBIndexEntryKindString(desc.Kind) << ' '
+         << pubNames.getCStr(&offset) << "\n";
+    }
+  }
+
   if (DumpType == DIDT_All || DumpType == DIDT_AbbrevDwo) {
     const DWARFDebugAbbrev *D = getDebugAbbrevDWO();
     if (D) {
@@ -566,6 +587,7 @@ DWARFContextInMemory::DWARFContextInMemo
         .Case("debug_str", &StringSection)
         .Case("debug_ranges", &RangeSection)
         .Case("debug_pubnames", &PubNamesSection)
+        .Case("debug_gnu_pubnames", &GnuPubNamesSection)
         .Case("debug_info.dwo", &InfoDWOSection)
         .Case("debug_abbrev.dwo", &AbbrevDWOSection)
         .Case("debug_str.dwo", &StringDWOSection)

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.h?rev=191050&r1=191049&r2=191050&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.h Thu Sep 19 18:01:29 2013
@@ -125,6 +125,7 @@ public:
   virtual StringRef getStringSection() = 0;
   virtual StringRef getRangeSection() = 0;
   virtual StringRef getPubNamesSection() = 0;
+  virtual StringRef getGnuPubNamesSection() = 0;
 
   // Sections for DWARF5 split dwarf proposal.
   virtual StringRef getInfoDWOSection() = 0;
@@ -166,6 +167,7 @@ class DWARFContextInMemory : public DWAR
   StringRef StringSection;
   StringRef RangeSection;
   StringRef PubNamesSection;
+  StringRef GnuPubNamesSection;
 
   // Sections for DWARF5 split dwarf proposal.
   RelocAddrMap InfoDWORelocMap;
@@ -195,6 +197,7 @@ public:
   virtual StringRef getStringSection() { return StringSection; }
   virtual StringRef getRangeSection() { return RangeSection; }
   virtual StringRef getPubNamesSection() { return PubNamesSection; }
+  virtual StringRef getGnuPubNamesSection() { return GnuPubNamesSection; }
 
   // Sections for DWARF5 split dwarf proposal.
   virtual StringRef getInfoDWOSection() { return InfoDWOSection; }

Modified: llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll?rev=191050&r1=191049&r2=191050&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll Thu Sep 19 18:01:29 2013
@@ -1,4 +1,5 @@
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -o - %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections < %s | FileCheck -check-prefix=ASM %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s
 ; ModuleID = 'dwarf-public-names.cpp'
 ;
 ; Generated from:
@@ -33,18 +34,20 @@
 ; }
 
 
-; CHECK: .byte   32                      # Kind: VARIABLE, EXTERNAL
-; CHECK-NEXT: .asciz   "global_namespace_variable" # External Name
-; CHECK: .byte   48                      # Kind: FUNCTION, EXTERNAL
-; CHECK-NEXT: .asciz   "global_namespace_function" # External Name
-; CHECK: .byte   176                     # Kind: FUNCTION, STATIC
-; CHECK-NEXT: .asciz   "static_member_function" # External Name
-; CHECK: .byte   32                      # Kind: VARIABLE, EXTERNAL
-; CHECK-NEXT: .asciz   "global_variable"      # External Name
-; CHECK: .byte   48                      # Kind: FUNCTION, EXTERNAL
-; CHECK-NEXT: .asciz   "global_function"      # External Name
-; CHECK: .byte   176                     # Kind: FUNCTION, STATIC
-; CHECK-NEXT: .asciz   "member_function"      # External Name
+; ASM: .byte   32                      # Kind: VARIABLE, EXTERNAL
+
+; CHECK: .debug_gnu_pubnames contents:
+; CHECK-NEXT: Length:   167
+; CHECK-NEXT: Version:  2
+; CHECK-NEXT: Offset in .debug_info: 0
+; CHECK-NEXT: Size:     317
+; CHECK-NEXT: Offset     Linkage  Kind     Name
+; CHECK-DAG:  0x00000094 EXTERNAL VARIABLE global_namespace_variable
+; CHECK-DAG:  0x000000a3 EXTERNAL FUNCTION global_namespace_function
+; CHECK-DAG:  0x000000e8 STATIC   FUNCTION static_member_function
+; CHECK-DAG:  0x0000007c EXTERNAL VARIABLE global_variable
+; CHECK-DAG:  0x000000ff EXTERNAL FUNCTION global_function
+; CHECK-DAG:  0x000000be STATIC   FUNCTION member_function
 
 %struct.C = type { i8 }
 





More information about the llvm-commits mailing list