gdb_probe.rs
You love ipdb.set_trace()
in python or binding.pry
in ruby? You are sad that rust doesn’t offer the same comfort?
gdb_probe.rs is here to safe the day! With a simple call, it suspends the current process, spawns a new terminal and
attaches gdb. This has many advantages:
- Comfortable debugging. If you program in an IDE with limited debugger support, you get a much simpler debugging story than manually using gdb.
- Fast conditional breakpoints. Real conditional breakpoints are slow as molasses. Doing
if cond {gdb_probe();}
is very fast. - No more stdout mess. If you debug a program with output on stdout, the debugger outputs doesn’t fight the programs output.
How to use
add "gdb_probe="0.1"
to your Cargo.toml
extern crate gdb_probe;
use gdb_probe::gdb_probe;
fn main() {
println!("Hello, world!");
let x = 3+4;
gdb_probe(); //spawns a new terminal (urxvt) with gdb attached at this position.
}
Known Caveats
Warning If the target process dies before the debugger can attach, sometimes init is debugged instead. In that case forcefully terminating the debugger causes a reboot.
Depends on urxvt as a terminal.