1 //===-- SWIG Interface for SBSymbolContext ----------------------*- C++ -*-===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 namespace lldb { 10 11 %feature("docstring", 12 "A context object that provides access to core debugger entities. 13 14 Many debugger functions require a context when doing lookups. This class 15 provides a common structure that can be used as the result of a query that 16 can contain a single result. 17 18 For example, :: 19 20 exe = os.path.join(os.getcwd(), 'a.out') 21 22 # Create a target for the debugger. 23 target = self.dbg.CreateTarget(exe) 24 25 # Now create a breakpoint on main.c by name 'c'. 26 breakpoint = target.BreakpointCreateByName('c', 'a.out') 27 28 # Now launch the process, and do not stop at entry point. 29 process = target.LaunchSimple(None, None, os.getcwd()) 30 31 # The inferior should stop on 'c'. 32 from lldbutil import get_stopped_thread 33 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) 34 frame0 = thread.GetFrameAtIndex(0) 35 36 # Now get the SBSymbolContext from this frame. We want everything. :-) 37 context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) 38 39 # Get the module. 40 module = context.GetModule() 41 ... 42 43 # And the compile unit associated with the frame. 44 compileUnit = context.GetCompileUnit() 45 ... 46 " 47 ) SBSymbolContext; 48 class SBSymbolContext 49 { 50 public: 51 SBSymbolContext (); 52 53 SBSymbolContext (const lldb::SBSymbolContext& rhs); 54 55 ~SBSymbolContext (); 56 57 bool 58 IsValid () const; 59 60 explicit operator bool() const; 61 62 lldb::SBModule GetModule (); 63 lldb::SBCompileUnit GetCompileUnit (); 64 lldb::SBFunction GetFunction (); 65 lldb::SBBlock GetBlock (); 66 lldb::SBLineEntry GetLineEntry (); 67 lldb::SBSymbol GetSymbol (); 68 69 void SetModule (lldb::SBModule module); 70 void SetCompileUnit (lldb::SBCompileUnit compile_unit); 71 void SetFunction (lldb::SBFunction function); 72 void SetBlock (lldb::SBBlock block); 73 void SetLineEntry (lldb::SBLineEntry line_entry); 74 void SetSymbol (lldb::SBSymbol symbol); 75 76 lldb::SBSymbolContext 77 GetParentOfInlinedScope (const lldb::SBAddress &curr_frame_pc, 78 lldb::SBAddress &parent_frame_addr) const; 79 80 81 bool 82 GetDescription (lldb::SBStream &description); 83 84 STRING_EXTENSION(SBSymbolContext) 85 86 #ifdef SWIGPYTHON 87 %pythoncode %{ 88 module = property(GetModule, SetModule, doc='''A read/write property that allows the getting/setting of the module (lldb.SBModule) in this symbol context.''') 89 compile_unit = property(GetCompileUnit, SetCompileUnit, doc='''A read/write property that allows the getting/setting of the compile unit (lldb.SBCompileUnit) in this symbol context.''') 90 function = property(GetFunction, SetFunction, doc='''A read/write property that allows the getting/setting of the function (lldb.SBFunction) in this symbol context.''') 91 block = property(GetBlock, SetBlock, doc='''A read/write property that allows the getting/setting of the block (lldb.SBBlock) in this symbol context.''') 92 symbol = property(GetSymbol, SetSymbol, doc='''A read/write property that allows the getting/setting of the symbol (lldb.SBSymbol) in this symbol context.''') 93 line_entry = property(GetLineEntry, SetLineEntry, doc='''A read/write property that allows the getting/setting of the line entry (lldb.SBLineEntry) in this symbol context.''') 94 %} 95 #endif 96 97 }; 98 99 } // namespace lldb 100