SBProcess#

class lldb.SBProcess(*args)#

Represents the process associated with the target program.

SBProcess supports thread iteration. For example (from test/lldbutil.py),

# ==================================================
# Utility functions related to Threads and Processes
# ==================================================

def get_stopped_threads(process, reason):
    '''Returns the thread(s) with the specified stop reason in a list.

    The list can be empty if no such thread exists.
    '''
    threads = []
    for t in process:
        if t.GetStopReason() == reason:
            threads.append(t)
    return threads

Attributes Summary

broadcaster

A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.

eBroadcastBitInterrupt

eBroadcastBitProfileData

eBroadcastBitSTDERR

eBroadcastBitSTDOUT

eBroadcastBitStateChanged

eBroadcastBitStructuredData

exit_description

A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.

exit_state

A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.

id

A read only property that returns the process ID as an integer.

is_alive

A read only property that returns a boolean value that indicates if this process is currently alive.

is_running

A read only property that returns a boolean value that indicates if this process is currently running.

is_stopped

A read only property that returns a boolean value that indicates if this process is currently stopped.

num_threads

A read only property that returns the number of threads in this process as an integer.

selected_thread

A read/write property that gets/sets the currently selected thread in this process.

state

A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eState") that represents the current state of this process (running, stopped, exited, etc.).

target

A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.

thread

A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).

threads

A read only property that returns a list() of lldb.SBThread objects for this process.

Methods Summary

AllocateMemory(size, permissions, error)

Allocates a block of memory within the process, with size and access permissions specified in the arguments.

AppendEventStateReport(SBProcess self, ...)

Clear(SBProcess self)

Continue(SBProcess self)

CreateOSPluginThread(tid, context)

Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it.

DeallocateMemory(ptr)

Deallocates the block of memory (previously allocated using AllocateMemory) given in the argument.

Destroy(SBProcess self)

Kills the process and shuts down all threads that were spawned to track and monitor process.

Detach(-> SBError)

EventIsProcessEvent(SBEvent event)

EventIsStructuredDataEvent(SBEvent event)

ForceScriptedState(SBProcess self, lldb)

GetAddressByteSize(SBProcess self)

GetAsyncProfileData(SBProcess self, char * dst)

GetBroadcaster(SBProcess self)

GetBroadcasterClass()

GetBroadcasterClassName()

GetByteOrder(SBProcess self)

GetDescription(SBProcess self, ...)

GetExitDescription(SBProcess self)

GetExitStatus(SBProcess self)

GetExtendedBacktraceTypeAtIndex(idx)

Takes an index argument, returns the name of one of the thread-origin extended backtrace methods as a str.

GetExtendedCrashInformation()

Returns the process' extended crash information.

GetHistoryThreads(SBProcess self, lldb)

GetInterruptedFromEvent(SBEvent event)

GetMemoryRegionInfo(SBProcess self, lldb, ...)

GetMemoryRegions(SBProcess self)

GetNumExtendedBacktraceTypes()

Return the number of different thread-origin extended backtraces this process can support as a uint32_t.

GetNumQueues(SBProcess self)

GetNumRestartedReasonsFromEvent(SBEvent event)

GetNumSupportedHardwareWatchpoints(...)

GetNumThreads(SBProcess self)

GetPluginName(SBProcess self)

GetProcessFromEvent(SBEvent event)

GetProcessID()

Returns the process ID of the process.

GetProcessInfo()

Get information about the process. Valid process info will only be returned when the process is alive, use IsValid() to check if the info returned is valid. ::.

GetQueueAtIndex(SBProcess self, size_t index)

GetRestartedFromEvent(SBEvent event)

GetRestartedReasonAtIndexFromEvent(...)

GetSTDERR(dst)

Reads data from the current process's stderr stream.

GetSTDOUT(dst)

Reads data from the current process's stdout stream.

GetScriptedImplementation()

Returns the implementation object of the process plugin if available.

GetSelectedThread()

Returns the currently selected thread.

GetShortPluginName(SBProcess self)

GetState(SBProcess self)

GetStateFromEvent(SBEvent event)

GetStopEventForStopID(SBProcess self, ...)

GetStopID(SBProcess self, ...)

Returns a stop id that will increase every time the process executes.

GetStructuredDataFromEvent(SBEvent event)

GetTarget(SBProcess self)

GetThreadAtIndex(index)

Returns the INDEX'th thread from the list of current threads.

GetThreadByID(sb_thread_id)

Returns the thread with the given thread ID.

GetThreadByIndexID(index_id)

Returns the thread with the given thread IndexID.

GetUniqueID()

Returns an integer ID that is guaranteed to be unique across all process instances.

GetUnixSignals(SBProcess self)

IsInstrumentationRuntimePresent(...)

IsValid(SBProcess self)

Kill(SBProcess self)

Same as Destroy(self).

LoadImage(-> uint32_t)

LoadImageUsingPaths(image_spec, paths, ...)

Load the library whose filename is given by image_spec looking in all the paths supplied in the paths argument.

PutSTDIN(src)

Writes data into the current process's stdin.

ReadCStringFromMemory(addr, char_buf, error)

Reads a NULL terminated C string from the current process's address space. It returns a python string of the exact length, or truncates the string if the maximum character limit is reached. Example: ::.

ReadMemory(addr, buf, error)

Reads memory from the current process's address space and removes any traps that may have been inserted into the memory. It returns the byte buffer in a Python string. Example: ::.

ReadPointerFromMemory(addr, error)

Reads a pointer from memory from an address and returns the value. Example: ::.

ReadUnsignedFromMemory(addr, byte_size, error)

Reads an unsigned integer from memory given a byte size and an address. Returns the unsigned integer that was read. Example: ::.

RemoteAttachToProcessWithID(SBProcess self, ...)

Remote connection related functions.

RemoteLaunch(SBProcess self, ...)

See SBTarget.Launch for argument description and usage.

ReportEventState()

SaveCore(-> SBError)

SendAsyncInterrupt(SBProcess self)

SendEventData(SBProcess self, char const * data)

SetSelectedThread(SBProcess self, ...)

SetSelectedThreadByID(SBProcess self, lldb)

SetSelectedThreadByIndexID(SBProcess self, ...)

Signal(SBProcess self, int signal)

Sends the process a unix signal.

Stop(SBProcess self)

UnloadImage(SBProcess self, uint32_t image_token)

WriteMemory(addr, buf, error)

Writes memory to the current process's address space and maintains any traps that might be present due to software breakpoints. Example: ::.

WriteMemoryAsCString(addr, str, error)

WriteMemoryAsCString(self, addr, str, error):

get_process_thread_list()

An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.

get_threads_access_object()

An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.

Attributes Documentation

broadcaster#

A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.

eBroadcastBitInterrupt = <Mock name='mock.SBProcess_eBroadcastBitInterrupt' id='4433286288'>#
eBroadcastBitProfileData = <Mock name='mock.SBProcess_eBroadcastBitProfileData' id='4433261008'>#
eBroadcastBitSTDERR = <Mock name='mock.SBProcess_eBroadcastBitSTDERR' id='4433261456'>#
eBroadcastBitSTDOUT = <Mock name='mock.SBProcess_eBroadcastBitSTDOUT' id='4433285904'>#
eBroadcastBitStateChanged = <Mock name='mock.SBProcess_eBroadcastBitStateChanged' id='4433286352'>#
eBroadcastBitStructuredData = <Mock name='mock.SBProcess_eBroadcastBitStructuredData' id='4433256272'>#
exit_description#

A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.

exit_state#

A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.

id#

A read only property that returns the process ID as an integer.

is_alive#

A read only property that returns a boolean value that indicates if this process is currently alive.

is_running#

A read only property that returns a boolean value that indicates if this process is currently running.

is_stopped#

A read only property that returns a boolean value that indicates if this process is currently stopped.

num_threads#

A read only property that returns the number of threads in this process as an integer.

selected_thread#

A read/write property that gets/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.

state#

A read only property that returns an lldb enumeration value (see enumerations that start with ā€œlldb.eStateā€) that represents the current state of this process (running, stopped, exited, etc.).

target#

A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.

thread#

A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).

threads#

A read only property that returns a list() of lldb.SBThread objects for this process.

Methods Documentation

AllocateMemory(size, permissions, error)#

Allocates a block of memory within the process, with size and access permissions specified in the arguments. The permissions argument is an or-combination of zero or more of lldb.ePermissionsWritable, lldb.ePermissionsReadable, and lldb.ePermissionsExecutable. Returns the address of the allocated buffer in the process, or lldb.LLDB_INVALID_ADDRESS if the allocation failed.

AppendEventStateReport(SBProcess self, SBEvent event, SBCommandReturnObject result)#
Clear(SBProcess self)#
Continue(SBProcess self) SBError#
CreateOSPluginThread(tid, context)#

Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it.

DeallocateMemory(ptr)#

Deallocates the block of memory (previously allocated using AllocateMemory) given in the argument.

Destroy(SBProcess self) SBError#

Kills the process and shuts down all threads that were spawned to track and monitor process.

Detach(SBProcess self) SBError#
Detach(SBProcess self, bool keep_stopped) SBError
static EventIsProcessEvent(SBEvent event) bool#
static EventIsStructuredDataEvent(SBEvent event) bool#
ForceScriptedState(SBProcess self, lldb::StateType new_state)#
GetAddressByteSize(SBProcess self) uint32_t#
GetAsyncProfileData(SBProcess self, char * dst) size_t#
GetBroadcaster(SBProcess self) SBBroadcaster#
static GetBroadcasterClass() char const *#
static GetBroadcasterClassName() char const *#
GetByteOrder(SBProcess self) lldb::ByteOrder#
GetDescription(SBProcess self, SBStream description) bool#
GetExitDescription(SBProcess self) char const *#
GetExitStatus(SBProcess self) int#
GetExtendedBacktraceTypeAtIndex(idx)#

Takes an index argument, returns the name of one of the thread-origin extended backtrace methods as a str.

GetExtendedCrashInformation()#

Returns the processā€™ extended crash information.

GetHistoryThreads(SBProcess self, lldb::addr_t addr) SBThreadCollection#
static GetInterruptedFromEvent(SBEvent event) bool#
GetMemoryRegionInfo(SBProcess self, lldb::addr_t load_addr, SBMemoryRegionInfo region_info) SBError#
GetMemoryRegions(SBProcess self) SBMemoryRegionInfoList#
GetNumExtendedBacktraceTypes()#

Return the number of different thread-origin extended backtraces this process can support as a uint32_t. When the process is stopped and you have an SBThread, lldb may be able to show a backtrace of when that thread was originally created, or the work item was enqueued to it (in the case of a libdispatch queue).

GetNumQueues(SBProcess self) uint32_t#
static GetNumRestartedReasonsFromEvent(SBEvent event) size_t#
GetNumSupportedHardwareWatchpoints(SBProcess self, SBError error) uint32_t#
GetNumThreads(SBProcess self) uint32_t#
GetPluginName(SBProcess self) char const *#
static GetProcessFromEvent(SBEvent event) SBProcess#
GetProcessID()#

Returns the process ID of the process.

GetProcessInfo()#

Get information about the process. Valid process info will only be returned when the process is alive, use IsValid() to check if the info returned is valid.

process_info = process.GetProcessInfo()
if process_info.IsValid():
    process_info.GetProcessID()
GetQueueAtIndex(SBProcess self, size_t index) SBQueue#
static GetRestartedFromEvent(SBEvent event) bool#
static GetRestartedReasonAtIndexFromEvent(SBEvent event, size_t idx) char const *#
GetSTDERR(dst)#

Reads data from the current processā€™s stderr stream. API client specifies the size of the buffer to read data into. It returns the byte buffer in a Python string.

GetSTDOUT(dst)#

Reads data from the current processā€™s stdout stream. API client specifies the size of the buffer to read data into. It returns the byte buffer in a Python string.

GetScriptedImplementation()#

Returns the implementation object of the process plugin if available. None otherwise.

GetSelectedThread()#

Returns the currently selected thread.

GetShortPluginName(SBProcess self) char const *#
GetState(SBProcess self) lldb::StateType#
static GetStateFromEvent(SBEvent event) lldb::StateType#
GetStopEventForStopID(SBProcess self, uint32_t stop_id) SBEvent#
GetStopID(SBProcess self, bool include_expression_stops=False) uint32_t#

Returns a stop id that will increase every time the process executes. If include_expression_stops is true, then stops caused by expression evaluation will cause the returned value to increase, otherwise the counter returned will only increase when execution is continued explicitly by the user. Note, the value will always increase, but may increase by more than one per stop.

static GetStructuredDataFromEvent(SBEvent event) SBStructuredData#
GetTarget(SBProcess self) SBTarget#
GetThreadAtIndex(index)#

Returns the INDEXā€™th thread from the list of current threads. The index of a thread is only valid for the current stop. For a persistent thread identifier use either the thread ID or the IndexID. See help on SBThread for more details.

GetThreadByID(sb_thread_id)#

Returns the thread with the given thread ID.

GetThreadByIndexID(index_id)#

Returns the thread with the given thread IndexID.

GetUniqueID()#

Returns an integer ID that is guaranteed to be unique across all process instances. This is not the process ID, just a unique integer for comparison and caching purposes.

GetUnixSignals(SBProcess self) SBUnixSignals#
IsInstrumentationRuntimePresent(SBProcess self, lldb::InstrumentationRuntimeType type) bool#
IsValid(SBProcess self) bool#
Kill(SBProcess self) SBError#

Same as Destroy(self).

LoadImage(SBProcess self, SBFileSpec remote_image_spec, SBError error) uint32_t#
LoadImage(SBProcess self, SBFileSpec local_image_spec, SBFileSpec remote_image_spec, SBError error) uint32_t
LoadImageUsingPaths(image_spec, paths, loaded_path, error)#

Load the library whose filename is given by image_spec looking in all the paths supplied in the paths argument. If successful, return a token that can be passed to UnloadImage and fill loaded_path with the path that was successfully loaded. On failure, return lldb.LLDB_INVALID_IMAGE_TOKEN.

PutSTDIN(src)#

Writes data into the current processā€™s stdin. API client specifies a Python string as the only argument.

ReadCStringFromMemory(addr, char_buf, error)#

Reads a NULL terminated C string from the current processā€™s address space. It returns a python string of the exact length, or truncates the string if the maximum character limit is reached. Example:

# Read a C string of at most 256 bytes from address '0x1000'
error = lldb.SBError()
cstring = process.ReadCStringFromMemory(0x1000, 256, error)
if error.Success():
    print('cstring: ', cstring)
else
    print('error: ', error)
ReadMemory(addr, buf, error)#

Reads memory from the current processā€™s address space and removes any traps that may have been inserted into the memory. It returns the byte buffer in a Python string. Example:

# Read 4 bytes from address 'addr' and assume error.Success() is True.
content = process.ReadMemory(addr, 4, error)
new_bytes = bytearray(content)
ReadPointerFromMemory(addr, error)#

Reads a pointer from memory from an address and returns the value. Example:

# Read a pointer from address 0x1000
error = lldb.SBError()
ptr = ReadPointerFromMemory(0x1000, error)
if error.Success():
    print('pointer: 0x%x' % ptr)
else
    print('error: ', error)
ReadUnsignedFromMemory(addr, byte_size, error)#

Reads an unsigned integer from memory given a byte size and an address. Returns the unsigned integer that was read. Example:

# Read a 4 byte unsigned integer from address 0x1000
error = lldb.SBError()
uint = ReadUnsignedFromMemory(0x1000, 4, error)
if error.Success():
    print('integer: %u' % uint)
else
    print('error: ', error)
RemoteAttachToProcessWithID(SBProcess self, lldb::pid_t pid, SBError error) bool#

Remote connection related functions. These will fail if the process is not in eStateConnected. They are intended for use when connecting to an externally managed debugserver instance.

RemoteLaunch(SBProcess self, char const ** argv, char const ** envp, char const * stdin_path, char const * stdout_path, char const * stderr_path, char const * working_directory, uint32_t launch_flags, bool stop_at_entry, SBError error) bool#

See SBTarget.Launch for argument description and usage.

ReportEventState(SBProcess self, SBEvent event, SBFile file)#
ReportEventState(SBProcess self, SBEvent event, lldb::FileSP BORROWED) None
SaveCore(SBProcess self, char const * file_name, char const * flavor, lldb::SaveCoreStyle core_style) SBError#
SaveCore(SBProcess self, char const * file_name) SBError
SendAsyncInterrupt(SBProcess self)#
SendEventData(SBProcess self, char const * data) SBError#
SetSelectedThread(SBProcess self, SBThread thread) bool#
SetSelectedThreadByID(SBProcess self, lldb::tid_t tid) bool#
SetSelectedThreadByIndexID(SBProcess self, uint32_t index_id) bool#
Signal(SBProcess self, int signal) SBError#

Sends the process a unix signal.

Stop(SBProcess self) SBError#
UnloadImage(SBProcess self, uint32_t image_token) SBError#
WriteMemory(addr, buf, error)#

Writes memory to the current processā€™s address space and maintains any traps that might be present due to software breakpoints. Example:

# Create a Python string from the byte array.
new_value = str(bytes)
result = process.WriteMemory(addr, new_value, error)
if not error.Success() or result != len(bytes):
    print('SBProcess.WriteMemory() failed!')
WriteMemoryAsCString(addr, str, error)#
WriteMemoryAsCString(self, addr, str, error):

This functions the same as WriteMemory except a null-terminator is appended to the end of the buffer if it is not there already.

get_process_thread_list()#

An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.

get_threads_access_object()#

An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.

__iter__()#

Iterate over all threads in a lldb.SBProcess object.

__len__()#

Return the number of threads in a lldb.SBProcess object.