From patchwork Fri Jan 6 18:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62808 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BFF54385781F for ; Fri, 6 Jan 2023 18:57:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFF54385781F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031477; bh=YgJXnI35g9u2RcI5nwacV0uIJI+PUWI0CHqvQm36XvQ=; 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=lC0s5/J2J8AmR2yQOnu/1u0przyWg7jvYBdqa+3DkD2Yr66BlBp6AIYhMTb6Fhz4w MY/X/dI5ebXW0Nuu5cmPAw5kBhlJVA+nO5dPwSDu6W1eBtnHe8hT7/Kul0XLDYtZcq 7RQFpynzKElolHV39i3XEjfaH8eWhn5VOeApXAi4= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 1775E3858D33 for ; Fri, 6 Jan 2023 18:57:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1775E3858D33 X-ASG-Debug-ID: 1673031450-0c856e762a4b70a0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id tw8AWYw1PjDL9ldS (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 06 Jan 2023 13:57:30 -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 97A7E441D64; Fri, 6 Jan 2023 13:57:30 -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 1/9] gdb/testsuite/dap: use gdb_assert in gdb.dap/basic-dap.exp Date: Fri, 6 Jan 2023 13:57:21 -0500 X-ASG-Orig-Subj: [PATCH 1/9] gdb/testsuite/dap: use gdb_assert in gdb.dap/basic-dap.exp Message-Id: <20230106185729.42372-2-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 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1673031450 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2055 X-Barracuda-BRTS-Status: 1 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Use gdb_assert instead of manual pass/fail. Change-Id: I71fbc4e37a0a1ef4783056c7424e932651fa397f --- gdb/testsuite/gdb.dap/basic-dap.exp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index d3acf0c22c8..c60989d2a6f 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -75,12 +75,7 @@ set obj [dap_check_request_and_response "reset breakpoint by line number" \ [format {o source [o path [%s]] breakpoints [a [o line [i %d]]]} \ [list s $srcfile] $line]] set new_line_bpno [dap_get_breakpoint_number $obj] - -if {$new_line_bpno == $line_bpno} { - pass "re-setting kept same breakpoint number" -} else { - fail "re-setting kept same breakpoint number" -} +gdb_assert {$new_line_bpno == $line_bpno} "re-setting kept same breakpoint number" # This uses "&address_breakpoint_here" as the address -- this is a # hack because we know how this is implemented under the hood. @@ -131,21 +126,13 @@ dap_match_values "global value in main" [lindex $obj 0] \ set obj [dap_request_and_response "evaluate non-existing variable" \ evaluate {o expression [s nosuchvariable]}] set d [namespace eval ton::2dict [lindex $obj 0]] -if {[dict get $d success] == "false"} { - pass "result of invalid request" -} else { - fail "result of invalid request" -} +gdb_assert { [dict get $d success] == "false" } "result of invalid request" set obj [dap_check_request_and_response "disassemble one instruction" \ disassemble \ [format {o memoryReference [s %s] instructionCount [i 1]} \ $insn_pc]] set d [namespace eval ton::2dict [lindex $obj 0]] -if {[dict exists $d body instructions]} { - pass "instructions in disassemble output" -} else { - fail "instructions in disassemble output" -} +gdb_assert { [dict exists $d body instructions] } "instructions in disassemble output" dap_shutdown From patchwork Fri Jan 6 18:57:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62809 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 628303860C36 for ; Fri, 6 Jan 2023 18:58:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 628303860C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031486; bh=GxrdtdpUTOvZ+cbDQszmqJJrJ3OlmEPxQDENPlursUM=; 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=snrZ9prTd4Q2KDSUNEawMnTy3bX/54+uQQLF/rB3xgvInSYMQDhnj/uLUyc/PGwia Lhmyzw0Nx1k2huVSSCWB5dSD8rJELpI05g7UxHTquEh6XtJ7x9j4KittViakvx29bt 2L3anbvmekQldjW7buV0A+OOG3o5zc2W8nRbdRhY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 8E72F3858D39 for ; Fri, 6 Jan 2023 18:57:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E72F3858D39 X-ASG-Debug-ID: 1673031450-0c856e762b4b7e80001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id QDlUH30qCWLaKtkR (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 06 Jan 2023 13:57:30 -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 AF934441D65; Fri, 6 Jan 2023 13:57:30 -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 2/9] gdb/testsuite/dap: prefix some procs with _ Date: Fri, 6 Jan 2023 13:57:22 -0500 X-ASG-Orig-Subj: [PATCH 2/9] gdb/testsuite/dap: prefix some procs with _ Message-Id: <20230106185729.42372-3-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 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1673031450 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 4054 X-Barracuda-BRTS-Status: 1 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Prefix some procs that are only used internally with an underscore, to make it clear they are internal. If they need to be used by some test later, we can always un-prefix them. Change-Id: Iacb8e77363b5d1f8b98d9ba5a6d115aee5c8925d --- gdb/testsuite/lib/dap-support.exp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index adf332cd7a5..a91b5533643 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -98,7 +98,7 @@ proc dap_to_ton {obj} { } # Format the object OBJ, in TON format, as JSON and send it to gdb. -proc dap_send_ton {obj} { +proc _dap_send_ton {obj} { set json [namespace eval ton::2json $obj] # FIXME this is wrong for non-ASCII characters. set len [string length $json] @@ -111,7 +111,7 @@ proc dap_send_ton {obj} { # omitted. The sequence number of the request is automatically added, # and this is also the return value. OBJ is assumed to already be in # TON form. -proc dap_send_request {command {obj {}}} { +proc _dap_send_request {command {obj {}}} { # We can construct this directly as a TON object. set result $::dap_seq incr ::dap_seq @@ -120,13 +120,13 @@ proc dap_send_request {command {obj {}}} { if {$obj != ""} { append req " arguments \[$obj\]" } - dap_send_ton $req + _dap_send_ton $req return $result } # Read a JSON response from gdb. This will return a TON object on # success, or throw an exception on error. -proc dap_read_json {} { +proc _dap_read_json {} { set length "" gdb_expect { -re "^Content-Length: (\[0-9\]+)\r\n" { @@ -181,10 +181,10 @@ proc dap_read_json {} { # emitted. The objects are in TON format. If a response object is # seen but has the wrong sequence number or command, throw an # exception -proc dap_read_response {cmd num} { +proc _dap_read_response {cmd num} { set result {} while 1 { - set obj [dap_read_json] + set obj [_dap_read_json] set d [namespace eval ton::2dict $obj] if {[dict get $d type] == "response"} { if {[dict get $d request_seq] != $num} { @@ -200,14 +200,14 @@ proc dap_read_response {cmd num} { } } -# A wrapper for dap_send_request and dap_read_response. This sends a +# A wrapper for _dap_send_request and _dap_read_response. This sends a # request to gdb and returns the result. NAME is used to issue a pass # or fail; on failure, this always returns an empty string. proc dap_request_and_response {name command {obj {}}} { set result {} if {[catch { - set seq [dap_send_request $command $obj] - set result [dap_read_response $command $seq] + set seq [_dap_send_request $command $obj] + set result [_dap_read_response $command $seq] } text]} { verbose "reason: $text" fail $name @@ -239,7 +239,7 @@ proc dap_check_request_and_response {name command {obj {}}} { # desired. Callers not caring about this should probably use # dap_launch. Returns the empty string on failure. NAME is used as # the test name. -proc dap_initialize {name} { +proc _dap_initialize {name} { if {[dap_gdb_start]} { return "" } @@ -254,7 +254,7 @@ proc dap_initialize {name} { # reasonable default but can be overridden in case a test needs to # launch gdb more than once. proc dap_launch {file {name startup}} { - if {[dap_initialize "$name - initialize"] == ""} { + if {[_dap_initialize "$name - initialize"] == ""} { return "" } return [dap_check_request_and_response "$name - launch" launch \ @@ -303,7 +303,7 @@ proc _dap_read_event {type} { while 1 { # We don't do any extra error checking here for the time # being; we'll just get a timeout thrown instead. - set obj [dap_read_json] + set obj [_dap_read_json] set d [namespace eval ton::2dict $obj] if {[dict get $d type] == "event" && [dict get $d event] == $type} { From patchwork Fri Jan 6 18:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62810 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 694503858022 for ; Fri, 6 Jan 2023 18:58:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 694503858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031488; bh=xO5aG4TC4gB8zsV6YaPzak0+CV0BZ144Nsiyi/Wn6Q4=; 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=SXj/chUqJ7gXktRztXsNXCtr/7uL/QbOUegLLwr7svk7X3ippgpPo9fpnuf2WENHy JbwexALpZQDksQJWTJulkgw6+SCdTBxJW+SVlp4Lc7asVyTHFUcNXSYk88AN5c9WXu C/6OwpEIn4llR4c/K2K3BjiZ3JpmZ4EH9MK/tBoQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 90DFB3858CDA for ; Fri, 6 Jan 2023 18:57:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90DFB3858CDA X-ASG-Debug-ID: 1673031450-0c856e762a4b70b0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 3KQkDgwAxScM7Qwh (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 06 Jan 2023 13:57:30 -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 C4FB4441D66; Fri, 6 Jan 2023 13:57:30 -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 3/9] gdb/testsuite/dap: write requests to gdb.log Date: Fri, 6 Jan 2023 13:57:23 -0500 X-ASG-Orig-Subj: [PATCH 3/9] gdb/testsuite/dap: write requests to gdb.log Message-Id: <20230106185729.42372-4-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 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1673031450 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: 1082 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This helps following what happens when reading gdb.log. The downside is that it becomes harder to tell what text is from GDB and what text is going to GDB, but I think that seeing responses without seeing requests is even more confusing. At least, the lines are prefix with >>>, so when you see this, you know that until the end of the line, it's something that was sent to GDB, and not GDB output. Change-Id: I1ba1acd8b16f4e64686c5ad268cc41082951c874 --- gdb/testsuite/lib/dap-support.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index a91b5533643..94a0d27c8a8 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -102,7 +102,7 @@ proc _dap_send_ton {obj} { set json [namespace eval ton::2json $obj] # FIXME this is wrong for non-ASCII characters. set len [string length $json] - verbose ">>> $json" + verbose -log ">>> $json" send_gdb "Content-Length: $len\r\n\r\n$json" } From patchwork Fri Jan 6 18:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62811 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B14553857C48 for ; Fri, 6 Jan 2023 18:58:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B14553857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031496; bh=hCtxmAa3VfITbwFIlG2VBMlvMyzwjvdOD+W72jNiCSc=; 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=qIKS1a1e64Eoluc2KPsJDmGOH64BxvOkj3H7GBQW5a7eF01rE5nw8ZYRteFOsHRFj drxyxw/utJE5DwPJcpLSMn1+0pOMVYuRjgrrHJ3iqzxl7vMkaMc6lq4h/AsMMLb/3U T7geqRqYi3Vofv4lMFf1XyN1ZsNxUGyLFONZRNGU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 225FB3858CDB for ; Fri, 6 Jan 2023 18:57:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 225FB3858CDB X-ASG-Debug-ID: 1673031450-0c856e762b4b7e90001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id swSdvAMN6W18NYBG (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 06 Jan 2023 13:57:30 -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 E3595441B21; Fri, 6 Jan 2023 13:57:30 -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 4/9] gdb/testsuite/dap: make dap_request_and_response not catch / issue test result Date: Fri, 6 Jan 2023 13:57:24 -0500 X-ASG-Orig-Subj: [PATCH 4/9] gdb/testsuite/dap: make dap_request_and_response not catch / issue test result Message-Id: <20230106185729.42372-5-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 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1673031450 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: 2837 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Following some of my changes, dap_request_and_response was failing and I didn't know why. I think it's better to make it not catch any exception, and just make it do a simple "send request, read response". If an exception is thrown while sending a request or reading a response, things are going really badly, it's not like we'll want to recover from that and continue the test. Change-Id: I27568d3547f753c3a74e3e5a730d38a8caef9356 --- gdb/testsuite/gdb.dap/basic-dap.exp | 2 +- gdb/testsuite/lib/dap-support.exp | 25 ++++++------------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index c60989d2a6f..af55d19349f 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -123,7 +123,7 @@ set obj [dap_check_request_and_response "evaluate global in main" \ dap_match_values "global value in main" [lindex $obj 0] \ "body result" 25 -set obj [dap_request_and_response "evaluate non-existing variable" \ +set obj [dap_request_and_response \ evaluate {o expression [s nosuchvariable]}] set d [namespace eval ton::2dict [lindex $obj 0]] gdb_assert { [dict get $d success] == "false" } "result of invalid request" diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index 94a0d27c8a8..bc99f0182a7 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -201,29 +201,16 @@ proc _dap_read_response {cmd num} { } # A wrapper for _dap_send_request and _dap_read_response. This sends a -# request to gdb and returns the result. NAME is used to issue a pass -# or fail; on failure, this always returns an empty string. -proc dap_request_and_response {name command {obj {}}} { - set result {} - if {[catch { - set seq [_dap_send_request $command $obj] - set result [_dap_read_response $command $seq] - } text]} { - verbose "reason: $text" - fail $name - } else { - pass $name - } - return $result +# request to gdb and returns the response as a dict. +proc dap_request_and_response {command {obj {}}} { + set seq [_dap_send_request $command $obj] + return [_dap_read_response $command $seq] } # Like dap_request_and_response, but also checks that the response -# indicates success. +# indicates success. NAME is used to issue a test result. proc dap_check_request_and_response {name command {obj {}}} { - set result [dap_request_and_response $name $command $obj] - if {$result == ""} { - return "" - } + set result [dap_request_and_response $command $obj] set d [namespace eval ton::2dict [lindex $result 0]] if {[dict get $d success] != "true"} { verbose "request failure: $result" From patchwork Fri Jan 6 18:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62813 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 023F338432DC for ; Fri, 6 Jan 2023 18:58:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 023F338432DC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031525; bh=bouALoGEG05Qv92MKm808uXQ6r29DscTLBQ0CfI98xo=; 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=PVkpTSTf03FM+rKO2Wyf13cbSfVwEl0izNihhhAkJLXdtyg+qc58fo1MTg0HjCTqa 75cdEfg5eaq0GKPV3iAaheLG7BRd703D8k7zJ/oSbL0UbwVIgqVFYKr245BlPOqVGD dlyY7Zjq7Y8zbn0fvKQyoNb2D1nXzZVc8Bu6mM+Q= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 8C21E3858C53 for ; Fri, 6 Jan 2023 18:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C21E3858C53 X-ASG-Debug-ID: 1673031451-0c856e762a4b70c0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id ZwEZzB0CJ3x22xPR (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 0522F441D64; 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 5/9] gdb/testsuite/dap: remove catch from dap_read_event Date: Fri, 6 Jan 2023 13:57:25 -0500 X-ASG-Orig-Subj: [PATCH 5/9] gdb/testsuite/dap: remove catch from dap_read_event Message-Id: <20230106185729.42372-6-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 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-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 863 X-Barracuda-BRTS-Status: 1 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This catch didn't cause me any trouble, but for the same reason as the preceding patch, I think it's a bit better to just let any exception propagate, to make for easier debugging. Change-Id: I1779e62c788b77fef2d50434edf4c3d2ec5e1c4c --- gdb/testsuite/lib/dap-support.exp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index bc99f0182a7..8c85f90c352 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -310,11 +310,7 @@ proc dap_read_event {name type args} { set name $type } - if {[catch {_dap_read_event $type} result]} { - fail $name - return "" - } - + set result [_dap_read_event $type] eval dap_match_values [list $name $result] $args return $result From patchwork Fri Jan 6 18:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62816 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B9318385B537 for ; Fri, 6 Jan 2023 18:59:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9318385B537 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031574; bh=amWtC5pbcEKup8wzG67/19tn9gjkfHL8WoQFU96bcPk=; 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=ESWwlbOrIoTef13N4dAjv5MF5uLkDW0PrLwjENg5cFSCCdmxe2TDa1kBeS2veJ6gd fcqyEismsKTUCIxTEfE2w2RdfHPSwT2AWj8rtCf7bIV4lvH89oNAwhKXosIY6Q1Dip o9ryIMyJW9mhDXrRWRCNiWc7JE1bBXKIXmede2uk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 8E26F3858C74 for ; Fri, 6 Jan 2023 18:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E26F3858C74 X-ASG-Debug-ID: 1673031451-0c856e762b4b7ea0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 6ny3HcJ1TZGztavz (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 27160441B21; 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 6/9] gdb/testsuite/dap: pass around dicts instead of ton objects Date: Fri, 6 Jan 2023 13:57:26 -0500 X-ASG-Orig-Subj: [PATCH 6/9] gdb/testsuite/dap: pass around dicts instead of ton objects Message-Id: <20230106185729.42372-7-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 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: 7229 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Change-Id: I2ca47bea355bf459090bae8680c6a917350b5c3f --- gdb/testsuite/gdb.dap/basic-dap.exp | 15 +++++---- gdb/testsuite/lib/dap-support.exp | 48 ++++++++++++++--------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index af55d19349f..68d0440f692 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -53,8 +53,7 @@ set line_bpno [dap_get_breakpoint_number $obj] # Check the new breakpoint event. set ok 0 -foreach event [lindex $obj 1] { - set d [namespace eval ton::2dict $event] +foreach d [lindex $obj 1] { if {[dict get $d type] != "event" || [dict get $d event] != "breakpoint"} { continue @@ -84,8 +83,8 @@ set obj [dap_check_request_and_response "set breakpoint by address" \ {o breakpoints [a [o instructionReference [s &address_breakpoint_here]]]}] set insn_bpno [dap_get_breakpoint_number $obj] -set d [namespace eval ton::2dict [lindex $obj 0]] -set bplist [dict get $d body breakpoints] +set response [lindex $obj 0] +set bplist [dict get $response body breakpoints] set insn_pc [dict get [lindex $bplist 0] instructionReference] dap_check_request_and_response "start inferior" configurationDone @@ -125,14 +124,14 @@ dap_match_values "global value in main" [lindex $obj 0] \ set obj [dap_request_and_response \ evaluate {o expression [s nosuchvariable]}] -set d [namespace eval ton::2dict [lindex $obj 0]] -gdb_assert { [dict get $d success] == "false" } "result of invalid request" +set response [lindex $obj 0] +gdb_assert { [dict get $response success] == "false" } "result of invalid request" set obj [dap_check_request_and_response "disassemble one instruction" \ disassemble \ [format {o memoryReference [s %s] instructionCount [i 1]} \ $insn_pc]] -set d [namespace eval ton::2dict [lindex $obj 0]] -gdb_assert { [dict exists $d body instructions] } "instructions in disassemble output" +set response [lindex $obj 0] +gdb_assert { [dict exists $response body instructions] } "instructions in disassemble output" dap_shutdown diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index 8c85f90c352..ee55a4acc9c 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -124,7 +124,7 @@ proc _dap_send_request {command {obj {}}} { return $result } -# Read a JSON response from gdb. This will return a TON object on +# Read a JSON response from gdb. This will return a dict on # success, or throw an exception on error. proc _dap_read_json {} { set length "" @@ -171,31 +171,31 @@ proc _dap_read_json {} { incr length -$this_len } - return [ton::json2ton $json] + set ton [ton::json2ton $json] + return [namespace eval ton::2dict $ton] } # Read a sequence of JSON objects from gdb, until a response object is # seen. If the response object has the request sequence number NUM, # and is for command CMD, return a list of two elements: the response # object and a list of any preceding events, in the order they were -# emitted. The objects are in TON format. If a response object is -# seen but has the wrong sequence number or command, throw an -# exception +# emitted. The objects are dicts. If a response object is seen but has +# the wrong sequence number or command, throw an exception + proc _dap_read_response {cmd num} { set result {} while 1 { - set obj [_dap_read_json] - set d [namespace eval ton::2dict $obj] + set d [_dap_read_json] if {[dict get $d type] == "response"} { if {[dict get $d request_seq] != $num} { error "saw wrong request_seq in $obj" } elseif {[dict get $d command] != $cmd} { error "saw wrong command in $obj" } else { - return [list $obj $result] + return [list $d $result] } } else { - lappend result $obj + lappend result $d } } } @@ -210,15 +210,15 @@ proc dap_request_and_response {command {obj {}}} { # Like dap_request_and_response, but also checks that the response # indicates success. NAME is used to issue a test result. proc dap_check_request_and_response {name command {obj {}}} { - set result [dap_request_and_response $command $obj] - set d [namespace eval ton::2dict [lindex $result 0]] - if {[dict get $d success] != "true"} { - verbose "request failure: $result" + set response_and_events [dap_request_and_response $command $obj] + set response [lindex $response_and_events 0] + if {[dict get $response success] != "true"} { + verbose "request failure: $response" fail "$name success" return "" } pass "$name success" - return $result + return $response_and_events } # Start gdb, send a DAP initialization request and return the @@ -257,8 +257,7 @@ proc dap_shutdown {{name shutdown}} { # Search the event list EVENTS for an output event matching the regexp # RX. Pass the test NAME if found, fail if not. proc dap_search_output {name rx events} { - foreach event $events { - set d [namespace eval ton::2dict $event] + foreach d $events { if {[dict get $d type] != "event" || [dict get $d event] != "output"} { continue @@ -271,10 +270,9 @@ proc dap_search_output {name rx events} { fail $name } -# Check that OBJ (a single TON object) has values that match the +# Check that D (a dict object) has values that match the # key/value pairs given in ARGS. NAME is used as the test name. -proc dap_match_values {name obj args} { - set d [namespace eval ton::2dict $obj] +proc dap_match_values {name d args} { foreach {key value} $args { if {[eval dict get [list $d] $key] != $value} { fail "$name (checking $key)" @@ -290,21 +288,21 @@ proc _dap_read_event {type} { while 1 { # We don't do any extra error checking here for the time # being; we'll just get a timeout thrown instead. - set obj [_dap_read_json] - set d [namespace eval ton::2dict $obj] + set d [_dap_read_json] if {[dict get $d type] == "event" && [dict get $d event] == $type} { - return $obj + return $d } } } # Read JSON objects looking for an event whose "event" field is TYPE. +# # NAME is used as the test name; it defaults to TYPE. Extra arguments # 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 TON object for the chosen event, or empty string on -# error. +# +# Returns the dict for the chosen event, or empty string on error. proc dap_read_event {name type args} { if {$name == ""} { set name $type @@ -320,7 +318,7 @@ proc dap_read_event {name type args} { # breakpoint is created. OBJ is an object as returned by # dap_check_request_and_response. proc dap_get_breakpoint_number {obj} { - set d [namespace eval ton::2dict [lindex $obj 0]] + set d [lindex $obj 0] set bplist [dict get $d body breakpoints] return [dict get [lindex $bplist 0] id] } From patchwork Fri Jan 6 18:57:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62812 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0623438493DB for ; Fri, 6 Jan 2023 18:58:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0623438493DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031518; bh=BzNWSN7HCIq20mneLG2UZjJQgomhHFTXUipEcAWEDNo=; 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=W+SkfNk+QGvCIy00uly9rzpLPozyJCXqHyqLocff8/lQbQzamDWcwUZpe6KnL1a1j hCnjiTJAQHQpZT6qqh416Z7V1U3bq4ByTiO9xFgc+aH7Q7SyW6oUW5QmEXag3IF3EX SwICfpUcyq37oSaXiCvRD0KCBBpAgY9BWlEDKrUE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 904503858C1F for ; Fri, 6 Jan 2023 18:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 904503858C1F X-ASG-Debug-ID: 1673031451-0c856e762a4b70d0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id ZIB0ODESH4zLZDUx (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 43F2A441D64; 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 7/9] gdb/testsuite/dap: rename dap_read_event to dap_wait_for_event_and_check Date: Fri, 6 Jan 2023 13:57:27 -0500 X-ASG-Orig-Subj: [PATCH 7/9] gdb/testsuite/dap: rename dap_read_event to dap_wait_for_event_and_check Message-Id: <20230106185729.42372-8-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 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: 3268 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I think that name describes a bit better what the proc does, it is similar to "wait_for" in tuiterm.exp. Change-Id: Ie55aa011e6595dd1b5a874db13881ba572ace419 --- gdb/testsuite/gdb.dap/basic-dap.exp | 10 +++++----- gdb/testsuite/lib/dap-support.exp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index 68d0440f692..795702a5a8f 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -88,9 +88,9 @@ set bplist [dict get $response body breakpoints] set insn_pc [dict get [lindex $bplist 0] instructionReference] dap_check_request_and_response "start inferior" configurationDone -dap_read_event "inferior started" thread "body reason" started +dap_wait_for_event_and_check "inferior started" thread "body reason" started -dap_read_event "stopped at function breakpoint" stopped \ +dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $fn_bpno @@ -100,7 +100,7 @@ dap_match_values "global value in function" [lindex $obj 0] \ "body result" 23 dap_check_request_and_response step stepIn {o threadId [i 1]} -dap_read_event "stopped after step" stopped "body reason" step +dap_wait_for_event_and_check "stopped after step" stopped "body reason" step set obj [dap_check_request_and_response "evaluate global second time" \ evaluate {o expression [s global_variable]}] @@ -108,12 +108,12 @@ dap_match_values "global value after step" [lindex $obj 0] \ "body result" 24 dap_check_request_and_response "continue to address" continue -dap_read_event "stopped at address breakpoint" stopped \ +dap_wait_for_event_and_check "stopped at address breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $insn_bpno dap_check_request_and_response "continue to line" continue -dap_read_event "stopped at line breakpoint" stopped \ +dap_wait_for_event_and_check "stopped at line breakpoint" stopped \ "body reason" breakpoint \ "body hitBreakpointIds" $line_bpno diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index ee55a4acc9c..179f675b4d8 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -284,7 +284,7 @@ proc dap_match_values {name d args} { # A helper for dap_read_event that reads events, looking for one # matching TYPE. -proc _dap_read_event {type} { +proc _dap_wait_for_event {type} { while 1 { # We don't do any extra error checking here for the time # being; we'll just get a timeout thrown instead. @@ -303,12 +303,12 @@ proc _dap_read_event {type} { # between a field name (in "dict get" form) and its expected value. # # Returns the dict for the chosen event, or empty string on error. -proc dap_read_event {name type args} { +proc dap_wait_for_event_and_check {name type args} { if {$name == ""} { set name $type } - set result [_dap_read_event $type] + set result [_dap_wait_for_event $type] eval dap_match_values [list $name $result] $args return $result From patchwork Fri Jan 6 18:57:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62814 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 80C09385B503 for ; Fri, 6 Jan 2023 18:58:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80C09385B503 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031534; 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=WJeeYaIEEa5C3SCCT6Ov35ACQ39pNBhXDH2Z+SdkT9LdvOWGLcbAkxjYl7cCor1fn qNbAdLeT2/1+79A9yY65Uj4TwIf2Ra9pbn/TIetlk8E1jIRtzdtRWV3/KSOKBVQwAj mp9/yHraYSKhE6gnO0nY8ndCsBfFOSt9u5xvrRKo= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@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 } From patchwork Fri Jan 6 18:57:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62815 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43693385B51C for ; Fri, 6 Jan 2023 18:59:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43693385B51C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673031546; bh=5jBdFDIi508gPc2ExC14dJJkT4HDSt513qlkuTbhLLI=; 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=NLEj5G062yEc7WSKbYLJ5yH8th7xUIkSRN0LctBsj2qZNTlvm9WrQwGa9JeIu43UG nOy4XXjTyOUmstrodLDOyqZsZe6YuwZSb4GnCTTU1U2ZwZlIa+xqx8eyYYu9SfpS40 PGnQ3SzXZFyp+8QfuzA2LcyirWO86XT4J3z0tQms= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 97CF23858C20 for ; Fri, 6 Jan 2023 18:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97CF23858C20 X-ASG-Debug-ID: 1673031451-0c856e762a4b70e0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id AbIzD3kaeanAC4t8 (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 7DBAC441D64; 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 9/9] gdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIE Date: Fri, 6 Jan 2023 13:57:29 -0500 X-ASG-Orig-Subj: [PATCH 9/9] gdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIE Message-Id: <20230106185729.42372-10-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 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-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 3033 X-Barracuda-BRTS-Status: 1 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-Spam-Status: No, score=-3498.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Prior to this patch, I get: >>> {"seq": 17, "type": "request", "command": "disassemble", "arguments": {"memoryReference": "0x115d", "instructionCount": 1}} Content-Length: 147 {"request_seq": 17, "type": "response", "command": "disassemble", "success": false, "message": "Cannot access memory at address 0x115d", "seq": 41}FAIL: gdb.dap/basic-dap.exp: disassemble one instruction success FAIL: gdb.dap/basic-dap.exp: instructions in disassemble output The problem is that the PC to disassemble is taken from the breakpoint insertion response, which happens before running. With a PIE executable, that PC is unrelocated, but the disassembly request happens after relocation. I chose to fix this by watching for a breakpoint changed event giving the new breakpoint address, and recording the address from there. I think this is an interesting way to fix it, because it adds a bit of test coverage, I don't think these events are checked right now. Other ways to fix it would be: - Get the address by doing a breakpoint insertion after the program is started, or some other way. - Do the disassembly by symbol instead of by address. - Do the disassembly before running the program. Change-Id: I3c396f796ac4c8b22e7dfd2fa1c5467f7a47e84e --- gdb/testsuite/gdb.dap/basic-dap.exp | 33 ++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index 795702a5a8f..5303e943320 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -90,9 +90,36 @@ set insn_pc [dict get [lindex $bplist 0] instructionReference] dap_check_request_and_response "start inferior" configurationDone dap_wait_for_event_and_check "inferior started" thread "body reason" started -dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ - "body reason" breakpoint \ - "body hitBreakpointIds" $fn_bpno +# While waiting for the stopped event, we might receive breakpoint changed +# events indicating some breakpoint addresses were relocated. Update INSN_PC +# if necessary. +lassign [dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ + "body reason" breakpoint \ + "body hitBreakpointIds" $fn_bpno] unused objs +foreach obj $objs { + if { [dict get $obj "type"] != "event" } { + continue + } + + if { [dict get $obj "event"] != "breakpoint" } { + continue + } + + set body [dict get $obj "body"] + + if { [dict get $body "reason"] != "changed" } { + continue + } + + set breakpoint [dict get $body "breakpoint"] + set breakpoint_id [dict get $breakpoint "id"] + + if { $breakpoint_id != $insn_bpno } { + continue + } + + set insn_pc [dict get $breakpoint "instructionReference"] +} set obj [dap_check_request_and_response "evaluate global in function" \ evaluate {o expression [s global_variable]}]