Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] [gdb/testsuite] Add gdb_exit_cleanup
Date: Sat, 19 Sep 2026 10:42:35 +0200	[thread overview]
Message-ID: <20260919084237.1045724-2-tdevries@suse.de> (raw)
In-Reply-To: <20260919084237.1045724-1-tdevries@suse.de>

Proc default_gdb_exit does two things:
- it tries to make gdb exit, and
- it does cleanup that needs doing after gdb exits.

Factor out the second part as new proc gdb_exit_cleanup.
---
 .../gdb.server/monitor-exit-quit.exp          |  7 +-----
 gdb/testsuite/lib/gdb.exp                     | 23 ++++++++++++-------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/gdb/testsuite/gdb.server/monitor-exit-quit.exp b/gdb/testsuite/gdb.server/monitor-exit-quit.exp
index cb90169ef0c..75c3e6e2221 100644
--- a/gdb/testsuite/gdb.server/monitor-exit-quit.exp
+++ b/gdb/testsuite/gdb.server/monitor-exit-quit.exp
@@ -70,10 +70,5 @@ gdb_test_multiple "quit" "" {
 
 # Cleanup, as in default_gdb_exit.
 if { $do_cleanup } {
-    if { ![is_remote host] } {
-	    remote_close host
-    }
-    unset gdb_spawn_id
-    unset ::gdb_tty_name
-    unset inferior_spawn_id
+    gdb_exit_cleanup
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1ebdaf6ba10..7bdc5dad0a7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2505,6 +2505,20 @@ proc gdb_reinitialize_dir { subdir } {
     }
 }
 
+# Clean up after the current gdb instance that has exited.
+
+proc gdb_exit_cleanup {} {
+    if {![is_remote host]} {
+	if {[catch { remote_close host } message]} {
+	    warning "closing gdb failed with: $message"
+	}
+    }
+
+    unset ::gdb_spawn_id
+    unset ::gdb_tty_name
+    unset ::inferior_spawn_id
+}
+
 #
 # gdb_exit -- exit the GDB, killing the target program if necessary
 #
@@ -2547,14 +2561,7 @@ proc default_gdb_exit {} {
 	}
     }
 
-    if {![is_remote host]} {
-	if {[catch { remote_close host } message]} {
-	    warning "closing gdb failed with: $message"
-	}
-    }
-    unset gdb_spawn_id
-    unset ::gdb_tty_name
-    unset inferior_spawn_id
+    gdb_exit_cleanup
 }
 
 # Load a file into the debugger.
-- 
2.51.0


  reply	other threads:[~2026-09-19  8:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19  8:42 [PATCH 0/3] [gdb/testsuite] Fix gdb.base/quit-live.exp for remote host Tom de Vries
2026-09-19  8:42 ` Tom de Vries [this message]
2026-09-27  8:52   ` [PATCH 1/3] [gdb/testsuite] Add gdb_exit_cleanup Andrew Burgess
2026-09-19  8:42 ` [PATCH 2/3] [gdb/testsuite] Use gdb_exit_cleanup a bit more Tom de Vries
2026-09-27  8:52   ` Andrew Burgess
2026-09-28  8:59     ` Tom de Vries
2026-09-19  8:42 ` [PATCH 3/3] [gdb/testsuite] Fix gdb.base/quit-live.exp for remote host Tom de Vries

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=20260919084237.1045724-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --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