* [PATCH] gdb/aarch64: fix stack unwinding in aarch64_scan_prologue's fallback path
@ 2026-11-23 18:43 tony.v6gh5
0 siblings, 0 replies; only message in thread
From: tony.v6gh5 @ 2026-11-23 18:43 UTC (permalink / raw)
To: gdb-patches
From 654c4c35a331c9222a0ff590318abe0ae9c46433 Mon Sep 17 00:00:00 2001
From: Tony Wasserka <tony.v6gh5@8shield.net>
Date: Mon, 23 Nov 2026 18:08:52 +0100
Subject: [PATCH] gdb/aarch64: fix stack unwinding in aarch64_scan_prologue's
fallback path
gdb failed to produce correct backtraces for programs that have no unwind
tables. Such metadata is often missing in code generated by JIT binary
recompilers, for example.
The underlying issue was that offsets to the previous frame's FP/LR values are
relative to FP+framesize rather than the current FP. Shifting them by the
frame size resolves the problem.
For example, a simple main->outer->middle->inner backtrace may look like this:
Before this patch:
#0 0x0000aaaaaaaa082c in inner ()
#1 0x0000aaaaaaaa0868 in outer ()
#2 0x0000fffff7df6f74 in __libc_start_call_main ()
#3 0xcc2b86b0ca7be000 in ?? ()
After this patch:
#0 0x0000aaaaaaaa082c in inner ()
#1 0x0000aaaaaaaa0848 in middle ()
#2 0x0000aaaaaaaa0868 in outer ()
#3 0x0000aaaaaaaa0888 in main ()
I couldn't run the testsuite since it fails locally on aarch64 NixOS even with
vanilla gdb.
---
gdb/aarch64-tdep.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 9f40cb8f83..234365c750 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1056,8 +1056,8 @@ aarch64_scan_prologue (const frame_info_ptr &this_frame,
cache->framereg = AARCH64_FP_REGNUM;
cache->framesize = 16;
- cache->saved_regs[29].set_addr (0);
- cache->saved_regs[30].set_addr (8);
+ cache->saved_regs[29].set_addr (-16);
+ cache->saved_regs[30].set_addr (-8);
}
}
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 18:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 18:43 [PATCH] gdb/aarch64: fix stack unwinding in aarch64_scan_prologue's fallback path tony.v6gh5
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox