From: Tom de Vries Date: Wed, 13 Nov 2024 18:44:21 +0000 (+0100) Subject: [gdb/tdep] Fix recording of T1 push X-Git-Tag: gdb-16-branchpoint~440 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e4577fc298767aab3756fd929fce61bb8560091;p=thirdparty%2Fbinutils-gdb.git [gdb/tdep] Fix recording of T1 push When running test-case gdb.reverse/recursion.exp on arm-linux with target board unix/-mthumb, I run into: ... (gdb) PASS: gdb.reverse/recursion.exp: Skipping recursion from inside reverse-next^M bar (x=4195569) at /home/linux/gdb/src/gdb/testsuite/gdb.reverse/recursion.c:34^M 34 int r = foo (x);^M (gdb) FAIL: gdb.reverse/recursion.exp: print frame when stepping out ... The problem is the recording of the T1 push instruction [1,2], specifically: ... 000004d8 : 4d8: b580 push {r7, lr} ... The current code fails to add a memory record for the memory written with the value of the lr register. Fix this by adding the missing memory record. Tested on arm-linux. Reviewed-By: Guinevere Larsen Approved-By: Luis Machado [1] https://developer.arm.com/documentation/ddi0406/c/Application-Level-Architecture/Instruction-Details/Encoding-of-lists-of-ARM-core-registers [2] https://developer.arm.com/documentation/ddi0597/2024-09/T32-Instructions-by-Encoding/16-bit?lang=en#pushpop16 --- diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 9c996b821be..34507615975 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -13557,9 +13557,12 @@ thumb_record_misc (arm_insn_decode_record *thumb_insn_r) record_buf[0] = bits (thumb_insn_r->arm_insn, 0, 2); thumb_insn_r->reg_rec_count = 1; break; - case 4: /* fall through */ case 5: - /* PUSH. */ + /* PUSH with lr. */ + register_count++; + [[fallthrough]]; + case 4: + /* PUSH without lr. */ register_bits = bits (thumb_insn_r->arm_insn, 0, 7); regcache_raw_read_unsigned (reg_cache, ARM_SP_REGNUM, &u_regval); while (register_bits) @@ -13568,8 +13571,7 @@ thumb_record_misc (arm_insn_decode_record *thumb_insn_r) register_count++; register_bits = register_bits >> 1; } - start_address = u_regval - \ - (4 * (bit (thumb_insn_r->arm_insn, 8) + register_count)); + start_address = u_regval - (4 * register_count); thumb_insn_r->mem_rec_count = register_count; while (register_count) {