diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index fa5baf1a0eeb1..08089a4e5ad39 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -131,8 +131,12 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const DebugNames::Entry &entry) const { unit_offset = entry.getLocalTUOffset(); if (unit_offset) { if (DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, - *unit_offset)) - return &cu->GetNonSkeletonUnit(); + *unit_offset)) { + DWARFUnit &ret = cu->GetNonSkeletonUnit(); + if (ret.IsSkeletonUnit()) + return nullptr; + return &ret; + } } return nullptr; } diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c b/lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c new file mode 100644 index 0000000000000..4f847590bab8a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c @@ -0,0 +1,19 @@ +/// Check that LLDB does not emit "GetDIE for DIE {{0x[0-9a-f]+}} is outside of its CU" +/// error message when user is searching for a matching symbol from .debug_names +/// and fail to locate the corresponding .dwo file. + +/// -gsplit-dwarf is supported only on Linux. +// REQUIRES: system-linux + +// RUN: %clang_host -g -gsplit-dwarf -gpubnames -gdwarf-5 %s -o main +/// Remove the DWO file away from the expected location so that LLDB won't find the DWO next to the binary. +// RUN: rm *.dwo +// RUN: %lldb --no-lldbinit main \ +// RUN: -o "b main" --batch 2>&1 | FileCheck %s + +// CHECK: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded. +// CHECK-NOT: main GetDIE for DIE {{0x[0-9a-f]+}} is outside of its CU {{0x[0-9a-f]+}} + +int num = 5; + +int main(void) { return 0; }