Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: tony.v6gh5@8shield.net
To: gdb-patches@sourceware.org
Subject: gdb/aarch64: fix stack unwinding in aarch64_scan_prologue's fallback path
Date: Mon, 23 Nov 2026 17:37:06 +0000	[thread overview]
Message-ID: <179545543471.7.12959301038376216540.1797343602@8shield.net> (raw)

 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 ()
---
  gdb/aarch64-tdep.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git < gdb/aarch64-tdep.c > gdb/aarch64-tdep.c
index 9f40cb8f83..234365c750 100644
--- < gdb/aarch64-tdep.c	
+++ > 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





                 reply	other threads:[~2026-11-23 17:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179545543471.7.12959301038376216540.1797343602@8shield.net \
    --to=tony.v6gh5@8shield.net \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox