Author: Jim Ingham Date: 2020-09-21T17:29:40-07:00 New Revision: 94b0d836a105116220052313df5a58473f706cdf
URL: https://github.com/llvm/llvm-project/commit/94b0d836a105116220052313df5a58473f706cdf DIFF: https://github.com/llvm/llvm-project/commit/94b0d836a105116220052313df5a58473f706cdf.diff LOG: 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 <N> This patch fixes that error message to say the intended: no global variables in current compile unit <rdar://problem/69086361> Added: lldb/test/API/functionalities/target_var/no_vars/Makefile lldb/test/API/functionalities/target_var/no_vars/TestTargetVarNoVars.py lldb/test/API/functionalities/target_var/no_vars/main.c Modified: lldb/source/Commands/CommandObjectTarget.cpp Removed: ################################################################################ diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 30fdaf9ec9a2..431c2f3a19f0 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -907,6 +907,7 @@ class CommandObjectTargetVariable : public CommandObjectParsed { 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 000000000000..10495940055b --- /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 000000000000..60ca8b1252b3 --- /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 000000000000..d7877b0a519b --- /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; +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits