Unwind the stack even if GDB can’t? (ARM)

Reason
Since GCC 5.0 for ARM the default used ABI is AAPCS (Procedure Call Standard for the Arm 64-bit Architecture). With AAPCS the stack unwinding works based on unwind tables. The GDB won’t provide a backtrace if these tables are missing in the binaries (GCC build flag: ‘-fno-asynchronous-unwind-tables’).

Alternative: The stack is really corrupted. Then the following solution will maby also not help.


Possible Solution
The following strategy tries to unwind the stack with an user-defined command based on the hope that GCC created the stack frames in the common structure even if not forced by AAPCS itself 1.

(gdb) define stackwalker
  set $a = $arg0
  while $a < *(long*) $a
    x/2a $a
    set $a = *(long*) $a
  end
end
(gdb) stackwalker $fp

1 “It may elect not to maintain a frame chain and to use the frame pointer register as a general-purpose callee-saved register.” (Link, Spec on GitHub, Tag: 2022Q3)


Drawback
This simple solution doesn’t provide the possibility to switch between frames (‘(gdb) frame <idx>’).