Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stephan Rohr <stephan.rohr@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/1] gdb, testsuite: unify 'Switching to thread' message
Date: Tue, 16 Jun 2026 13:04:19 +0000	[thread overview]
Message-ID: <20260616130419.121388-1-stephan.rohr@intel.com> (raw)

From: "Rohr, Stephan" <stephan.rohr@intel.com>

The 'normal_stop ()' function in infrun prints

  [Switching to Thread 0x155554dff6c0 (LWP 77976)]

on thread switch.  The 'print_selected_thread_frame ()' function
in thread.c prints

  [Switching to thread 2 (Thread 0x155554dff6c0 (LWP 96643))]

Ensure consistent output by updating the thread switch message in
'normal_stop ()'.
---
 gdb/infrun.c                                                 | 3 ++-
 gdb/testsuite/gdb.replay/missing-thread.exp                  | 2 +-
 .../gdb.threads/infcall-from-bp-cond-other-thread-event.exp  | 2 +-
 gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp   | 2 +-
 gdb/testsuite/gdb.threads/manythreads.exp                    | 2 +-
 gdb/testsuite/gdb.threads/stepi-over-clone.exp               | 5 +++--
 6 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 22a05608486..f17c9758918 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9762,7 +9762,8 @@ normal_stop ()
 	  SWITCH_THRU_ALL_UIS ()
 	    {
 	      target_terminal::ours_for_output ();
-	      gdb_printf (_("[Switching to %s]\n"),
+	      gdb_printf (_("[Switching to thread %s (%s)]\n"),
+			  print_thread_id (inferior_thread ()),
 			  target_pid_to_str (inferior_ptid).c_str ());
 	      annotate_thread_changed ();
 	    }
diff --git a/gdb/testsuite/gdb.replay/missing-thread.exp b/gdb/testsuite/gdb.replay/missing-thread.exp
index 6a4eaaaafcc..e3844c82453 100644
--- a/gdb/testsuite/gdb.replay/missing-thread.exp
+++ b/gdb/testsuite/gdb.replay/missing-thread.exp
@@ -162,7 +162,7 @@ proc_with_prefix replay_with_log { remote_log expect_error non_stop } {
 		 "warning: command aborted, Thread \[^\r\n\]+ unexpectedly exited after signal stop event"]
 
 	if { !$non_stop } {
-	    lappend expected_output "\\\[Switching to Thread \[^\r\n\]+\\\]"
+	    lappend expected_output "\\\[Switching to thread \[^\r\n\]+\\\]"
 	}
 
 	gdb_test "continue" [multi_line {*}$expected_output]
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp
index 530f231d49c..fa13a61e746 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp
@@ -132,7 +132,7 @@ proc run_condition_test { stop_at_cond other_thread_signal \
 		 "Continuing\\." \
 		 ".*" \
 		 "Thread ${::decimal} \"\[^\"\r\n\]+\" received signal SIGSEGV, Segmentation fault\\." \
-		 "\\\[Switching to Thread \[^\r\n\]+\\\]" \
+		 "\\\[Switching to thread \[^\r\n\]+\\\]" \
 		 "${::hex} in worker_func \[^\r\n\]+:${::signal_line}" \
 		 "${::decimal}\\s+\[^\r\n\]+Signal here\[^\r\n\]+"] \
 	    "received signal in other thread"
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp
index 56c2d60f163..041bf2076c4 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp
@@ -155,7 +155,7 @@ proc run_test { target_async target_non_stop non_stop other_thread_bp unwind } {
 		 "Continuing\\." \
 		 ".*" \
 		 "Thread ${::decimal} \"infcall-from-bp\" received signal SIGSEGV, Segmentation fault\\." \
-		 "\\\[Switching to Thread \[^\r\n\]+\\\]" \
+		 "\\\[Switching to thread \[^\r\n\]+\\\]" \
 		 "${::hex} in do_segfault \\(\\) at \[^\r\n\]+:${::segfault_line}" \
 		 "${::decimal}\\s+\[^\r\n\]+Segfault here\[^\r\n\]+"] \
 	    "hit the segfault"
diff --git a/gdb/testsuite/gdb.threads/manythreads.exp b/gdb/testsuite/gdb.threads/manythreads.exp
index aabbb24b4d9..ba665df24ae 100644
--- a/gdb/testsuite/gdb.threads/manythreads.exp
+++ b/gdb/testsuite/gdb.threads/manythreads.exp
@@ -84,7 +84,7 @@ proc interrupt_and_wait { message } {
 	    #  [New Thread NNN]
 	    #  [New Thread NNN]
 	    #  ... pages of new threads output ...
-	    #  [Switching to Thread NNN]
+	    #  [Switching to thread NNN]
 	    #  foo () at foo.c:31
 	    #  31      bar ();
 	    #
diff --git a/gdb/testsuite/gdb.threads/stepi-over-clone.exp b/gdb/testsuite/gdb.threads/stepi-over-clone.exp
index 7a887d7d184..af2fa6d10bb 100644
--- a/gdb/testsuite/gdb.threads/stepi-over-clone.exp
+++ b/gdb/testsuite/gdb.threads/stepi-over-clone.exp
@@ -173,9 +173,10 @@ proc test {non_stop displaced third_thread} {
 		    incr stepi_new_thread_count
 		    exp_continue
 		}
-		-re "^\\\[Switching to Thread\[^\r\n\]+\\\]\r\n" {
+		-re "^\\\[Switching to thread\[^\r\n\]+\\\]\r\n" {
+		    puts "XXX: Consume switching to thread line"
 		    verbose -log "XXX: Consume switching to thread line"
-		    exp_continue
+		    fail $gdb_test_name
 		}
 		-re "^\\s*\r\n" {
 		    verbose -log "XXX: Consume blank line"
-- 
2.43.0

Intel Deutschland GmbH

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


             reply	other threads:[~2026-06-16 13:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 13:04 Stephan Rohr [this message]
2026-06-17 19:23 ` 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=20260616130419.121388-1-stephan.rohr@intel.com \
    --to=stephan.rohr@intel.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