[llvm] r314481 - llvm-dwarfdump: support .apple-namespaces in --find

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


Author: adrian
Date: Thu Sep 28 17:52:33 2017
New Revision: 314481

URL: http://llvm.org/viewvc/llvm-project?rev=314481&view=rev
Log:
llvm-dwarfdump: support .apple-namespaces 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=314481&r1=314480&r2=314481&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Thu Sep 28 17:52:33 2017
@@ -71,6 +71,8 @@ class DWARFContext : public DIContext {
   std::unique_ptr<DWARFDebugMacro> Macro;
   std::unique_ptr<DWARFAcceleratorTable> AppleNames;
   std::unique_ptr<DWARFAcceleratorTable> AppleTypes;
+  std::unique_ptr<DWARFAcceleratorTable> AppleNamespaces;
+  std::unique_ptr<DWARFAcceleratorTable> AppleObjC;
 
   DWARFUnitSection<DWARFCompileUnit> DWOCUs;
   std::deque<DWARFUnitSection<DWARFTypeUnit>> DWOTUs;
@@ -246,6 +248,12 @@ public:
   /// Get a reference to the parsed accelerator table object.
   const DWARFAcceleratorTable &getAppleTypes();
 
+  /// Get a reference to the parsed accelerator table object.
+  const DWARFAcceleratorTable &getAppleNamespaces();
+
+  /// Get a reference to the parsed accelerator table object.
+  const DWARFAcceleratorTable &getAppleObjC();
+
   /// 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=314481&r1=314480&r2=314481&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Thu Sep 28 17:52:33 2017
@@ -68,17 +68,6 @@ DWARFContext::DWARFContext(std::unique_p
 
 DWARFContext::~DWARFContext() = default;
 
-static void dumpAccelSection(raw_ostream &OS, const DWARFObject &Obj,
-                             const DWARFSection &Section,
-                             StringRef StringSection, bool LittleEndian) {
-  DWARFDataExtractor AccelSection(Obj, Section, LittleEndian, 0);
-  DataExtractor StrData(StringSection, LittleEndian, 0);
-  DWARFAcceleratorTable Accel(AccelSection, StrData);
-  if (!Accel.extract())
-    return;
-  Accel.dump(OS);
-}
-
 /// Dump the UUID load command.
 static void dumpUUID(raw_ostream &OS, const ObjectFile &Obj) {
   auto *MachO = dyn_cast<MachOObjectFile>(&Obj);
@@ -461,13 +450,11 @@ void DWARFContext::dump(
 
   if (shouldDump(Explicit, ".apple_namespaces", DIDT_ID_AppleNamespaces,
                  DObj->getAppleNamespacesSection().Data))
-    dumpAccelSection(OS, *DObj, DObj->getAppleNamespacesSection(),
-                     DObj->getStringSection(), isLittleEndian());
+    getAppleNamespaces().dump(OS);
 
   if (shouldDump(Explicit, ".apple_objc", DIDT_ID_AppleObjC,
                  DObj->getAppleObjCSection().Data))
-    dumpAccelSection(OS, *DObj, DObj->getAppleObjCSection(),
-                     DObj->getStringSection(), isLittleEndian());
+    getAppleObjC().dump(OS);
 }
 
 DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) {
@@ -659,6 +646,17 @@ const DWARFAcceleratorTable &DWARFContex
                        DObj->getStringSection(), isLittleEndian());
 }
 
+const DWARFAcceleratorTable &DWARFContext::getAppleNamespaces() {
+  return getAccelTable(AppleNamespaces, *DObj,
+                       DObj->getAppleNamespacesSection(),
+                       DObj->getStringSection(), isLittleEndian());
+}
+
+const DWARFAcceleratorTable &DWARFContext::getAppleObjC() {
+  return getAccelTable(AppleObjC, *DObj, DObj->getAppleObjCSection(),
+                       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=314481&r1=314480&r2=314481&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:52:33 2017
@@ -35,3 +35,10 @@ TYPES: : DW_TAG_base_type
 TYPES-NOT: {{:}}
 TYPES:     DW_AT_name ("int")
 TYPES-NOT: {{:}}
+
+RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/odr-anon-namespace/1.o \
+RUN:    -find="(anonymous namespace)" \
+RUN:   | FileCheck %s --check-prefix=NAMESPACE
+NAMESPACE-NOT: {{: DW}}
+NAMESPACE: 0x0000005b: DW_TAG_namespace
+NAMESPACE-NOT: {{: DW}}

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=314481&r1=314480&r2=314481&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Thu Sep 28 17:52:33 2017
@@ -260,6 +260,8 @@ static bool dumpObjectFile(ObjectFile &O
           return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
         if (auto Offset = find(DICtx.getAppleTypes()))
           return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+        if (auto Offset = find(DICtx.getAppleNamespaces()))
+          return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
       }
       return None;
     }();




More information about the llvm-commits mailing list