From f17727b3497a630b01dffd219cdc372a058be121 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 4 Dec 2020 13:36:47 +0100 Subject: [PATCH] [gdb/testsuite] Fix count usage in gdb.reverse/insn-reverse.exp 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 * gdb.reverse/insn-reverse.exp: Fix count handling. --- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.reverse/insn-reverse.exp | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e7408a033eb..a88668d9b4e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-12-04 Tom de Vries + + * gdb.reverse/insn-reverse.exp: Fix count handling. + 2020-12-04 Tom de Vries * gdb.reverse/insn-reverse-x86.c: Guard x86_64 assembly with #ifdef diff --git a/gdb/testsuite/gdb.reverse/insn-reverse.exp b/gdb/testsuite/gdb.reverse/insn-reverse.exp index d60f873e0d0..583195263ca 100644 --- a/gdb/testsuite/gdb.reverse/insn-reverse.exp +++ b/gdb/testsuite/gdb.reverse/insn-reverse.exp @@ -102,9 +102,8 @@ proc test { func testcase_nr } { 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" ""] } -- 2.30.2