Skip to content

Commit 74ca072

Browse files
authored
[lldb] improve dwo path in missing dwo error when relative (#69783)
When the debug info refers to a dwo with relative `DW_AT_comp_dir` and `DW_AT_dwo_name`, we only print the `DW_AT_comp_dir` in our error message if we can't find it. This often isn't very helpful, especially when the `DW_AT_comp_dir` is ".": ``` (lldb) fr v error: unable to locate .dwo debug file "." for skeleton DIE 0x000000000000003c ``` I'm updating the error message to include both `DW_AT_comp_dir` (if it exists) and `DW_AT_dwo_name` when the `DW_AT_dwo_name` is relative. The behavior when `DW_AT_dwo_name` is absolute should be the same.
1 parent 6250afe commit 74ca072

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,10 +1855,16 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
18551855
}
18561856

18571857
if (!found) {
1858+
FileSpec error_dwo_path(dwo_name);
1859+
FileSystem::Instance().Resolve(error_dwo_path);
1860+
if (error_dwo_path.IsRelative() && comp_dir != nullptr) {
1861+
error_dwo_path.PrependPathComponent(comp_dir);
1862+
FileSystem::Instance().Resolve(error_dwo_path);
1863+
}
18581864
unit.SetDwoError(Status::createWithFormat(
18591865
"unable to locate .dwo debug file \"{0}\" for skeleton DIE "
18601866
"{1:x16}",
1861-
dwo_file.GetPath().c_str(), cu_die.GetOffset()));
1867+
error_dwo_path.GetPath().c_str(), cu_die.GetOffset()));
18621868

18631869
if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) {
18641870
GetObjectFile()->GetModule()->ReportWarning(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int main(void) { return 0; }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Check that LLDB prints an error message containing the DWO_AT_comp_dir and
2+
# DW_AT_dwo_name when it can't find a DWO and the DW_AT_comp_dir and
3+
# DW_AT_dwo_name are relative.
4+
5+
# -gsplit-dwarf is supported only on Linux.
6+
# REQUIRES: system-linux
7+
8+
# Test the error message with a relative DW_AT_comp_dir and DW_AT_dwo_name.
9+
# Creating and compiling to %t.compdir makes it easy to remove the dwo files.
10+
# DW_AT_comp_dir should be "./a/b/", and DW_AT_dwo_name should be
11+
# "a.out-dwo-missing-error.dwo".
12+
# since %T is deprecated.
13+
# RUN: rm -rf %t.compdir/
14+
# RUN: mkdir -p %t.compdir/a/b/
15+
# RUN: cd %t.compdir/a/b/
16+
# RUN: %clang_host %S/Inputs/dwo-missing-error.c -glldb -gdwarf-5 \
17+
# RUN: -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. -o a.out
18+
# RUN: rm *.dwo
19+
# RUN: %lldb a.out -s %s -o exit 2>&1 | FileCheck %s
20+
# RUN: cd -
21+
22+
# Test the error message with an absolute DW_AT_comp_dir and DW_AT_dwo_name.
23+
# RUN: rm -rf %t.compdir/
24+
# RUN: mkdir -p %t.compdir/a/b/
25+
# RUN: %clang_host %S/Inputs/dwo-missing-error.c -glldb -gdwarf-5 \
26+
# RUN: -gsplit-dwarf -o %t.compdir/a/b/a.out
27+
# RUN: rm %t.compdir/a/b/*.dwo
28+
# RUN: %lldb %t.compdir/a/b/a.out -s %s -o exit 2>&1 | FileCheck %s
29+
30+
b main
31+
run
32+
33+
fr v
34+
# CHECK: error: unable to locate .dwo debug file "{{.*}}a/b/a.out-dwo-missing-error.dwo" for skeleton DIE {{.*}}

0 commit comments

Comments
 (0)