We have a C++ program such as:
int&
Instance()
{
static int test;
return test;
}
int
main( int argc, char ** argv )
{
int& test = Instance();
printf("%d\n",test);
return 0;
}
Now I'm trying to print Instance::test, as suggested by some gdb documentation: ftp://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_52.html
However, this yields:
(gdb) p Instance::test
No symbol "test" in specified context.
I'm compiling with -O0 -g .
(gdb) p 'Instance()::test'
works for me on Ubuntu 14.04, gdb 7.7, g++ 4.8.2 . How did I know that was the symbol?
$ nm -C a.out | grep test
0000000000601040 d Instance()::test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With