diff options
author | Greg Clayton <gclayton@apple.com> | 2012-02-03 07:02:37 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-02-03 07:02:37 +0000 |
commit | 7edbdfc97c40f87111d4d95afad7f5d0d274c28e (patch) | |
tree | ad14f3f8635d9a35b46323806f435d17ebbf968d /lldb/scripts/Python/interface/SBFrame.i | |
parent | 47e6d269112e9fc5576fe97236b778b36db6a8e1 (diff) | |
download | llvm-7edbdfc97c40f87111d4d95afad7f5d0d274c28e.zip llvm-7edbdfc97c40f87111d4d95afad7f5d0d274c28e.tar.gz llvm-7edbdfc97c40f87111d4d95afad7f5d0d274c28e.tar.bz2 |
Expose more convenience functionality in the python classes.
lldb.SBValueList now exposes the len() method and also allows item access:
lldb.SBValueList[<int>] - where <int> is an integer index into the list, returns a single lldb.SBValue which might be empty if the index is out of range
lldb.SBValueList[<str>] - where <str> is the name to look for, returns a list() of lldb.SBValue objects with any matching values (the list might be empty if nothing matches)
lldb.SBValueList[<re>] - where <re> is a compiles regular expression, returns a list of lldb.SBValue objects for containing any matches or a empty list if nothing matches
lldb.SBFrame now exposes:
lldb.SBFrame.variables => SBValueList of all variables that are in scope
lldb.SBFrame.vars => see lldb.SBFrame.variables
lldb.SBFrame.locals => SBValueList of all variables that are locals in the current frame
lldb.SBFrame.arguments => SBValueList of all variables that are arguments in the current frame
lldb.SBFrame.args => see lldb.SBFrame.arguments
lldb.SBFrame.statics => SBValueList of all static variables
lldb.SBFrame.registers => SBValueList of all registers for the current frame
lldb.SBFrame.regs => see lldb.SBFrame.registers
Combine any of the above properties with the new lldb.SBValueList functionality
and now you can do:
y = lldb.frame.vars['rect.origin.y']
or
vars = lldb.frame.vars
for i in range len(vars):
print vars[i]
Also expose "lldb.SBFrame.var(<str>)" where <str> can be en expression path
for any variable or child within the variable. This makes it easier to get a
value from the current frame like "rect.origin.y". The resulting value is also
not a constant result as expressions will return, but a live value that will
continue to track the current value for the variable expression path.
lldb.SBValue now exposes:
lldb.SBValue.unsigned => unsigned integer for the value
lldb.SBValue.signed => a signed integer for the value
llvm-svn: 149684
Diffstat (limited to 'lldb/scripts/Python/interface/SBFrame.i')
-rw-r--r-- | lldb/scripts/Python/interface/SBFrame.i | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lldb/scripts/Python/interface/SBFrame.i b/lldb/scripts/Python/interface/SBFrame.i index 3a6e799..c7180735 100644 --- a/lldb/scripts/Python/interface/SBFrame.i +++ b/lldb/scripts/Python/interface/SBFrame.i @@ -203,6 +203,34 @@ public: FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic); %feature("docstring", " + /// Get a lldb.SBValue for a variable path. + /// + /// Variable paths can include access to pointer or instance members: + /// rect_ptr->origin.y + /// pt.x + /// Pointer dereferences: + /// *this->foo_ptr + /// **argv + /// Address of: + /// &pt + /// &my_array[3].x + /// Array accesses and treating pointers as arrays: + /// int_array[1] + /// pt_ptr[22].x + /// + /// Unlike EvaluateExpression() which returns lldb.SBValue objects + /// with constant copies of the values at the time of evaluation, + /// the result of this function is a value that will continue to + /// track the current value of the value as execution progresses + /// in the current frame. + ") GetValueForVariablePath; + lldb::SBValue + GetValueForVariablePath (const char *var_path); + + lldb::SBValue + GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic); + + %feature("docstring", " /// Find variables, register sets, registers, or persistent variables using /// the frame as the scope. /// @@ -219,6 +247,23 @@ public: GetDescription (lldb::SBStream &description); %pythoncode %{ + def get_all_variables(self): + return self.GetVariables(True,True,True,True) + + def get_arguments(self): + return self.GetVariables(True,False,False,False) + + def get_locals(self): + return self.GetVariables(False,True,False,False) + + def get_statics(self): + return self.GetVariables(False,False,True,False) + + def var(self, var_expr_path): + '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns + a value that represents the variable expression path''' + return self.GetValueForVariablePath(var_expr_path) + __swig_getmethods__["pc"] = GetPC __swig_setmethods__["pc"] = SetPC if _newclass: x = property(GetPC, SetPC) @@ -265,6 +310,30 @@ public: __swig_getmethods__["idx"] = GetFrameID if _newclass: x = property(GetFrameID, None) + __swig_getmethods__["variables"] = get_all_variables + if _newclass: x = property(get_all_variables, None) + + __swig_getmethods__["vars"] = get_all_variables + if _newclass: x = property(get_all_variables, None) + + __swig_getmethods__["locals"] = get_locals + if _newclass: x = property(get_locals, None) + + __swig_getmethods__["args"] = get_arguments + if _newclass: x = property(get_arguments, None) + + __swig_getmethods__["arguments"] = get_arguments + if _newclass: x = property(get_arguments, None) + + __swig_getmethods__["statics"] = get_statics + if _newclass: x = property(get_statics, None) + + __swig_getmethods__["registers"] = GetRegisters + if _newclass: x = property(GetRegisters, None) + + __swig_getmethods__["regs"] = GetRegisters + if _newclass: x = property(GetRegisters, None) + %} }; |