From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Fix Tcl quoting in gdb_assert
Date: Wed, 15 Feb 2023 14:58:28 -0700 [thread overview]
Message-ID: <20230215215828.1337884-1-tromey@adacore.com> (raw)
The gdb_assert proc under-quotes the expression that is passed in.
This leads to weird code in a couple of spots that tries to
compensate:
gdb_assert {{$all_regs eq $completed_regs}} ...
The fix is to add a bit of quoting when evaluating the expression.
---
gdb/testsuite/gdb.base/completion.exp | 2 +-
gdb/testsuite/gdb.base/step-over-no-symbols.exp | 6 +++---
gdb/testsuite/lib/gdb.exp | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 1533acbf4f9..4686e6f8f34 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -159,7 +159,7 @@ foreach {-> reg} [regexp -all -inline -line {^info registers (\w+\S*)} $regs_out
lappend completed_regs $reg
}
set completed_regs [join [lsort $completed_regs]]
-gdb_assert {{$all_regs eq $completed_regs}} "complete 'info registers '"
+gdb_assert {$all_regs eq $completed_regs} "complete 'info registers '"
# Tests below are about tab-completion, which doesn't work if readline
# library isn't used. Check it first.
diff --git a/gdb/testsuite/gdb.base/step-over-no-symbols.exp b/gdb/testsuite/gdb.base/step-over-no-symbols.exp
index 00b32deacf7..1136b47571b 100644
--- a/gdb/testsuite/gdb.base/step-over-no-symbols.exp
+++ b/gdb/testsuite/gdb.base/step-over-no-symbols.exp
@@ -76,9 +76,9 @@ proc test_step_over { displaced } {
set after_addr [get_pc "get after PC"]
- gdb_assert {{[regexp "^${hex}$" $before_addr] \
- && [regexp "^${hex}$" $after_addr] \
- && $before_addr != $after_addr}} "advanced"
+ gdb_assert {[regexp "^${hex}$" $before_addr] \
+ && [regexp "^${hex}$" $after_addr] \
+ && $before_addr != $after_addr} "advanced"
}
foreach displaced { "off" "on" "auto" } {
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e48228ed4f6..ecd6ca0a8ef 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1947,7 +1947,7 @@ proc gdb_assert { condition {message ""} } {
set message $condition
}
- set code [catch {uplevel 1 expr $condition} res]
+ set code [catch {uplevel 1 [list expr $condition]} res]
if {$code == 1} {
# If code is 1 (TCL_ERROR), it means evaluation failed and res contains
# an error message. Print the error message, and set res to 0 since we
--
2.39.1
next reply other threads:[~2023-02-15 21:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 21:58 Tom Tromey [this message]
2023-02-16 16:06 ` Simon Marchi
2023-02-16 18:12 ` Tom Tromey
2023-02-23 18:11 ` Tom Tromey
2023-02-23 19:16 ` Simon Marchi
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=20230215215828.1337884-1-tromey@adacore.com \
--to=tromey@adacore.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).