[PATCH] D44025: [llvm-symbolizer] Use correct path when resolving .gnu_debuglink in .debug

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 2 09:14:32 PST 2018


fjricci created this revision.
fjricci added reviewers: rnk, glider, zturner.
Herald added a subscriber: aprantl.

The symbolizer was checking for .debug as a subdirectory of the
binary file itself, not of the directory containing the binary. This led to
a failure to find split debug info when it was contained in a .debug directory.


Repository:
  rL LLVM

https://reviews.llvm.org/D44025

Files:
  lib/DebugInfo/Symbolize/Symbolize.cpp
  test/tools/llvm-symbolizer/split-debug.test


Index: test/tools/llvm-symbolizer/split-debug.test
===================================================================
--- /dev/null
+++ test/tools/llvm-symbolizer/split-debug.test
@@ -0,0 +1,26 @@
+#Source:
+##include <stdio.h>
+#static inline int inctwo (int *a) {
+#  printf ("%d\n",(*a)++);
+#  return (*a)++;
+#}
+#static inline int inc (int *a) {
+#  printf ("%d\n",inctwo(a));
+#  return (*a)++;
+#}
+#
+#
+#int main () {
+#  int x = 1;
+#  return inc(&x);
+#}
+#
+#Build as : clang -g -O2 addr.c
+
+RUN: mkdir -p %t/.debug
+RUN: llvm-objcopy --keep=.debug_info %p/Inputs/addr.exe %t/.debug/addr
+RUN: llvm-objcopy --strip-debug --add-gnu-debuglink=%t/.debug/addr %p/Inputs/addr.exe %t/addr.exe
+RUN: llvm-symbolizer -print-address -obj=%t/addr.exe < %p/Inputs/addr.inp | FileCheck %s
+
+#CHECK: 0x40054d
+#CHECK: {{[/\]+}}tmp{{[/\]+}}x.c:14:0
Index: lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- lib/DebugInfo/Symbolize/Symbolize.cpp
+++ lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -185,7 +185,7 @@
     return true;
   }
   // Try /path/to/original_binary/.debug/debuglink_name
-  DebugPath = OrigRealPath;
+  DebugPath = OrigDir;
   llvm::sys::path::append(DebugPath, ".debug", DebuglinkName);
   if (checkFileCRC(DebugPath, CRCHash)) {
     Result = DebugPath.str();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44025.136771.patch
Type: text/x-patch
Size: 1339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/e4dc356a/attachment.bin>


More information about the llvm-commits mailing list