list = target.FindGlobalVariables('days_of_week', 1)
days_of_week = list.GetValueAtIndex(0)
self.assertTrue(days_of_week, VALID_VARIABLE)
- self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE)
+ self.assertEqual(days_of_week.GetNumChildren(), 7, VALID_VARIABLE)
self.DebugSBValue(days_of_week)
+ # Use this to test the "child" and "children" accessors:
+ children = days_of_week.children
+ self.assertEqual(len(children), 7, VALID_VARIABLE)
+ for i in range(0, len(children)):
+ day = days_of_week.child[i]
+ list_day = children[i]
+ self.assertNotEqual(day, None)
+ self.assertNotEqual(list_day, None)
+ self.assertEqual(day.GetSummary(), list_day.GetSummary(), VALID_VARIABLE)
+
+ # Spot check the actual value:
+ first_day = days_of_week.child[1]
+ self.assertEqual(first_day.GetSummary(), '"Monday"', VALID_VARIABLE)
+
# Get global variable 'weekdays'.
list = target.FindGlobalVariables('weekdays', 1)
weekdays = list.GetValueAtIndex(0)
lldb::SBValue
CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type);
- lldb::SBValue
- CreateValueFromData (const char* name,
- lldb::SBData data,
- lldb::SBType type);
+ lldb::SBValue
+ CreateValueFromData (const char* name,
+ lldb::SBData data,
+ lldb::SBType type);
lldb::SBType
GetType();
bool
GetExpressionPath (lldb::SBStream &description);
- %feature("docstring", "
- //------------------------------------------------------------------
+ %feature("docstring", "
+ //------------------------------------------------------------------
/// Get an SBData wrapping what this SBValue points to.
///
/// This method will dereference the current SBValue, if its
/// An SBData with the contents of the copied items, on success.
/// An empty SBData otherwise.
//------------------------------------------------------------------
- ") GetPointeeData;
- lldb::SBData
- GetPointeeData (uint32_t item_idx = 0,
- uint32_t item_count = 1);
+ ") GetPointeeData;
+ lldb::SBData
+ GetPointeeData (uint32_t item_idx = 0,
+ uint32_t item_count = 1);
%feature("docstring", "
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
/// Get an SBData wrapping the contents of this SBValue.
///
/// This method will read the contents of this object in memory
/// An SBData with the contents of this SBValue, on success.
/// An empty SBData otherwise.
//------------------------------------------------------------------
- ") GetData;
+ ") GetData;
lldb::SBData
GetData ();
bool
SetData (lldb::SBData &data, lldb::SBError& error);
- lldb::addr_t
- GetLoadAddress();
+ lldb::addr_t
+ GetLoadAddress();
- lldb::SBAddress
- GetAddress();
+ lldb::SBAddress
+ GetAddress();
lldb::SBValue
Persist ();
'''Helper function for the "SBValue.dynamic" property.'''
return self.GetDynamicValue (eDynamicCanRunTarget)
+ class children_access(object):
+ '''A helper object that will lazily hand out thread for a process when supplied an index.'''
+
+ def __init__(self, sbvalue):
+ self.sbvalue = sbvalue
+
+ def __len__(self):
+ if self.sbvalue:
+ return int(self.sbvalue.GetNumChildren())
+ return 0
+
+ def __getitem__(self, key):
+ if type(key) is int and key < len(self):
+ return self.sbvalue.GetChildAtIndex(key)
+ return None
+
+ def get_child_access_object(self):
+ '''An accessor function that returns a children_access() object which allows lazy member variable access from a lldb.SBValue object.'''
+ return self.children_access (self)
+
+ def get_value_child_list(self):
+ '''An accessor function that returns a list() that contains all children in a lldb.SBValue object.'''
+ children = []
+ accessor = self.get_child_access_object()
+ for idx in range(len(accessor)):
+ children.append(accessor[idx])
+ return children
+
+ __swig_getmethods__["children"] = get_value_child_list
+ if _newclass: children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''')
+
+ __swig_getmethods__["child"] = get_child_access_object
+ if _newclass: child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''')
+
__swig_getmethods__["name"] = GetName
if _newclass: name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''')