blob: c718073506cfae1cd3d8b7aa6fab3b9bf0f15b39 [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
58 IsValid() const;
59
60 uint32_t
61 GetFrameID () const;
62
63 lldb::addr_t
64 GetPC () const;
65
66 bool
67 SetPC (lldb::addr_t new_pc);
68
69 lldb::addr_t
70 GetSP () const;
71
72 lldb::addr_t
73 GetFP () const;
74
75 lldb::SBAddress
76 GetPCAddress () const;
77
78 lldb::SBSymbolContext
79 GetSymbolContext (uint32_t resolve_scope) const;
80
81 lldb::SBModule
82 GetModule () const;
83
84 lldb::SBCompileUnit
85 GetCompileUnit () const;
86
87 lldb::SBFunction
88 GetFunction () const;
89
90 lldb::SBSymbol
91 GetSymbol () const;
92
93 %feature("docstring", "
94 /// Gets the deepest block that contains the frame PC.
95 ///
96 /// See also GetFrameBlock().
97 ") GetBlock;
98 lldb::SBBlock
99 GetBlock () const;
100
101 %feature("docstring", "
102 /// Get the appropriate function name for this frame. Inlined functions in
103 /// LLDB are represented by Blocks that have inlined function information, so
104 /// just looking at the SBFunction or SBSymbol for a frame isn't enough.
105 /// This function will return the appriopriate function, symbol or inlined
106 /// function name for the frame.
107 ///
108 /// This function returns:
109 /// - the name of the inlined function (if there is one)
110 /// - the name of the concrete function (if there is one)
111 /// - the name of the symbol (if there is one)
112 /// - NULL
113 ///
114 /// See also IsInlined().
115 ") GetFunctionName;
116 const char *
117 GetFunctionName();
118
119 %feature("docstring", "
120 /// Return true if this frame represents an inlined function.
121 ///
122 /// See also GetFunctionName().
123 ") IsInlined;
124 bool
125 IsInlined();
126
127 %feature("docstring", "
128 /// The version that doesn't supply a 'use_dynamic' value will use the
129 /// target's default.
130 ") EvaluateExpression;
131 lldb::SBValue
132 EvaluateExpression (const char *expr);
133
134 lldb::SBValue
135 EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
136
137 %feature("docstring", "
138 /// Gets the lexical block that defines the stack frame. Another way to think
139 /// of this is it will return the block that contains all of the variables
140 /// for a stack frame. Inlined functions are represented as SBBlock objects
141 /// that have inlined function information: the name of the inlined function,
142 /// where it was called from. The block that is returned will be the first
143 /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
144 /// the scope of the frame. When a function contains no inlined functions,
145 /// this will be the top most lexical block that defines the function.
146 /// When a function has inlined functions and the PC is currently
147 /// in one of those inlined functions, this method will return the inlined
148 /// block that defines this frame. If the PC isn't currently in an inlined
149 /// function, the lexical block that defines the function is returned.
150 ") GetFrameBlock;
151 lldb::SBBlock
152 GetFrameBlock () const;
153
154 lldb::SBLineEntry
155 GetLineEntry () const;
156
157 lldb::SBThread
158 GetThread () const;
159
160 const char *
161 Disassemble () const;
162
163 void
164 Clear();
165
166#ifndef SWIG
167 bool
168 operator == (const lldb::SBFrame &rhs) const;
169
170 bool
171 operator != (const lldb::SBFrame &rhs) const;
172
173#endif
174
175 %feature("docstring", "
176 /// The version that doesn't supply a 'use_dynamic' value will use the
177 /// target's default.
178 ") GetVariables;
179 lldb::SBValueList
180 GetVariables (bool arguments,
181 bool locals,
182 bool statics,
183 bool in_scope_only);
184
185 lldb::SBValueList
186 GetVariables (bool arguments,
187 bool locals,
188 bool statics,
189 bool in_scope_only,
190 lldb::DynamicValueType use_dynamic);
191
192 lldb::SBValueList
193 GetRegisters ();
194
195 %feature("docstring", "
196 /// The version that doesn't supply a 'use_dynamic' value will use the
197 /// target's default.
198 ") FindVariable;
199 lldb::SBValue
200 FindVariable (const char *var_name);
201
202 lldb::SBValue
203 FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
204
205 %feature("docstring", "
Greg Claytond62b9c12012-02-03 07:02:37 +0000206 /// Get a lldb.SBValue for a variable path.
207 ///
208 /// Variable paths can include access to pointer or instance members:
209 /// rect_ptr->origin.y
210 /// pt.x
211 /// Pointer dereferences:
212 /// *this->foo_ptr
213 /// **argv
214 /// Address of:
215 /// &pt
216 /// &my_array[3].x
217 /// Array accesses and treating pointers as arrays:
218 /// int_array[1]
219 /// pt_ptr[22].x
220 ///
221 /// Unlike EvaluateExpression() which returns lldb.SBValue objects
222 /// with constant copies of the values at the time of evaluation,
223 /// the result of this function is a value that will continue to
224 /// track the current value of the value as execution progresses
225 /// in the current frame.
226 ") GetValueForVariablePath;
227 lldb::SBValue
228 GetValueForVariablePath (const char *var_path);
229
230 lldb::SBValue
231 GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic);
232
233 %feature("docstring", "
Johnny Chenc3fba812011-07-18 20:13:38 +0000234 /// Find variables, register sets, registers, or persistent variables using
235 /// the frame as the scope.
236 ///
237 /// The version that doesn't supply a 'use_dynamic' value will use the
238 /// target's default.
239 ") FindValue;
240 lldb::SBValue
241 FindValue (const char *name, ValueType value_type);
242
243 lldb::SBValue
244 FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
245
Johnny Chenc3fba812011-07-18 20:13:38 +0000246 bool
247 GetDescription (lldb::SBStream &description);
Greg Clayton1b925202012-01-29 06:07:39 +0000248
249 %pythoncode %{
Greg Claytond62b9c12012-02-03 07:02:37 +0000250 def get_all_variables(self):
251 return self.GetVariables(True,True,True,True)
252
253 def get_arguments(self):
254 return self.GetVariables(True,False,False,False)
255
256 def get_locals(self):
257 return self.GetVariables(False,True,False,False)
258
259 def get_statics(self):
260 return self.GetVariables(False,False,True,False)
261
262 def var(self, var_expr_path):
263 '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns
264 a value that represents the variable expression path'''
265 return self.GetValueForVariablePath(var_expr_path)
266
Greg Clayton1b925202012-01-29 06:07:39 +0000267 __swig_getmethods__["pc"] = GetPC
268 __swig_setmethods__["pc"] = SetPC
269 if _newclass: x = property(GetPC, SetPC)
Johnny Chenc3fba812011-07-18 20:13:38 +0000270
Greg Claytonb302dff2012-02-01 08:09:32 +0000271 __swig_getmethods__["addr"] = GetPCAddress
272 if _newclass: x = property(GetPCAddress, None)
273
Greg Clayton1b925202012-01-29 06:07:39 +0000274 __swig_getmethods__["fp"] = GetFP
275 if _newclass: x = property(GetFP, None)
276
277 __swig_getmethods__["sp"] = GetSP
278 if _newclass: x = property(GetSP, None)
279
280 __swig_getmethods__["module"] = GetModule
281 if _newclass: x = property(GetModule, None)
282
283 __swig_getmethods__["compile_unit"] = GetCompileUnit
284 if _newclass: x = property(GetCompileUnit, None)
285
286 __swig_getmethods__["function"] = GetFunction
287 if _newclass: x = property(GetFunction, None)
288
289 __swig_getmethods__["symbol"] = GetSymbol
290 if _newclass: x = property(GetSymbol, None)
291
292 __swig_getmethods__["block"] = GetBlock
293 if _newclass: x = property(GetBlock, None)
294
295 __swig_getmethods__["is_inlined"] = IsInlined
296 if _newclass: x = property(IsInlined, None)
297
298 __swig_getmethods__["name"] = GetFunctionName
299 if _newclass: x = property(GetFunctionName, None)
300
301 __swig_getmethods__["line_entry"] = GetLineEntry
302 if _newclass: x = property(GetLineEntry, None)
303
304 __swig_getmethods__["thread"] = GetThread
305 if _newclass: x = property(GetThread, None)
306
307 __swig_getmethods__["disassembly"] = Disassemble
308 if _newclass: x = property(Disassemble, None)
309
310 __swig_getmethods__["idx"] = GetFrameID
311 if _newclass: x = property(GetFrameID, None)
312
Greg Claytond62b9c12012-02-03 07:02:37 +0000313 __swig_getmethods__["variables"] = get_all_variables
314 if _newclass: x = property(get_all_variables, None)
315
316 __swig_getmethods__["vars"] = get_all_variables
317 if _newclass: x = property(get_all_variables, None)
318
319 __swig_getmethods__["locals"] = get_locals
320 if _newclass: x = property(get_locals, None)
321
322 __swig_getmethods__["args"] = get_arguments
323 if _newclass: x = property(get_arguments, None)
324
325 __swig_getmethods__["arguments"] = get_arguments
326 if _newclass: x = property(get_arguments, None)
327
328 __swig_getmethods__["statics"] = get_statics
329 if _newclass: x = property(get_statics, None)
330
331 __swig_getmethods__["registers"] = GetRegisters
332 if _newclass: x = property(GetRegisters, None)
333
334 __swig_getmethods__["regs"] = GetRegisters
335 if _newclass: x = property(GetRegisters, None)
336
Greg Clayton1b925202012-01-29 06:07:39 +0000337 %}
Johnny Chenc3fba812011-07-18 20:13:38 +0000338};
339
340} // namespace lldb