Skip to content

Fix reporting the lack of global variables in "target var". #1844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/source/Commands/CommandObjectTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,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(
Expand Down
3 changes: 3 additions & 0 deletions lldb/test/API/functionalities/target_var/no_vars/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
C_SOURCES := main.c

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -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)

5 changes: 5 additions & 0 deletions lldb/test/API/functionalities/target_var/no_vars/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
int
main(int argc, char **argv)
{
return argc;
}