[Lldb-commits] [lldb] [LLDB] Check comp_unit before accessing it in DIL (PR #147955)
Ilia Kuklin via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 10 07:54:55 PDT 2025
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/147955
>From 6b72ecb0f25b34ca112220e8587ef7fea46a38dd Mon Sep 17 00:00:00 2001
From: Ilia Kuklin <ikuklin at accesssoftek.com>
Date: Thu, 10 Jul 2025 17:45:15 +0500
Subject: [PATCH 1/2] [LLDB] Check comp_unit before accessing it in DIL
---
lldb/source/ValueObject/DILEval.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp
index 8ca9b4215985d..fd3f9f8724608 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -50,8 +50,9 @@ lldb::ValueObjectSP LookupGlobalIdentifier(
// Get a global variables list without the locals from the current frame
SymbolContext symbol_context =
stack_frame->GetSymbolContext(lldb::eSymbolContextCompUnit);
- lldb::VariableListSP variable_list =
- symbol_context.comp_unit->GetVariableList(true);
+ lldb::VariableListSP variable_list;
+ if (symbol_context.comp_unit)
+ variable_list = symbol_context.comp_unit->GetVariableList(true);
name_ref.consume_front("::");
lldb::ValueObjectSP value_sp;
>From f55c3a216a8299091f4f40de92d27d4ac7a58231 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin <ikuklin at accesssoftek.com>
Date: Thu, 10 Jul 2025 19:37:17 +0500
Subject: [PATCH 2/2] Add a test without debug info
---
.../frame/var-dil/basics/NoDebugInfo/Makefile | 4 +++
.../NoDebugInfo/TestFrameVarDILNoDebugInfo.py | 29 +++++++++++++++++++
.../frame/var-dil/basics/NoDebugInfo/main.cpp | 3 ++
3 files changed, 36 insertions(+)
create mode 100644 lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/Makefile
create mode 100644 lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/TestFrameVarDILNoDebugInfo.py
create mode 100644 lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/main.cpp
diff --git a/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/Makefile b/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/Makefile
new file mode 100644
index 0000000000000..df9f4a7b518c7
--- /dev/null
+++ b/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS := -g0
+
+include Makefile.rules
diff --git a/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/TestFrameVarDILNoDebugInfo.py b/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/TestFrameVarDILNoDebugInfo.py
new file mode 100644
index 0000000000000..defea39826267
--- /dev/null
+++ b/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/TestFrameVarDILNoDebugInfo.py
@@ -0,0 +1,29 @@
+"""
+Test DIL without debug info.
+"""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbutil
+
+
+class TestFrameVarDILNoDebugInfo(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_no_debug_info(self):
+ self.build()
+ lldbutil.run_to_name_breakpoint(self, "main")
+
+ self.runCmd("settings set target.experimental.use-DIL true")
+
+ self.expect(
+ "frame var 'argc'",
+ error=True,
+ substrs=["use of undeclared identifier"],
+ )
+ self.expect(
+ "frame var 'foo'",
+ error=True,
+ substrs=["use of undeclared identifier"],
+ )
diff --git a/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/main.cpp b/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/main.cpp
new file mode 100644
index 0000000000000..abf9ecf88fa30
--- /dev/null
+++ b/lldb/test/API/commands/frame/var-dil/basics/NoDebugInfo/main.cpp
@@ -0,0 +1,3 @@
+int foo = 1;
+
+int main(int argc, char **argv) { return foo; }
More information about the lldb-commits
mailing list