Re: GDB Stacktrace for optimized code!

Hannes Domani via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
 Am Dienstag, 20. April 2021, 07:55:39 MESZ hat Thamil K via Gdb <[email protected]> Folgendes geschrieben:

> Hi Geeks,
>
> For programs compiled with -O2, where the compiler uses 'jmp' where
> possible instead of 'call' or where callee doesn't push $rbp onto the
> stack, gdb is still able to generate stack trace properly.  But by
> inspecting the $rbp and return address, I am unable to trace back the
> calls. I would like to know how gdb synthesises the stack trace ?  Any
> pointers on documentation?  Thanks in advance.

For tail call optimization ('call' optimized to 'jmp'), see [1].
For for frame pointer omission ($rbp) I couldn't find documentation in gdb, but this blog [2] has some explanations.

[1] https://sourceware.org/gdb/download/onlinedocs/gdb/Tail-Call-Frames.html
[2] https://yosefk.com/blog/getting-the-call-stack-without-a-frame-pointer.html


Hannes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.