Skip to content

Fix SBValue::FindValue for file static variables #6938

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
3 changes: 2 additions & 1 deletion lldb/source/API/SBFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type,
stop_if_block_is_inlined_function,
[frame](Variable *v) { return v->IsInScope(frame); },
&variable_list);
if (value_type == eValueTypeVariableGlobal) {
if (value_type == eValueTypeVariableGlobal
|| value_type == eValueTypeVariableStatic) {
const bool get_file_globals = true;
VariableList *frame_vars = frame->GetVariableList(get_file_globals,
nullptr);
Expand Down
8 changes: 4 additions & 4 deletions lldb/test/API/python_api/process/TestProcessAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def test_read_memory(self):
)
frame = thread.GetFrameAtIndex(0)

# Get the SBValue for the global variable 'my_char'.
val = frame.FindValue("my_char", lldb.eValueTypeVariableGlobal)
# Get the SBValue for the file static variable 'my_char'.
val = frame.FindValue("my_char", lldb.eValueTypeVariableStatic)
self.DebugSBValue(val)

# Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and
Expand Down Expand Up @@ -148,8 +148,8 @@ def test_write_memory(self):
)
frame = thread.GetFrameAtIndex(0)

# Get the SBValue for the global variable 'my_char'.
val = frame.FindValue("my_char", lldb.eValueTypeVariableGlobal)
# Get the SBValue for the static variable 'my_char'.
val = frame.FindValue("my_char", lldb.eValueTypeVariableStatic)
self.DebugSBValue(val)

# If the variable does not have a load address, there's no sense
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/python_api/process/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// This simple program is to test the lldb Python API related to process.

char my_char = 'u';
static char my_char = 'u';
char my_cstring[] = "lldb.SBProcess.ReadCStringFromMemory() works!";
char *my_char_ptr = (char *)"Does it work?";
uint32_t my_uint32 = 12345;
Expand Down