From 94b0d836a105116220052313df5a58473f706cdf Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Mon, 21 Sep 2020 17:26:39 -0700 Subject: [PATCH] Fix reporting the lack of global variables in "target var". There was a little thinko which meant when stopped in a frame with debug information but whose CU didn't have any global variables we report: no debug info for frame This patch fixes that error message to say the intended: no global variables in current compile unit --- lldb/source/Commands/CommandObjectTarget.cpp | 1 + .../API/functionalities/target_var/no_vars/Makefile | 3 +++ .../target_var/no_vars/TestTargetVarNoVars.py | 21 +++++++++++++++++++++ .../API/functionalities/target_var/no_vars/main.c | 5 +++++ 4 files changed, 30 insertions(+) create mode 100644 lldb/test/API/functionalities/target_var/no_vars/Makefile create mode 100644 lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py create mode 100644 lldb/test/API/functionalities/target_var/no_vars/main.c diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 30fdaf9..431c2f3 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -907,6 +907,7 @@ protected: CompileUnit *comp_unit = nullptr; if (frame) { SymbolContext sc = frame->GetSymbolContext(eSymbolContextCompUnit); + comp_unit = sc.comp_unit; if (sc.comp_unit) { const bool can_create = true; VariableListSP comp_unit_varlist_sp( diff --git a/lldb/test/API/functionalities/target_var/no_vars/Makefile b/lldb/test/API/functionalities/target_var/no_vars/Makefile new file mode 100644 index 0000000..1049594 --- /dev/null +++ b/lldb/test/API/functionalities/target_var/no_vars/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py b/lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py new file mode 100644 index 0000000..60ca8b1 --- /dev/null +++ b/lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py @@ -0,0 +1,21 @@ +""" +Test that target var with no variables returns a correct error +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTargetVarNoVars(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def test_target_var_no_vars(self): + self.build() + lldbutil.run_to_name_breakpoint(self, 'main') + self.expect("target variable", substrs=['no global variables in current compile unit', 'main.c'], error=True) + diff --git a/lldb/test/API/functionalities/target_var/no_vars/main.c b/lldb/test/API/functionalities/target_var/no_vars/main.c new file mode 100644 index 0000000..d7877b0 --- /dev/null +++ b/lldb/test/API/functionalities/target_var/no_vars/main.c @@ -0,0 +1,5 @@ +int +main(int argc, char **argv) +{ + return argc; +} -- 2.7.4