Consider the test-case gdb.reverse/insn-reverse.exp.
After the loop setting count, the valid entries in various arrays range from 0
to $count - 1 inclusive.
Then $count is decremented:
...
incr count -1
...
after which the valid entries range from 0 to $count inclusive.
The first subsequent loop handles that properly:
...
for {set i $count} {$i >= 0} {incr i -1} {
...
but the following loop does not, because it treats $count as exclusive bound:
...
for {set i 0} {$i < $count} {incr i} {
...
Fix this by removing the incr, and using $count - 1 as starting value in the
first loop.
gdb/testsuite/ChangeLog:
2020-12-04 Tom de Vries <tdevries@suse.de>
* gdb.reverse/insn-reverse.exp: Fix count handling.
+2020-12-04 Tom de Vries <tdevries@suse.de>
+
+ * gdb.reverse/insn-reverse.exp: Fix count handling.
+
2020-12-04 Tom de Vries <tdevries@suse.de>
* gdb.reverse/insn-reverse-x86.c: Guard x86_64 assembly with #ifdef
gdb_test "si" "" ""
}
- incr count -1
# Registers contents after each backward single step.
- for {set i $count} {$i >= 0} {incr i -1} {
+ for {set i [expr $count - 1]} {$i >= 0} {incr i -1} {
gdb_test "reverse-stepi" "" ""
set post_regs($i) [capture_command_output "info all-registers" ""]
}