[llvm] r191329 - llvm-dwarfdump support for gnu_pubtypes

David Blaikie dblaikie at gmail.com
Tue Sep 24 12:50:01 PDT 2013


Author: dblaikie
Date: Tue Sep 24 14:50:00 2013
New Revision: 191329

URL: http://llvm.org/viewvc/llvm-project?rev=191329&view=rev
Log:
llvm-dwarfdump support for gnu_pubtypes

Modified:
    llvm/trunk/include/llvm/DebugInfo/DIContext.h
    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=191329&r1=191328&r2=191329&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Tue Sep 24 14:50:00 2013
@@ -110,6 +110,7 @@ enum DIDumpType {
   DIDT_Ranges,
   DIDT_Pubnames,
   DIDT_GnuPubnames,
+  DIDT_GnuPubtypes,
   DIDT_Str,
   DIDT_StrDwo,
   DIDT_StrOffsetsDwo

Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=191329&r1=191328&r2=191329&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Tue Sep 24 14:50:00 2013
@@ -28,6 +28,28 @@ DWARFContext::~DWARFContext() {
   DeleteContainerPointers(DWOCUs);
 }
 
+static void dumpPubSection(raw_ostream &OS, StringRef Name, StringRef Data,
+                           bool LittleEndian) {
+  OS << "\n." << Name << " contents:\n";
+  DataExtractor pubNames(Data, LittleEndian, 0);
+  uint32_t 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 < Data.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";
+  }
+}
+
 void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) {
   if (DumpType == DIDT_All || DumpType == DIDT_Abbrev) {
     OS << ".debug_abbrev contents:\n";
@@ -126,26 +148,13 @@ 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))
-         << ' ' << format("%-8s", dwarf::GDBIndexEntryKindString(desc.Kind))
-         << " \"" << pubNames.getCStr(&offset) << "\"\n";
-    }
-  }
+  if (DumpType == DIDT_All || DumpType == DIDT_GnuPubnames)
+    dumpPubSection(OS, "debug_gnu_pubnames", getGnuPubNamesSection(),
+                   isLittleEndian());
+
+  if (DumpType == DIDT_All || DumpType == DIDT_GnuPubtypes)
+    dumpPubSection(OS, "debug_gnu_pubtypes", getGnuPubTypesSection(),
+                   isLittleEndian());
 
   if (DumpType == DIDT_All || DumpType == DIDT_AbbrevDwo) {
     const DWARFDebugAbbrev *D = getDebugAbbrevDWO();
@@ -612,6 +621,7 @@ DWARFContextInMemory::DWARFContextInMemo
         .Case("debug_ranges", &RangeSection)
         .Case("debug_pubnames", &PubNamesSection)
         .Case("debug_gnu_pubnames", &GnuPubNamesSection)
+        .Case("debug_gnu_pubtypes", &GnuPubTypesSection)
         .Case("debug_info.dwo", &InfoDWOSection.Data)
         .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=191329&r1=191328&r2=191329&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.h Tue Sep 24 14:50:00 2013
@@ -148,6 +148,7 @@ public:
   virtual StringRef getRangeSection() = 0;
   virtual StringRef getPubNamesSection() = 0;
   virtual StringRef getGnuPubNamesSection() = 0;
+  virtual StringRef getGnuPubTypesSection() = 0;
 
   // Sections for DWARF5 split dwarf proposal.
   virtual const Section &getInfoDWOSection() = 0;
@@ -187,6 +188,7 @@ class DWARFContextInMemory : public DWAR
   StringRef RangeSection;
   StringRef PubNamesSection;
   StringRef GnuPubNamesSection;
+  StringRef GnuPubTypesSection;
 
   // Sections for DWARF5 split dwarf proposal.
   Section InfoDWOSection;
@@ -216,6 +218,7 @@ public:
   virtual StringRef getRangeSection() { return RangeSection; }
   virtual StringRef getPubNamesSection() { return PubNamesSection; }
   virtual StringRef getGnuPubNamesSection() { return GnuPubNamesSection; }
+  virtual StringRef getGnuPubTypesSection() { return GnuPubTypesSection; }
 
   // Sections for DWARF5 split dwarf proposal.
   virtual const Section &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=191329&r1=191328&r2=191329&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll Tue Sep 24 14:50:00 2013
@@ -35,14 +35,17 @@
 
 ; ASM: .section        .debug_gnu_pubnames
 ; ASM: .byte   32                      # Kind: VARIABLE, EXTERNAL
+; ASM-NEXT: .asciz  "global_namespace_variable" # External Name
 
 ; ASM: .section        .debug_gnu_pubtypes
 ; ASM: .byte   16                      # Kind: TYPE, EXTERNAL
-; ASM: .asciz  "C"                     # External Name
-; ASM: .byte   144                     # Kind: TYPE, STATIC
-; ASM: .asciz  "int"                   # External Name
+; ASM-NEXT: .asciz  "C"                     # External Name
 
 ; CHECK: .debug_info contents:
+; CHECK: 0x00000026: DW_TAG_base_type
+; CHECK-NEXT: DW_AT_name {{.*}} "int"
+; CHECK: 0x00000032: DW_TAG_structure_type
+; CHECK-NEXT: DW_AT_name {{.*}} "C"
 ; CHECK: 0x00000046: DW_TAG_subprogram
 ; CHECK-NEXT: DW_AT_MIPS_linkage_name
 ; CHECK-NEXT: DW_AT_name {{.*}} "member_function"
@@ -78,6 +81,15 @@
 ; CHECK-DAG:  0x00000101 EXTERNAL FUNCTION "global_function"
 ; CHECK-DAG:  0x000000c2 STATIC   FUNCTION "member_function"
 
+; CHECK-LABEL: debug_gnu_pubtypes contents:
+; CHECK-NEXT: Length:
+; CHECK-NEXT: Version:
+; CHECK-NEXT: Offset in .debug_info:
+; CHECK-NEXT: Size:
+; CHECK-NEXT: Offset     Linkage  Kind     Name
+; CHECK-DAG:  0x00000032 EXTERNAL TYPE     "C"
+; CHECK-DAG:  0x00000026 STATIC   TYPE     "int"
+
 %struct.C = type { i8 }
 
 @_ZN1C22static_member_variableE = global i32 0, align 4





More information about the llvm-commits mailing list