1 //===-- 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 10 namespace lldb { 11 12 %feature("docstring", 13 "Represents one of the stack frames associated with a thread. 14 SBThread contains SBFrame(s). For example (from test/lldbutil.py), 15 16 def 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 ... 40 41 And, 42 43 for frame in thread: 44 print frame 45 46 See also SBThread." 47 ) SBFrame; 48 class SBFrame 49 { 50 public: 51 SBFrame (); 52 53 SBFrame (const lldb::SBFrame &rhs); 54 55 ~SBFrame(); 56 57 bool 58 IsEqual (const lldb::SBFrame &rhs) const; 59 60 bool 61 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 140 lldb::SBValue 141 EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error); 142 143 lldb::SBValue 144 EvaluateExpression (const char *expr, SBExpressionOptions &options); 145 146 %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 lldb::SBValue 215 FindRegister (const char *name); 216 217 %feature("docstring", " 218 /// Get a lldb.SBValue for a variable path. 219 /// 220 /// Variable paths can include access to pointer or instance members: 221 /// rect_ptr->origin.y 222 /// pt.x 223 /// Pointer dereferences: 224 /// *this->foo_ptr 225 /// **argv 226 /// Address of: 227 /// &pt 228 /// &my_array[3].x 229 /// Array accesses and treating pointers as arrays: 230 /// int_array[1] 231 /// pt_ptr[22].x 232 /// 233 /// Unlike EvaluateExpression() which returns lldb.SBValue objects 234 /// with constant copies of the values at the time of evaluation, 235 /// the result of this function is a value that will continue to 236 /// track the current value of the value as execution progresses 237 /// in the current frame. 238 ") GetValueForVariablePath; 239 lldb::SBValue 240 GetValueForVariablePath (const char *var_path); 241 242 lldb::SBValue 243 GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic); 244 245 %feature("docstring", " 246 /// Find variables, register sets, registers, or persistent variables using 247 /// the frame as the scope. 248 /// 249 /// The version that doesn't supply a 'use_dynamic' value will use the 250 /// target's default. 251 ") FindValue; 252 lldb::SBValue 253 FindValue (const char *name, ValueType value_type); 254 255 lldb::SBValue 256 FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); 257 258 bool 259 GetDescription (lldb::SBStream &description); 260 261 %pythoncode %{ 262 def get_all_variables(self): 263 return self.GetVariables(True,True,True,True) 264 265 def get_arguments(self): 266 return self.GetVariables(True,False,False,False) 267 268 def get_locals(self): 269 return self.GetVariables(False,True,False,False) 270 271 def get_statics(self): 272 return self.GetVariables(False,False,True,False) 273 274 def var(self, var_expr_path): 275 '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns 276 a value that represents the variable expression path''' 277 return self.GetValueForVariablePath(var_expr_path) 278 279 __swig_getmethods__["pc"] = GetPC 280 __swig_setmethods__["pc"] = SetPC 281 if _newclass: pc = property(GetPC, SetPC) 282 283 __swig_getmethods__["addr"] = GetPCAddress 284 if _newclass: addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''') 285 286 __swig_getmethods__["fp"] = GetFP 287 if _newclass: fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''') 288 289 __swig_getmethods__["sp"] = GetSP 290 if _newclass: sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''') 291 292 __swig_getmethods__["module"] = GetModule 293 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.''') 294 295 __swig_getmethods__["compile_unit"] = GetCompileUnit 296 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.''') 297 298 __swig_getmethods__["function"] = GetFunction 299 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.''') 300 301 __swig_getmethods__["symbol"] = GetSymbol 302 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.''') 303 304 __swig_getmethods__["block"] = GetBlock 305 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.''') 306 307 __swig_getmethods__["is_inlined"] = IsInlined 308 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.''') 309 310 __swig_getmethods__["name"] = GetFunctionName 311 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).''') 312 313 __swig_getmethods__["line_entry"] = GetLineEntry 314 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.''') 315 316 __swig_getmethods__["thread"] = GetThread 317 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.''') 318 319 __swig_getmethods__["disassembly"] = Disassemble 320 if _newclass: disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''') 321 322 __swig_getmethods__["idx"] = GetFrameID 323 if _newclass: idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''') 324 325 __swig_getmethods__["variables"] = get_all_variables 326 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.''') 327 328 __swig_getmethods__["vars"] = get_all_variables 329 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.''') 330 331 __swig_getmethods__["locals"] = get_locals 332 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.''') 333 334 __swig_getmethods__["args"] = get_arguments 335 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.''') 336 337 __swig_getmethods__["arguments"] = get_arguments 338 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.''') 339 340 __swig_getmethods__["statics"] = get_statics 341 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.''') 342 343 __swig_getmethods__["registers"] = GetRegisters 344 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.''') 345 346 __swig_getmethods__["regs"] = GetRegisters 347 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.''') 348 349 %} 350 }; 351 352 } // namespace lldb 353