You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
I recently added some additional benchmarks to my library including one that didn't converge. I built debug binaries with cargo build --benches, which outputs:
However, when I run gdb target/debug/bench-12ca78b61d26ae10 and try to list or bt I find that the debug symbols for my benchmark code (the code I've written for benchmarks) seem to be missing or corrupted. A backtrace shows function names but no files or line numbers for my code, but it does information for some of the bencher library code. Using list in a stack frame for my own code will give an error about not being able to find a libcore file instead.
(gdb) run
Starting program: rkm/target/debug/bench-12ca78b61d26ae10
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
running 4 tests
test bench_birch3 ... ^C
Program received signal SIGINT, Interrupt.
0x000055555556df70 in core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once ()
(gdb) bt
#0 0x000055555556df70 in core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once ()
#1 0x000055555556b725 in <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter ()
#2 0x000055555556d183 in rkm::kmeans_lloyd ()
#3 0x0000555555568b68 in bencher::Bencher::iter ()
#4 0x000055555556a043 in bench::bench_birch3 ()
#5 0x0000555555577b40 in bencher::run_test::{{closure}} (
harness=0x7fffffffc390)
at /home/nick/.cargo/registry/src/github.com-1ecc6299db9ec823/bencher-0.1.5/lib.rs:571
#6 0x0000555555578f05 in bencher::Bencher::auto_bench::{{closure}} (
x=0x7fffffffc390)
at /home/nick/.cargo/registry/src/github.com-1ecc6299db9ec823/bencher-0.1.5/lib.rs:661
#7 0x0000555555577d5c in bencher::Bencher::bench_n (self=0x7fffffffc390, n=1,
f=...)
at /home/nick/.cargo/registry/src/github.com-1ecc6299db9ec823/bencher-0.1.5/lib.rs:628
#8 0x000055555557897b in bencher::Bencher::auto_bench (self=0x7fffffffc390,
f=...)
at /home/nick/.cargo/registry/src/github.com-1ecc6299db9ec823/bencher-0.1.5/lib.rs:661
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) frame 2
#2 0x000055555556d183 in rkm::kmeans_lloyd ()
(gdb) list
1 libcore/str/mod.rs: No such file or directory.
(gdb)
Steps
The code I'm trying to debug is in the NewBenchmarks branch of my rkm repo, but my impression is that any benchmark code can be used to reproduce this.
Compile a benchmark with cargo build --benches or cargo build --bench
Debug the resulting binary under gdb/rust-gdb with rust-gdb target/debug/bench-################
Possible Solution(s)
One way I've found (after a couple of days of being stumped) is to set RUSTFLAGS to -C debuginfo=2, e.g.
RUSTFLAGS="-C debuginfo=2" cargo build --benches
This produces binaries with the correct debug information.
Notes
Output of cargo version:
cargo 1.30.0 (36d96825d 2018-10-24)
rustc version:
rustc 1.30.0 (da5f414c2 2018-10-24)
Platform is Antergos Linux 4.17 x86_64
This seems to be related to #4240, but I thought I'd create a new bug since my issue is with a different cargo command.
The text was updated successfully, but these errors were encountered:
Yea, it's a bit confusing because build --bench builds with the "bench" profile (which does not have debug) but places it in the "debug" directory. There are a few issues related to this: #4240, #5575, #4929.
I think the best course is to have build --bench xxx use the "test" profile, and build --bench xxx --release to use the "bench" profile.
As a temporary workaround, you can edit [profile.bench] in your Cargo.toml to enable debug, and possibly lower opt-level.
Use "test" profile for `cargo build` benchmarks.
When using `cargo build` (without `--release`), build benchmarks using the "test" profile. This was causing some confusion where the benchmark is placed in the `target/debug` directory, and also causing some duplicates that may not be expected. It also makes it easier to debug benchmarks (previously you had to edit the `[profile.bench]` profile).
Closes#5575, closes#6301, closes#4240, closes#4929.
Problem
I recently added some additional benchmarks to my library including one that didn't converge. I built debug binaries with cargo build --benches, which outputs:
However, when I run
gdb target/debug/bench-12ca78b61d26ae10
and try tolist
orbt
I find that the debug symbols for my benchmark code (the code I've written for benchmarks) seem to be missing or corrupted. A backtrace shows function names but no files or line numbers for my code, but it does information for some of the bencher library code. Usinglist
in a stack frame for my own code will give an error about not being able to find a libcore file instead.Steps
The code I'm trying to debug is in the
NewBenchmarks
branch of my rkm repo, but my impression is that any benchmark code can be used to reproduce this.cargo build --benches
orcargo build --bench
rust-gdb target/debug/bench-################
Possible Solution(s)
One way I've found (after a couple of days of being stumped) is to set
RUSTFLAGS
to-C debuginfo=2
, e.g.This produces binaries with the correct debug information.
Notes
Output of
cargo version
:rustc version
:Platform is Antergos Linux 4.17 x86_64
This seems to be related to #4240, but I thought I'd create a new bug since my issue is with a different cargo command.
The text was updated successfully, but these errors were encountered: