blob: 1735dd9947216cc8820dbc76aa21d9d745168152 [file] [log] [blame]
Johnny Chenc3fba812011-07-18 20:13:38 +00001//===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10namespace lldb {
11
12%feature("docstring",
13"Represents one of the stack frames associated with a thread.
Johnny Chen6d91e0a2011-07-19 01:07:06 +000014SBThread contains SBFrame(s). For example (from test/lldbutil.py),
15
16def print_stacktrace(thread, string_buffer = False):
17 '''Prints a simple stack trace of this thread.'''
18
19 ...
20
21 for i in range(depth):
22 frame = thread.GetFrameAtIndex(i)
23 function = frame.GetFunction()
24
25 load_addr = addrs[i].GetLoadAddress(target)
26 if not function:
27 file_addr = addrs[i].GetFileAddress()
28 start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress()
29 symbol_offset = file_addr - start_addr
30 print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
31 num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset)
32 else:
33 print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
34 num=i, addr=load_addr, mod=mods[i],
35 func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i],
36 file=files[i], line=lines[i],
37 args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()')
38
39 ...
Johnny Chenc6f09f02011-07-27 18:13:32 +000040
41And,
42
43 for frame in thread:
44 print frame
45
46See also SBThread."
Johnny Chenc3fba812011-07-18 20:13:38 +000047) SBFrame;
48class SBFrame
49{
50public:
51 SBFrame ();
52
53 SBFrame (const lldb::SBFrame &rhs);
54
55 ~SBFrame();
56
57 bool
Johnny Chen0164b752012-03-05 19:53:24 +000058 IsEqual (const lldb::SBFrame &rhs) const;
59
60 bool
Johnny Chenc3fba812011-07-18 20:13:38 +000061 IsValid() const;
62
63 uint32_t
64 GetFrameID () const;
65
66 lldb::addr_t
67 GetPC () const;
68
69 bool
70 SetPC (lldb::addr_t new_pc);
71
72 lldb::addr_t
73 GetSP () const;
74
75 lldb::addr_t
76 GetFP () const;
77
78 lldb::SBAddress
79 GetPCAddress () const;
80
81 lldb::SBSymbolContext
82 GetSymbolContext (uint32_t resolve_scope) const;
83
84 lldb::SBModule
85 GetModule () const;
86
87 lldb::SBCompileUnit
88 GetCompileUnit () const;
89
90 lldb::SBFunction
91 GetFunction () const;
92
93 lldb::SBSymbol
94 GetSymbol () const;
95
96 %feature("docstring", "
97 /// Gets the deepest block that contains the frame PC.
98 ///
99 /// See also GetFrameBlock().
100 ") GetBlock;
101 lldb::SBBlock
102 GetBlock () const;
103
104 %feature("docstring", "
105 /// Get the appropriate function name for this frame. Inlined functions in
106 /// LLDB are represented by Blocks that have inlined function information, so
107 /// just looking at the SBFunction or SBSymbol for a frame isn't enough.
108 /// This function will return the appriopriate function, symbol or inlined
109 /// function name for the frame.
110 ///
111 /// This function returns:
112 /// - the name of the inlined function (if there is one)
113 /// - the name of the concrete function (if there is one)
114 /// - the name of the symbol (if there is one)
115 /// - NULL
116 ///
117 /// See also IsInlined().
118 ") GetFunctionName;
119 const char *
120 GetFunctionName();
121
122 %feature("docstring", "
123 /// Return true if this frame represents an inlined function.
124 ///
125 /// See also GetFunctionName().
126 ") IsInlined;
127 bool
128 IsInlined();
129
130 %feature("docstring", "
131 /// The version that doesn't supply a 'use_dynamic' value will use the
132 /// target's default.
133 ") EvaluateExpression;
134 lldb::SBValue
135 EvaluateExpression (const char *expr);
136
137 lldb::SBValue
138 EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
139
Jim Inghamd82bc6d2012-05-11 23:47:32 +0000140 lldb::SBValue
141 EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error);
Jim Ingham47beabb2012-10-16 21:41:58 +0000142
143 lldb::SBValue
144 EvaluateExpression (const char *expr, SBExpressionOptions &options);
Jim Inghamd82bc6d2012-05-11 23:47:32 +0000145
Johnny Chenc3fba812011-07-18 20:13:38 +0000146 %feature("docstring", "
147 /// Gets the lexical block that defines the stack frame. Another way to think
148 /// of this is it will return the block that contains all of the variables
149 /// for a stack frame. Inlined functions are represented as SBBlock objects
150 /// that have inlined function information: the name of the inlined function,
151 /// where it was called from. The block that is returned will be the first
152 /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
153 /// the scope of the frame. When a function contains no inlined functions,
154 /// this will be the top most lexical block that defines the function.
155 /// When a function has inlined functions and the PC is currently
156 /// in one of those inlined functions, this method will return the inlined
157 /// block that defines this frame. If the PC isn't currently in an inlined
158 /// function, the lexical block that defines the function is returned.
159 ") GetFrameBlock;
160 lldb::SBBlock
161 GetFrameBlock () const;
162
163 lldb::SBLineEntry
164 GetLineEntry () const;
165
166 lldb::SBThread
167 GetThread () const;
168
169 const char *
170 Disassemble () const;
171
172 void
173 Clear();
174
175#ifndef SWIG
176 bool
177 operator == (const lldb::SBFrame &rhs) const;
178
179 bool
180 operator != (const lldb::SBFrame &rhs) const;
181
182#endif
183
184 %feature("docstring", "
185 /// The version that doesn't supply a 'use_dynamic' value will use the
186 /// target's default.
187 ") GetVariables;
188 lldb::SBValueList
189 GetVariables (bool arguments,
190 bool locals,
191 bool statics,
192 bool in_scope_only);
193
194 lldb::SBValueList
195 GetVariables (bool arguments,
196 bool locals,
197 bool statics,
198 bool in_scope_only,
199 lldb::DynamicValueType use_dynamic);
200
201 lldb::SBValueList
202 GetRegisters ();
203
204 %feature("docstring", "
205 /// The version that doesn't supply a 'use_dynamic' value will use the
206 /// target's default.
207 ") FindVariable;
208 lldb::SBValue
209 FindVariable (const char *var_name);
210
211 lldb::SBValue
212 FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
213
214 %feature("docstring", "
Greg Claytond62b9c12012-02-03 07:02:37 +0000215 /// Get a lldb.SBValue for a variable path.
216 ///
217 /// Variable paths can include access to pointer or instance members:
218 /// rect_ptr->origin.y
219 /// pt.x
220 /// Pointer dereferences:
221 /// *this->foo_ptr
222 /// **argv
223 /// Address of:
224 /// &pt
225 /// &my_array[3].x
226 /// Array accesses and treating pointers as arrays:
227 /// int_array[1]
228 /// pt_ptr[22].x
229 ///
230 /// Unlike EvaluateExpression() which returns lldb.SBValue objects
231 /// with constant copies of the values at the time of evaluation,
232 /// the result of this function is a value that will continue to
233 /// track the current value of the value as execution progresses
234 /// in the current frame.
235 ") GetValueForVariablePath;
236 lldb::SBValue
237 GetValueForVariablePath (const char *var_path);
238
239 lldb::SBValue
240 GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic);
241
242 %feature("docstring", "
Johnny Chenc3fba812011-07-18 20:13:38 +0000243 /// Find variables, register sets, registers, or persistent variables using
244 /// the frame as the scope.
245 ///
246 /// The version that doesn't supply a 'use_dynamic' value will use the
247 /// target's default.
248 ") FindValue;
249 lldb::SBValue
250 FindValue (const char *name, ValueType value_type);
251
252 lldb::SBValue
253 FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
254
Johnny Chenc3fba812011-07-18 20:13:38 +0000255 bool
256 GetDescription (lldb::SBStream &description);
Greg Clayton1b925202012-01-29 06:07:39 +0000257
258 %pythoncode %{
Greg Claytond62b9c12012-02-03 07:02:37 +0000259 def get_all_variables(self):
260 return self.GetVariables(True,True,True,True)
261
262 def get_arguments(self):
263 return self.GetVariables(True,False,False,False)
264
265 def get_locals(self):
266 return self.GetVariables(False,True,False,False)
267
268 def get_statics(self):
269 return self.GetVariables(False,False,True,False)
270
271 def var(self, var_expr_path):
272 '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns
273 a value that represents the variable expression path'''
274 return self.GetValueForVariablePath(var_expr_path)
275
Greg Clayton1b925202012-01-29 06:07:39 +0000276 __swig_getmethods__["pc"] = GetPC
277 __swig_setmethods__["pc"] = SetPC
Greg Clayton2a94be12012-06-29 22:00:42 +0000278 if _newclass: pc = property(GetPC, SetPC)
Johnny Chenc3fba812011-07-18 20:13:38 +0000279
Greg Claytonb302dff2012-02-01 08:09:32 +0000280 __swig_getmethods__["addr"] = GetPCAddress
Greg Clayton2a94be12012-06-29 22:00:42 +0000281 if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''')
Greg Claytonb302dff2012-02-01 08:09:32 +0000282
Greg Clayton1b925202012-01-29 06:07:39 +0000283 __swig_getmethods__["fp"] = GetFP
Greg Clayton2a94be12012-06-29 22:00:42 +0000284 if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000285
286 __swig_getmethods__["sp"] = GetSP
Greg Clayton2a94be12012-06-29 22:00:42 +0000287 if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000288
289 __swig_getmethods__["module"] = GetModule
Greg Clayton2a94be12012-06-29 22:00:42 +0000290 if _newclass: module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000291
292 __swig_getmethods__["compile_unit"] = GetCompileUnit
Greg Clayton2a94be12012-06-29 22:00:42 +0000293 if _newclass: 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.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000294
295 __swig_getmethods__["function"] = GetFunction
Greg Clayton2a94be12012-06-29 22:00:42 +0000296 if _newclass: function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000297
298 __swig_getmethods__["symbol"] = GetSymbol
Greg Clayton2a94be12012-06-29 22:00:42 +0000299 if _newclass: symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000300
301 __swig_getmethods__["block"] = GetBlock
Greg Clayton2a94be12012-06-29 22:00:42 +0000302 if _newclass: block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000303
304 __swig_getmethods__["is_inlined"] = IsInlined
Greg Clayton2a94be12012-06-29 22:00:42 +0000305 if _newclass: is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000306
307 __swig_getmethods__["name"] = GetFunctionName
Greg Clayton2a94be12012-06-29 22:00:42 +0000308 if _newclass: 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).''')
Greg Clayton1b925202012-01-29 06:07:39 +0000309
310 __swig_getmethods__["line_entry"] = GetLineEntry
Greg Clayton2a94be12012-06-29 22:00:42 +0000311 if _newclass: 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.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000312
313 __swig_getmethods__["thread"] = GetThread
Greg Clayton2a94be12012-06-29 22:00:42 +0000314 if _newclass: thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000315
316 __swig_getmethods__["disassembly"] = Disassemble
Greg Clayton2a94be12012-06-29 22:00:42 +0000317 if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000318
319 __swig_getmethods__["idx"] = GetFrameID
Greg Clayton2a94be12012-06-29 22:00:42 +0000320 if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000321
Greg Claytond62b9c12012-02-03 07:02:37 +0000322 __swig_getmethods__["variables"] = get_all_variables
Greg Clayton2a94be12012-06-29 22:00:42 +0000323 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000324
325 __swig_getmethods__["vars"] = get_all_variables
Greg Clayton2a94be12012-06-29 22:00:42 +0000326 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000327
328 __swig_getmethods__["locals"] = get_locals
Greg Clayton2a94be12012-06-29 22:00:42 +0000329 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000330
331 __swig_getmethods__["args"] = get_arguments
Greg Clayton2a94be12012-06-29 22:00:42 +0000332 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000333
334 __swig_getmethods__["arguments"] = get_arguments
Greg Clayton2a94be12012-06-29 22:00:42 +0000335 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000336
337 __swig_getmethods__["statics"] = get_statics
Greg Clayton2a94be12012-06-29 22:00:42 +0000338 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000339
340 __swig_getmethods__["registers"] = GetRegisters
Greg Clayton2a94be12012-06-29 22:00:42 +0000341 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000342
343 __swig_getmethods__["regs"] = GetRegisters
Greg Clayton2a94be12012-06-29 22:00:42 +0000344 if _newclass: 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.''')
Greg Claytond62b9c12012-02-03 07:02:37 +0000345
Greg Clayton1b925202012-01-29 06:07:39 +0000346 %}
Johnny Chenc3fba812011-07-18 20:13:38 +0000347};
348
349} // namespace lldb