From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1ABF53858D38; Tue, 24 Jan 2023 00:14:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1ABF53858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674519260; bh=3X3UEUQoxfpaQdKKN0WmzXGC9Zcm88d5DbfwxXKdB7g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=viywQe5v6oONjBMvIX1HKLBDVJ68AhtSIMaTb+axbQcwQjEhUDf+Vd0pgReDZ8n9B nTb7BePWMPgyH37G51e87wdeGsv4M/6n0BlqSAmkzXuW0DkCK1OxmNj6Oqhb9F+aEi B+iYFEDP6LX+nHarvoBkiCTNZFZezjCFKPtWq91c= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug tdep/30021] [gdb/tdep, powerpc64le] previous frame inner to this frame (corrupt stack?) Date: Tue, 24 Jan 2023 00:14:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: tdep X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30021 --- Comment #4 from Tom de Vries --- (In reply to Tom de Vries from comment #3) > I analyzed this down to rs6000_epilogue_frame_prev_register giving the wr= ong > value for r31 at that insn. >=20 > 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 =3D > rs6000_epilogue_frame_cache (this_frame, this_cache); > + if (regnum =3D=3D 31) > + /* In foo, we get rs6000_in_function_epilogue_frame_p =3D=3D 1 start= ing > + the insn at 0x100006ec. > + 00000000100006dc : > + 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 val= ue. > + Workaround this by getting r1 instead. */ > + regnum =3D 1; > return trad_frame_get_prev_register (this_frame, info->saved_regs, > regnum); > } >=20=20 > ... >=20 Testing when fine, but I think this approach is too rough. I found that r31 is mostly used for frame pointer, but on darwin r30 is used instead, so we just can't make the assumption that r1 will have the value of r31. --=20 You are receiving this mail because: You are on the CC list for the bug.=