Cargo test under gdb

  1. I know how to run individual tests via:
cargo test blahblah::test_00
  1. However, I want to run the test under gdb. I can do this via:
gdb target-dir/...../crate-name blahblah::test_00
  1. Getting the target-dir/crate-name is not always easy (for some reason, there are multiple builds). Is there some way to tell cargo to directly run the binary under gdb?


The test executable path is printed when you run the test via Cargo. The path is relatively stable, so that you can do cargo build && gdb <that executable>.

1 Like
  1. I see the name after "Running" in cargo test.

  2. Is there a way to get "cargo build" to dump the name? I'd prefer to setup some regex/script instead of hand copying.