From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb/testsuite] Fix count usage in gdb.reverse/insn-reverse.exp
Date: Wed, 25 Nov 2020 23:51:15 +0100 [thread overview]
Message-ID: <20201125225114.GA16467@delia> (raw)
Hi,
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.
Any comments?
Thanks,
- Tom
[gdb/testsuite] Fix count usage in gdb.reverse/insn-reverse.exp
gdb/testsuite/ChangeLog:
2020-11-25 Tom de Vries <tdevries@suse.de>
* gdb.reverse/insn-reverse.exp: Fix count handling.
---
gdb/testsuite/gdb.reverse/insn-reverse.exp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.reverse/insn-reverse.exp b/gdb/testsuite/gdb.reverse/insn-reverse.exp
index 5627f9d2605..39e276964f9 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" ""]
}
next reply other threads:[~2020-11-25 22:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-25 22:51 Tom de Vries [this message]
2020-12-03 19:51 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201125225114.GA16467@delia \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox