From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id C60933858D20; Tue, 13 Feb 2024 08:10:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C60933858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707811845; bh=L5KIMgnUvBKxWOMD/RKZD9iI4O0U7qslld9P3DZaEgs=; h=From:To:Subject:Date:From; b=XKDpmaI2pA5dNoOgZhc9jyKdVly8E9x6S9C46qJ5PeOmUbxkuY1r0O2nqUqJshqE0 fnEaKLq7fS3f+3R6nFLbG85baSG0Jk2wOvbINEYd/O+YYbU1u5AuIFGhnL8+dR2K/C w5/BEVo0sVYJm238NcU2/ama3UQQcyhU4v/2QEwo= 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 reverse execution of LDR(immediate) T4 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 0fd455766e7f1bd7df328e104281b49a5268677f X-Git-Newrev: 7e4208a3f5d60f43b4a8f02e583fa950b599cd00 Message-Id: <20240213081045.C60933858D20@sourceware.org> Date: Tue, 13 Feb 2024 08:10:45 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7e4208a3f5d6= 0f43b4a8f02e583fa950b599cd00 commit 7e4208a3f5d60f43b4a8f02e583fa950b599cd00 Author: Tom de Vries Date: Tue Feb 13 09:10:54 2024 +0100 [gdb/tdep] Fix reverse execution of LDR(immediate) T4 =20 When running test-case gdb.reverse/func-map-to-same-line.exp on arm-lin= ux with target board unix/-mthumb, we run into: ... (gdb) reverse-step func2 () at func-map-to-same-line.c:26 26 { (gdb) FAIL: gdb.reverse/func-map-to-same-line.exp: \ column_info_flag=3Dcolumn-info: step-test: reverse-step into func2 ... =20 The FAIL is caused by incorrect recording of this insn: ... 4f6: f85d 7b04 ldr.w r7, [sp], #4 ... =20 The insn updates the sp, but we don't record this: ... $ gdb -q -batch func-map-to-same-line \ -ex "b *func2+8" \ -ex run \ -ex record \ -ex "set debug record 2" \ -ex stepi Breakpoint 1 at 0x4f6: file func-map-to-same-line.c, line 27. =20 Breakpoint 1, 0xaaaaa4f6 in func2 () at func-map-to-same-line.c:27 27 } /* END FUNC2 */ Process record: arm_process_record addr =3D 0xaaaaa4f6 Process record: add register num =3D 15 to record list. Process record: record_full_arch_list_add 0xabc6c460. Process record: add register num =3D 7 to record list. Process record: record_full_arch_list_add 0xabc3b868. Process record: add register num =3D 25 to record list. ... [ Note that sp is r13, and we see here only r15 (pc), r7, and r25 (ps).= ] =20 The problem is that the specific insn, an LDR(immediate) T4, is not han= dled in thumb2_record_ld_word. =20 Fix this by detecting the insn in thumb2_record_ld_word, and recording = the updated base register. =20 Tested on arm-linux. =20 Reported-By: Thiago Jung Bauermann Approved-By: Luis Machado =20 PR tdep/31278 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31278 Diff: --- gdb/arm-tdep.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 861d50a6a3b..081e934cf86 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -14184,6 +14184,14 @@ thumb2_record_ld_word (arm_insn_decode_record *thu= mb2_insn_r) record_buf[1] =3D ARM_PS_REGNUM; thumb2_insn_r->reg_rec_count =3D 2; =20 + if ((thumb2_insn_r->arm_insn & 0xfff00900) =3D=3D 0xf8500900) + { + /* Detected LDR(immediate), T4, with write-back bit set. Record Rn + update. */ + record_buf[2] =3D bits (thumb2_insn_r->arm_insn, 16, 19); + thumb2_insn_r->reg_rec_count++; + } + REG_ALLOC (thumb2_insn_r->arm_regs, thumb2_insn_r->reg_rec_count, record_buf); return ARM_RECORD_SUCCESS;