[llvm] r314479 - llvm-dwarfdump: add support for .apple_types in --find

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 17:33:22 PDT 2017


Author: adrian
Date: Thu Sep 28 17:33:22 2017
New Revision: 314479

URL: http://llvm.org/viewvc/llvm-project?rev=314479&view=rev
Log:
llvm-dwarfdump: add support for .apple_types in --find

Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
    llvm/trunk/test/tools/llvm-dwarfdump/X86/find.test
    llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=314479&r1=314478&r2=314479&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Thu Sep 28 17:33:22 2017
@@ -70,6 +70,7 @@ class DWARFContext : public DIContext {
   std::unique_ptr<DWARFDebugFrame> EHFrame;
   std::unique_ptr<DWARFDebugMacro> Macro;
   std::unique_ptr<DWARFAcceleratorTable> AppleNames;
+  std::unique_ptr<DWARFAcceleratorTable> AppleTypes;
 
   DWARFUnitSection<DWARFCompileUnit> DWOCUs;
   std::deque<DWARFUnitSection<DWARFTypeUnit>> DWOTUs;
@@ -242,6 +243,9 @@ public:
   /// Get a reference to the parsed accelerator table object.
   const DWARFAcceleratorTable &getAppleNames();
 
+  /// Get a reference to the parsed accelerator table object.
+  const DWARFAcceleratorTable &getAppleTypes();
+
   /// Get a pointer to a parsed line table corresponding to a compile unit.
   const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu);
 

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=314479&r1=314478&r2=314479&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Thu Sep 28 17:33:22 2017
@@ -457,8 +457,7 @@ void DWARFContext::dump(
 
   if (shouldDump(Explicit, ".apple_types", DIDT_ID_AppleTypes,
                  DObj->getAppleTypesSection().Data))
-    dumpAccelSection(OS, *DObj, DObj->getAppleTypesSection(),
-                     DObj->getStringSection(), isLittleEndian());
+    getAppleTypes().dump(OS);
 
   if (shouldDump(Explicit, ".apple_namespaces", DIDT_ID_AppleNamespaces,
                  DObj->getAppleNamespacesSection().Data))
@@ -655,6 +654,11 @@ const DWARFAcceleratorTable &DWARFContex
                        DObj->getStringSection(), isLittleEndian());
 }
 
+const DWARFAcceleratorTable &DWARFContext::getAppleTypes() {
+  return getAccelTable(AppleTypes, *DObj, DObj->getAppleTypesSection(),
+                       DObj->getStringSection(), isLittleEndian());
+}
+
 const DWARFLineTable *
 DWARFContext::getLineTableForUnit(DWARFUnit *U) {
   if (!Line)

Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/find.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/find.test?rev=314479&r1=314478&r2=314479&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/find.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/find.test Thu Sep 28 17:33:22 2017
@@ -26,3 +26,12 @@ MULTI: : DW_TAG_variable
 MULTI-NOT: {{: DW}}
 MULTI:    DW_AT_name ("x86_64h_var")
 MULTI-NOT: {{: DW}}
+
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN:   | llvm-dwarfdump -find=int - | FileCheck %s --check-prefix=TYPES
+TYPES: .debug_info contents:
+TYPES-NOT: {{:}}
+TYPES: : DW_TAG_base_type
+TYPES-NOT: {{:}}
+TYPES:     DW_AT_name ("int")
+TYPES-NOT: {{:}}

Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=314479&r1=314478&r2=314479&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Thu Sep 28 17:33:22 2017
@@ -247,11 +247,20 @@ static bool dumpObjectFile(ObjectFile &O
   // Handle the --find option and lower it to --debug-info=<offset>.
   if (!Find.empty()) {
     DumpOffsets[DIDT_ID_DebugInfo] = [&]() -> llvm::Optional<uint64_t> {
-      for (auto Name : Find)
-        for (auto Entry : DICtx.getAppleNames().equal_range(Name))
-          for (auto Atom : Entry)
-            if (auto Offset = Atom.getAsSectionOffset())
-              return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+      for (auto Name : Find) {
+        auto find = [&](const DWARFAcceleratorTable &Accel)
+            -> llvm::Optional<uint64_t> {
+          for (auto Entry : Accel.equal_range(Name))
+            for (auto Atom : Entry)
+              if (auto Offset = Atom.getAsSectionOffset())
+                return Offset;
+          return None;
+        };
+        if (auto Offset = find(DICtx.getAppleNames()))
+          return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+        if (auto Offset = find(DICtx.getAppleTypes()))
+          return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+      }
       return None;
     }();
     // Early exit if --find was specified but the current file doesn't have it.




More information about the llvm-commits mailing list