1 //===-- SWIG Interface for SBDebugger ---------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
13 "SBDebugger is the primordial object that creates SBTargets and provides
14 access to them. It also manages the overall debugging experiences.
16 For example (from example/disasm.py),
22 def disassemble_instructions (insts):
28 # Create a new debugger instance
29 debugger = lldb.SBDebugger.Create()
31 # When we step or continue, don't return from the function until the process
32 # stops. We do this by setting the async mode to false.
33 debugger.SetAsync (False)
35 # Create a target from a file and arch
36 print('Creating a target for \'%s\'' % exe)
38 target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
41 # If the target is valid set a breakpoint at main
42 main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());
46 # Launch the process. Since we specified synchronous mode, we won't return
47 # from this function until we hit the breakpoint at main
48 process = target.LaunchSimple (None, None, os.getcwd())
50 # Make sure the launch went ok
52 # Print some simple process info
53 state = process.GetState ()
55 if state == lldb.eStateStopped:
56 # Get the first thread
57 thread = process.GetThreadAtIndex (0)
59 # Print some simple thread info
62 frame = thread.GetFrameAtIndex (0)
64 # Print some simple frame info
66 function = frame.GetFunction()
67 # See if we have debug info (a function)
69 # We do have a function, print some info for the function
71 # Now get all instructions for this function and print them
72 insts = function.GetInstructions(target)
73 disassemble_instructions (insts)
75 # See if we have a symbol in the symbol table for where we stopped
76 symbol = frame.GetSymbol();
78 # We do have a symbol, print some info for the symbol
80 # Now get all instructions for this symbol and print them
81 insts = symbol.GetInstructions(target)
82 disassemble_instructions (insts)
84 registerList = frame.GetRegisters()
85 print('Frame registers (size of register set = %d):' % registerList.GetSize())
86 for value in registerList:
88 print('%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()))
90 print('Name: ', child.GetName(), ' Value: ', child.GetValue())
92 print('Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program')
93 next = sys.stdin.readline()
94 if not next or next.rstrip('\n') == 'quit':
95 print('Terminating the inferior process...')
98 # Now continue to the program exit
100 # When we return from the above function we will hopefully be at the
101 # program exit. Print out some process info
103 elif state == lldb.eStateExited:
104 print('Didn\'t hit the breakpoint at main, program has exited...')
106 print('Unexpected process state: %s, killing process...' % debugger.StateAsCString (state))
109 Sometimes you need to create an empty target that will get filled in later. The most common use for this
110 is to attach to a process by name or pid where you don't know the executable up front. The most convenient way
113 target = debugger.CreateTarget('')
114 error = lldb.SBError()
115 process = target.AttachToProcessWithName(debugger.GetListener(), 'PROCESS_NAME', False, error)
117 or the equivalent arguments for AttachToProcessWithID.
129 static lldb::SBDebugger
132 static lldb::SBDebugger
133 Create(bool source_init_files);
135 static lldb::SBDebugger
136 Create(bool source_init_files, lldb::LogOutputCallback log_callback, void *baton);
139 Destroy (lldb::SBDebugger &debugger);
142 MemoryPressureDetected();
146 SBDebugger(const lldb::SBDebugger &rhs);
163 SkipLLDBInitFiles (bool b);
166 SetInputFileHandle (FILE *f, bool transfer_ownership);
169 SetOutputFileHandle (FILE *f, bool transfer_ownership);
172 SetErrorFileHandle (FILE *f, bool transfer_ownership);
175 GetInputFileHandle ();
178 GetOutputFileHandle ();
181 GetErrorFileHandle ();
183 lldb::SBCommandInterpreter
184 GetCommandInterpreter ();
187 HandleCommand (const char *command);
193 HandleProcessEvent (const lldb::SBProcess &process,
194 const lldb::SBEvent &event,
199 CreateTarget (const char *filename,
200 const char *target_triple,
201 const char *platform_name,
202 bool add_dependent_modules,
203 lldb::SBError& sb_error);
206 CreateTargetWithFileAndTargetTriple (const char *filename,
207 const char *target_triple);
210 CreateTargetWithFileAndArch (const char *filename,
211 const char *archname);
214 CreateTarget (const char *filename);
216 %feature("docstring",
217 "Return true if target is deleted from the target list of the debugger."
220 DeleteTarget (lldb::SBTarget &target);
223 GetTargetAtIndex (uint32_t idx);
226 GetIndexOfTarget (lldb::SBTarget target);
229 FindTargetWithProcessID (pid_t pid);
232 FindTargetWithFileAndArch (const char *filename,
239 GetSelectedTarget ();
242 SetSelectedTarget (lldb::SBTarget &target);
245 GetSelectedPlatform();
248 SetSelectedPlatform(lldb::SBPlatform &platform);
250 lldb::SBSourceManager
253 // REMOVE: just for a quick fix, need to expose platforms through
254 // SBPlatform from this class.
256 SetCurrentPlatform (const char *platform_name);
259 SetCurrentPlatformSDKRoot (const char *sysroot);
261 // FIXME: Once we get the set show stuff in place, the driver won't need
262 // an interface to the Set/Get UseExternalEditor.
264 SetUseExternalEditor (bool input);
267 GetUseExternalEditor ();
270 SetUseColor (bool use_color);
273 GetUseColor () const;
276 GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
279 SetDefaultArchitecture (const char *arch_name);
282 GetScriptingLanguage (const char *script_language_name);
288 StateAsCString (lldb::StateType state);
291 StateIsRunningState (lldb::StateType state);
294 StateIsStoppedState (lldb::StateType state);
297 EnableLog (const char *channel, const char ** types);
300 SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
303 DispatchInput (const void *data, size_t data_len);
306 DispatchInputInterrupt ();
309 DispatchInputEndOfFile ();
315 FindDebuggerWithID (int id);
318 SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
320 static lldb::SBStringList
321 GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
324 GetDescription (lldb::SBStream &description);
327 GetTerminalWidth () const;
330 SetTerminalWidth (uint32_t term_width);
339 SetPrompt (const char *prompt);
342 GetScriptLanguage() const;
345 SetScriptLanguage (lldb::ScriptLanguage script_lang);
348 GetCloseInputOnEOF () const;
351 SetCloseInputOnEOF (bool b);
354 GetCategory (const char* category_name);
357 GetCategory (lldb::LanguageType lang_type);
360 CreateCategory (const char* category_name);
363 DeleteCategory (const char* category_name);
369 GetCategoryAtIndex (uint32_t);
372 GetDefaultCategory();
375 GetFormatForType (lldb::SBTypeNameSpecifier);
378 GetSummaryForType (lldb::SBTypeNameSpecifier);
381 GetFilterForType (lldb::SBTypeNameSpecifier);
383 lldb::SBTypeSynthetic
384 GetSyntheticForType (lldb::SBTypeNameSpecifier);
387 RunCommandInterpreter (bool auto_handle_events,
389 SBCommandInterpreterRunOptions &options,
391 bool &quit_requested,
392 bool &stopped_for_crash);
395 RunREPL (lldb::LanguageType language, const char *repl_options);
396 }; // class SBDebugger