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