1 //===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 "Represents one of the stack frames associated with a thread.
13 SBThread contains SBFrame(s). For example (from test/lldbutil.py),
15 def print_stacktrace(thread, string_buffer = False):
16 '''Prints a simple stack trace of this thread.'''
20 for i in range(depth):
21 frame = thread.GetFrameAtIndex(i)
22 function = frame.GetFunction()
24 load_addr = addrs[i].GetLoadAddress(target)
26 file_addr = addrs[i].GetFileAddress()
27 start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress()
28 symbol_offset = file_addr - start_addr
29 print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
30 num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset)
32 print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
33 num=i, addr=load_addr, mod=mods[i],
34 func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i],
35 file=files[i], line=lines[i],
36 args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()')
52 SBFrame (const lldb::SBFrame &rhs);
57 IsEqual (const lldb::SBFrame &rhs) const;
62 explicit operator bool() const;
67 %feature("docstring", "
68 Get the Canonical Frame Address for this stack frame.
69 This is the DWARF standard's definition of a CFA, a stack address
70 that remains constant throughout the lifetime of the function.
71 Returns an lldb::addr_t stack address, or LLDB_INVALID_ADDRESS if
72 the CFA cannot be determined.") GetCFA;
80 SetPC (lldb::addr_t new_pc);
89 GetPCAddress () const;
92 GetSymbolContext (uint32_t resolve_scope) const;
98 GetCompileUnit () const;
101 GetFunction () const;
106 %feature("docstring", "
107 Gets the deepest block that contains the frame PC.
109 See also GetFrameBlock().") GetBlock;
113 %feature("docstring", "
114 Get the appropriate function name for this frame. Inlined functions in
115 LLDB are represented by Blocks that have inlined function information, so
116 just looking at the SBFunction or SBSymbol for a frame isn't enough.
117 This function will return the appropriate function, symbol or inlined
118 function name for the frame.
120 This function returns:
121 - the name of the inlined function (if there is one)
122 - the name of the concrete function (if there is one)
123 - the name of the symbol (if there is one)
126 See also IsInlined().") GetFunctionName;
131 GetDisplayFunctionName ();
134 GetFunctionName() const;
136 %feature("docstring", "
137 Returns the language of the frame's SBFunction, or if there.
138 is no SBFunction, guess the language from the mangled name.
141 GuessLanguage() const;
143 %feature("docstring", "
144 Return true if this frame represents an inlined function.
146 See also GetFunctionName().") IsInlined;
153 %feature("docstring", "
154 Return true if this frame is artificial (e.g a frame synthesized to
155 capture a tail call). Local variables may not be available in an artificial
156 frame.") IsArtificial;
161 IsArtificial() const;
163 %feature("docstring", "
164 The version that doesn't supply a 'use_dynamic' value will use the
165 target's default.") EvaluateExpression;
167 EvaluateExpression (const char *expr);
170 EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
173 EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error);
176 EvaluateExpression (const char *expr, SBExpressionOptions &options);
178 %feature("docstring", "
179 Gets the lexical block that defines the stack frame. Another way to think
180 of this is it will return the block that contains all of the variables
181 for a stack frame. Inlined functions are represented as SBBlock objects
182 that have inlined function information: the name of the inlined function,
183 where it was called from. The block that is returned will be the first
184 block at or above the block for the PC (SBFrame::GetBlock()) that defines
185 the scope of the frame. When a function contains no inlined functions,
186 this will be the top most lexical block that defines the function.
187 When a function has inlined functions and the PC is currently
188 in one of those inlined functions, this method will return the inlined
189 block that defines this frame. If the PC isn't currently in an inlined
190 function, the lexical block that defines the function is returned.") GetFrameBlock;
192 GetFrameBlock () const;
195 GetLineEntry () const;
201 Disassemble () const;
207 operator == (const lldb::SBFrame &rhs) const;
210 operator != (const lldb::SBFrame &rhs) const;
212 %feature("docstring", "
213 The version that doesn't supply a 'use_dynamic' value will use the
214 target's default.") GetVariables;
216 GetVariables (bool arguments,
222 GetVariables (bool arguments,
226 lldb::DynamicValueType use_dynamic);
229 GetVariables (const lldb::SBVariablesOptions& options);
234 %feature("docstring", "
235 The version that doesn't supply a 'use_dynamic' value will use the
236 target's default.") FindVariable;
238 FindVariable (const char *var_name);
241 FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
244 FindRegister (const char *name);
246 %feature("docstring", "
247 Get a lldb.SBValue for a variable path.
249 Variable paths can include access to pointer or instance members:
252 Pointer dereferences:
258 Array accesses and treating pointers as arrays:
262 Unlike EvaluateExpression() which returns lldb.SBValue objects
263 with constant copies of the values at the time of evaluation,
264 the result of this function is a value that will continue to
265 track the current value of the value as execution progresses
266 in the current frame.") GetValueForVariablePath;
268 GetValueForVariablePath (const char *var_path);
271 GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic);
273 %feature("docstring", "
274 Find variables, register sets, registers, or persistent variables using
275 the frame as the scope.
277 The version that doesn't supply a 'use_dynamic' value will use the
278 target's default.") FindValue;
280 FindValue (const char *name, ValueType value_type);
283 FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
286 GetDescription (lldb::SBStream &description);
288 STRING_EXTENSION(SBFrame)
292 def get_all_variables(self):
293 return self.GetVariables(True,True,True,True)
295 def get_parent_frame(self):
296 parent_idx = self.idx + 1
297 if parent_idx >= 0 and parent_idx < len(self.thread.frame):
298 return self.thread.frame[parent_idx]
302 def get_arguments(self):
303 return self.GetVariables(True,False,False,False)
305 def get_locals(self):
306 return self.GetVariables(False,True,False,False)
308 def get_statics(self):
309 return self.GetVariables(False,False,True,False)
311 def var(self, var_expr_path):
312 '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns
313 a value that represents the variable expression path'''
314 return self.GetValueForVariablePath(var_expr_path)
316 def get_registers_access(self):
317 class registers_access(object):
318 '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.'''
319 def __init__(self, regs):
322 def __getitem__(self, key):
324 for i in range(0,len(self.regs)):
326 for j in range (0,rs.num_children):
327 reg = rs.GetChildAtIndex(j)
328 if reg.name == key: return reg
330 return lldb.SBValue()
332 return registers_access(self.registers)
334 pc = property(GetPC, SetPC)
335 addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''')
336 fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''')
337 sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''')
338 module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''')
339 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.''')
340 function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''')
341 symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''')
342 block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''')
343 is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''')
344 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).''')
345 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.''')
346 thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''')
347 disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''')
348 idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''')
349 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.''')
350 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.''')
351 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.''')
352 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.''')
353 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.''')
354 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.''')
355 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.''')
356 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.''')
357 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.''')
358 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''')
359 parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')