I'm working on proprietary software, so don't want to leak source code. It's a shared library (a .so) so I don't want to have a crash reporting tool built-in, that's too intrusive given it's running in someone else's application.
But, I do want Rust backtraces (and stacktraces from gdb) to have line numbers, so I can debug bug reports more easily.
There's the debug
option in Cargo.toml's profile. If I set it to 0, I get function names but not line numbers:
stack backtrace:
0: rust_begin_unwind
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
2: stacktraces_in_rust::panics
3: stacktraces_in_rust::main
If I do debug = 1
, I get line numbers:
stack backtrace:
0: rust_begin_unwind
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
2: stacktraces_in_rust::panics
at ./src/main.rs:13:5
3: stacktraces_in_rust::main
at ./src/main.rs:5:9
4: core::ops::function::FnOnce::call_once
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
The problem is that with debug = 1
my proprietary source code is embedded in the resulting file, which I don't want.
So how can I do this? First thought was debug = 1
and stripping out source code, but so far I've failed to figure out how to strip source code while still allowing informative backtraces.