Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] Adjust gdb.threads/schedlock.exp for Cygwin
Date: Tue,  5 May 2026 13:42:08 +0100	[thread overview]
Message-ID: <20260505124210.1450101-2-pedro@palves.net> (raw)
In-Reply-To: <20260505124210.1450101-1-pedro@palves.net>

This commit adjusts gdb.threads/schedlock.exp to work on Cygwin too.
The main difference to other systems is that on Windows, a Ctrl-C in
the terminal results in Windows injecting a new thread in the inferior
to report a EXCEPTION_DEBUG_EVENT/DBG_CONTROL_C event.  That means
that even with schedlock on, Ctrl-C always switches focus to a
different thread.

With this, gdb.threads/schedlock.exp passes cleanly on Cygwin.

Change-Id: I574c702d370da6eaf92e82ce81efe1a44660b24f
commit-id: f96fcdea
---
 gdb/testsuite/gdb.threads/schedlock.exp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index eeca3f8fd0f..169f6876b62 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -105,6 +105,17 @@ proc goto_loop { msg } {
 }
 
 proc my_continue { msg } {
+
+    # On Cygwin, a Ctrl-C in the terminal results in Windows injecting
+    # a new thread in the inferior to report a
+    # EXCEPTION_DEBUG_EVENT/DBG_CONTROL_C event.  That means that even
+    # with schedlock on, Ctrl-C always switches focus to a different
+    # thread.  Hide that fact here by saving/restoring the current
+    # thread.
+    if {[istarget *-*-cygwin*]} {
+	set gdb_thr [get_valueof "" "\$_thread" 0 "save current gdb thread"]
+    }
+
     set test "continue ($msg)"
     gdb_test_multiple "continue" $test {
 	-re "Continuing" {
@@ -114,6 +125,13 @@ proc my_continue { msg } {
 
     stop_process "stop all threads ($msg)"
 
+    # See above.  This must be done before goto_loop, otherwise with
+    # schedlock on, we'd be resuming the injected Ctrl-C thread.
+    if {[istarget *-*-cygwin*]} {
+	gdb_test "thread $gdb_thr" "Switching to thread .*" \
+	    "restore current gdb thread"
+    }
+
     goto_loop $msg
 }
 
@@ -201,6 +219,9 @@ if { $bad == 0 } {
 # before the command was run.  BEFORE_ARGS is the value of the
 # thread's args before the command was run.  LOCKED indicates whether
 # we expect threads other than the selected thread remained locked.
+#
+# Note, on Cygwin, the "we didn't switch threads" test is pointless,
+# see my_continue.
 
 proc check_result { cmd before_thread before_args locked } {
     global NUM
-- 
2.53.0


  reply	other threads:[~2026-05-05 12:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05 12:42 [PATCH 0/3] Adjust a few gdb.threads/ testcases " Pedro Alves
2026-05-05 12:42 ` Pedro Alves [this message]
2026-05-05 12:42 ` [PATCH 2/3] Adjust gdb.threads/multiple-successive-infcall.exp " Pedro Alves
2026-05-05 12:42 ` [PATCH 3/3] Adjust gdb.threads/step-over-trips-on-watchpoint.exp " Pedro Alves

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=20260505124210.1450101-2-pedro@palves.net \
    --to=pedro@palves.net \
    --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