Crate gdb_command
source ·Expand description
§gdb-command
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).
§Example
use std::process::Command;
use std::thread;
use std::time::Duration;
use gdb_command::*;
fn main () -> error::Result<()> {
// Get stack trace from running program (stopped at crash)
let result = GdbCommand::new(&ExecType::Local(&["tests/bins/test_abort", "A"])).r().bt().launch()?;
// Get stack trace from core
let result = GdbCommand::new(
&ExecType::Core {target: "tests/bins/test_canary",
core: "tests/bins/core.test_canary"})
.bt().launch()?;
// Get info from remote attach to process
let mut child = Command::new("tests/bins/test_callstack_remote")
.spawn()
.expect("failed to execute child");
thread::sleep(Duration::from_millis(10));
// To run this test: echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
let result = GdbCommand::new(&ExecType::Remote(&child.id().to_string()))
.bt()
.regs()
.disassembly()
.launch();
child.kill().unwrap();
Ok(())
}
Modules§
- A custom GdbCommand error.
- The
MappedFiles
struct holds information about all mapped files in process. - The
MemoryObject
represents raw data in memory. - The
Registers
is a map from register name to it’s value. - The
Siginfo
is the struct for Linux signals. - The
Stacktrace
struct represents gathered stacktrace.
Structs§
- Struct contains information about arguments for
gdb
to run.
Enums§
- Type of
gdb
execution: Remote attach to process, local run with args, core.