Crate gdb_command[][src]

Expand description


gdb-command is a library providing API for manipulating gdb in batch mode. It supports:

  • Execution of target program (Local type).
  • Opening core of target program (Core type).
  • Attaching to remote process (Remote type).


use std::process::Command;
use std::thread;
use std::time::Duration;
use gdb_command::*;

fn main () -> error::Result<()> {
    // Get stacktrace from running program (stopped at crash)
    let result = GdbCommand::new(&ExecType::Local(&["tests/bins/test_abort", "A"])).bt().run()?;

    // Get stacktrace from core
    let result = GdbCommand::new(
            &ExecType::Core {target: "tests/bins/test_canary",
                core: "tests/bins/core.test_canary"})

    // Get info from remote attach to process
    let mut child = Command::new("tests/bins/test_callstack_remote")
       .expect("failed to execute child");


    // To run this test: echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
    let result = GdbCommand::new(&ExecType::Remote(&



A custom GdbCommand error


FrameDebug struct represents the debug information of one frame in stack trace.

File struct represents unit (segment) in proccess address space.

Struct contains information about arguments for gdb to run.

MappedFiles all mapped files in proccess.

Struct represents the information about stack trace

StacktraceEntry struct represents the information about one line of the stacktrace.


Type of gdb execution: Remote attach to process, local run with args, core.

‘ModuleInfo’ enum represents the name of the module or contains information about the module.