From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +KuqKWtvuGMnHxEAWB0awg (envelope-from ) for ; Fri, 06 Jan 2023 13:58:51 -0500 Received: by simark.ca (Postfix, from userid 112) id A7CE71E222; Fri, 6 Jan 2023 13:58:51 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=UEjkdxN6; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 627231E112 for ; Fri, 6 Jan 2023 13:58:51 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7F4E3846469 for ; Fri, 6 Jan 2023 18:58:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7F4E3846469 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031530; bh=3TWnu68oRk5SfE0l/hdPpB0WoqCFLXNHVceQ8IHX3ys=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=UEjkdxN67NPDxnG9AqfxrdtCcDdDmaWUpmxwby8r2iNAs1Lf/5/a5RSkVsJYWISC+ E83I+MjzHr28dMipyaCAyB2EQDtxD3gmgQ+rkmP/GjShVLmehiTJQ9L0rY+EiFDGmi KIC1PLu3pb2Dfl/NI+LDMMvL+EXS14t+VXC2Tr+w= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 9014A3858C00 for ; Fri, 6 Jan 2023 18:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9014A3858C00 X-ASG-Debug-ID: 1673031451-0c856e762b4b7eb0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id KpoqD07DbYu9UoDN (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 06 Jan 2023 13:57:31 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 5DDFB441B21; Fri, 6 Jan 2023 13:57:31 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi 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 X-ASG-Orig-Subj: [PATCH 8/9] gdb/testsuite/dap: make dap_wait_for_event_and_check return preceding messages Message-Id: <20230106185729.42372-9-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230106185729.42372-1-simon.marchi@efficios.com> References: <20230106185729.42372-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1673031451 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2494 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.103363 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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