I have the following project:
// main.rs
mod other;
#[derive(Debug)]
pub(crate) struct MainStruct {
number: usize,
}
pub(crate) static MY_MAIN: MainStruct = MainStruct { number: 123 };
fn main() {
loop {
::std::thread::sleep_ms(1000);
println!("{:?} {:?}", MY_MAIN, other::MY_STATIC);
}
}
// other.rs
#[derive(Debug)]
pub(crate) struct MyStruct {
number: usize,
}
pub(crate) static MY_STATIC: MyStruct = MyStruct { number: 1337 };
I run the program, and connect to it with gdb -p (PID)
. I want to print out the statics:
(gdb) p gdb_test<TAB>
gdb_test gdb_test::main gdb_test::other::MyStruct
gdb_test::MY_MAIN gdb_test::other gdb_test::other::{{impl}}
gdb_test::MainStruct gdb_test::other::MY_STATIC gdb_test::{{impl}}
(gdb) p gdb_test::MY_MAIN
$1 = {number = 123}
(gdb) p gdb_test::other::MY_STATIC
No type "other" within class or namespace "gdb_test".
That is, I'm unable to print out statics that are not in the top level.
The version of gdb
I'm running is
~/t/gdb-test> gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Running rust-gdb
does not help.
I'm sure I've been able to do this previously (a few months ago).