blob: 20093a026aa3ed3e069dbadce5bf5c9502691f1d [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);
142
Johnny Chenc3fba812011-07-18 20:13:38 +0000143 %feature("docstring", "
144 /// Gets the lexical block that defines the stack frame. Another way to think
145 /// of this is it will return the block that contains all of the variables
146 /// for a stack frame. Inlined functions are represented as SBBlock objects
147 /// that have inlined function information: the name of the inlined function,
148 /// where it was called from. The block that is returned will be the first
149 /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
150 /// the scope of the frame. When a function contains no inlined functions,
151 /// this will be the top most lexical block that defines the function.
152 /// When a function has inlined functions and the PC is currently
153 /// in one of those inlined functions, this method will return the inlined
154 /// block that defines this frame. If the PC isn't currently in an inlined
155 /// function, the lexical block that defines the function is returned.
156 ") GetFrameBlock;
157 lldb::SBBlock
158 GetFrameBlock () const;
159
160 lldb::SBLineEntry
161 GetLineEntry () const;
162
163 lldb::SBThread
164 GetThread () const;
165
166 const char *
167 Disassemble () const;
168
169 void
170 Clear();
171
172#ifndef SWIG
173 bool
174 operator == (const lldb::SBFrame &rhs) const;
175
176 bool
177 operator != (const lldb::SBFrame &rhs) const;
178
179#endif
180
181 %feature("docstring", "
182 /// The version that doesn't supply a 'use_dynamic' value will use the
183 /// target's default.
184 ") GetVariables;
185 lldb::SBValueList
186 GetVariables (bool arguments,
187 bool locals,
188 bool statics,
189 bool in_scope_only);
190
191 lldb::SBValueList
192 GetVariables (bool arguments,
193 bool locals,
194 bool statics,
195 bool in_scope_only,
196 lldb::DynamicValueType use_dynamic);
197
198 lldb::SBValueList
199 GetRegisters ();
200
201 %feature("docstring", "
202 /// The version that doesn't supply a 'use_dynamic' value will use the
203 /// target's default.
204 ") FindVariable;
205 lldb::SBValue
206 FindVariable (const char *var_name);
207
208 lldb::SBValue
209 FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
210
211 %feature("docstring", "
Greg Claytond62b9c12012-02-03 07:02:37 +0000212 /// Get a lldb.SBValue for a variable path.
213 ///
214 /// Variable paths can include access to pointer or instance members:
215 /// rect_ptr->origin.y
216 /// pt.x
217 /// Pointer dereferences:
218 /// *this->foo_ptr
219 /// **argv
220 /// Address of:
221 /// &pt
222 /// &my_array[3].x
223 /// Array accesses and treating pointers as arrays:
224 /// int_array[1]
225 /// pt_ptr[22].x
226 ///
227 /// Unlike EvaluateExpression() which returns lldb.SBValue objects
228 /// with constant copies of the values at the time of evaluation,
229 /// the result of this function is a value that will continue to
230 /// track the current value of the value as execution progresses
231 /// in the current frame.
232 ") GetValueForVariablePath;
233 lldb::SBValue
234 GetValueForVariablePath (const char *var_path);
235
236 lldb::SBValue
237 GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic);
238
239 %feature("docstring", "
Johnny Chenc3fba812011-07-18 20:13:38 +0000240 /// Find variables, register sets, registers, or persistent variables using
241 /// the frame as the scope.
242 ///
243 /// The version that doesn't supply a 'use_dynamic' value will use the
244 /// target's default.
245 ") FindValue;
246 lldb::SBValue
247 FindValue (const char *name, ValueType value_type);
248
249 lldb::SBValue
250 FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
251
Johnny Chenc3fba812011-07-18 20:13:38 +0000252 bool
253 GetDescription (lldb::SBStream &description);
Greg Clayton1b925202012-01-29 06:07:39 +0000254
255 %pythoncode %{
Greg Claytond62b9c12012-02-03 07:02:37 +0000256 def get_all_variables(self):
257 return self.GetVariables(True,True,True,True)
258
259 def get_arguments(self):
260 return self.GetVariables(True,False,False,False)
261
262 def get_locals(self):
263 return self.GetVariables(False,True,False,False)
264
265 def get_statics(self):
266 return self.GetVariables(False,False,True,False)
267
268 def var(self, var_expr_path):
269 '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns
270 a value that represents the variable expression path'''
271 return self.GetValueForVariablePath(var_expr_path)
272
Greg Clayton1b925202012-01-29 06:07:39 +0000273 __swig_getmethods__["pc"] = GetPC
274 __swig_setmethods__["pc"] = SetPC
275 if _newclass: x = property(GetPC, SetPC)
Johnny Chenc3fba812011-07-18 20:13:38 +0000276
Greg Claytonb302dff2012-02-01 08:09:32 +0000277 __swig_getmethods__["addr"] = GetPCAddress
278 if _newclass: x = property(GetPCAddress, None)
279
Greg Clayton1b925202012-01-29 06:07:39 +0000280 __swig_getmethods__["fp"] = GetFP
281 if _newclass: x = property(GetFP, None)
282
283 __swig_getmethods__["sp"] = GetSP
284 if _newclass: x = property(GetSP, None)
285
286 __swig_getmethods__["module"] = GetModule
287 if _newclass: x = property(GetModule, None)
288
289 __swig_getmethods__["compile_unit"] = GetCompileUnit
290 if _newclass: x = property(GetCompileUnit, None)
291
292 __swig_getmethods__["function"] = GetFunction
293 if _newclass: x = property(GetFunction, None)
294
295 __swig_getmethods__["symbol"] = GetSymbol
296 if _newclass: x = property(GetSymbol, None)
297
298 __swig_getmethods__["block"] = GetBlock
299 if _newclass: x = property(GetBlock, None)
300
301 __swig_getmethods__["is_inlined"] = IsInlined
302 if _newclass: x = property(IsInlined, None)
303
304 __swig_getmethods__["name"] = GetFunctionName
305 if _newclass: x = property(GetFunctionName, None)
306
307 __swig_getmethods__["line_entry"] = GetLineEntry
308 if _newclass: x = property(GetLineEntry, None)
309
310 __swig_getmethods__["thread"] = GetThread
311 if _newclass: x = property(GetThread, None)
312
313 __swig_getmethods__["disassembly"] = Disassemble
314 if _newclass: x = property(Disassemble, None)
315
316 __swig_getmethods__["idx"] = GetFrameID
317 if _newclass: x = property(GetFrameID, None)
318
Greg Claytond62b9c12012-02-03 07:02:37 +0000319 __swig_getmethods__["variables"] = get_all_variables
320 if _newclass: x = property(get_all_variables, None)
321
322 __swig_getmethods__["vars"] = get_all_variables
323 if _newclass: x = property(get_all_variables, None)
324
325 __swig_getmethods__["locals"] = get_locals
326 if _newclass: x = property(get_locals, None)
327
328 __swig_getmethods__["args"] = get_arguments
329 if _newclass: x = property(get_arguments, None)
330
331 __swig_getmethods__["arguments"] = get_arguments
332 if _newclass: x = property(get_arguments, None)
333
334 __swig_getmethods__["statics"] = get_statics
335 if _newclass: x = property(get_statics, None)
336
337 __swig_getmethods__["registers"] = GetRegisters
338 if _newclass: x = property(GetRegisters, None)
339
340 __swig_getmethods__["regs"] = GetRegisters
341 if _newclass: x = property(GetRegisters, None)
342
Greg Clayton1b925202012-01-29 06:07:39 +0000343 %}
Johnny Chenc3fba812011-07-18 20:13:38 +0000344};
345
346} // namespace lldb