Skip to content

Commit c410cd3

Browse files
authored
Merge pull request #1844 from jimingham/no-vars-not-no-debug-info
Fix reporting the lack of global variables in "target var".
2 parents a90793e + 823f635 commit c410cd3

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
922922
CompileUnit *comp_unit = nullptr;
923923
if (frame) {
924924
SymbolContext sc = frame->GetSymbolContext(eSymbolContextCompUnit);
925+
comp_unit = sc.comp_unit;
925926
if (sc.comp_unit) {
926927
const bool can_create = true;
927928
VariableListSP comp_unit_varlist_sp(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
C_SOURCES := main.c
2+
3+
include Makefile.rules
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Test that target var with no variables returns a correct error
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.decorators import *
7+
from lldbsuite.test.lldbtest import *
8+
from lldbsuite.test import lldbutil
9+
10+
11+
class TestTargetVarNoVars(TestBase):
12+
13+
mydir = TestBase.compute_mydir(__file__)
14+
15+
NO_DEBUG_INFO_TESTCASE = True
16+
17+
def test_target_var_no_vars(self):
18+
self.build()
19+
lldbutil.run_to_name_breakpoint(self, 'main')
20+
self.expect("target variable", substrs=['no global variables in current compile unit', 'main.c'], error=True)
21+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int
2+
main(int argc, char **argv)
3+
{
4+
return argc;
5+
}

0 commit comments

Comments
 (0)