SBTarget

Struct SBTarget 

Source
pub struct SBTarget {
    pub raw: SBTargetRef,
}
Expand description

The target program running under the debugger.

§Process Management

Starting a debug session is done by launching the target, attaching to a running process, or loading a core file.

§Launching

Launching a process can be done by creating and filling out an SBLaunchInfo and calling SBTarget::launch().

use lldb::*;
fn launch_target(target: &SBTarget) -> Result<SBProcess, SBError> {
    let launch_info = SBLaunchInfo::new();
    launch_info.set_launch_flags(LaunchFlags::STOP_AT_ENTRY);
    // Probably want to set up a listener here.
    target.launch(launch_info)
}

§Attaching

Attaching to a process can be done by creating and filling out an SBAttachInfo and calling SBTarget::attach().

use lldb::{lldb_pid_t, SBAttachInfo, SBError, SBProcess, SBTarget};
fn attach_to_pid(target: &SBTarget, pid: lldb_pid_t) -> Result<SBProcess, SBError> {
    let attach_info = SBAttachInfo::new_with_pid(pid);
    // Probably want to set up a listener here.
    target.attach(attach_info)
}

§Core Files

§Breakpoints and Watchpoints

§Modules

§Events

Fields§

§raw: SBTargetRef

The underlying raw SBTargetRef.

Implementations§

Source§

impl SBTarget

Source

pub fn is_valid(&self) -> bool

Check whether or not this is a valid SBTarget value.

Source

pub fn broadcaster_class_name() -> &'static str

Source

pub fn platform(&self) -> SBPlatform

Get the SBPlatform associated with this target.

After return, the platform object should be checked for validity.

Source

pub fn process(&self) -> SBProcess

Get the SBProcess associated with this target.

Source

pub fn launch(&self, launch_info: SBLaunchInfo) -> Result<SBProcess, SBError>

Launch a target for debugging.

Examples found in repository?
examples/basic_synchronous.rs (line 15)
3fn main() {
4    SBDebugger::initialize();
5
6    let debugger = SBDebugger::create(false);
7    debugger.set_asynchronous(false);
8    println!("{debugger:?}");
9
10    if let Some(target) = debugger.create_target_simple("/usr/local/bin/servo") {
11        println!("{target:?}");
12
13        let launchinfo = SBLaunchInfo::new();
14        launchinfo.set_launch_flags(LaunchFlags::STOP_AT_ENTRY);
15        match target.launch(launchinfo) {
16            Ok(process) => {
17                println!("{process:?}");
18                let _ = process.continue_execution();
19                println!("{process:?}");
20            }
21            Err(e) => println!("Uhoh: {e:?}"),
22        }
23    }
24    SBDebugger::terminate();
25}
Source

pub fn load_core(&self, core_file: &str) -> Result<SBProcess, SBError>

Source

pub fn attach(&self, attach_info: SBAttachInfo) -> Result<SBProcess, SBError>

Source

pub fn executable(&self) -> Option<SBFileSpec>

Get a filespec for the executable.

Source

pub fn add_module(&self, module: &SBModule) -> bool

Add a module to the target.

Source

pub fn add_module_spec(&self, module_spec: &SBModuleSpec) -> Option<SBModule>

Add a module to the target using an SBModuleSpec.

Source

pub fn remove_module(&self, module: &SBModule) -> bool

Remove a module from the target.

Source

pub fn debugger(&self) -> SBDebugger

Get the debugger controlling this target.

Source

pub fn modules(&self) -> SBTargetModuleIter<'_>

Get an iterator over the modules known to this target instance.

Source

pub fn find_module(&self, file_spec: &SBFileSpec) -> Option<SBModule>

Find the module for the given SBFileSpec.

Source

pub fn resolve_file_address(&self, file_addr: lldb_addr_t) -> Option<SBAddress>

Resolve a current file address into a section offset address.

Source

pub fn resolve_load_address(&self, vm_addr: lldb_addr_t) -> Option<SBAddress>

Resolve a current load address into a section offset address.

The return value will be None if the vm_addr doesn’t resolve to a section within a module.

Source

pub fn delete_breakpoint(&self, break_id: i32)

Source

pub fn find_breakpoint_by_id(&self, break_id: i32) -> Option<SBBreakpoint>

Source

pub fn enable_all_breakpoints(&self)

Source

pub fn disable_all_breakpoints(&self)

Source

pub fn delete_all_breakpoints(&self)

Source

pub fn breakpoint_create_by_location( &self, file: &str, line: u32, ) -> SBBreakpoint

Source

pub fn breakpoint_create_by_address(&self, address: lldb_addr_t) -> SBBreakpoint

Source

pub fn breakpoint_create_by_sbaddress(&self, address: SBAddress) -> SBBreakpoint

Source

pub fn breakpoints(&self) -> SBTargetBreakpointIter<'_>

Source

pub fn delete_watchpoint(&self, watch_id: i32)

Source

pub fn find_watchpoint_by_id(&self, watch_id: i32) -> Option<SBWatchpoint>

Source

pub fn enable_all_watchpoints(&self)

Source

pub fn disable_all_watchpoints(&self)

Source

pub fn delete_all_watchpoints(&self)

Source

pub fn watch_address( &self, addr: lldb_addr_t, size: usize, read: bool, write: bool, ) -> Result<SBWatchpoint, SBError>

Source

pub fn watchpoints(&self) -> SBTargetWatchpointIter<'_>

Source

pub fn broadcaster(&self) -> SBBroadcaster

Source

pub fn find_functions( &self, name: &str, name_type_mask: u32, ) -> SBSymbolContextList

Source

pub fn find_global_functions( &self, name: &str, max_matches: u32, matchtype: MatchType, ) -> SBSymbolContextList

Source

pub fn find_symbols( &self, name: &str, symbol_type: SymbolType, ) -> SBSymbolContextList

Source

pub fn evaluate_expression( &self, expression: &str, options: &SBExpressionOptions, ) -> SBValue

Evaluate an expression.

Source

pub fn event_as_target_event(event: &SBEvent) -> Option<SBTargetEvent<'_>>

Source

pub fn get_stack_red_zone_size(&self) -> lldb_addr_t

Source

pub fn is_loaded(&self, module: &SBModule) -> bool

Source

pub fn get_launch_info(&self) -> SBLaunchInfo

Source

pub fn set_launch_info(&self, launch_info: SBLaunchInfo)

Source

pub fn byte_order(&self) -> ByteOrder

Returns the byte order of target

Source

pub fn get_address_byte_size(&self) -> u32

Returns the size of address in bytes

Trait Implementations§

Source§

impl Clone for SBTarget

Source§

fn clone(&self) -> SBTarget

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SBTarget

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SBTarget

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for SBTarget

Source§

impl Sync for SBTarget

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.