[PATCH] D113717: [Symbolizer][Debuginfo] Add debuginfod client to llvm-symbolizer.

Noah Shutty via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 5 20:05:14 PST 2021


noajshu updated this revision to Diff 391955.
noajshu marked 10 inline comments as done.
noajshu added a comment.

Simplify testing.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113717/new/

https://reviews.llvm.org/D113717

Files:
  llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
  llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
  llvm/test/tools/llvm-symbolizer/debuginfod.test


Index: llvm/test/tools/llvm-symbolizer/debuginfod.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-symbolizer/debuginfod.test
@@ -0,0 +1,26 @@
+# This test uses the local debuginfod cache to test the symbolizer integration
+# with the debuginfod client.
+RUN: rm -rf %t
+RUN: mkdir %t
+
+# Produce a stripped copy of the input binary addr.exe
+RUN: llvm-objcopy --strip-debug %p/Inputs/addr.exe %t/addr.exe
+
+# Symbolizing the stripped binary should fail.
+RUN: DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer --print-address \
+RUN:   --obj=%t/addr.exe 0x40054d | FileCheck %s --check-prefix=NOTFOUND
+NOTFOUND: 0x40054d
+NOTFOUND-NEXT: main
+NOTFOUND-NEXT: ??:0:0
+
+# Place a debuginfo binary in the llvm debuginfod cache. The filename is
+# determined by the debuginfod client's caching scheme, so it is manually
+# specified here (llvmcache-98...19)
+RUN: llvm-objcopy --keep-section=.debug_info %p/Inputs/addr.exe \
+RUN:   %t/llvmcache-9800707741016212219
+
+# The symbolizer should call debuginfod client library, which finds the
+# debuginfo placed in the cache, enabling symbolization of the address.
+RUN: DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer --print-address \
+RUN:   --obj=%t/addr.exe 0x40054d | FileCheck %s --check-prefix=FOUND
+FOUND: {{[/\]+}}tmp{{[/\]+}}x.c:14:0
Index: llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -20,6 +20,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/DebugInfo/PDB/PDB.h"
 #include "llvm/DebugInfo/PDB/PDBContext.h"
+#include "llvm/Debuginfod/Debuginfod.h"
 #include "llvm/Demangle/Demangle.h"
 #include "llvm/Object/COFF.h"
 #include "llvm/Object/MachO.h"
@@ -384,7 +385,14 @@
       }
     }
   }
-  return false;
+  // Try debuginfod client cache and known servers.
+  Expected<std::string> PathOrErr = getCachedOrDownloadDebuginfo(BuildID);
+  if (!PathOrErr) {
+    consumeError(PathOrErr.takeError());
+    return false;
+  }
+  Result = *PathOrErr;
+  return true;
 }
 
 } // end anonymous namespace
Index: llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
===================================================================
--- llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
+++ llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
@@ -9,6 +9,7 @@
   LINK_COMPONENTS
   DebugInfoDWARF
   DebugInfoPDB
+  Debuginfod
   Object
   Support
   Demangle


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113717.391955.patch
Type: text/x-patch
Size: 2523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211206/eac38b29/attachment.bin>


More information about the llvm-commits mailing list