From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id BAAD23858407; Thu, 4 Aug 2022 13:23:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAAD23858407 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/tdep] Fix gdb.base/large-frame.exp for aarch64 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: b82817674f46e4f08a5910719499ddc72399473f X-Git-Newrev: 60adf22c1440723435262b9d867ebd76300c3325 Message-Id: <20220804132339.BAAD23858407@sourceware.org> Date: Thu, 4 Aug 2022 13:23:39 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2022 13:23:39 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D60adf22c1440= 723435262b9d867ebd76300c3325 commit 60adf22c1440723435262b9d867ebd76300c3325 Author: Tom de Vries Date: Thu Aug 4 15:23:34 2022 +0200 [gdb/tdep] Fix gdb.base/large-frame.exp for aarch64 =20 On aarch64, I run into: ... FAIL: gdb.base/large-frame.exp: optimize=3D-O0: backtrace ... =20 The problem is that the architecture-specific prologue analyzer fails to handle the first two insns in the prologue properly: ... 0000000000400610 : 400610: d2880210 mov x16, #0x4010 400614: cb3063ff sub sp, sp, x16 400618: a9007bfd stp x29, x30, [sp] 40061c: 910003fd mov x29, sp 400620: 910043a0 add x0, x29, #0x10 400624: 97fffff0 bl 4005e4 ... so we get: ... $ gdb -q -batch ./outputs/gdb.base/large-frame/large-frame-O0 -ex "b fu= nc" Breakpoint 1 at 0x400614 ... =20 Fix this by: - fixing the support for the first insn to extract the immediate operan= d, and - adding support for the second insn, such that we have: ... Breakpoint 1 at 0x400624 ... Note that we're overshooting by one insn (0x400620 is the first insn af= ter the prologue), but that's a pre-existing problem. =20 Tested on aarch64-linux. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29408 Diff: --- gdb/aarch64-tdep.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 8670197a888..f747ebda1ab 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -340,6 +340,20 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, if (rn =3D=3D AARCH64_SP_REGNUM && rd =3D=3D AARCH64_FP_REGNUM) seen_stack_set =3D true; } + else if (inst.opcode->iclass =3D=3D addsub_ext + && strcmp ("sub", inst.opcode->name) =3D=3D 0) + { + unsigned rd =3D inst.operands[0].reg.regno; + unsigned rn =3D inst.operands[1].reg.regno; + unsigned rm =3D inst.operands[2].reg.regno; + + gdb_assert (aarch64_num_of_operands (inst.opcode) =3D=3D 3); + gdb_assert (inst.operands[0].type =3D=3D AARCH64_OPND_Rd_SP); + gdb_assert (inst.operands[1].type =3D=3D AARCH64_OPND_Rn_SP); + gdb_assert (inst.operands[2].type =3D=3D AARCH64_OPND_Rm_EXT); + + regs[rd] =3D pv_subtract (regs[rn], regs[rm]); + } else if (inst.opcode->iclass =3D=3D pcreladdr && inst.operands[1].type =3D=3D AARCH64_OPND_ADDR_ADRP) { @@ -370,14 +384,20 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, } else if (inst.opcode->op =3D=3D OP_MOVZ) { + unsigned rd =3D inst.operands[0].reg.regno; + + gdb_assert (aarch64_num_of_operands (inst.opcode) =3D=3D 2); gdb_assert (inst.operands[0].type =3D=3D AARCH64_OPND_Rd); + gdb_assert (inst.operands[1].type =3D=3D AARCH64_OPND_HALF); + gdb_assert (inst.operands[1].shifter.kind =3D=3D AARCH64_MOD_LSL); =20 /* If this shows up before we set the stack, keep going. Otherwise stop the analysis. */ if (seen_stack_set) break; =20 - regs[inst.operands[0].reg.regno] =3D pv_unknown (); + regs[rd] =3D pv_constant (inst.operands[1].imm.value + << inst.operands[1].shifter.amount); } else if (inst.opcode->iclass =3D=3D log_shift && strcmp (inst.opcode->name, "orr") =3D=3D 0)