public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug tdep/30010] New: [gdb/tdep, aarch64] Incorrect frame address for last insn (non-leaf case) Date: Tue, 17 Jan 2023 13:24:50 +0000 [thread overview] Message-ID: <bug-30010-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=30010 Bug ID: 30010 Summary: [gdb/tdep, aarch64] Incorrect frame address for last insn (non-leaf case) Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: tdep Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- [ Spinoff from PR29721. ] Consider the following test-case: ... $ cat test.c void foo (const char *s) { } int main (void) { foo ("foo"); return 0; } ... Compiled without debug info: ... $ gcc test.c ... Disassembly of main: ... 0000000000400578 <main>: 400578: a9bf7bfd stp x29, x30, [sp, #-16]! 40057c: 910003fd mov x29, sp 400580: 90000000 adrp x0, 400000 <_init-0x408> 400584: 91192000 add x0, x0, #0x648 400588: 97fffff7 bl 400564 <foo> 40058c: 52800000 mov w0, #0x0 // #0 400590: a8c17bfd ldp x29, x30, [sp], #16 400594: d65f03c0 ret ... Now, let's do "info frame" at each insn in main (so, using ni to skip over foo), as well as printing $sp and $fp: ... $ gdb a.out Reading symbols from a.out... (gdb) b *main Breakpoint 1 at 0x400578 (gdb) r Starting program: a.out Breakpoint 1, 0x0000000000400578 in main () (gdb) display /x $sp 1: /x $sp = 0xfffffffff3b0 (gdb) display /x $fp 2: /x $fp = 0xfffffffff3b0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x400578 in main; saved pc = 0xfffff7e5bfa0 Arglist at 0xfffffffff3b0, args: Locals at 0xfffffffff3b0, Previous frame's sp is 0xfffffffff3b0 (gdb) ni 0x000000000040057c in main () 1: /x $sp = 0xfffffffff3a0 2: /x $fp = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x40057c in main; saved pc = 0xfffff7e5bfa0 Arglist at 0xfffffffff3a0, args: Locals at 0xfffffffff3a0, Previous frame's sp is 0xfffffffff3b0 Saved registers: x29 at 0xfffffffff3a0, x30 at 0xfffffffff3a8 (gdb) ni 0x0000000000400580 in main () 1: /x $sp = 0xfffffffff3a0 2: /x $fp = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x400580 in main; saved pc = 0xfffff7e5bfa0 Arglist at 0xfffffffff3a0, args: Locals at 0xfffffffff3a0, Previous frame's sp is 0xfffffffff3b0 Saved registers: x29 at 0xfffffffff3a0, x30 at 0xfffffffff3a8 (gdb) ni 0x0000000000400584 in main () 1: /x $sp = 0xfffffffff3a0 2: /x $fp = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x400584 in main; saved pc = 0xfffff7e5bfa0 Arglist at 0xfffffffff3a0, args: Locals at 0xfffffffff3a0, Previous frame's sp is 0xfffffffff3b0 Saved registers: x29 at 0xfffffffff3a0, x30 at 0xfffffffff3a8 (gdb) ni 0x0000000000400588 in main () 1: /x $sp = 0xfffffffff3a0 2: /x $fp = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x400588 in main; saved pc = 0xfffff7e5bfa0 Arglist at 0xfffffffff3a0, args: Locals at 0xfffffffff3a0, Previous frame's sp is 0xfffffffff3b0 Saved registers: x29 at 0xfffffffff3a0, x30 at 0xfffffffff3a8 (gdb) ni 0x000000000040058c in main () 1: /x $sp = 0xfffffffff3a0 2: /x $fp = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x40058c in main; saved pc = 0xfffff7e5bfa0 Arglist at 0xfffffffff3a0, args: Locals at 0xfffffffff3a0, Previous frame's sp is 0xfffffffff3b0 Saved registers: x29 at 0xfffffffff3a0, x30 at 0xfffffffff3a8 (gdb) ni 0x0000000000400590 in main () 1: /x $sp = 0xfffffffff3a0 2: /x $fp = 0xfffffffff3a0 (gdb) info frame Stack level 0, frame at 0xfffffffff3b0: pc = 0x400590 in main; saved pc = 0xfffff7e5bfa0 Arglist at 0xfffffffff3a0, args: Locals at 0xfffffffff3a0, Previous frame's sp is 0xfffffffff3b0 Saved registers: x29 at 0xfffffffff3a0, x30 at 0xfffffffff3a8 (gdb) ni 0x0000000000400594 in main () 1: /x $sp = 0xfffffffff3b0 2: /x $fp = 0xfffffffff3b0 (gdb) info frame Stack level 0, frame at 0xfffffffff3c0: pc = 0x400594 in main; saved pc = 0x4004a4 Arglist at 0xfffffffff3b0, args: Locals at 0xfffffffff3b0, Previous frame's sp is 0xfffffffff3c0 Saved registers: x29 at 0xfffffffff3b0, x30 at 0xfffffffff3b8 (gdb) ni 0x0000fffff7e5bfa0 in __libc_start_main () from /lib64/libc.so.6 1: /x $sp = 0xfffffffff3b0 2: /x $fp = 0xfffffffff3b0 ... The "frame at" bit lists 0xfffffffff3b0 except at the last insn. The frame address is calculated here in aarch64_make_prologue_cache_1: ... unwound_fp = get_frame_register_unsigned (this_frame, cache->framereg); if (unwound_fp == 0) return; cache->prev_sp = unwound_fp + cache->framesize; ... For insns after the prologue, we have cache->framereg == fp and cache->framesize == 16, so unwound_fp + cache->framesize gives the wrong answer once fp has been restored to entry value by the before-last insn. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2023-01-17 13:24 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-17 13:24 vries at gcc dot gnu.org [this message] 2023-01-19 11:13 ` [Bug tdep/30010] " vries at gcc dot gnu.org 2023-01-23 15:49 ` cvs-commit at gcc dot gnu.org 2023-01-23 15:53 ` vries at gcc dot gnu.org
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=bug-30010-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).