106c3fb27SDimitry Andric STRING_EXTENSION_OUTSIDE(SBFrame) 206c3fb27SDimitry Andric 306c3fb27SDimitry Andric %extend lldb::SBFrame { 406c3fb27SDimitry Andric #ifdef SWIGPYTHON 506c3fb27SDimitry Andric %pythoncode %{ 65f757f3fSDimitry Andric # operator== is a free function, which swig does not handle, so we inject 75f757f3fSDimitry Andric # our own equality operator here 85f757f3fSDimitry Andric def __eq__(self, other): 95f757f3fSDimitry Andric return not self.__ne__(other) 105f757f3fSDimitry Andric 115f757f3fSDimitry Andric def __int__(self): 125f757f3fSDimitry Andric return self.GetFrameID() 135f757f3fSDimitry Andric 145f757f3fSDimitry Andric def __hex__(self): 155f757f3fSDimitry Andric return self.GetPC() 165f757f3fSDimitry Andric 1706c3fb27SDimitry Andric def get_all_variables(self): 1806c3fb27SDimitry Andric return self.GetVariables(True,True,True,True) 1906c3fb27SDimitry Andric 2006c3fb27SDimitry Andric def get_parent_frame(self): 2106c3fb27SDimitry Andric parent_idx = self.idx + 1 2206c3fb27SDimitry Andric if parent_idx >= 0 and parent_idx < len(self.thread.frame): 2306c3fb27SDimitry Andric return self.thread.frame[parent_idx] 2406c3fb27SDimitry Andric else: 2506c3fb27SDimitry Andric return SBFrame() 2606c3fb27SDimitry Andric 2706c3fb27SDimitry Andric def get_arguments(self): 2806c3fb27SDimitry Andric return self.GetVariables(True,False,False,False) 2906c3fb27SDimitry Andric 3006c3fb27SDimitry Andric def get_locals(self): 3106c3fb27SDimitry Andric return self.GetVariables(False,True,False,False) 3206c3fb27SDimitry Andric 3306c3fb27SDimitry Andric def get_statics(self): 3406c3fb27SDimitry Andric return self.GetVariables(False,False,True,False) 3506c3fb27SDimitry Andric 3606c3fb27SDimitry Andric def var(self, var_expr_path): 3706c3fb27SDimitry Andric '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns 3806c3fb27SDimitry Andric a value that represents the variable expression path''' 3906c3fb27SDimitry Andric return self.GetValueForVariablePath(var_expr_path) 4006c3fb27SDimitry Andric 4106c3fb27SDimitry Andric def get_registers_access(self): 4206c3fb27SDimitry Andric class registers_access(object): 4306c3fb27SDimitry Andric '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.''' 4406c3fb27SDimitry Andric def __init__(self, regs): 4506c3fb27SDimitry Andric self.regs = regs 4606c3fb27SDimitry Andric 47*0fca6ea1SDimitry Andric def __iter__(self): 48*0fca6ea1SDimitry Andric return self.get_registers() 49*0fca6ea1SDimitry Andric 50*0fca6ea1SDimitry Andric def get_registers(self): 51*0fca6ea1SDimitry Andric for i in range(0,len(self.regs)): 52*0fca6ea1SDimitry Andric rs = self.regs[i] 53*0fca6ea1SDimitry Andric for j in range (0,rs.num_children): 54*0fca6ea1SDimitry Andric reg = rs.GetChildAtIndex(j) 55*0fca6ea1SDimitry Andric yield reg 56*0fca6ea1SDimitry Andric 5706c3fb27SDimitry Andric def __getitem__(self, key): 5806c3fb27SDimitry Andric if type(key) is str: 5906c3fb27SDimitry Andric for i in range(0,len(self.regs)): 6006c3fb27SDimitry Andric rs = self.regs[i] 6106c3fb27SDimitry Andric for j in range (0,rs.num_children): 6206c3fb27SDimitry Andric reg = rs.GetChildAtIndex(j) 6306c3fb27SDimitry Andric if reg.name == key: return reg 6406c3fb27SDimitry Andric else: 65*0fca6ea1SDimitry Andric return SBValue() 6606c3fb27SDimitry Andric 6706c3fb27SDimitry Andric return registers_access(self.registers) 6806c3fb27SDimitry Andric 6906c3fb27SDimitry Andric pc = property(GetPC, SetPC) 7006c3fb27SDimitry Andric addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') 7106c3fb27SDimitry Andric fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') 7206c3fb27SDimitry Andric sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') 7306c3fb27SDimitry Andric module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''') 7406c3fb27SDimitry Andric 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.''') 7506c3fb27SDimitry Andric function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''') 7606c3fb27SDimitry Andric symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''') 7706c3fb27SDimitry Andric block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''') 7806c3fb27SDimitry Andric is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''') 7906c3fb27SDimitry Andric 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).''') 8006c3fb27SDimitry Andric 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.''') 8106c3fb27SDimitry Andric thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''') 8206c3fb27SDimitry Andric disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') 8306c3fb27SDimitry Andric idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') 8406c3fb27SDimitry Andric 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.''') 8506c3fb27SDimitry Andric 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.''') 8606c3fb27SDimitry Andric 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.''') 8706c3fb27SDimitry Andric 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.''') 8806c3fb27SDimitry Andric 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.''') 8906c3fb27SDimitry Andric 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.''') 9006c3fb27SDimitry Andric 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.''') 9106c3fb27SDimitry Andric 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.''') 9206c3fb27SDimitry Andric 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.''') 9306c3fb27SDimitry Andric 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''') 9406c3fb27SDimitry Andric parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''') 9506c3fb27SDimitry Andric %} 9606c3fb27SDimitry Andric #endif 9706c3fb27SDimitry Andric } 98