public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
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	[thread overview]
Message-ID: <20230106185729.42372-5-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230106185729.42372-1-simon.marchi@efficios.com>

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"
-- 
2.38.1


  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 ` Simon Marchi [this message]
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 ` [PATCH 8/9] gdb/testsuite/dap: make dap_wait_for_event_and_check return preceding messages Simon Marchi
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-5-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).