Package lldb :: Class SBDebugger
[hide private]
[frames] | no frames]

Class SBDebugger

source code



SBDebugger is the primordial object that creates SBTargets and provides
access to them.  It also manages the overall debugging experiences.

For example (from example/disasm.py),

import lldb
import os
import sys

def disassemble_instructions (insts):
    for i in insts:
        print i

...

# Create a new debugger instance
debugger = lldb.SBDebugger.Create()

# When we step or continue, don't return from the function until the process
# stops. We do this by setting the async mode to false.
debugger.SetAsync (False)

# Create a target from a file and arch
print('Creating a target for '%s'' % exe)

target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)

if target:
    # If the target is valid set a breakpoint at main
    main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());

    print main_bp

    # Launch the process. Since we specified synchronous mode, we won't return
    # from this function until we hit the breakpoint at main
    process = target.LaunchSimple (None, None, os.getcwd())

    # Make sure the launch went ok
    if process:
        # Print some simple process info
        state = process.GetState ()
        print process
        if state == lldb.eStateStopped:
            # Get the first thread
            thread = process.GetThreadAtIndex (0)
            if thread:
                # Print some simple thread info
                print thread
                # Get the first frame
                frame = thread.GetFrameAtIndex (0)
                if frame:
                    # Print some simple frame info
                    print frame
                    function = frame.GetFunction()
                    # See if we have debug info (a function)
                    if function:
                        # We do have a function, print some info for the function
                        print function
                        # Now get all instructions for this function and print them
                        insts = function.GetInstructions(target)
                        disassemble_instructions (insts)
                    else:
                        # See if we have a symbol in the symbol table for where we stopped
                        symbol = frame.GetSymbol();
                        if symbol:
                            # We do have a symbol, print some info for the symbol
                            print symbol
                            # Now get all instructions for this symbol and print them
                            insts = symbol.GetInstructions(target)
                            disassemble_instructions (insts)

                    registerList = frame.GetRegisters()
                    print('Frame registers (size of register set = %d):' % registerList.GetSize())
                    for value in registerList:
                        #print value
                        print('%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()))
                        for child in value:
                            print('Name: ', child.GetName(), ' Value: ', child.GetValue())

            print('Hit the breakpoint at main, enter to continue and wait for program to exit or 'Ctrl-D'/'quit' to terminate the program')
            next = sys.stdin.readline()
            if not next or next.rstrip('
') == 'quit':
                print('Terminating the inferior process...')
                process.Kill()
            else:
                # Now continue to the program exit
                process.Continue()
                # When we return from the above function we will hopefully be at the
                # program exit. Print out some process info
                print process
        elif state == lldb.eStateExited:
            print('Didn't hit the breakpoint at main, program has exited...')
        else:
            print('Unexpected process state: %s, killing process...' % debugger.StateAsCString (state))
            process.Kill()

Sometimes you need to create an empty target that will get filled in later.  The most common use for this
is to attach to a process by name or pid where you don't know the executable up front.  The most convenient way
to do this is:

target = debugger.CreateTarget('')
error = lldb.SBError()
process = target.AttachToProcessWithName(debugger.GetListener(), 'PROCESS_NAME', False, error)

or the equivalent arguments for AttachToProcessWithID.

Instance Methods [hide private]
 
__repr__(self) source code
 
Initialize() source code
SBError
InitializeWithErrorHandling() source code
 
Terminate() source code
SBDebugger
Create()
Create(bool source_init_files) -> SBDebugger Create(bool source_init_files, lldb::LogOutputCallback log_callback) -> SBDebugger
source code
 
Destroy(*args)
Destroy(SBDebugger debugger)
source code
 
MemoryPressureDetected() source code
 
__init__(self, *args)
__init__(lldb::SBDebugger self) -> SBDebugger __init__(lldb::SBDebugger self, SBDebugger rhs) -> SBDebugger
source code
 
IsValid(self)
IsValid(SBDebugger self) -> bool
source code
 
__nonzero__(self) source code
 
__bool__(self) source code
 
Clear(self)
Clear(SBDebugger self)
source code
 
SetAsync(self, *args)
SetAsync(SBDebugger self, bool b)
source code
 
GetAsync(self)
GetAsync(SBDebugger self) -> bool
source code
 
SkipLLDBInitFiles(self, *args)
SkipLLDBInitFiles(SBDebugger self, bool b)
source code
 
SetInputFileHandle(self, *args)
SetInputFileHandle(SBDebugger self, FILE * f, bool transfer_ownership)
source code
 
SetOutputFileHandle(self, *args)
SetOutputFileHandle(SBDebugger self, FILE * f, bool transfer_ownership)
source code
 
SetErrorFileHandle(self, *args)
SetErrorFileHandle(SBDebugger self, FILE * f, bool transfer_ownership)
source code
 
GetInputFileHandle(self)
GetInputFileHandle(SBDebugger self) -> FILE *
source code
 
GetOutputFileHandle(self)
GetOutputFileHandle(SBDebugger self) -> FILE *
source code
 
GetErrorFileHandle(self)
GetErrorFileHandle(SBDebugger self) -> FILE *
source code
 
GetCommandInterpreter(self)
GetCommandInterpreter(SBDebugger self) -> SBCommandInterpreter
source code
 
HandleCommand(self, *args)
HandleCommand(SBDebugger self, char const * command)
source code
 
GetListener(self)
GetListener(SBDebugger self) -> SBListener
source code
 
HandleProcessEvent(self, *args)
HandleProcessEvent(SBDebugger self, SBProcess process, SBEvent event, FILE * out, FILE * err)
source code
 
CreateTargetWithFileAndTargetTriple(self, *args)
CreateTargetWithFileAndTargetTriple(SBDebugger self, char const * filename, char const * target_triple) -> SBTarget
source code
 
CreateTargetWithFileAndArch(self, *args)
CreateTargetWithFileAndArch(SBDebugger self, char const * filename, char const * archname) -> SBTarget
source code
 
CreateTarget(self, *args)
CreateTarget(SBDebugger self, char const * filename, char const * target_triple, char const * platform_name, bool add_dependent_modules, ...
source code
 
GetDummyTarget(self)
GetDummyTarget(SBDebugger self) -> SBTarget
source code
 
DeleteTarget(self, *args)
DeleteTarget(SBDebugger self, SBTarget target) -> bool
source code
 
GetTargetAtIndex(self, *args)
GetTargetAtIndex(SBDebugger self, uint32_t idx) -> SBTarget
source code
 
GetIndexOfTarget(self, *args)
GetIndexOfTarget(SBDebugger self, SBTarget target) -> uint32_t
source code
 
FindTargetWithProcessID(self, *args)
FindTargetWithProcessID(SBDebugger self, lldb::pid_t pid) -> SBTarget
source code
 
FindTargetWithFileAndArch(self, *args)
FindTargetWithFileAndArch(SBDebugger self, char const * filename, char const * arch) -> SBTarget
source code
 
GetNumTargets(self)
GetNumTargets(SBDebugger self) -> uint32_t
source code
 
GetSelectedTarget(self)
GetSelectedTarget(SBDebugger self) -> SBTarget
source code
 
SetSelectedTarget(self, *args)
SetSelectedTarget(SBDebugger self, SBTarget target)
source code
 
GetSelectedPlatform(self)
GetSelectedPlatform(SBDebugger self) -> SBPlatform
source code
 
SetSelectedPlatform(self, *args)
SetSelectedPlatform(SBDebugger self, SBPlatform platform)
source code
 
GetNumPlatforms(self)
GetNumPlatforms(SBDebugger self) -> uint32_t
source code
 
GetPlatformAtIndex(self, *args)
GetPlatformAtIndex(SBDebugger self, uint32_t idx) -> SBPlatform
source code
 
GetNumAvailablePlatforms(self)
GetNumAvailablePlatforms(SBDebugger self) -> uint32_t
source code
 
GetAvailablePlatformInfoAtIndex(self, *args)
GetAvailablePlatformInfoAtIndex(SBDebugger self, uint32_t idx) -> SBStructuredData
source code
 
GetSourceManager(self)
GetSourceManager(SBDebugger self) -> SBSourceManager
source code
 
SetCurrentPlatform(self, *args)
SetCurrentPlatform(SBDebugger self, char const * platform_name) -> SBError
source code
 
SetCurrentPlatformSDKRoot(self, *args)
SetCurrentPlatformSDKRoot(SBDebugger self, char const * sysroot) -> bool
source code
 
SetUseExternalEditor(self, *args)
SetUseExternalEditor(SBDebugger self, bool input) -> bool
source code
 
GetUseExternalEditor(self)
GetUseExternalEditor(SBDebugger self) -> bool
source code
 
SetUseColor(self, *args)
SetUseColor(SBDebugger self, bool use_color) -> bool
source code
 
GetUseColor(self)
GetUseColor(SBDebugger self) -> bool
source code
 
GetDefaultArchitecture(*args)
GetDefaultArchitecture(char * arch_name, size_t arch_name_len) -> bool
source code
 
SetDefaultArchitecture(*args)
SetDefaultArchitecture(char const * arch_name) -> bool
source code
 
GetScriptingLanguage(self, *args)
GetScriptingLanguage(SBDebugger self, char const * script_language_name) -> lldb::ScriptLanguage
source code
char const *
GetVersionString() source code
 
StateAsCString(*args)
StateAsCString(lldb::StateType state) -> char const *
source code
SBStructuredData
GetBuildConfiguration() source code
 
StateIsRunningState(*args)
StateIsRunningState(lldb::StateType state) -> bool
source code
 
StateIsStoppedState(*args)
StateIsStoppedState(lldb::StateType state) -> bool
source code
 
EnableLog(self, *args)
EnableLog(SBDebugger self, char const * channel, char const ** types) -> bool
source code
 
SetLoggingCallback(self, *args)
SetLoggingCallback(SBDebugger self, lldb::LogOutputCallback log_callback)
source code
 
DispatchInput(self, *args)
DispatchInput(SBDebugger self, void const * data)
source code
 
DispatchInputInterrupt(self)
DispatchInputInterrupt(SBDebugger self)
source code
 
DispatchInputEndOfFile(self)
DispatchInputEndOfFile(SBDebugger self)
source code
 
GetInstanceName(self)
GetInstanceName(SBDebugger self) -> char const *
source code
 
FindDebuggerWithID(*args)
FindDebuggerWithID(int id) -> SBDebugger
source code
 
SetInternalVariable(*args)
SetInternalVariable(char const * var_name, char const * value, char const * debugger_instance_name) -> SBError
source code
 
GetInternalVariableValue(*args)
GetInternalVariableValue(char const * var_name, char const * debugger_instance_name) -> SBStringList
source code
 
GetDescription(self, *args)
GetDescription(SBDebugger self, SBStream description) -> bool
source code
 
GetTerminalWidth(self)
GetTerminalWidth(SBDebugger self) -> uint32_t
source code
 
SetTerminalWidth(self, *args)
SetTerminalWidth(SBDebugger self, uint32_t term_width)
source code
 
GetID(self)
GetID(SBDebugger self) -> lldb::user_id_t
source code
 
GetPrompt(self)
GetPrompt(SBDebugger self) -> char const *
source code
 
SetPrompt(self, *args)
SetPrompt(SBDebugger self, char const * prompt)
source code
 
GetReproducerPath(self)
GetReproducerPath(SBDebugger self) -> char const *
source code
 
GetScriptLanguage(self)
GetScriptLanguage(SBDebugger self) -> lldb::ScriptLanguage
source code
 
SetScriptLanguage(self, *args)
SetScriptLanguage(SBDebugger self, lldb::ScriptLanguage script_lang)
source code
 
GetCloseInputOnEOF(self)
GetCloseInputOnEOF(SBDebugger self) -> bool
source code
 
SetCloseInputOnEOF(self, *args)
SetCloseInputOnEOF(SBDebugger self, bool b)
source code
 
GetCategory(self, *args)
GetCategory(SBDebugger self, char const * category_name) -> SBTypeCategory GetCategory(SBDebugger self, lldb::LanguageType lang_type) -> SBTypeCategory
source code
 
CreateCategory(self, *args)
CreateCategory(SBDebugger self, char const * category_name) -> SBTypeCategory
source code
 
DeleteCategory(self, *args)
DeleteCategory(SBDebugger self, char const * category_name) -> bool
source code
 
GetNumCategories(self)
GetNumCategories(SBDebugger self) -> uint32_t
source code
 
GetCategoryAtIndex(self, *args)
GetCategoryAtIndex(SBDebugger self, uint32_t arg2) -> SBTypeCategory
source code
 
GetDefaultCategory(self)
GetDefaultCategory(SBDebugger self) -> SBTypeCategory
source code
 
GetFormatForType(self, *args)
GetFormatForType(SBDebugger self, SBTypeNameSpecifier arg2) -> SBTypeFormat
source code
 
GetSummaryForType(self, *args)
GetSummaryForType(SBDebugger self, SBTypeNameSpecifier arg2) -> SBTypeSummary
source code
 
GetFilterForType(self, *args)
GetFilterForType(SBDebugger self, SBTypeNameSpecifier arg2) -> SBTypeFilter
source code
 
GetSyntheticForType(self, *args)
GetSyntheticForType(SBDebugger self, SBTypeNameSpecifier arg2) -> SBTypeSynthetic
source code
 
RunCommandInterpreter(self, *args)
RunCommandInterpreter(SBDebugger self, bool auto_handle_events, bool spawn_thread, SBCommandInterpreterRunOptions options, ...
source code
 
RunREPL(self, *args)
RunREPL(SBDebugger self, lldb::LanguageType language, char const * repl_options) -> SBError
source code
 
__iter__(self)
Iterate over all targets in a lldb.SBDebugger object.
source code
 
__len__(self)
Return the number of targets in a lldb.SBDebugger object.
source code
 
__str__(self)
__str__(SBDebugger self) -> PyObject *
source code
Class Variables [hide private]
  __swig_setmethods__ = {}
  __setattr__ = lambda self, name, value:
  __swig_getmethods__ = {}
  __getattr__ = lambda self, name:
  __swig_destroy__ = _lldb.delete_SBDebugger
  __del__ = lambda self:
Method Details [hide private]

CreateTarget(self, *args)

source code 

CreateTarget(SBDebugger self, char const * filename, char const * target_triple, char const * platform_name, bool add_dependent_modules, 
    SBError sb_error) -> SBTarget
CreateTarget(SBDebugger self, char const * filename) -> SBTarget

GetDummyTarget(self)

source code 

GetDummyTarget(SBDebugger self) -> SBTarget

The dummy target holds breakpoints and breakpoint names that will prime newly created targets.

DeleteTarget(self, *args)

source code 

DeleteTarget(SBDebugger self, SBTarget target) -> bool

Return true if target is deleted from the target list of the debugger.

GetNumPlatforms(self)

source code 

GetNumPlatforms(SBDebugger self) -> uint32_t

Get the number of currently active platforms.

GetPlatformAtIndex(self, *args)

source code 

GetPlatformAtIndex(SBDebugger self, uint32_t idx) -> SBPlatform

Get one of the currently active platforms.

GetNumAvailablePlatforms(self)

source code 

GetNumAvailablePlatforms(SBDebugger self) -> uint32_t

Get the number of available platforms.

GetAvailablePlatformInfoAtIndex(self, *args)

source code 

GetAvailablePlatformInfoAtIndex(SBDebugger self, uint32_t idx) -> SBStructuredData

Get the name and description of one of the available platforms.

@param idx Zero-based index of the platform for which info should be
           retrieved, must be less than the value returned by
           GetNumAvailablePlatforms().

RunCommandInterpreter(self, *args)

source code 

RunCommandInterpreter(SBDebugger self, bool auto_handle_events, bool spawn_thread, SBCommandInterpreterRunOptions options, 
    int & num_errors, bool & quit_requested, bool & stopped_for_crash)