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))
119 static lldb::SBDebugger
122 static lldb::SBDebugger
123 Create(bool source_init_files);
125 static lldb::SBDebugger
126 Create(bool source_init_files, lldb::LogOutputCallback log_callback, void *baton);
129 Destroy (lldb::SBDebugger &debugger);
132 MemoryPressureDetected();
136 SBDebugger(const lldb::SBDebugger &rhs);
153 SkipLLDBInitFiles (bool b);
156 SetInputFileHandle (FILE *f, bool transfer_ownership);
159 SetOutputFileHandle (FILE *f, bool transfer_ownership);
162 SetErrorFileHandle (FILE *f, bool transfer_ownership);
165 GetInputFileHandle ();
168 GetOutputFileHandle ();
171 GetErrorFileHandle ();
173 lldb::SBCommandInterpreter
174 GetCommandInterpreter ();
177 HandleCommand (const char *command);
183 HandleProcessEvent (const lldb::SBProcess &process,
184 const lldb::SBEvent &event,
189 CreateTarget (const char *filename,
190 const char *target_triple,
191 const char *platform_name,
192 bool add_dependent_modules,
193 lldb::SBError& sb_error);
196 CreateTargetWithFileAndTargetTriple (const char *filename,
197 const char *target_triple);
200 CreateTargetWithFileAndArch (const char *filename,
201 const char *archname);
204 CreateTarget (const char *filename);
206 %feature("docstring",
207 "Return true if target is deleted from the target list of the debugger."
210 DeleteTarget (lldb::SBTarget &target);
213 GetTargetAtIndex (uint32_t idx);
216 GetIndexOfTarget (lldb::SBTarget target);
219 FindTargetWithProcessID (pid_t pid);
222 FindTargetWithFileAndArch (const char *filename,
229 GetSelectedTarget ();
232 SetSelectedTarget (lldb::SBTarget &target);
235 GetSelectedPlatform();
238 SetSelectedPlatform(lldb::SBPlatform &platform);
240 lldb::SBSourceManager
243 // REMOVE: just for a quick fix, need to expose platforms through
244 // SBPlatform from this class.
246 SetCurrentPlatform (const char *platform_name);
249 SetCurrentPlatformSDKRoot (const char *sysroot);
251 // FIXME: Once we get the set show stuff in place, the driver won't need
252 // an interface to the Set/Get UseExternalEditor.
254 SetUseExternalEditor (bool input);
257 GetUseExternalEditor ();
260 SetUseColor (bool use_color);
263 GetUseColor () const;
266 GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
269 SetDefaultArchitecture (const char *arch_name);
272 GetScriptingLanguage (const char *script_language_name);
278 StateAsCString (lldb::StateType state);
281 StateIsRunningState (lldb::StateType state);
284 StateIsStoppedState (lldb::StateType state);
287 EnableLog (const char *channel, const char ** types);
290 SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
293 DispatchInput (const void *data, size_t data_len);
296 DispatchInputInterrupt ();
299 DispatchInputEndOfFile ();
305 FindDebuggerWithID (int id);
308 SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
310 static lldb::SBStringList
311 GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
314 GetDescription (lldb::SBStream &description);
317 GetTerminalWidth () const;
320 SetTerminalWidth (uint32_t term_width);
329 SetPrompt (const char *prompt);
332 GetScriptLanguage() const;
335 SetScriptLanguage (lldb::ScriptLanguage script_lang);
338 GetCloseInputOnEOF () const;
341 SetCloseInputOnEOF (bool b);
344 GetCategory (const char* category_name);
347 GetCategory (lldb::LanguageType lang_type);
350 CreateCategory (const char* category_name);
353 DeleteCategory (const char* category_name);
359 GetCategoryAtIndex (uint32_t);
362 GetDefaultCategory();
365 GetFormatForType (lldb::SBTypeNameSpecifier);
368 GetSummaryForType (lldb::SBTypeNameSpecifier);
371 GetFilterForType (lldb::SBTypeNameSpecifier);
373 lldb::SBTypeSynthetic
374 GetSyntheticForType (lldb::SBTypeNameSpecifier);
377 RunCommandInterpreter (bool auto_handle_events,
379 SBCommandInterpreterRunOptions &options,
381 bool &quit_requested,
382 bool &stopped_for_crash);
385 RunREPL (lldb::LanguageType language, const char *repl_options);
386 }; // class SBDebugger