[LLDB] Use path relative to binary for finding .dwo files.
authorCaroline Tice <cmtice@google.com>
Thu, 15 Apr 2021 20:36:23 +0000 (13:36 -0700)
committerCaroline Tice <cmtice@google.com>
Thu, 15 Apr 2021 21:43:47 +0000 (14:43 -0700)
commitb241f3cb292d0ba1ad5a33b3bbd4a8a3a9c909dc
treedbfe16a4c15307af11d6c36ff998c043deb8b0ef
parentf019e5f73ed732b374e376f5ddbba5d1f67dca0c
[LLDB] Use path relative to binary for finding .dwo files.

DWARF allows .dwo file paths to be relative rather than absolute. When
they are relative, DWARF uses DW_AT_comp_dir to find the .dwo
file. DW_AT_comp_dir can also be relative, making the entire search
patch for the .dwo file relative. In this case, LLDB currently
searches relative to its current working directory, i.e. the directory
from which the debugger was launched. This is not right, as the
compiler, which generated the relative paths, can have no idea where
the debugger will be launched. The correct thing is to search relative
to the location of the executable binary. That is what this patch
does.

Differential Revision: https://reviews.llvm.org/D97786
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/Shell/SymbolFile/DWARF/dwo-relative-path.s [new file with mode: 0644]