public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/4] Check for rogue DAP exceptions in test suite
Date: Tue, 12 Dec 2023 10:44:45 -0700	[thread overview]
Message-ID: <20231212-dap-no-test-exceptions-v1-4-af0e33f10093@adacore.com> (raw)
In-Reply-To: <20231212-dap-no-test-exceptions-v1-0-af0e33f10093@adacore.com>

This changes the test suite to look for rogue DAP exceptions in the
log file, and issue a "fail" if one is found.
---
 gdb/testsuite/lib/dap-support.exp | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index b9ac314fee5..4aaae637c45 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -16,6 +16,11 @@
 # The JSON parser.
 load_lib ton.tcl
 
+# The sequence number for the currently-executing instance of gdb
+# launched via dap_gdb_start.  This is used for log-file checking
+# after the run is complete.  Zero means gdb hasn't started yet.
+set dap_gdb_instance 0
+
 # The sequence number for the next DAP request.  This is used by the
 # automatic sequence-counting code below.  It is reset each time GDB
 # is restarted.
@@ -29,10 +34,13 @@ proc dap_gdb_start {} {
 
     gdb_stdin_log_init
 
+    global dap_gdb_instance
+    incr dap_gdb_instance
+
     global GDBFLAGS stty_init
     save_vars { GDBFLAGS stty_init } {
 	set stty_init "-echo raw"
-	set logfile [standard_output_file "dap.log.$gdb_instances"]
+	set logfile [standard_output_file "dap.log.$dap_gdb_instance"]
 	append GDBFLAGS " -iex \"set debug dap-log-file $logfile\" -q -i=dap"
 	set res [gdb_spawn]
 	if {$res != 0} {
@@ -325,11 +333,35 @@ proc dap_target_remote {target} {
 		[format {o target [s %s]} $target]]
 }
 
+# Read the most recent DAP log file and check it for exceptions.
+proc _dap_check_log_file {} {
+    global dap_gdb_instance
+
+    set fd [open [standard_output_file "dap.log.$dap_gdb_instance"]]
+    set contents [read $fd]
+    close $fd
+
+    set ok 1
+    foreach line [split $contents "\n"] {
+	if {[regexp "^Traceback" $line]} {
+	    set ok 0
+	    break
+	}
+    }
+
+    if {$ok} {
+	pass "exceptions in log file"
+    } else {
+	fail "exceptions in log file"
+    }
+}
+
 # Cleanly shut down gdb.  TERMINATE is passed as the terminateDebuggee
 # parameter to the request.
 proc dap_shutdown {{terminate false}} {
     dap_check_request_and_response "shutdown" disconnect \
 	[format {o terminateDebuggee [l %s]} $terminate]
+    _dap_check_log_file
 }
 
 # Search the event list EVENTS for an output event matching the regexp

-- 
2.43.0


  parent reply	other threads:[~2023-12-12 17:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 17:44 [PATCH 0/4] Check for rogue DAP exceptions Tom Tromey
2023-12-12 17:44 ` [PATCH 1/4] Introduce and use DAPException Tom Tromey
2023-12-12 17:44 ` [PATCH 2/4] Add DAP log level parameter Tom Tromey
2023-12-12 18:39   ` Eli Zaretskii
2023-12-14 19:02     ` Tom Tromey
2023-12-13 16:35   ` Kévin Le Gouguec
2023-12-14 19:06     ` Tom Tromey
2023-12-12 17:44 ` [PATCH 3/4] Avoid exception from attach in DAP Tom Tromey
2023-12-13 16:36   ` Kévin Le Gouguec
2023-12-14 18:52     ` Tom Tromey
2023-12-12 17:44 ` Tom Tromey [this message]
2023-12-13 16:36 ` [PATCH 0/4] Check for rogue DAP exceptions Kévin Le Gouguec
2023-12-22 16:57 ` Tom Tromey

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=20231212-dap-no-test-exceptions-v1-4-af0e33f10093@adacore.com \
    --to=tromey@adacore.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).