[PATCH] D57916: [DebugInfo] Fix /usr/lib/debug llvm-symbolizer lookup with relative paths

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 7 11:09:16 PST 2019


rupprecht created this revision.
rupprecht added reviewers: dblaikie, samsonov.
Herald added subscribers: llvm-commits, hiraditya, aprantl.
Herald added a project: LLVM.

rL189250 <https://reviews.llvm.org/rL189250> added a realpath call, and rL352916 <https://reviews.llvm.org/rL352916> because realpath breaks assumptions with some build systems. However, the /usr/lib/debug case has been clarified, falling back to /usr/lib/debug is currently broken if the obj passed in is a relative path. Adding a call to use absolute paths when falling back to /usr/lib/debug fixes that while still not making any realpath assumptions.

I don't know of a good way to write a test for this, but I manually verified with:

  $ rm -f path/to/dwarfdump-test.elf-x86-64
  $ strace llvm-symbolizer --obj=relative/path/to/dwarfdump-test.elf-x86-64.debuglink 0x40113f |& grep dwarfdump

Lookups went to relative/path/to/dwarfdump-test.elf-x86-64, relative/path/to/.debug/dwarfdump-test.elf-x86-64, and then finally /usr/lib/debug/absolute/path/to/dwarfdump-test.elf-x86-64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57916

Files:
  llvm/lib/DebugInfo/Symbolize/Symbolize.cpp


Index: llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -189,6 +189,10 @@
   // Try /usr/lib/debug/path/to/original_binary/debuglink_name
   DebugPath = "/usr/lib/debug";
 #endif
+  // Make the path absolute so that lookups will go to
+  // "/usr/lib/debug/full/path/to/debug", not
+  // "/usr/lib/debug/to/debug"
+  llvm::sys::fs::make_absolute(OrigDir);
   llvm::sys::path::append(DebugPath, llvm::sys::path::relative_path(OrigDir),
                           DebuglinkName);
   if (checkFileCRC(DebugPath, CRCHash)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57916.185829.patch
Type: text/x-patch
Size: 680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190207/9c27ab4d/attachment.bin>


More information about the llvm-commits mailing list