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(SBProcess self, size_t size, ...)

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(SBProcess self, lldb, lldb)

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

DeallocateMemory(SBProcess self, lldb)

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)

FindInMemory(SBProcess self, ...)

FindRangesInMemory(SBProcess self, ...)

FixAddress(SBProcess self, lldb, lldb)

Given a virtual address, clear the bits that are not used for addressing (and may be used for metadata, memory tagging, point authentication, etc).

ForceScriptedState(SBProcess self, lldb)

GetAddressByteSize(SBProcess self)

GetAddressMask(SBProcess self, lldb, lldb)

Get the current address mask in this Process of a given type.

GetAsyncProfileData(SBProcess self, char * dst)

GetBroadcaster(SBProcess self)

GetBroadcasterClass()

Get default process broadcaster class name (lldb.process).

GetBroadcasterClassName()

GetByteOrder(SBProcess self)

GetCoreFile(SBProcess self)

GetDescription(SBProcess self, ...)

GetExitDescription(SBProcess self)

GetExitStatus(SBProcess self)

GetExtendedBacktraceTypeAtIndex(...)

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

GetExtendedCrashInformation(SBProcess self)

Returns the process' extended crash information.

GetHistoryThreads(SBProcess self, lldb)

GetInterruptedFromEvent(SBEvent event)

GetMemoryRegionInfo(SBProcess self, lldb, ...)

GetMemoryRegions(SBProcess self)

GetNumExtendedBacktraceTypes(SBProcess self)

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(SBProcess self)

Returns the process ID of the process.

GetProcessInfo(SBProcess self)

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(SBProcess self, char * dst)

Reads data from the current process's stderr stream.

GetSTDOUT(SBProcess self, char * dst)

Reads data from the current process's stdout stream.

GetScriptedImplementation(SBProcess self)

Returns the implementation object of the process plugin if available.

GetSelectedThread(SBProcess self)

Returns the currently selected thread.

GetShortPluginName(SBProcess self)

GetState(SBProcess self)

GetStateFromEvent(SBEvent event)

GetStatus(SBProcess self, SBStream status)

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(SBProcess self, size_t index)

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

GetThreadByID(SBProcess self, lldb)

Returns the thread with the given thread ID.

GetThreadByIndexID(SBProcess self, ...)

Returns the thread with the given thread IndexID.

GetUniqueID(SBProcess self)

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(SBProcess self, ...)

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

PutSTDIN(SBProcess self, char const * src)

Writes data into the current process's stdin.

ReadCStringFromMemory(SBProcess self, lldb, ...)

Reads a NUL 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(SBProcess self, lldb, void * buf, ...)

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(SBProcess self, lldb, ...)

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

ReadUnsignedFromMemory(SBProcess self, lldb, ...)

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 -> SBError)

SendAsyncInterrupt(SBProcess self)

SendEventData(SBProcess self, char const * data)

SetAddressMask(SBProcess self, lldb, lldb, lldb)

Set the current address mask in this Process for a given type, lldb.eAddressMaskTypeCode or lldb.eAddressMaskTypeData.

SetAddressableBits(SBProcess self, lldb, ...)

Set the number of low bits relevant for addressing in this Process for a given type, lldb.eAddressMaskTypeCode or lldb.eAddressMaskTypeData.

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(SBProcess self, lldb, ...)

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='140438884723152'>#
eBroadcastBitProfileData = <Mock name='mock.SBProcess_eBroadcastBitProfileData' id='140438884723104'>#
eBroadcastBitSTDERR = <Mock name='mock.SBProcess_eBroadcastBitSTDERR' id='140438884723056'>#
eBroadcastBitSTDOUT = <Mock name='mock.SBProcess_eBroadcastBitSTDOUT' id='140438884723200'>#
eBroadcastBitStateChanged = <Mock name='mock.SBProcess_eBroadcastBitStateChanged' id='140438884722960'>#
eBroadcastBitStructuredData = <Mock name='mock.SBProcess_eBroadcastBitStructuredData' id='140438884723296'>#
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(SBProcess self, size_t size, uint32_t permissions, SBError error) lldb::addr_t#

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(SBProcess self, lldb::tid_t tid, lldb::addr_t context) SBThread#

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

DeallocateMemory(SBProcess self, lldb::addr_t ptr) SBError#

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#
FindInMemory(SBProcess self, void const * buf, SBAddressRange range, uint32_t alignment, SBError error) lldb::addr_t#
FindRangesInMemory(SBProcess self, void const * buf, SBAddressRangeList ranges, uint32_t alignment, uint32_t max_matches, SBError error) SBAddressRangeList#
FixAddress(SBProcess self, lldb::addr_t addr, lldb::AddressMaskType type=eAddressMaskTypeAny) lldb::addr_t#

Given a virtual address, clear the bits that are not used for addressing (and may be used for metadata, memory tagging, point authentication, etc). By default the most general mask, lldb.eAddressMaskTypeAny is used to process the address, but lldb.eAddressMaskTypeData and lldb.eAddressMaskTypeCode may be specified if the type of address is known.

ForceScriptedState(SBProcess self, lldb::StateType new_state)#
GetAddressByteSize(SBProcess self) uint32_t#
GetAddressMask(SBProcess self, lldb::AddressMaskType type, lldb::AddressMaskRange addr_range=eAddressMaskRangeLow) lldb::addr_t#

Get the current address mask in this Process of a given type. There are lldb.eAddressMaskTypeCode and lldb.eAddressMaskTypeData address masks, and on most Targets, the the Data address mask is more general because there are no alignment restrictions, as there can be with Code addresses. lldb.eAddressMaskTypeAny may be used to get the most general mask. The bits which are not used for addressing are set to 1 in the returned mask. In an unusual environment with different address masks for high and low memory, this may also be specified. This is uncommon, default is lldb.eAddressMaskRangeLow.

GetAsyncProfileData(SBProcess self, char * dst) size_t#
GetBroadcaster(SBProcess self) SBBroadcaster#
static GetBroadcasterClass() char const *#

Get default process broadcaster class name (lldb.process).

static GetBroadcasterClassName() char const *#
GetByteOrder(SBProcess self) lldb::ByteOrder#
GetCoreFile(SBProcess self) SBFileSpec#
GetDescription(SBProcess self, SBStream description) bool#
GetExitDescription(SBProcess self) char const *#
GetExitStatus(SBProcess self) int#
GetExtendedBacktraceTypeAtIndex(SBProcess self, uint32_t idx) char const *#

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

GetExtendedCrashInformation(SBProcess self) SBStructuredData#

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(SBProcess self) uint32_t#

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(SBProcess self) lldb::pid_t#

Returns the process ID of the process.

GetProcessInfo(SBProcess self) SBProcessInfo#

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(SBProcess self, char * dst) size_t#

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(SBProcess self, char * dst) size_t#

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(SBProcess self) SBScriptObject#

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

GetSelectedThread(SBProcess self) SBThread#

Returns the currently selected thread.

GetShortPluginName(SBProcess self) char const *#
GetState(SBProcess self) lldb::StateType#
static GetStateFromEvent(SBEvent event) lldb::StateType#
GetStatus(SBProcess self, SBStream status)#
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(SBProcess self, size_t index) SBThread#

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(SBProcess self, lldb::tid_t sb_thread_id) SBThread#

Returns the thread with the given thread ID.

GetThreadByIndexID(SBProcess self, uint32_t index_id) SBThread#

Returns the thread with the given thread IndexID.

GetUniqueID(SBProcess self) uint32_t#

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(SBProcess self, SBFileSpec image_spec, SBStringList paths, SBFileSpec loaded_path, SBError error) uint32_t#

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(SBProcess self, char const * src) size_t#

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

ReadCStringFromMemory(SBProcess self, lldb::addr_t addr, void * char_buf, SBError error) size_t#

Reads a NUL 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(SBProcess self, lldb::addr_t addr, void * buf, SBError error) size_t#

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(SBProcess self, lldb::addr_t addr, SBError error) lldb::addr_t#

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(SBProcess self, lldb::addr_t addr, uint32_t byte_size, SBError error) uint64_t#

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
SaveCore(SBProcess self, SBSaveCoreOptions options) SBError
SendAsyncInterrupt(SBProcess self)#
SendEventData(SBProcess self, char const * data) SBError#
SetAddressMask(SBProcess self, lldb::AddressMaskType type, lldb::addr_t mask, lldb::AddressMaskRange addr_range=eAddressMaskRangeLow)#

Set the current address mask in this Process for a given type, lldb.eAddressMaskTypeCode or lldb.eAddressMaskTypeData. Bits that are not used for addressing should be set to 1 in the mask. When setting all masks, lldb.eAddressMaskTypeAll may be specified. In an unusual environment with different address masks for high and low memory, this may also be specified. This is uncommon, default is lldb.eAddressMaskRangeLow.

SetAddressableBits(SBProcess self, lldb::AddressMaskType type, uint32_t num_bits, lldb::AddressMaskRange addr_range=eAddressMaskRangeLow)#

Set the number of low bits relevant for addressing in this Process for a given type, lldb.eAddressMaskTypeCode or lldb.eAddressMaskTypeData. When setting all masks, lldb.eAddressMaskTypeAll may be specified. In an unusual environment with different address masks for high and low memory, the address range may also be specified. This is uncommon, default is lldb.eAddressMaskRangeLow.

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(SBProcess self, lldb::addr_t addr, void const * buf, SBError error) size_t#

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.