Skip to content

Commit 5ded2a3

Browse files
authored
Merge pull request #6938 from jimingham/fix-sbvalue-find-value
Fix SBValue::FindValue for file static variables
2 parents 761429b + 50b4e96 commit 5ded2a3

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lldb/source/API/SBFrame.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type,
611611
stop_if_block_is_inlined_function,
612612
[frame](Variable *v) { return v->IsInScope(frame); },
613613
&variable_list);
614-
if (value_type == eValueTypeVariableGlobal) {
614+
if (value_type == eValueTypeVariableGlobal
615+
|| value_type == eValueTypeVariableStatic) {
615616
const bool get_file_globals = true;
616617
VariableList *frame_vars = frame->GetVariableList(get_file_globals,
617618
nullptr);

lldb/test/API/python_api/process/TestProcessAPI.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def test_read_memory(self):
4848
)
4949
frame = thread.GetFrameAtIndex(0)
5050

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

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

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

155155
# If the variable does not have a load address, there's no sense

lldb/test/API/python_api/process/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

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

6-
char my_char = 'u';
6+
static char my_char = 'u';
77
char my_cstring[] = "lldb.SBProcess.ReadCStringFromMemory() works!";
88
char *my_char_ptr = (char *)"Does it work?";
99
uint32_t my_uint32 = 12345;

0 commit comments

Comments
 (0)