Closed
Description
Repro
-
cargo new --bin static
-
cd static
-
add the following code to
main.rs
:#[no_mangle] pub static TEST: u64 = 0xdeadbeef; pub fn main() { println!("TEST: {}", TEST); }
-
cargo build
-
gdb target/debug/static
-
break static::main
-
r
-
whatis TEST
-
output:
type = <data variable, no debug info>
-
frown
When TEST
is a repr(C)
struct, etc., this makes debugging extraordinarily difficult and laborious.
Actual Use Case
I'm implementing the gdb debugger interface specified in /usr/include/link.h
, which requires a single symbol, _r_debug
to be present in the _DYNAMIC
array.
(The symbol is actually not exported either, roughly GLOBAL and in the _DYNAMIC
array, which I get around by using a --dynamic-list
flag to the linker.)
I don't get around the lack of debug symbols at all, which vexes me.