[llvm-symbolizer] Use correct path when resolving .gnu_debuglink in .debug
authorFrancis Ricci <francisjricci@gmail.com>
Fri, 2 Mar 2018 22:56:45 +0000 (22:56 +0000)
committerFrancis Ricci <francisjricci@gmail.com>
Fri, 2 Mar 2018 22:56:45 +0000 (22:56 +0000)
Summary:
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.

Reviewers: rnk, glider, zturner

Subscribers: llvm-commits, aprantl

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

llvm-svn: 326630

llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/test/tools/llvm-symbolizer/split-debug.test [new file with mode: 0644]

index e997ef5..681334b 100644 (file)
@@ -185,7 +185,7 @@ bool findDebugBinary(const std::string &OrigPath,
     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();
diff --git a/llvm/test/tools/llvm-symbolizer/split-debug.test b/llvm/test/tools/llvm-symbolizer/split-debug.test
new file mode 100644 (file)
index 0000000..2d5b073
--- /dev/null
@@ -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