Why can't gdb display a non-binary non-symbolic stack trace?

Just curious: when I load the kernel file into gdb, the backtraces look like this:

...

Thread 2 (Thread 1109):
#0  0x2b03d968 in ?? ()

Thread 1 (Thread 23490):
#0  0x2b0c3624 in ?? ()
(gdb) 

      

But after I downloaded the binary using "file", I get this:

...

#0  __pthread_cond_wait (cond=0x46b810, mutex=0x46b7f0) at pthread_cond_wait.c:156
#1  0x004076a8 in main (argc=1, argv=0x7fa66784) at idpoint.c:258
...

#0  0x2b0c3624 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:67
#1  0x2b0c8464 in *__GI_abort () at abort.c:88
#2  0x2b0faeec in __libc_message (do_abort=2, fmt=0x2b1d0840 "*** glibc detected *** %s: %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:173
#3  0x2b107e3c in malloc_printerr (action=3, str=0x2b1d0930 "free(): invalid next size (fast)", ptr=<value optimized out>) at malloc.c:5994
...

      

Question: Why doesn't gdb even try to display the call stack before symbols are loaded? My guess is that it doesn't know where the segments fit into memory and cannot know what stack data to interpret as data versus addresses? Is it correct?

It would be nice if gdb: s could be a better attempt at displaying the call stack without symbols to get an idea of ​​stack depths or for later interpretation ...

+3


source to share


1 answer


Because the binary contains symbolic information (debug symbols) that allow the debugger to understand, for example, how big the stack structure is for each function [at any point in time in the function!]. This information is not loaded into memory when the code is run, so there is no way to be in a file core

.



You can of course use x/200 $esp

(or whatever the stack pointer is - I'm assuming x86 - if it's ARM then it's called $R15

from memory). Unfortunately, without access to symbols, gdb

it will not know what is on the stack and will be able to simply provide the original stack dump, which in most cases will be even less useful than not showing anything showing a load of random data (and most stack will be - especially if frame pointers are off - with frame pointers you have a chance of expanding the stack) is almost useless most of the time.

+3


source







All Articles