public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* GDB Stacktrace for optimized code!
@ 2021-04-20  5:55 Thamil K
  2021-04-20 10:54 ` Hannes Domani
  0 siblings, 1 reply; 2+ messages in thread
From: Thamil K @ 2021-04-20  5:55 UTC (permalink / raw)
  To: gdb

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.

Thanks
Thamil

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GDB Stacktrace for optimized code!
  2021-04-20  5:55 GDB Stacktrace for optimized code! Thamil K
@ 2021-04-20 10:54 ` Hannes Domani
  0 siblings, 0 replies; 2+ messages in thread
From: Hannes Domani @ 2021-04-20 10:54 UTC (permalink / raw)
  To: gdb, Thamil K

 Am Dienstag, 20. April 2021, 07:55:39 MESZ hat Thamil K via Gdb <gdb@sourceware.org> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-20 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  5:55 GDB Stacktrace for optimized code! Thamil K
2021-04-20 10:54 ` Hannes Domani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).