]> granicus.if.org Git - llvm/commitdiff
Symbolize: Make DWPName a symbolizer option instead of an argument to symbolize{...
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 11 Jun 2019 02:32:27 +0000 (02:32 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 11 Jun 2019 02:32:27 +0000 (02:32 +0000)
This makes the interface simpler and more consistent with the interface for
.dSYM files and fixes a bug where llvm-symbolizer would not read the dwp if
it was asked to symbolize data before symbolizing code.

Differential Revision: https://reviews.llvm.org/D63114

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363025 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/Symbolize/Symbolize.h
lib/DebugInfo/Symbolize/Symbolize.cpp
test/tools/llvm-symbolizer/split-dwarf-dwp.test
tools/llvm-symbolizer/llvm-symbolizer.cpp

index 773b01c82124812fcbb094095076148edb77bd15..c954cc6490802ec6464ef9be6b24df2bfc28d8e3 100644 (file)
@@ -42,6 +42,7 @@ public:
     std::string DefaultArch;
     std::vector<std::string> DsymHints;
     std::string FallbackDebugPath;
+    std::string DWPName;
   };
 
   LLVMSymbolizer() = default;
@@ -52,12 +53,10 @@ public:
   }
 
   Expected<DILineInfo> symbolizeCode(const std::string &ModuleName,
-                                     object::SectionedAddress ModuleOffset,
-                                     StringRef DWPName = "");
+                                     object::SectionedAddress ModuleOffset);
   Expected<DIInliningInfo>
   symbolizeInlinedCode(const std::string &ModuleName,
-                       object::SectionedAddress ModuleOffset,
-                       StringRef DWPName = "");
+                       object::SectionedAddress ModuleOffset);
   Expected<DIGlobal> symbolizeData(const std::string &ModuleName,
                                    object::SectionedAddress ModuleOffset);
   void flush();
@@ -76,7 +75,7 @@ private:
   /// only reported once. Subsequent calls to get module info for a module that
   /// failed to load will return nullptr.
   Expected<SymbolizableModule *>
-  getOrCreateModuleInfo(const std::string &ModuleName, StringRef DWPName = "");
+  getOrCreateModuleInfo(const std::string &ModuleName);
 
   ObjectFile *lookUpDsymFile(const std::string &Path,
                              const MachOObjectFile *ExeObj,
index 00e4139c0ba1b764ed88bb5661440d88baa05365..27632a10bad86b74ee928a6115e3ffecd2d45501 100644 (file)
@@ -53,10 +53,9 @@ namespace symbolize {
 
 Expected<DILineInfo>
 LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
-                              object::SectionedAddress ModuleOffset,
-                              StringRef DWPName) {
+                              object::SectionedAddress ModuleOffset) {
   SymbolizableModule *Info;
-  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))
+  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))
     Info = InfoOrErr.get();
   else
     return InfoOrErr.takeError();
@@ -80,10 +79,9 @@ LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
 
 Expected<DIInliningInfo>
 LLVMSymbolizer::symbolizeInlinedCode(const std::string &ModuleName,
-                                     object::SectionedAddress ModuleOffset,
-                                     StringRef DWPName) {
+                                     object::SectionedAddress ModuleOffset) {
   SymbolizableModule *Info;
-  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName, DWPName))
+  if (auto InfoOrErr = getOrCreateModuleInfo(ModuleName))
     Info = InfoOrErr.get();
   else
     return InfoOrErr.takeError();
@@ -378,8 +376,7 @@ LLVMSymbolizer::getOrCreateObject(const std::string &Path,
 }
 
 Expected<SymbolizableModule *>
-LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName,
-                                      StringRef DWPName) {
+LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) {
   const auto &I = Modules.find(ModuleName);
   if (I != Modules.end()) {
     return I->second.get();
@@ -425,8 +422,9 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName,
     }
   }
   if (!Context)
-    Context = DWARFContext::create(*Objects.second, nullptr,
-                                   DWARFContext::defaultErrorHandler, DWPName);
+    Context =
+        DWARFContext::create(*Objects.second, nullptr,
+                             DWARFContext::defaultErrorHandler, Opts.DWPName);
   assert(Context);
   auto InfoOrErr =
       SymbolizableObjectFile::create(Objects.first, std::move(Context));
index 71ecca436ebefc87f5576b6ac6f99fba58ceb68e..cadc5592961c7979351c8d8585431a3418398baa 100644 (file)
@@ -3,8 +3,9 @@ RUN: mkdir -p %t
 
 RUN: cp %p/Inputs/split-dwarf-dwp.o %t/split-dwarf-dwp-different-name.o
 
-RUN: llvm-symbolizer --dwp=%p/Inputs/split-dwarf-dwp.o.dwp \
-RUN:     --obj=%t/split-dwarf-dwp-different-name.o 0x54 | FileCheck %s
+RUN: echo -e 'DATA 0\n0x54' | \
+RUN:     llvm-symbolizer --dwp=%p/Inputs/split-dwarf-dwp.o.dwp \
+RUN:     --obj=%t/split-dwarf-dwp-different-name.o | FileCheck %s
 
 CHECK:      f2
 CHECK-NEXT: split-dwarf-dwp.cpp:3:3
index 93270e61b277793d3a960e3d0a80ab98ab7cda43..00b8931c740c388faaeabf794b1586ef55e38e9e 100644 (file)
@@ -224,8 +224,7 @@ static void symbolizeInput(StringRef InputString, LLVMSymbolizer &Symbolizer,
     Printer << (error(ResOrErr) ? DIGlobal() : ResOrErr.get());
   } else if (ClPrintInlining) {
     auto ResOrErr = Symbolizer.symbolizeInlinedCode(
-        ModuleName, {Offset, object::SectionedAddress::UndefSection},
-        ClDwpName);
+        ModuleName, {Offset, object::SectionedAddress::UndefSection});
     Printer << (error(ResOrErr) ? DIInliningInfo() : ResOrErr.get());
   } else if (ClOutputStyle == DIPrinter::OutputStyle::GNU) {
     // With ClPrintFunctions == FunctionNameKind::LinkageName (default)
@@ -235,13 +234,11 @@ static void symbolizeInput(StringRef InputString, LLVMSymbolizer &Symbolizer,
     // behavior of addr2line. Symbolizer.symbolizeInlinedCode() overrides only
     // the topmost function, which suits our needs better.
     auto ResOrErr = Symbolizer.symbolizeInlinedCode(
-        ModuleName, {Offset, object::SectionedAddress::UndefSection},
-        ClDwpName);
+        ModuleName, {Offset, object::SectionedAddress::UndefSection});
     Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get().getFrame(0));
   } else {
     auto ResOrErr = Symbolizer.symbolizeCode(
-        ModuleName, {Offset, object::SectionedAddress::UndefSection},
-        ClDwpName);
+        ModuleName, {Offset, object::SectionedAddress::UndefSection});
     Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get());
   }
   if (ClOutputStyle == DIPrinter::OutputStyle::LLVM)
@@ -275,6 +272,7 @@ int main(int argc, char **argv) {
   Opts.RelativeAddresses = ClUseRelativeAddress;
   Opts.DefaultArch = ClDefaultArch;
   Opts.FallbackDebugPath = ClFallbackDebugPath;
+  Opts.DWPName = ClDwpName;
 
   for (const auto &hint : ClDsymHint) {
     if (sys::path::extension(hint) == ".dSYM") {