https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/157574

>From 01ca83a440c9169c5f695ef67a16f503cbb51bd5 Mon Sep 17 00:00:00 2001
From: Jeffrey Tan <jeffrey...@fb.com>
Date: Mon, 8 Sep 2025 15:43:48 -0700
Subject: [PATCH] Fix GetDIE is outside of its CU error from .debug_names

---
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp |  8 ++++++--
 .../DWARF/dwo-miss-getdie-ouside-cu-error.c   | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/dwo-miss-getdie-ouside-cu-error.c

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; }

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to