O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

GDB - basics

Let's start from the command line. A binary that we'll debug needs specific additional instrumentation that the tools latch on to. This instrumentation gives us essential runtime information such as the ability to match the source code to the running binary code, and so on. Running the debugger is possible against a release build too, but the selection of operations is very much limited. As you've seen several times before, the binaries Cargo and rustc builds for us by default reside in the target/debug/ directory. So, that is covered for us already.

Rust comes with wrappers for both debuggers: rust-gdb and rust-lldb. Here's how to get to GDB's prompt after building the project:

GDB now obediently awaits our commands. For a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required