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
impl SBTarget
pub fn broadcaster_class_name() -> &'static str
Sourcepub fn platform(&self) -> SBPlatform
pub fn platform(&self) -> SBPlatform
Get the SBPlatform
associated with this target.
After return, the platform object should be checked for validity.
Sourcepub fn launch(&self, launch_info: SBLaunchInfo) -> Result<SBProcess, SBError>
pub fn launch(&self, launch_info: SBLaunchInfo) -> Result<SBProcess, SBError>
Launch a target for debugging.
Examples found in repository?
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}
pub fn load_core(&self, core_file: &str) -> Result<SBProcess, SBError>
pub fn attach(&self, attach_info: SBAttachInfo) -> Result<SBProcess, SBError>
Sourcepub fn executable(&self) -> Option<SBFileSpec>
pub fn executable(&self) -> Option<SBFileSpec>
Get a filespec for the executable.
Sourcepub fn add_module(&self, module: &SBModule) -> bool
pub fn add_module(&self, module: &SBModule) -> bool
Add a module to the target.
Sourcepub fn add_module_spec(&self, module_spec: &SBModuleSpec) -> Option<SBModule>
pub fn add_module_spec(&self, module_spec: &SBModuleSpec) -> Option<SBModule>
Add a module to the target using an SBModuleSpec
.
Sourcepub fn remove_module(&self, module: &SBModule) -> bool
pub fn remove_module(&self, module: &SBModule) -> bool
Remove a module from the target.
Sourcepub fn debugger(&self) -> SBDebugger
pub fn debugger(&self) -> SBDebugger
Get the debugger controlling this target.
Sourcepub fn modules(&self) -> SBTargetModuleIter<'_> ⓘ
pub fn modules(&self) -> SBTargetModuleIter<'_> ⓘ
Get an iterator over the modules known to this target instance.
Sourcepub fn find_module(&self, file_spec: &SBFileSpec) -> Option<SBModule>
pub fn find_module(&self, file_spec: &SBFileSpec) -> Option<SBModule>
Find the module for the given SBFileSpec
.
Sourcepub fn resolve_file_address(&self, file_addr: lldb_addr_t) -> Option<SBAddress>
pub fn resolve_file_address(&self, file_addr: lldb_addr_t) -> Option<SBAddress>
Resolve a current file address into a section offset address.
Sourcepub fn resolve_load_address(&self, vm_addr: lldb_addr_t) -> Option<SBAddress>
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.
pub fn delete_breakpoint(&self, break_id: i32)
pub fn find_breakpoint_by_id(&self, break_id: i32) -> Option<SBBreakpoint>
pub fn enable_all_breakpoints(&self)
pub fn disable_all_breakpoints(&self)
pub fn delete_all_breakpoints(&self)
pub fn breakpoint_create_by_location( &self, file: &str, line: u32, ) -> SBBreakpoint
pub fn breakpoint_create_by_address(&self, address: lldb_addr_t) -> SBBreakpoint
pub fn breakpoint_create_by_sbaddress(&self, address: SBAddress) -> SBBreakpoint
pub fn breakpoints(&self) -> SBTargetBreakpointIter<'_> ⓘ
pub fn delete_watchpoint(&self, watch_id: i32)
pub fn find_watchpoint_by_id(&self, watch_id: i32) -> Option<SBWatchpoint>
pub fn enable_all_watchpoints(&self)
pub fn disable_all_watchpoints(&self)
pub fn delete_all_watchpoints(&self)
pub fn watch_address( &self, addr: lldb_addr_t, size: usize, read: bool, write: bool, ) -> Result<SBWatchpoint, SBError>
pub fn watchpoints(&self) -> SBTargetWatchpointIter<'_> ⓘ
pub fn broadcaster(&self) -> SBBroadcaster
pub fn find_functions( &self, name: &str, name_type_mask: u32, ) -> SBSymbolContextList
pub fn find_global_functions( &self, name: &str, max_matches: u32, matchtype: MatchType, ) -> SBSymbolContextList
pub fn find_symbols( &self, name: &str, symbol_type: SymbolType, ) -> SBSymbolContextList
Sourcepub fn evaluate_expression(
&self,
expression: &str,
options: &SBExpressionOptions,
) -> SBValue
pub fn evaluate_expression( &self, expression: &str, options: &SBExpressionOptions, ) -> SBValue
Evaluate an expression.
pub fn event_as_target_event(event: &SBEvent) -> Option<SBTargetEvent<'_>>
pub fn get_stack_red_zone_size(&self) -> lldb_addr_t
pub fn is_loaded(&self, module: &SBModule) -> bool
pub fn get_launch_info(&self) -> SBLaunchInfo
pub fn set_launch_info(&self, launch_info: SBLaunchInfo)
Sourcepub fn byte_order(&self) -> ByteOrder
pub fn byte_order(&self) -> ByteOrder
Returns the byte order of target
Sourcepub fn get_address_byte_size(&self) -> u32
pub fn get_address_byte_size(&self) -> u32
Returns the size of address in bytes