From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 8/9] gdb/testsuite/dap: make dap_wait_for_event_and_check return preceding messages
Date: Fri, 6 Jan 2023 13:57:28 -0500 [thread overview]
Message-ID: <20230106185729.42372-9-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230106185729.42372-1-simon.marchi@efficios.com>
In the following patch, I change gdb.dap/basic-dap.exp such that after
waiting for some event, it checks if it received another event
meanwhile. To help with this, make dap_wait_for_event_and_check and
_dap_dap_wait_for_event return a list with everything received before
the event of interest. This is similar to what
dap_check_request_and_response returns.
Change-Id: I85c8980203a2dec833937e7552c2196bc137935d
---
gdb/testsuite/lib/dap-support.exp | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index 179f675b4d8..527e7db5228 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -282,17 +282,27 @@ proc dap_match_values {name d args} {
pass $name
}
-# A helper for dap_read_event that reads events, looking for one
+# A helper for dap_wait_for_event_and_check that reads events, looking for one
# matching TYPE.
-proc _dap_wait_for_event {type} {
+#
+# Return a list of two items:
+#
+# - the matched event
+# - a list of any JSON objects (events or others) seen before the matched
+# event.
+proc _dap_wait_for_event { {type ""} } {
+ set preceding [list]
+
while 1 {
# We don't do any extra error checking here for the time
# being; we'll just get a timeout thrown instead.
set d [_dap_read_json]
if {[dict get $d type] == "event"
- && [dict get $d event] == $type} {
- return $d
+ && ($type == "" || [dict get $d event] == $type)} {
+ return [list $d $preceding]
}
+
+ lappend preceding $d
}
}
@@ -302,14 +312,20 @@ proc _dap_wait_for_event {type} {
# are used to check fields of the event; the arguments alternate
# between a field name (in "dict get" form) and its expected value.
#
-# Returns the dict for the chosen event, or empty string on error.
+# Return a list of two items:
+#
+# - the matched event (regardless of whether it passed the field validation or
+# not)
+# - a list of any JSON objects (events or others) seen before the matched
+# event.
proc dap_wait_for_event_and_check {name type args} {
if {$name == ""} {
set name $type
}
set result [_dap_wait_for_event $type]
- eval dap_match_values [list $name $result] $args
+ set event [lindex $result 0]
+ eval dap_match_values [list $name $event] $args
return $result
}
--
2.38.1
next prev parent reply other threads:[~2023-01-06 18:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-06 18:57 [PATCH 0/9] Fix gdb.dap/basic-dap.exp for PIE Simon Marchi
2023-01-06 18:57 ` [PATCH 1/9] gdb/testsuite/dap: use gdb_assert in gdb.dap/basic-dap.exp Simon Marchi
2023-01-25 21:58 ` Tom Tromey
2023-01-06 18:57 ` [PATCH 2/9] gdb/testsuite/dap: prefix some procs with _ Simon Marchi
2023-01-25 21:59 ` Tom Tromey
2023-01-06 18:57 ` [PATCH 3/9] gdb/testsuite/dap: write requests to gdb.log Simon Marchi
2023-01-25 21:59 ` Tom Tromey
2023-01-25 22:01 ` Tom Tromey
2023-01-26 3:01 ` Simon Marchi
2023-01-06 18:57 ` [PATCH 4/9] gdb/testsuite/dap: make dap_request_and_response not catch / issue test result Simon Marchi
2023-01-06 18:57 ` [PATCH 5/9] gdb/testsuite/dap: remove catch from dap_read_event Simon Marchi
2023-01-06 18:57 ` [PATCH 6/9] gdb/testsuite/dap: pass around dicts instead of ton objects Simon Marchi
2023-01-25 22:04 ` Tom Tromey
2023-01-26 3:29 ` Simon Marchi
2023-01-26 14:55 ` Tom Tromey
2023-01-06 18:57 ` [PATCH 7/9] gdb/testsuite/dap: rename dap_read_event to dap_wait_for_event_and_check Simon Marchi
2023-01-06 18:57 ` Simon Marchi [this message]
2023-01-06 18:57 ` [PATCH 9/9] gdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIE Simon Marchi
2023-01-25 22:10 ` Tom Tromey
2023-01-26 3:40 ` Simon Marchi
2023-01-26 15:08 ` Tom Tromey
2023-01-26 20:21 ` Simon Marchi
2023-01-16 16:07 ` [PATCH 0/9] Fix gdb.dap/basic-dap.exp " Simon Marchi
2023-01-25 22:10 ` Tom Tromey
2023-01-26 20:22 ` 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=20230106185729.42372-9-simon.marchi@efficios.com \
--to=simon.marchi@efficios.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).