* [PATCH 1/1] gdb, testsuite: unify 'Switching to thread' message
@ 2026-06-16 13:04 Stephan Rohr
2026-06-17 19:23 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Stephan Rohr @ 2026-06-16 13:04 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] gdb, testsuite: unify 'Switching to thread' message
2026-06-16 13:04 [PATCH 1/1] gdb, testsuite: unify 'Switching to thread' message Stephan Rohr
@ 2026-06-17 19:23 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2026-06-17 19:23 UTC (permalink / raw)
To: Stephan Rohr; +Cc: gdb-patches
>>>>> Stephan Rohr <stephan.rohr@intel.com> writes:
> 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 ()'.
I'm in favor of uniformity so I'm in favor of the core part of the
patch. See below.
Also see commit f99be06d where some other things display thread info
differently:
[New Thread 0x7ffff7cbe6c0 (LWP 1267702) (id 2)]
[Thread 0x7ffff6cbd6c0 (LWP 1267703) (id 3) exited]
Maybe we ought to make those more uniform as well.
You don't have to do this in order to land this patch though.
> - -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
This seems wrong. At least the puts is clearly just for debugging
(unclear why the verbose wasn't enough); but I think the 'fail' is a
leftover too.
Ok with this hunk fixed up.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-17 19:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-16 13:04 [PATCH 1/1] gdb, testsuite: unify 'Switching to thread' message Stephan Rohr
2026-06-17 19:23 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox