“Basically, rust-gdb is a wrapper that loads external Python pretty-printing scripts into GDB. This is useful (and somewhat necessary) when debugging more complex Rust programs because it significantly improves the display of Rust data types.” (src)

what the developer has to do:

hostnamectl; # tested on
   Static hostname: lenovo
  Operating System: Debian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.0-17-amd64
      Architecture: x86-64

# as non-root user
# install rust (will be installed per-user, not system-wide)
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
# reload the shell to find the paths to rustc
su - non-root-user
# or restart shell
# test that paths are working
rustc --version
rustc 1.53.0 (53cb7b09b 2021-06-17)

# create new project with cargo
cargo new helloworld
cd ./helloworld/src
cargo build
 Finished dev [unoptimized + debuginfo] target(s) in 0.00s
cargo run
 Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `/home/devrust2/helloworld/target/debug/helloworld`
Hello, world!

vim main.rs
# within vim
:packadd termdebug
:let termdebugger="rust-gdb"

# now this should show up

congrats! ready to debug 🙂

within gdb:

# load the compiled binary with symbols

file ../target/debug/helloworld
# then the developer is ready to start

# hurray! :) step debugging works :)

video with music:


related Links:

creditz go to: https://alpha2phi.medium.com/setting-up-neovim-for-rust-debugging-termdebug-and-vimspector-df749e1ba47c

RUST – most loved programming language ever – C++ with safety – new programming language from Mozilla for Mozilla and Safety – now also with step debugging

stay updated: https://this-week-in-rust.org/rss.xml


GDB Cheat Sheet.pdf

PS: Conque-GDB vim plugin can (probably) enable rust and c++ setp debugging in vim prior to v.8.1 too, but it was not updated since 2016 and throws errors.