I read golang official gdb document here https://golang.org/doc/gdb
And I'm curious about what causes question mark when inspecting the stack.
(gdb) bt # backtrace
#0 regexp.TestFind (t=0xf8404a89c0) at /home/user/go/src/regexp/find_test.go:148
#1 0x000000000042f60b in testing.tRunner (t=0xf8404a89c0, test=0x573720) at /home/user/go/src/testing/testing.go:156
#2 0x000000000040df64 in runtime.initdone () at /home/user/go/src/runtime/proc.c:242
#3 0x000000f8404a89c0 in ?? ()
#4 0x0000000000573720 in ?? ()
#5 0x0000000000000000 in ?? ()
So, Is the gdb optimizations caused the question mark? Or what on earth result in such question mark?
One more question, How can I retrieve the message hiden behind question mark?
The code, probably, has stripped debugging symbols:
gcc -s
You can see that behavior with this simple sample
#include <stdio.h>
void riskyCode() {
char *error_str = "This code will fail with SIGSEGV";
*error_str = 'g';
}
int c() {
riskyCode();
return 1;
}
int b() {
return c();
}
int a() {
return b();
}
int main() {
return a();
}
Compile it like this
gcc -s -O0 -o main main.c
And run code in gdb
gdb main
> run
Then, you will see ?? in stack locations
bt
#0 0x000000000040056a in ?? ()
#1 0x000000000040057d in ?? ()
#2 0x0000000000400592 in ?? ()
#3 0x00000000004005a2 in ?? ()
#4 0x00000000004005b2 in ?? ()
#5 0x00002aaaaacebc36 in __libc_start_main () from /lib64/libc.so.6
#6 0x0000000000400429 in ?? ()
#7 0x00007fffffff93f8 in ?? ()
#8 0x000000000000001c in ?? ()
#9 0x0000000000000001 in ?? ()
#10 0x00007fffffff9ca2 in ?? ()
#11 0x0000000000000000 in ?? ()
Try to use very same library, but compiled with debugging symbols?