GDB Annoyances: Incomplete Stack Trace
Users of WinDbg debugger accustomed to full thread stack traces will wonder whether a thread starts from main:
(gdb) where
#0 0x000000010d3b0e90 in bar () at main.c:15
#1 0x000000010d3b0ea9 in foo () at main.c:20
#2 0x000000010d3b0ec4 in main (argc=1,
argv=0x7fff6cfafbf8) at main.c:25
Of course, not and by default a stack trace is shown starting from main function. You can change this behavior by using the following command:
(gdb) set backtrace past-main
Now we see an additional frame:
(gdb) where
#0 0x000000010d3b0e90 in bar () at main.c:15
#1 0x000000010d3b0ea9 in foo () at main.c:20
#2 0x000000010d3b0ec4 in main (argc=1,
argv=0x7fff6cfafbf8) at main.c:25
#3 0×000000010d3b0e74 in start ()
- Dmitry Vostokov @ DumpAnalysis.org + TraceAnalysis.org -
Forthcoming Training: Accelerated Mac OS X Core Dump Analysis
December 18th, 2015 at 8:43 pm
For Linux we have:
(gdb) set backtrace past-main
(gdb) bt
#0 0×000000000042fed1 in nanosleep ()
#1 0×000000000042fda0 in sleep ()
#2 0×000000000040078a in main ()
#3 0×0000000000405283 in __libc_start_main ()
#4 0×00000000004003e9 in _start ()