1 STRING_EXTENSION_OUTSIDE(SBFrame) 2 3 %extend lldb::SBFrame { 4 #ifdef SWIGPYTHON 5 %pythoncode %{ 6 # operator== is a free function, which swig does not handle, so we inject 7 # our own equality operator here 8 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 + 1 22 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_arguments(self): 28 return self.GetVariables(True,False,False,False) 29 30 def get_locals(self): 31 return self.GetVariables(False,True,False,False) 32 33 def get_statics(self): 34 return self.GetVariables(False,False,True,False) 35 36 def var(self, var_expr_path): 37 '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns 38 a value that represents the variable expression path''' 39 return self.GetValueForVariablePath(var_expr_path) 40 41 def get_registers_access(self): 42 class registers_access(object): 43 '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.''' 44 def __init__(self, regs): 45 self.regs = regs 46 47 def __getitem__(self, key): 48 if type(key) is str: 49 for i in range(0,len(self.regs)): 50 rs = self.regs[i] 51 for j in range (0,rs.num_children): 52 reg = rs.GetChildAtIndex(j) 53 if reg.name == key: return reg 54 else: 55 return lldb.SBValue() 56 57 return registers_access(self.registers) 58 59 pc = property(GetPC, SetPC) 60 addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') 61 fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') 62 sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') 63 module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') 64 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.''') 65 function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') 66 symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') 67 block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') 68 is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') 69 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).''') 70 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.''') 71 thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') 72 disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') 73 idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') 74 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.''') 75 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.''') 76 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.''') 77 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.''') 78 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.''') 79 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.''') 80 registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') 81 regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''') 82 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.''') 83 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''') 84 parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') 85 %} 86 #endif 87 } 88