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

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
This commit is contained in:
Francis Ricci 2018-03-02 22:56:45 +00:00
parent f69baf64eb
commit fe6cbceec2
2 changed files with 27 additions and 1 deletions

View 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();

View File

@ -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