From: Tom de Vries Date: Fri, 4 Dec 2020 12:36:47 +0000 (+0100) Subject: [gdb/testsuite] Fix count usage in gdb.reverse/insn-reverse.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f17727b3497a630b01dffd219cdc372a058be121;p=binutils-gdb.git [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. --- 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" ""] }