summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2010-11-19 18:07:14 +0000
committerJohnny Chen <johnny.chen@apple.com>2010-11-19 18:07:14 +0000
commitbeae523a204e69f658c6939ae0fc5d109e9f636e (patch)
tree61021f182bc930dcebf0ee0c02ef579d76d1cea1
parentd7a3550a5e72571d36a0661208d0e209471a127f (diff)
downloadbcm5719-llvm-beae523a204e69f658c6939ae0fc5d109e9f636e.tar.gz
bcm5719-llvm-beae523a204e69f658c6939ae0fc5d109e9f636e.zip
Fill in more test sequences for Python API SBFrame.LookupVarInScope(name, scope).
Change SBFrame::LookupVarInScope() to also work with "global" scope in addition to "local" and "parameter" scope. llvm-svn: 119811
-rw-r--r--lldb/source/API/SBFrame.cpp35
-rw-r--r--lldb/test/class_static/TestStaticVariables.py19
-rw-r--r--lldb/test/class_static/main.cpp2
3 files changed, 36 insertions, 20 deletions
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index 238464ebaf3..58faed6eea6 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -350,26 +350,25 @@ SBFrame::LookupVarInScope (const char *var_name, const char *scope)
if (var_scope != eValueTypeInvalid)
{
- lldb_private::VariableList variable_list;
- SBSymbolContext sc = GetSymbolContext (eSymbolContextEverything);
-
- SBBlock block = sc.GetBlock();
- if (block.IsValid())
- block.AppendVariables (true, true, &variable_list);
-
- const uint32_t num_variables = variable_list.GetSize();
-
- bool found = false;
- for (uint32_t i = 0; i < num_variables && !found; ++i)
+ lldb_private::VariableList *variable_list = m_opaque_sp->GetVariableList(true);
+ if (variable_list)
{
- var_sp = variable_list.GetVariableAtIndex(i);
- if (var_sp
- && (var_sp.get()->GetName() == lldb_private::ConstString(var_name))
- && var_sp.get()->GetScope() == var_scope)
- found = true;
+ const uint32_t num_variables = variable_list->GetSize();
+ bool found = false;
+ for (uint32_t i = 0; i < num_variables && !found; ++i)
+ {
+ var_sp = variable_list->GetVariableAtIndex(i);
+ if (var_sp
+ && (var_sp.get()->GetName() == lldb_private::ConstString(var_name))
+ && var_sp.get()->GetScope() == var_scope)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ var_sp.reset();
}
- if (!found)
- var_sp.reset();
}
}
diff --git a/lldb/test/class_static/TestStaticVariables.py b/lldb/test/class_static/TestStaticVariables.py
index cfcfaa96f7e..c9a5f6685d4 100644
--- a/lldb/test/class_static/TestStaticVariables.py
+++ b/lldb/test/class_static/TestStaticVariables.py
@@ -116,8 +116,23 @@ class StaticVariableTestCase(TestBase):
self.assertTrue(child1_x.GetTypeName() == 'int' and
child1_x.GetValue(frame) == '11')
- #variable = frame.LookupVarInScope("A::g_points", "global")
- #print "variable:", repr(variable)
+ # SBFrame.LookupVarInScope() should also work.
+ val = frame.LookupVarInScope("A::g_points", "global")
+ self.DebugSBValue(frame, val)
+ self.assertTrue(val.GetName() == 'A::g_points')
+
+ # Also exercise the "parameter" and "local" scopes while we are at it.
+ val = frame.LookupVarInScope("argc", "parameter")
+ self.DebugSBValue(frame, val)
+ self.assertTrue(val.GetName() == 'argc')
+
+ val = frame.LookupVarInScope("argv", "parameter")
+ self.DebugSBValue(frame, val)
+ self.assertTrue(val.GetName() == 'argv')
+
+ val = frame.LookupVarInScope("hello_world", "local")
+ self.DebugSBValue(frame, val)
+ self.assertTrue(val.GetName() == 'hello_world')
if __name__ == '__main__':
diff --git a/lldb/test/class_static/main.cpp b/lldb/test/class_static/main.cpp
index dfce224e00e..2068eadcac5 100644
--- a/lldb/test/class_static/main.cpp
+++ b/lldb/test/class_static/main.cpp
@@ -45,7 +45,9 @@ static PointType g_points[] =
int
main (int argc, char const *argv[])
{
+ const char *hello_world = "Hello, world!";
printf ("A::g_points[1].x = %i\n", A::g_points[1].x); // Set break point at this line.
printf ("::g_points[1].x = %i\n", g_points[1].x);
+ printf ("%s\n", hello_world);
return 0;
}
OpenPOWER on IntegriCloud