pub struct SBDebugger {
    pub raw: SBDebuggerRef,
}
Expand description

Creates SBTargets, provides access to them and manages the overall debugging experience.

Initialization and Teardown

LLDB must be initialized before the functionality is used. This is done with SBDebugger::initialize():

use lldb::SBDebugger;

SBDebugger::initialize();

Similarly, it must be terminated after you are done using it:

use lldb::SBDebugger;

SBDebugger::initialize();
// Use LLDB functionality ...
SBDebugger::terminate();

Once you’ve initialized LLDB, you’re ready to create an instance of SBDebugger:

use lldb::SBDebugger;

SBDebugger::initialize();

let debugger = SBDebugger::create(false);
// ... configure the debugger if needed ...
// ... create a target and do stuff ...

SBDebugger::terminate();

Configuration

Async Mode

While it is best to use LLDB in asynchronous mode, it does offer a synchronous mode, which can be easier to use for quick experiments or scripts.

In synchronous mode, calls to the LLDB API do not return until the underlying action has been completed. This means that the thread from which you call LLDB will be blocked during that time, so this is not an ideal way to use LLDB for building interactive tools or a new user interface.

In asynchronous mode, calls to the LLDB API will return immediately without waiting for the action to complete. This means that actions like launching a target, continuing the execution of a process and so on won’t be completed immediately and you must process events to see what the results of an action are.

Synchronous mode can be enabled by using SBDebugger::set_asynchronous() and passing it a false value. You can see if you’re in asynchronous mode or not by calling SBDebugger::asynchronous().

Platform Management

LLDB supports multiple platforms when debugging.

LLDB is aware of both available and active platforms. By default, the host platform is active for debugging processes on the local machine.

A number of additional platforms are available and can be activated via SBDebugger::set_current_platform().

The currently selected platform is controlled by SBDebugger::set_selected_platform() typically using instances of SBPlatform.

When doing remote debugging, additional confirmation and work is required. (See SBPlatform::connect_remote(). This is not yet wrapped in this library.)

See also:

Target Management

The SBDebugger instance tracks the various targets that are currently known to the debugger.

Typically, you create a target with SBDebugger::create_target(), SBDebugger::create_target_simple() or one of the related methods.

Sometimes, you’ll want to create a target without an associated executable. A common use case for this is to attach to a process by name or process ID where you don’t know the executable in advance. The most convenient way to do this is:

let debugger = SBDebugger::create(false);
if let Some(target) = debugger.create_target_simple("") {
    println!("Got a target: {:?}", target);
    // Now, maybe we'd like to attach to something.
}

You can iterate over these targets which have been created by using SBDebugger::targets():

// Iterate over the targets...
for target in debugger.targets() {
    println!("Hello {:?}!", target);
}
// Or collect them into a vector!
let targets = debugger.targets().collect::<Vec<SBTarget>>();

Fields

raw: SBDebuggerRef

The underlying raw SBDebuggerRef.

Implementations

Initialize LLDB.

This should be called before LLDB functionality is used.

Tear down LLDB.

This should be called once the application no longer needs to use LLDB functionality. Typically, this is called as the application exits.

Create a new instance of SBDebugger.

If source_init_files is true, then ~/.lldbinit will be processed.

Get whether or not the debugger is in asynchronous mode.

When in asynchronous mode, the debugger returns immediately when stepping or continuing without waiting for the process to change state.

Set the debugger to be in asynchronous mode or not.

When in asynchronous mode, the debugger returns immediately when stepping or continuing without waiting for the process to change state.

Enable logging (defaults to stderr).

enable_log("lldb", &["default"]) is useful for troubleshooting in most cases. Include "all" in categories for extra verbosity.

See invocations to lldb_private::Log::Register for more channels and categories.

Get the LLDB version string.

Create a target.

The executable name may be an empty string to create an empty target.

Create a target from just an executable name.

The executable name may be an empty string to create an empty target.

Using SBDebugger::create_target() is preferred in most cases as that provides access to an SBError to inform the caller about what might have gone wrong.

Get an iterator over the targets known to this debugger instance.

Get the default SBListener associated with the debugger.

Get the currently selected SBTarget.

Set the selected SBTarget.

Get an iterator over the currently active platforms.

By default, the host platform will be active. Additional platforms can be activated via SBDebugger::set_current_platform().

See also:

Set the selected SBPlatform.

Selecting a platform by name rather than an instance of SBPlatform can be done via SBDebugger::set_current_platform().

See also:

Get an iterator over the available platforms known to this debugger instance.

These correspond to the available platform plugins within LLDB. The platform name can be used with SBDebugger::set_current_platform() to activate and select it.

The structured data will have 2 string keys:

  • "name" - Name of the platform plugin.
  • "description" - The description of the platform plugin.

See also:

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.