1662548c8SAlex Langford STRING_EXTENSION_OUTSIDE(SBFrame) 2662548c8SAlex Langford 3662548c8SAlex Langford %extend lldb::SBFrame { 4662548c8SAlex Langford #ifdef SWIGPYTHON 5662548c8SAlex Langford %pythoncode %{ 66813ef37SMed Ismail Bennani # operator== is a free function, which swig does not handle, so we inject 76813ef37SMed Ismail Bennani # our own equality operator here 86813ef37SMed Ismail Bennani def __eq__(self, other): 96813ef37SMed Ismail Bennani return not self.__ne__(other) 106813ef37SMed Ismail Bennani 116813ef37SMed Ismail Bennani def __int__(self): 126813ef37SMed Ismail Bennani return self.GetFrameID() 136813ef37SMed Ismail Bennani 146813ef37SMed Ismail Bennani def __hex__(self): 156813ef37SMed Ismail Bennani return self.GetPC() 166813ef37SMed Ismail Bennani 17662548c8SAlex Langford def get_all_variables(self): 18662548c8SAlex Langford return self.GetVariables(True,True,True,True) 19662548c8SAlex Langford 20662548c8SAlex Langford def get_parent_frame(self): 21662548c8SAlex Langford parent_idx = self.idx + 1 22662548c8SAlex Langford if parent_idx >= 0 and parent_idx < len(self.thread.frame): 23662548c8SAlex Langford return self.thread.frame[parent_idx] 24662548c8SAlex Langford else: 25662548c8SAlex Langford return SBFrame() 26662548c8SAlex Langford 27662548c8SAlex Langford def get_arguments(self): 28662548c8SAlex Langford return self.GetVariables(True,False,False,False) 29662548c8SAlex Langford 30662548c8SAlex Langford def get_locals(self): 31662548c8SAlex Langford return self.GetVariables(False,True,False,False) 32662548c8SAlex Langford 33662548c8SAlex Langford def get_statics(self): 34662548c8SAlex Langford return self.GetVariables(False,False,True,False) 35662548c8SAlex Langford 36662548c8SAlex Langford def var(self, var_expr_path): 37662548c8SAlex Langford '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns 38662548c8SAlex Langford a value that represents the variable expression path''' 39662548c8SAlex Langford return self.GetValueForVariablePath(var_expr_path) 40662548c8SAlex Langford 41662548c8SAlex Langford def get_registers_access(self): 42662548c8SAlex Langford class registers_access(object): 43662548c8SAlex Langford '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.''' 44662548c8SAlex Langford def __init__(self, regs): 45662548c8SAlex Langford self.regs = regs 46662548c8SAlex Langford 47*4b0beb4fSjimingham def __iter__(self): 48*4b0beb4fSjimingham return self.get_registers() 49*4b0beb4fSjimingham 50*4b0beb4fSjimingham def get_registers(self): 51*4b0beb4fSjimingham for i in range(0,len(self.regs)): 52*4b0beb4fSjimingham rs = self.regs[i] 53*4b0beb4fSjimingham for j in range (0,rs.num_children): 54*4b0beb4fSjimingham reg = rs.GetChildAtIndex(j) 55*4b0beb4fSjimingham yield reg 56*4b0beb4fSjimingham 57662548c8SAlex Langford def __getitem__(self, key): 58662548c8SAlex Langford if type(key) is str: 59662548c8SAlex Langford for i in range(0,len(self.regs)): 60662548c8SAlex Langford rs = self.regs[i] 61662548c8SAlex Langford for j in range (0,rs.num_children): 62662548c8SAlex Langford reg = rs.GetChildAtIndex(j) 63662548c8SAlex Langford if reg.name == key: return reg 64662548c8SAlex Langford else: 65*4b0beb4fSjimingham return SBValue() 66662548c8SAlex Langford 67662548c8SAlex Langford return registers_access(self.registers) 68662548c8SAlex Langford 69662548c8SAlex Langford pc = property(GetPC, SetPC) 70662548c8SAlex Langford addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') 71662548c8SAlex Langford fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') 72662548c8SAlex Langford sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') 73662548c8SAlex Langford module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') 74662548c8SAlex Langford 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.''') 75662548c8SAlex Langford function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') 76662548c8SAlex Langford symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') 77662548c8SAlex Langford block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') 78662548c8SAlex Langford is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') 79662548c8SAlex Langford 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).''') 80662548c8SAlex Langford 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.''') 81662548c8SAlex Langford thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') 82662548c8SAlex Langford disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') 83662548c8SAlex Langford idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') 84662548c8SAlex Langford 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.''') 85662548c8SAlex Langford 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.''') 86662548c8SAlex Langford 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.''') 87662548c8SAlex Langford 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.''') 88662548c8SAlex Langford 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.''') 89662548c8SAlex Langford 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.''') 90662548c8SAlex Langford 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.''') 91662548c8SAlex Langford 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.''') 92662548c8SAlex Langford 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.''') 93662548c8SAlex Langford 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''') 94662548c8SAlex Langford parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') 95662548c8SAlex Langford %} 96662548c8SAlex Langford #endif 97662548c8SAlex Langford } 98