working of backtrace command in GDB

Simon Marchi
Wed Jan 25 16:53:55 GMT 2023

On 1/24/23 23:49, Varun Kumar Erigila wrote:
> Hello Everyone,
>               I'm trying to figure out whether gdb makes use of CFI information for "backtrace command."
>               In case of watchpoints, gdb tries to figure out whether the frame containing the variable on which watchpoint is set is still present by going through all the frames in stack. (it calls execute_cfa_program function to figure this out).
>               But in the case of the backtrace command it does not call the execute_cfa_program to unwind all the frames.
>               Is there another mechanism gdb uses to unwind the stack frames apart from CFI information.


If a frame's PC falls within a region described by DWARF debug info
(.debug_frame), then GDB will typically use it.  But if it doesn't, for
instance if the frame is in a library for which you don't have debug
info, then GDB will revert to its architecture-specific unwinders, which
tries to unwind the frame using some knowledge of the architecture's
ABI, or by analyzing the code.

Here's the fallback unwinder for the AArch64 architecture, for instance:


More information about the Gdb mailing list