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
sourceimpl SBProcess
impl SBProcess
pub fn broadcaster_class_name() -> &'static str
sourcepub fn state(&self) -> StateType
pub fn state(&self) -> StateType
The current state of this process (running, stopped, exited, etc.).
sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
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.
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true
if the process is currently running.
This corresponds to the process being in the Running
or Stepping
states.
sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
Returns true
if the process is currently stopped.
This corresponds to the process being in the Stopped
, Crashed
,
or Suspended
states.
sourcepub fn exit_status(&self) -> i32
pub fn exit_status(&self) -> i32
The exit status of the process when the process state is
Exited
.
sourcepub fn exit_description(&self) -> &str
pub fn exit_description(&self) -> &str
The exit description of the process when the process state
is Exited
.
sourcepub fn process_id(&self) -> lldb_pid_t
pub fn process_id(&self) -> lldb_pid_t
Returns the process ID of the process.
sourcepub fn unique_id(&self) -> u32
pub fn unique_id(&self) -> u32
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.
sourcepub fn address_byte_size(&self) -> u32
pub fn address_byte_size(&self) -> u32
Get the size, in bytes, of an address.
sourcepub fn destroy(&self) -> Result<(), SBError>
pub fn destroy(&self) -> Result<(), SBError>
Kills the process and shuts down all threads that were spawned to track and monitor the process.
pub fn continue_execution(&self) -> Result<(), SBError>
pub fn stop(&self) -> Result<(), SBError>
pub fn detach(&self) -> Result<(), SBError>
pub fn broadcaster(&self) -> SBBroadcaster
sourcepub fn get_extended_crash_information(&self) -> SBStructuredData
pub fn get_extended_crash_information(&self) -> SBStructuredData
Returns the process’ extended crash information.
pub fn get_num_supported_hardware_watchpoints(&self) -> Result<u32, SBError>
sourcepub fn threads(&self) -> SBProcessThreadIter<'_>ⓘNotable traits for SBProcessThreadIter<'d>impl<'d> Iterator for SBProcessThreadIter<'d> type Item = SBThread;
pub fn threads(&self) -> SBProcessThreadIter<'_>ⓘNotable traits for SBProcessThreadIter<'d>impl<'d> Iterator for SBProcessThreadIter<'d> type Item = SBThread;
Get an iterator over the threads known to this process instance.
sourcepub fn queues(&self) -> SBProcessQueueIter<'_>ⓘNotable traits for SBProcessQueueIter<'d>impl<'d> Iterator for SBProcessQueueIter<'d> type Item = SBQueue;
pub fn queues(&self) -> SBProcessQueueIter<'_>ⓘNotable traits for SBProcessQueueIter<'d>impl<'d> Iterator for SBProcessQueueIter<'d> type Item = SBQueue;
Get an iterator over the queues known to this process instance.
sourcepub fn thread_by_id(&self, thread_id: lldb_tid_t) -> Option<SBThread>
pub fn thread_by_id(&self, thread_id: lldb_tid_t) -> Option<SBThread>
Returns the thread with the given thread ID.
sourcepub fn thread_by_index_id(&self, thread_index_id: u32) -> Option<SBThread>
pub fn thread_by_index_id(&self, thread_index_id: u32) -> Option<SBThread>
Returns the thread with the given thread index ID.
sourcepub fn selected_thread(&self) -> SBThread
pub fn selected_thread(&self) -> SBThread
Returns the currently selected thread.
sourcepub fn set_selected_thread(&self, thread: &SBThread) -> bool
pub fn set_selected_thread(&self, thread: &SBThread) -> bool
Set the selected thread.
sourcepub fn set_selected_thread_by_id(&self, thread_id: lldb_tid_t) -> bool
pub fn set_selected_thread_by_id(&self, thread_id: lldb_tid_t) -> bool
Set the selected thread by ID.
sourcepub fn set_selected_thread_by_index_id(&self, thread_index_id: u32) -> bool
pub fn set_selected_thread_by_index_id(&self, thread_index_id: u32) -> bool
Set the selected thread by index ID.
pub fn event_as_process_event(event: &SBEvent) -> Option<SBProcessEvent<'_>>
sourcepub fn save_core(&self, file_name: &str) -> Result<(), SBError>
pub fn save_core(&self, file_name: &str) -> Result<(), SBError>
Save the state of the process in a core file (or mini dump on Windows).
pub fn process_info(&self) -> SBProcessInfo
sourcepub fn allocate_memory(
&self,
size: size_t,
permissions: Permissions
) -> Result<lldb_addr_t, SBError>
pub fn allocate_memory(
&self,
size: size_t,
permissions: Permissions
) -> Result<lldb_addr_t, SBError>
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.
}
sourcepub unsafe fn deallocate_memory(&self, ptr: lldb_addr_t) -> Result<(), SBError>
pub unsafe fn deallocate_memory(&self, ptr: lldb_addr_t) -> Result<(), SBError>
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.