106 lines · plain
1STRING_EXTENSION_OUTSIDE(SBFrame)2 3%extend lldb::SBFrame {4#ifdef SWIGPYTHON5 %pythoncode %{6 # operator== is a free function, which swig does not handle, so we inject7 # our own equality operator here8 def __eq__(self, other):9 return not self.__ne__(other)10 11 def __int__(self):12 return self.GetFrameID()13 14 def __hex__(self):15 return self.GetPC()16 17 def get_all_variables(self):18 return self.GetVariables(True,True,True,True)19 20 def get_parent_frame(self):21 parent_idx = self.idx + 122 if parent_idx >= 0 and parent_idx < len(self.thread.frame):23 return self.thread.frame[parent_idx]24 else:25 return SBFrame()26 27 def get_child_frame(self):28 child_idx = self.idx - 129 if child_idx >= 0:30 return self.thread.frame[child_idx]31 else:32 return SBFrame()33 34 def get_arguments(self):35 return self.GetVariables(True,False,False,False)36 37 def get_locals(self):38 return self.GetVariables(False,True,False,False)39 40 def get_statics(self):41 return self.GetVariables(False,False,True,False)42 43 def var(self, var_expr_path):44 '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns45 a value that represents the variable expression path'''46 return self.GetValueForVariablePath(var_expr_path)47 48 def get_registers_access(self):49 class registers_access(object):50 '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.'''51 def __init__(self, regs):52 self.regs = regs53 54 def __iter__(self):55 return self.get_registers()56 57 def get_registers(self):58 for i in range(0,len(self.regs)):59 rs = self.regs[i]60 for j in range (0,rs.num_children):61 reg = rs.GetChildAtIndex(j)62 yield reg63 64 def __getitem__(self, key):65 if type(key) is str:66 for i in range(0,len(self.regs)):67 rs = self.regs[i]68 for j in range (0,rs.num_children):69 reg = rs.GetChildAtIndex(j)70 if reg.name == key: return reg71 else:72 return SBValue()73 74 return registers_access(self.registers)75 76 pc = property(GetPC, SetPC)77 addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''')78 fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''')79 sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''')80 module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''')81 compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''')82 function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''')83 symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''')84 block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''')85 is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''')86 name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''')87 line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''')88 thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''')89 disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''')90 idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''')91 variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')92 vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')93 locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''')94 args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')95 arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')96 statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''')97 registers = property(GetRegisters, None, doc='''Returns the register sets for this thread as a list(). See SBFrame::GetRegisters() for details.''')98 regs = property(GetRegisters, None, doc='''Returns the register sets for this thread as a list(). See SBFrame::GetRegisters() for details.''')99 register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''')100 reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''')101 parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')102 child = property(get_child_frame, None, doc='''A read only property that returns the child (callee) frame of the current frame.''')103 %}104#endif105}106