pub struct SBProcess {
    pub raw: SBProcessRef,
}
Expand description

The process associated with the target program.

You get a process by attaching to or launching a target program. See SBTarget for details.

Process State

The OS process ID (pid_t) for the process is available via SBProcess::process_id().

The process state can be obtained via SBProcess::state(). It is common to just check to see if the process SBProcess::is_alive(), SBProcess::is_running() or SBProcess::is_stopped().

Once the process is in the Exited state, the SBProcess::exit_status() and SBProcess::exit_description() are available for inspection.

Execution Control

Once you have a process, you can:

Threads

The process contains the threads of execution for the target. The available threads can be iterated over with SBProcess::threads():

// Iterate over the threads...
for thread in process.threads() {
    println!("Hello {}!", thread.thread_id());
}
// Or collect them into a vector!
let threads = process.threads().collect::<Vec<SBThread>>();

Specific individual threads can be looked up via SBProcess::thread_by_id() and SBProcess::thread_by_index_id() methods.

Some functions operate on the ‘currently selected thread’. This can retrieved via SBProcess::selected_thread() and set via SBProcess::set_selected_thread(), SBProcess::set_selected_thread_by_id(), or SBProcess::set_selected_thread_by_index_id().

Queues

A process may also have a set of queues associated with it. This is used on macOS, iOS and other Apple operating systems to support debugger integration with libdispatch, also known as GCD or “Grand Central Dispatch”.

The active queues can be iterated over with SBProcess::queues():

// Iterate over the queues...
for queue in process.queues() {
    println!("Hello {}!", queue.queue_id());
}

Events

… to be written …

Fields

raw: SBProcessRef

The underlying raw SBProcessRef.

Implementations

Check whether or not this is a valid SBProcess value.

The current state of this process (running, stopped, exited, etc.).

Returns true if the process is currently alive.

This corresponds to the process being in the Attaching, Launching, Stopped, Running, Stepping, Crashed or Suspended states.

Returns true if the process is currently running.

This corresponds to the process being in the Running or Stepping states.

Returns true if the process is currently stopped.

This corresponds to the process being in the Stopped, Crashed, or Suspended states.

The exit status of the process when the process state is Exited.

The exit description of the process when the process state is Exited.

Returns the process ID of the process.

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.

Get the size, in bytes, of an address.

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

Same as calling destroy.

Send the process a Unix signal.

Returns the process’ extended crash information.

Get an iterator over the threads known to this process instance.

Get an iterator over the queues known to this process instance.

Returns the thread with the given thread ID.

Returns the thread with the given thread index ID.

Returns the currently selected thread.

Set the selected thread.

Set the selected thread by ID.

Set the selected thread by index ID.

Save the state of the process in a core file (or mini dump on Windows).

Allocate memory within the process.

This function will allocate size bytes in the process’s address space.

The permissions must be any of the Permissions bits OR’d together. The permissions on a given memory allocation can’t be changed after allocation. Note that a block that isn’t set writable can still be written from lldb, just not by the process itself.

Returns the address of the allocated buffer in the process or the error that occurred while trying to allocate.

Example
if let Ok(data_addr) = process.allocate_memory(1024, Permissions::READABLE) {
    // Do something with the address.
}
if let Ok(code_addr) = process.allocate_memory(1024, Permissions::READABLE | Permissions::EXECUTABLE) {
    // Do something with the address.
}

Deallocate memory in the process.

This function will deallocate memory in the process’s address space that was allocated with SBProcess::allocate_memory().

If an error occurs while deallocating, it will be returned.

Safety

The ptr must be a return value from SBProcess::allocate_memory(), pointing to the memory you want to deallocate.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.