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/30021] [gdb/tdep, powerpc64le] previous frame inner to this frame (corrupt stack?) Date: Mon, 23 Jan 2023 15:38:00 +0000 [thread overview] Message-ID: <bug-30021-4717-jXVYxHB48m@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-30021-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=30021 --- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> --- I analyzed this down to rs6000_epilogue_frame_prev_register giving the wrong value for r31 at that insn. This fix (or workaround?) make the test-case pass: ... diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 592b447..45b4454 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -3852,6 +3852,20 @@ struct rs6000_frame_cache { struct rs6000_frame_cache *info = rs6000_epilogue_frame_cache (this_frame, this_cache); + if (regnum == 31) + /* In foo, we get rs6000_in_function_epilogue_frame_p == 1 starting + the insn at 0x100006ec. + 00000000100006dc <foo>: + 100006dc: f8 ff e1 fb std r31,-8(r1) + 100006e0: d1 ff 21 f8 stdu r1,-48(r1) + 100006e4: 78 0b 3f 7c mr r31,r1 + 100006e8: 30 00 3f 38 addi r1,r31,48 + 100006ec: f8 ff e1 eb ld r31,-8(r1) + 100006f0: 20 00 80 4e blr + However, r31 is only restored after executing that insn, so asking for + r31 at 0x100006ec will just read the reg and return the wrong value. + Workaround this by getting r1 instead. */ + regnum = 1; return trad_frame_get_prev_register (this_frame, info->saved_regs, regnum); } ... Using the patch, we have instead: ... +b *foo + 12 Breakpoint 1 at 0x100006e8 +display /x $r1 +display /x $r31 +run Breakpoint 1, 0x00000000100006e8 in foo () 1: /x $r1 = 0x7fffffffec80 2: /x $r31 = 0x7fffffffec80 +info frame Stack level 0, frame at 0x7fffffffecb0: pc = 0x100006e8 in foo; saved pc = 0x100006b0 called by frame at 0x7fffffffed20 Arglist at 0x7fffffffec80, args: Locals at 0x7fffffffec80, Previous frame's sp is 0x7fffffffecb0 Saved registers: r31 at 0x7fffffffeca8 +si 0x00000000100006ec in foo () 1: /x $r1 = 0x7fffffffecb0 2: /x $r31 = 0x7fffffffec80 +info frame Stack level 0, frame at 0x7fffffffecb0: pc = 0x100006ec in foo; saved pc = 0x100006b0 called by frame at 0x7fffffffed20 Arglist at 0x7fffffffec80, args: Locals at 0x7fffffffec80, Previous frame's sp in r1 +si 0x00000000100006f0 in foo () 1: /x $r1 = 0x7fffffffecb0 2: /x $r31 = 0x7fffffffecb0 +info frame Stack level 0, frame at 0x7fffffffecb0: pc = 0x100006f0 in foo; saved pc = 0x100006b0 called by frame at 0x7fffffffed20 Arglist at 0x7fffffffecb0, args: Locals at 0x7fffffffecb0, Previous frame's sp in r1 ... -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2023-01-23 15:38 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-18 16:01 [Bug tdep/30021] New: " vries at gcc dot gnu.org 2023-01-19 11:14 ` [Bug tdep/30021] " vries at gcc dot gnu.org 2023-01-23 15:33 ` vries at gcc dot gnu.org 2023-01-23 15:38 ` vries at gcc dot gnu.org [this message] 2023-01-24 0:14 ` vries at gcc dot gnu.org 2023-01-24 10:46 ` vries at gcc dot gnu.org 2023-01-24 11:46 ` vries at gcc dot gnu.org 2023-01-25 12:27 ` cvs-commit at gcc dot gnu.org 2023-01-26 16:12 ` cel at us dot ibm.com 2023-01-26 16:14 ` cel at us dot ibm.com 2023-01-26 16:16 ` 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-30021-4717-jXVYxHB48m@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).