From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B24353858C50; Mon, 23 Jan 2023 15:38:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B24353858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674488280; bh=7I/Z3au20Qoyeqj/31YgJsnTxlE0RMrscA485IfV1HE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZtKaZ9Ajcchn+CVNboyvJoldwE/MrHb3IuFueKPIq8NBLHcfGYVCTWZdsh/3V/IU1 8NM3FYNsqOOi/CpRJTZfwDeg2GsiH9SO9QdduXde7vpPU/CBSkqdqt1y+jf/E0XKJT r0+/dkISvt6TGemQJWBSyQCat2QeAOy80+JpNJCI= 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: Mon, 23 Jan 2023 15:38:00 +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 #3 from Tom de Vries --- 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 =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 starting + 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 value. + Workaround this by getting r1 instead. */ + regnum =3D 1; return trad_frame_get_prev_register (this_frame, info->saved_regs, regnu= m); } ... 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 =3D 0x7fffffffec80 2: /x $r31 =3D 0x7fffffffec80 +info frame Stack level 0, frame at 0x7fffffffecb0: pc =3D 0x100006e8 in foo; saved pc =3D 0x100006b0 called by frame at 0x7fffffffed20 Arglist at 0x7fffffffec80, args:=20 Locals at 0x7fffffffec80, Previous frame's sp is 0x7fffffffecb0 Saved registers: r31 at 0x7fffffffeca8 +si 0x00000000100006ec in foo () 1: /x $r1 =3D 0x7fffffffecb0 2: /x $r31 =3D 0x7fffffffec80 +info frame Stack level 0, frame at 0x7fffffffecb0: pc =3D 0x100006ec in foo; saved pc =3D 0x100006b0 called by frame at 0x7fffffffed20 Arglist at 0x7fffffffec80, args:=20 Locals at 0x7fffffffec80, Previous frame's sp in r1 +si 0x00000000100006f0 in foo () 1: /x $r1 =3D 0x7fffffffecb0 2: /x $r31 =3D 0x7fffffffecb0 +info frame Stack level 0, frame at 0x7fffffffecb0: pc =3D 0x100006f0 in foo; saved pc =3D 0x100006b0 called by frame at 0x7fffffffed20 Arglist at 0x7fffffffecb0, args:=20 Locals at 0x7fffffffecb0, Previous frame's sp in r1 ... --=20 You are receiving this mail because: You are on the CC list for the bug.=