From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Fix unbalanced quotes in mi_expect_stop argument
Date: Fri, 24 Mar 2023 10:46:10 +0100 [thread overview]
Message-ID: <20230324094610.28590-1-tdevries@suse.de> (raw)
In proc mi_expect_stop there's a proc argument reason that's handled like so:
...
set r "reason=\"$reason\","
...
That's fine for say:
...
set reason "foo"
...
for which this evaluates to:
...
set r "reason=\"foo\","
...
But there are more complex uses, for instance:
...
set reason "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal"
...
which evaluates to:
...
set r "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\""
...
Note how in this reason argument, the first two '\"' seems to form a pair
surrounding ',disp=', which is not the case, which is confusing.
Fix this by only adding the quotes in mi_expect_stop if the string doesn't
already contain quotes, such that we have the more readable:
...
set reason "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\""
...
Tested on x86_64-linux.
---
gdb/testsuite/gdb.ada/mi_catch_assert.exp | 2 +-
gdb/testsuite/gdb.ada/mi_catch_ex.exp | 8 ++++----
gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp | 4 ++--
gdb/testsuite/gdb.ada/mi_ex_cond.exp | 2 +-
gdb/testsuite/lib/mi-support.exp | 6 +++++-
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/gdb/testsuite/gdb.ada/mi_catch_assert.exp b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
index e0d5439dc26..c3673fab8e8 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_assert.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
@@ -79,7 +79,7 @@ mi_gdb_test "-catch-assert -c \"Global_Var = 2\"" \
set bp_location [gdb_get_line_number "STOP" ${testdir}/bla.adb]
mi_execute_to "exec-continue" \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\"" \
"bla" "" ".*" "$bp_location" \
".*" \
"continue to assert failure catchpoint hit"
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex.exp b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
index 6a0f94a5f87..d0dfbd59764 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
@@ -92,7 +92,7 @@ proc continue_to_exception { exception_name exception_message test } {
# Now MI stream output.
mi_expect_stop \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"$exception_name\(\",exception-message=\"$exception_message\)?" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"$exception_name\(\",exception-message=\"$exception_message\)?\"" \
"foo" "" ".*" ".*" \
".*" \
$test
@@ -140,19 +140,19 @@ mi_gdb_test "-catch-exception -u" \
"catch unhandled exceptions"
mi_execute_to "exec-continue" \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR(\",exception-message=\"foo\\.adb:$decimal explicit raise)?" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR(\",exception-message=\"foo\\.adb:$decimal explicit raise)?\"" \
"foo" "" ".*" ".*" \
".*" \
"continue to exception catchpoint hit"
mi_execute_to "exec-continue" \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\"" \
"foo" "" ".*" ".*" \
".*" \
"continue to assert failure catchpoint hit"
mi_execute_to "exec-continue" \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR\"" \
"foo" "" ".*" ".*" \
".*" \
"continue to unhandled exception catchpoint hit"
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
index 82c7b2a300a..2cd175f098b 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
@@ -82,7 +82,7 @@ proc continue_to_exception_handler { test line } {
# Now MI stream output.
mi_expect_stop \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"" \
"foo" "" ".*" "$line" \
".*" \
$test
@@ -125,7 +125,7 @@ mi_gdb_test "-catch-handlers -e Constraint_Error" \
"catch Constraint_Error"
mi_execute_to "exec-continue" \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"" \
"foo" "" ".*" "$bp_ce_location" \
".*" \
"continue to exception catchpoint hit"
diff --git a/gdb/testsuite/gdb.ada/mi_ex_cond.exp b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
index f41b633a822..54aa6b54ee1 100644
--- a/gdb/testsuite/gdb.ada/mi_ex_cond.exp
+++ b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
@@ -77,7 +77,7 @@ mi_gdb_test "-catch-exception -c \"i = 2\" -e constraint_error" \
mi_run_cmd
mi_expect_stop \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR(\",exception-message=\"foo\\.adb:$decimal explicit raise)?" \
+ "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR(\",exception-message=\"foo\\.adb:$decimal explicit raise)?\"" \
"foo" "" ".*" ".*" \
".*" \
"run to exception catchpoint hit"
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 3c2dd2fab2b..c738b7be505 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1267,7 +1267,11 @@ proc mi_expect_stop { reason func args file line extra test } {
set r ""
if { $reason != "" } {
- set r "reason=\"$reason\","
+ if { [regexp {"} $reason] } {
+ set r "reason=$reason,"
+ } else {
+ set r "reason=\"$reason\","
+ }
}
base-commit: 1985d8cb7048bcfce60b59cfe219d3b09bda6373
--
2.35.3
reply other threads:[~2023-03-24 9:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230324094610.28590-1-tdevries@suse.de \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).