Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
@ 2023-04-18 20:13 John Baldwin
  2023-05-08 16:19 ` [PING] " John Baldwin
  2023-05-09 19:01 ` Simon Marchi via Gdb-patches
  0 siblings, 2 replies; 11+ messages in thread
From: John Baldwin @ 2023-04-18 20:13 UTC (permalink / raw)
  To: gdb-patches

Several tests assume that the first word after a thread ID in 'info
threads' output is "Thread".  However, several targets use "LWP"
instead such as the FreeBSD and NetBSD native targets.  The Linux
native target also uses "LWP" if libthread_db is not being used.

Add a tdlabel_re global variable as a regular-expression for a thread
label in `info threads' that matches either "thread" or "LWP".

Some other tests in the tree don't require a specific word, and
some targets may use other first words (e.g. OpenBSD uses "thread"
and Ravenscar threads use "Ravenscar Thread").
---
 .../gdb.multi/multi-target-thread-find.exp       |  2 +-
 gdb/testsuite/gdb.python/py-thrhandle.exp        |  2 +-
 .../gdb.server/stop-reply-no-thread-multi.exp    |  8 ++++----
 gdb/testsuite/gdb.threads/execl.exp              |  6 +++---
 gdb/testsuite/gdb.threads/fork-child-threads.exp |  2 +-
 .../gdb.threads/fork-thread-pending.exp          | 16 ++++++++--------
 .../gdb.threads/info-threads-cur-sal.exp         |  8 ++++----
 .../gdb.threads/interrupt-while-step-over.exp    |  3 ++-
 gdb/testsuite/gdb.threads/leader-exit.exp        |  2 +-
 gdb/testsuite/gdb.threads/manythreads.exp        |  2 +-
 .../gdb.threads/no-unwaited-for-left.exp         |  4 ++--
 gdb/testsuite/gdb.threads/non-ldr-exc-2.exp      |  3 ++-
 gdb/testsuite/gdb.threads/pthreads.exp           |  9 +++++----
 .../gdb.threads/signal-command-handle-nopass.exp |  4 ++--
 .../signal-command-multiple-signals-pending.exp  |  4 ++--
 .../signal-delivered-right-thread.exp            |  4 ++--
 gdb/testsuite/gdb.threads/signal-sigtrap.exp     |  6 +++---
 gdb/testsuite/gdb.threads/staticthreads.exp      |  2 +-
 gdb/testsuite/gdb.threads/thread-specific-bp.exp |  3 ++-
 gdb/testsuite/gdb.threads/thread-specific.exp    |  5 +++--
 gdb/testsuite/gdb.threads/tls.exp                | 12 ++++++------
 gdb/testsuite/gdb.trace/report.exp               |  2 +-
 gdb/testsuite/gdb.trace/strace.exp               |  2 +-
 gdb/testsuite/lib/gdb.exp                        |  4 ++++
 24 files changed, 62 insertions(+), 53 deletions(-)

diff --git a/gdb/testsuite/gdb.multi/multi-target-thread-find.exp b/gdb/testsuite/gdb.multi/multi-target-thread-find.exp
index 820190224ba..03b38eb25f2 100644
--- a/gdb/testsuite/gdb.multi/multi-target-thread-find.exp
+++ b/gdb/testsuite/gdb.multi/multi-target-thread-find.exp
@@ -50,7 +50,7 @@ proc test_thread_find {} {
     }
     set any "\[^\r\n\]*"
     gdb_test_multiple "info threads" "collect thread id" {
-	-re ". ($decimal).$decimal  (Thread ${any}) \"threadname_\[0-9\]+\" $any" {
+	-re ". ($decimal).$decimal  (${tdlabel_re} ${any}) \"threadname_\[0-9\]+\" $any" {
 	    set thr_num $expect_out(1,string)
 	    set target_id($thr_num) $expect_out(2,string)
 	    exp_continue
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
index e8004c77ad1..286bbe619bf 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.exp
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -63,7 +63,7 @@ gdb_test "continue" \
 # reported in the "Id" column.
 
 gdb_test "info threads"  \
-	{.*[\r\n]+\* +([0-9]+) +Thread[^\r\n]* do_something \(n=\1\) at.*}
+	[format {.*[\r\n]+\* +([0-9]+) +%s[^\r\n]* do_something \(n=\1\) at.*} $tdlabel_re]
 
 # Check for expected results when passing a valid thread handle to
 # thread_from_handle().
diff --git a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
index cf6be64fab3..6d7a7d3f61e 100644
--- a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
+++ b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
@@ -84,13 +84,13 @@ proc run_test { target_non_stop disable_feature } {
 
     # There should be only one thread listed at this point.
     gdb_test_multiple "info threads" "" {
-	-re "2 Thread.*$gdb_prompt $" {
+	-re "2 ${tdlabel_re}.*$gdb_prompt $" {
 	    fail $gdb_test_name
 	}
 	-re "has terminated.*$gdb_prompt $" {
 	    fail $gdb_test_name
 	}
-	-re "\\\* 1\[\t \]*Thread\[^\r\n\]*\r\n$gdb_prompt $" {
+	-re "\\\* 1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n$gdb_prompt $" {
 	    pass $gdb_test_name
 	}
     }
@@ -100,7 +100,7 @@ proc run_test { target_non_stop disable_feature } {
 
     # There should be two threads at this point with thread 1 selected.
     gdb_test "info threads" \
-	"\\\* 1\[\t \]*Thread\[^\r\n\]*\r\n  2\[\t \]*Thread\[^\r\n\]*" \
+	"\\\* 1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n  2\[\t \]*${tdlabel_re}\[^\r\n\]*" \
 	"second thread should now exist"
 
     # Switch threads.
@@ -124,7 +124,7 @@ proc run_test { target_non_stop disable_feature } {
 
     # Check that thread 2 is still selected.
     gdb_test "info threads" \
-	"  1\[\t \]*Thread\[^\r\n\]*\r\n\\\* 2\[\t \]*Thread\[^\r\n\]*" \
+	"  1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n\\\* 2\[\t \]*${tdlabel_re}\[^\r\n\]*" \
 	"second thread should still be selected after stepi"
 
     # Turn scheduler locking off again so that when we continue all
diff --git a/gdb/testsuite/gdb.threads/execl.exp b/gdb/testsuite/gdb.threads/execl.exp
index 92c6a6c8d81..283f7ab01d2 100644
--- a/gdb/testsuite/gdb.threads/execl.exp
+++ b/gdb/testsuite/gdb.threads/execl.exp
@@ -43,7 +43,7 @@ gdb_test "b [gdb_get_line_number "breakpoint here"]" \
 
 gdb_test "continue" ".*breakpoint here.*" "continue to exec"
 
-gdb_test "info threads" "1 *Thread.*2 *Thread.*3 *Thread.*" "info threads before exec"
+gdb_test "info threads" "1 *${tdlabel_re}.*2 *${tdlabel_re}.*3 *${tdlabel_re}.*" "info threads before exec"
 
 # Work around PR25656, where the breakpoint above sets 2 breakpoint locations:
 # - one on gdb.threads/execl.c:$linenumber, and
@@ -58,11 +58,11 @@ gdb_test "continue" ".*Breakpoint 1, main.*" \
     "continue across exec"
 
 gdb_test_multiple "info threads" "info threads after exec" {
-    -re "2 *Thread .*$gdb_prompt $" {
+    -re "2 *${tdlabel_re} .*$gdb_prompt $" {
 	# Old threads left behind.
 	fail "$gdb_test_name"
     }
-    -re "4 *Thread .*$gdb_prompt $" {
+    -re "4 *${tdlabel_re} .*$gdb_prompt $" {
 	# New threads registered.
 	fail "$gdb_test_name"
     }
diff --git a/gdb/testsuite/gdb.threads/fork-child-threads.exp b/gdb/testsuite/gdb.threads/fork-child-threads.exp
index d0d13a29fdf..92e2a59bf8b 100644
--- a/gdb/testsuite/gdb.threads/fork-child-threads.exp
+++ b/gdb/testsuite/gdb.threads/fork-child-threads.exp
@@ -44,4 +44,4 @@ gdb_test "continue" "Breakpoint 2, start.*" "get to the spawned thread"
 # * 3 Thread 0x40a00950 (LWP 5553)  start (arg=0x0) at ../.././gdb/testsuite/gdb.threads/fork-child-threads.c:28
 #   2 Thread 0x2aaaaaac3000 (LWP 5552)  0x00000031674076dd in pthread_join (threadid=<optimized out>, thread_return=<optimized out>) at pthread_join.c:89
 
-gdb_test "info threads" " Thread .* Thread .*" "two threads found"
+gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .*" "two threads found"
diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.exp b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
index 3ab2d31402c..a1f056e2035 100644
--- a/gdb/testsuite/gdb.threads/fork-thread-pending.exp
+++ b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
@@ -37,7 +37,7 @@ gdb_breakpoint "start" "" "1, set breakpoint at start"
 
 gdb_test "continue" "Catchpoint.*" "1, get to the fork event"
 
-gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "1, multiple threads found"
+gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "1, multiple threads found"
 
 gdb_test "thread 1" ".*" "1, switched away from event thread"
 
@@ -45,10 +45,10 @@ gdb_test "continue" "Not resuming.*" "1, refused to resume"
 
 set test "1, followed to the child, found one thread"
 gdb_test_multiple "info threads" "metest" {
-    -re " Thread .* Thread .*$gdb_prompt $" {
+    -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
 	fail "$test"
     }
-    -re " Thread .*$gdb_prompt $" {
+    -re " ${tdlabel_re} .*$gdb_prompt $" {
 	pass "$test"
     }
     -re "$gdb_prompt $" {
@@ -63,10 +63,10 @@ gdb_test "continue" "Breakpoint 3, start.*" "1, get to the spawned thread in for
 
 set test "1, followed to the child, found two threads"
 gdb_test_multiple "info threads" "$test" {
-    -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
+    -re " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
 	fail "$test"
     }
-    -re " Thread .* Thread .*$gdb_prompt $" {
+    -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
 	pass "$test"
     }
     -re "$gdb_prompt $" {
@@ -90,16 +90,16 @@ gdb_breakpoint "start"
 
 gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
 
-gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "2, multiple threads found"
+gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "2, multiple threads found"
 
 gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
 
 set test "2, followed to the child, found two threads"
 gdb_test_multiple "info threads" "$test" {
-    -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
+    -re " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
 	fail "$test"
     }
-    -re " Thread .* Thread .*$gdb_prompt $" {
+    -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
 	pass "$test"
     }
     -re "$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
index 0614b9cd664..ce14d677c98 100644
--- a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
+++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
@@ -43,8 +43,8 @@ gdb_test "list $line" \
 gdb_test "info threads" \
     [multi_line \
 	 "\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*" \
-	 "  1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
-	 "\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*"] \
+	 "  1 *${tdlabel_re} \[^\r\n\]* .* \[^\r\n\]*" \
+	 "\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*"] \
     "info threads before break"
 
 # Check that "break" is still operating on the same file by default.
@@ -53,8 +53,8 @@ gdb_test "break $line" ".*${srcfile2}.*" "break on line"
 gdb_test "info threads" \
     [multi_line \
 	 "\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*" \
-	 "  1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
-	 "\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*"] \
+	 "  1 *${tdlabel_re} \[^\r\n\]* .* \[^\r\n\]*" \
+	 "\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*"] \
     "info threads before list"
 
 # And that so is "list".
diff --git a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
index 0add65d3717..24a09ce9f94 100644
--- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
+++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
@@ -74,6 +74,7 @@ proc test_one_iteration {} {
     global gdb_prompt
     global NUM_THREADS
     global decimal
+    global tdlabel_re
 
     set saw_continuing 0
     set test "continue -a &"
@@ -145,7 +146,7 @@ proc test_one_iteration {} {
     set running_count 0
     set test "all threads are stopped"
     return_if_nonzero [gdb_test_multiple "info threads" $test {
-	-re "Thread \[^\r\n\]* \\(running\\)" {
+	-re "${tdlabel_re} \[^\r\n\]* \\(running\\)" {
 	    incr running_count
 	    exp_continue
 	}
diff --git a/gdb/testsuite/gdb.threads/leader-exit.exp b/gdb/testsuite/gdb.threads/leader-exit.exp
index 95811e975aa..feb1171b208 100644
--- a/gdb/testsuite/gdb.threads/leader-exit.exp
+++ b/gdb/testsuite/gdb.threads/leader-exit.exp
@@ -34,7 +34,7 @@ gdb_breakpoint [gdb_get_line_number "break-here"]
 gdb_continue_to_breakpoint "break-here" ".* break-here .*"
 
 gdb_test "info threads" \
-	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
+	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*" \
 	 "single thread has been left"
 
 # Test that ctrl-c works even if the leader has exited.
diff --git a/gdb/testsuite/gdb.threads/manythreads.exp b/gdb/testsuite/gdb.threads/manythreads.exp
index 5a176519051..87e75766328 100644
--- a/gdb/testsuite/gdb.threads/manythreads.exp
+++ b/gdb/testsuite/gdb.threads/manythreads.exp
@@ -112,7 +112,7 @@ interrupt_and_wait "stop threads 1"
 set cmd "info threads"
 set ok 0
 gdb_test_multiple $cmd $cmd {
-    -re " 1 *Thread " {
+    -re " 1 *${tdlabel_re} " {
 	set ok 1
 	exp_continue
     }
diff --git a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
index be372030cb8..3a0411ad73c 100644
--- a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
+++ b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
@@ -42,7 +42,7 @@ gdb_test "continue" \
     "continue stops when thread 2 exits"
 
 gdb_test "info threads" \
-	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *Thread \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 2> has terminated.*" \
+	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *${tdlabel_re} \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 2> has terminated.*" \
 	 "only main thread left, thread 2 terminated"
 
 # Select the main thread, let the third thread start, and stop at the
@@ -63,7 +63,7 @@ gdb_test "continue" \
     "continue stops when the main thread exits"
 
 gdb_test "info threads" \
-	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *Thread \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 1> has terminated.*" \
+	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *${tdlabel_re} \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 1> has terminated.*" \
 	 "only thread 3 left, main thread terminated"
 
 # Make sure thread apply all works when we have exited threads in the
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
index d51ae3115ef..04d34fc4e46 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
@@ -26,6 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
 
 proc do_test { lock_sched nonstop } {
     global executable
+    global tdlabel_re
 
     save_vars { GDBFLAGS } {
       append GDBFLAGS " -ex \"set non-stop $nonstop\""
@@ -44,7 +45,7 @@ proc do_test { lock_sched nonstop } {
     }
 
     gdb_test "info threads" \
-	"\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
+	"\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*" \
 	"single thread left"
 
     # Also test with sched-lock to make sure we can follow the
diff --git a/gdb/testsuite/gdb.threads/pthreads.exp b/gdb/testsuite/gdb.threads/pthreads.exp
index 41a7cb3800f..241166f83f0 100644
--- a/gdb/testsuite/gdb.threads/pthreads.exp
+++ b/gdb/testsuite/gdb.threads/pthreads.exp
@@ -123,11 +123,12 @@ proc test_startup {} {
     global srcdir srcfile gdb_prompt expect_out
     global horiz
     global main_id thread1_id thread2_id
+    global tdlabel_re
 
     # We should be able to do an info threads before starting any others.
     set return_me 1
     gdb_test_multiple "info threads" "info threads" {
-	-re ".*Thread.*main.*$gdb_prompt $" {
+	-re ".*${tdlabel_re}.*main.*$gdb_prompt $" {
 	    pass "info threads"
 	    set return_me 0
 	}
@@ -142,7 +143,7 @@ proc test_startup {} {
 
     # Extract the thread id number of main thread from "info threads" output.
     gdb_test_multiple "info threads" "get main thread id" {
-	-re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)" {
+	-re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}main.*)($gdb_prompt $)" {
 	}
     }
 
@@ -157,7 +158,7 @@ proc test_startup {} {
 
     # Extract the thread id number of thread 1 from "info threads" output.
     gdb_test_multiple "info threads" "get thread 1 id" {
-	-re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)" {
+	-re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}thread1.*)($gdb_prompt $)" {
 	}
     }
 
@@ -172,7 +173,7 @@ proc test_startup {} {
 
     # Extract the thread id number of thread 2 from "info threads" output.
     gdb_test_multiple "info threads" "get thread 2 id" {
-	-re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)" {
+	-re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}thread2.*)($gdb_prompt $)" {
 	}
     }
 
diff --git a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
index a099dbbb974..4455d984409 100644
--- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
+++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
@@ -32,7 +32,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 # request a signal be delivered with the "signal" command.
 
 proc test { step_over } {
-    global srcfile binfile
+    global srcfile binfile tdlabel_re
 
     with_test_prefix "step-over $step_over" {
 	clean_restart ${binfile}
@@ -59,7 +59,7 @@ proc test { step_over } {
 
 	gdb_test "thread 1" "Switching to thread 1.*"
 
-	set pattern "\\\* 1\[ \t\]+Thread.*"
+	set pattern "\\\* 1\[ \t\]+${tdlabel_re}.*"
 
 	gdb_test "info threads" $pattern "thread 1 selected"
 
diff --git a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
index 0802e403b5d..e808192969b 100644
--- a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
+++ b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
@@ -29,7 +29,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 # scheduler-locking) of the test to perform.
 
 proc test { schedlock } {
-    global srcfile binfile
+    global srcfile binfile tdlabel_re
 
     with_test_prefix "schedlock $schedlock" {
 	clean_restart ${binfile}
@@ -60,7 +60,7 @@ proc test { schedlock } {
 	gdb_test "continue" "all_threads_signalled.*" \
 	    "continue to all_threads signalled"
 
-	gdb_test "info threads" "\\\* 1\[ \t\]+Thread.*" "thread 1 selected"
+	gdb_test "info threads" "\\\* 1\[ \t\]+${tdlabel_re}.*" "thread 1 selected"
 
 	# With schedlock still enabled, let each thread report its
 	# signal.
diff --git a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
index 3407cfa0645..b78b92f3688 100644
--- a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
+++ b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 # with "signal 0" or "continue".
 
 proc test { command } {
-    global srcfile binfile
+    global srcfile binfile tdlabel_re
 
     with_test_prefix "$command" {
 	clean_restart ${binfile}
@@ -39,7 +39,7 @@ proc test { command } {
 
 	gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1"
 
-	set pattern "\\\* 2\[ \t\]+Thread.*"
+	set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
 
 	gdb_test "info threads" $pattern "thread 2 intercepted signal"
 
diff --git a/gdb/testsuite/gdb.threads/signal-sigtrap.exp b/gdb/testsuite/gdb.threads/signal-sigtrap.exp
index 1f524511ee9..f96e942ce54 100644
--- a/gdb/testsuite/gdb.threads/signal-sigtrap.exp
+++ b/gdb/testsuite/gdb.threads/signal-sigtrap.exp
@@ -29,7 +29,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile \
 # SIGTRAP.
 
 proc test { sigtrap_thread } {
-    global srcfile binfile
+    global srcfile binfile tdlabel_re
 
     with_test_prefix "sigtrap thread $sigtrap_thread" {
 	clean_restart ${binfile}
@@ -38,7 +38,7 @@ proc test { sigtrap_thread } {
 	    return 0
 	}
 
-	set pattern "\\\* 2\[ \t\]+Thread.*"
+	set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
 	gdb_test "info threads" $pattern "thread 2 hit breakpoint"
 
 	gdb_test "break sigtrap_handler" "Breakpoint .* at .*$srcfile.*"
@@ -54,7 +54,7 @@ proc test { sigtrap_thread } {
 	    "Continuing with signal SIGTRAP.*Breakpoint .* sigtrap_handler .*" \
 	    "signal SIGTRAP reaches handler"
 
-	set pattern "\\\* $sigtrap_thread\[ \t\]+Thread.*"
+	set pattern "\\\* $sigtrap_thread\[ \t\]+${tdlabel_re}.*"
 	gdb_test "info threads" $pattern "right thread got the signal"
     }
 }
diff --git a/gdb/testsuite/gdb.threads/staticthreads.exp b/gdb/testsuite/gdb.threads/staticthreads.exp
index 958aa2181b1..000d1f82070 100644
--- a/gdb/testsuite/gdb.threads/staticthreads.exp
+++ b/gdb/testsuite/gdb.threads/staticthreads.exp
@@ -73,7 +73,7 @@ gdb_test "continue" " .*sem_post .*" "handle $sig helps"
 
 set test "info threads"
 gdb_test_multiple "info threads" "$test" {
-    -re " Thread .*$gdb_prompt " {
+    -re " ${tdlabel_re} .*$gdb_prompt " {
 	pass "$test"
     }
     -re "$gdb_prompt " {
diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
index 2d1c71a68e3..575892d52c0 100644
--- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
@@ -29,11 +29,12 @@ if {[gdb_compile_pthreads \
 
 proc get_thread_id {func} {
     global gdb_prompt
+    global tdlabel_re
 
     set thre -1
     set test "get $func thread id"
     gdb_test_multiple "info threads" $test {
-	-re "(\[0-9\]+)\[^\n\r\]*Thread\[^\n\r\]*$func.*$gdb_prompt $" {
+	-re "(\[0-9\]+)\[^\n\r\]*${tdlabel_re}\[^\n\r\]*$func.*$gdb_prompt $" {
 	    # Get the thread's id.
 	    set thre $expect_out(1,string)
 	    pass $test
diff --git a/gdb/testsuite/gdb.threads/thread-specific.exp b/gdb/testsuite/gdb.threads/thread-specific.exp
index 9ba98ec6290..f95e249d03d 100644
--- a/gdb/testsuite/gdb.threads/thread-specific.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific.exp
@@ -28,6 +28,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
 proc get_thread_list { } {
   global gdb_prompt
   global expect_out
+  global tdlabel_re
 
   set thr_list ""
 
@@ -41,11 +42,11 @@ proc get_thread_list { } {
     -re "^ *Id *Target Id\[^\n\]*\n" {
       exp_continue
     }
-    -re "^\\*  *(\[0-9\]*) *Thread \[^\n\]*main\[^\n\]*\n" {
+    -re "^\\*  *(\[0-9\]*) *${tdlabel_re} \[^\n\]*main\[^\n\]*\n" {
       set thr_list "$expect_out(1,string) $thr_list"
       exp_continue
     }
-    -re "^  *(\[0-9\]*) *Thread \[^\n\]*\n" {
+    -re "^  *(\[0-9\]*) *${tdlabel_re} \[^\n\]*\n" {
       lappend thr_list $expect_out(1,string)
       exp_continue
     }
diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp
index 89f6fb89bac..f3c6288b142 100644
--- a/gdb/testsuite/gdb.threads/tls.exp
+++ b/gdb/testsuite/gdb.threads/tls.exp
@@ -207,19 +207,19 @@ gdb_expect {
     timeout { fail "continue to first thread (timeout)" }
 }
 
-gdb_test "info thread" ".*Thread.*spin.*" \
+gdb_test "info thread" ".*${tdlabel_re}.*spin.*" \
 	"at least one th in spin while stopped at first th"
 
 check_thread_local "first"
 
 gdb_test "continue" ".*Breakpoint 2.*tls value.*" "continue to second thread"
-gdb_test "info thread" "Thread.*spin.*" \
+gdb_test "info thread" "${tdlabel_re}.*spin.*" \
 	"at least one th in spin while stopped at second th"
 
 check_thread_local "second"
 
 gdb_test "continue" ".*Breakpoint 2.*tls value.*" "continue to third thread"
-gdb_test "info thread" ".*Thread.*spin.*" \
+gdb_test "info thread" ".*${tdlabel_re}.*spin.*" \
 	"at least one th in spin while stopped at third th"
 
 check_thread_local "third"
@@ -229,7 +229,7 @@ gdb_test "continue" ".*Breakpoint 3.*still alive.*" "continue to synch point"
 set no_of_threads 0
 send_gdb "info thread\n"
 gdb_expect {
-    -re "^info thread\[ \t\r\n\]+ *Id .*Frame\[ \t\r\n\]+.*(\[0-9\]+) *Thread\[^\r\n\]+\r\n$gdb_prompt $" {
+    -re "^info thread\[ \t\r\n\]+ *Id .*Frame\[ \t\r\n\]+.*(\[0-9\]+) *${tdlabel_re}\[^\r\n\]+\r\n$gdb_prompt $" {
 	   set no_of_threads $expect_out(1,string)
 	   pass "get number of threads"
         }
@@ -280,10 +280,10 @@ gdb_test "continue" ".*Breakpoint 4.*before exit.*" "threads exited"
 
 send_gdb "info thread\n" 
 gdb_expect {
-    -re ".* 1 *Thread.*2 *Thread.*$gdb_prompt $" {
+    -re ".* 1 *${tdlabel_re}.*2 *${tdlabel_re}.*$gdb_prompt $" {
         fail "too many threads left at end"
     }
-    -re ".*\\\* 1 *Thread.*main.*$gdb_prompt $" {
+    -re ".*\\\* 1 *${tdlabel_re}.*main.*$gdb_prompt $" {
         pass "expect only base thread at end"
     }
     -re ".*No stack.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
index 14db2511d40..a5b7ccf4ba5 100644
--- a/gdb/testsuite/gdb.trace/report.exp
+++ b/gdb/testsuite/gdb.trace/report.exp
@@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
 
 	# There is always a thread of an inferior, either a live one or
 	# a faked one.
-	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
+	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
 	gdb_test "info inferiors" "\\* 1    process ${decimal} \[ \t\]+\[^\r\n\]*\[ \t\]+${binfile}.*"
     }
 }
diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp
index bbdd8b78619..0ee55af923f 100644
--- a/gdb/testsuite/gdb.trace/strace.exp
+++ b/gdb/testsuite/gdb.trace/strace.exp
@@ -139,7 +139,7 @@ proc strace_info_marker { } {
 	# List all the thread.  It is expected to get three threads without
 	# any errors.
 	gdb_test_multiple "info threads 3 2 1" "info threads" {
-	    -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" {
+	    -re "3\[ \t\]+${tdlabel_re} .*2\[ \t\]+${tdlabel_re} .*1\[ \t\]+${tdlabel_re} .*${gdb_prompt} $" {
 		pass "info threads"
 	    }
 	}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7538071d1cf..3d2ead0103d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -281,6 +281,10 @@ set octal "\[0-7\]+"
 
 set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
 
+# A regular expression that matches the first word of a thread
+# description after the thread number info 'info threads'
+set tdlabel_re "(Thread|LWP)"
+
 # A regular expression that matches a value history number.
 # E.g., $1, $2, etc.
 set valnum_re "\\\$$decimal"
-- 
2.40.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PING] [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-04-18 20:13 [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
@ 2023-05-08 16:19 ` John Baldwin
  2023-05-09 19:01 ` Simon Marchi via Gdb-patches
  1 sibling, 0 replies; 11+ messages in thread
From: John Baldwin @ 2023-05-08 16:19 UTC (permalink / raw)
  To: gdb-patches

On 4/18/23 1:13 PM, John Baldwin wrote:
> Several tests assume that the first word after a thread ID in 'info
> threads' output is "Thread".  However, several targets use "LWP"
> instead such as the FreeBSD and NetBSD native targets.  The Linux
> native target also uses "LWP" if libthread_db is not being used.
> 
> Add a tdlabel_re global variable as a regular-expression for a thread
> label in `info threads' that matches either "thread" or "LWP".
> 
> Some other tests in the tree don't require a specific word, and
> some targets may use other first words (e.g. OpenBSD uses "thread"
> and Ravenscar threads use "Ravenscar Thread").
> ---
>   .../gdb.multi/multi-target-thread-find.exp       |  2 +-
>   gdb/testsuite/gdb.python/py-thrhandle.exp        |  2 +-
>   .../gdb.server/stop-reply-no-thread-multi.exp    |  8 ++++----
>   gdb/testsuite/gdb.threads/execl.exp              |  6 +++---
>   gdb/testsuite/gdb.threads/fork-child-threads.exp |  2 +-
>   .../gdb.threads/fork-thread-pending.exp          | 16 ++++++++--------
>   .../gdb.threads/info-threads-cur-sal.exp         |  8 ++++----
>   .../gdb.threads/interrupt-while-step-over.exp    |  3 ++-
>   gdb/testsuite/gdb.threads/leader-exit.exp        |  2 +-
>   gdb/testsuite/gdb.threads/manythreads.exp        |  2 +-
>   .../gdb.threads/no-unwaited-for-left.exp         |  4 ++--
>   gdb/testsuite/gdb.threads/non-ldr-exc-2.exp      |  3 ++-
>   gdb/testsuite/gdb.threads/pthreads.exp           |  9 +++++----
>   .../gdb.threads/signal-command-handle-nopass.exp |  4 ++--
>   .../signal-command-multiple-signals-pending.exp  |  4 ++--
>   .../signal-delivered-right-thread.exp            |  4 ++--
>   gdb/testsuite/gdb.threads/signal-sigtrap.exp     |  6 +++---
>   gdb/testsuite/gdb.threads/staticthreads.exp      |  2 +-
>   gdb/testsuite/gdb.threads/thread-specific-bp.exp |  3 ++-
>   gdb/testsuite/gdb.threads/thread-specific.exp    |  5 +++--
>   gdb/testsuite/gdb.threads/tls.exp                | 12 ++++++------
>   gdb/testsuite/gdb.trace/report.exp               |  2 +-
>   gdb/testsuite/gdb.trace/strace.exp               |  2 +-
>   gdb/testsuite/lib/gdb.exp                        |  4 ++++
>   24 files changed, 62 insertions(+), 53 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.multi/multi-target-thread-find.exp b/gdb/testsuite/gdb.multi/multi-target-thread-find.exp
> index 820190224ba..03b38eb25f2 100644
> --- a/gdb/testsuite/gdb.multi/multi-target-thread-find.exp
> +++ b/gdb/testsuite/gdb.multi/multi-target-thread-find.exp
> @@ -50,7 +50,7 @@ proc test_thread_find {} {
>       }
>       set any "\[^\r\n\]*"
>       gdb_test_multiple "info threads" "collect thread id" {
> -	-re ". ($decimal).$decimal  (Thread ${any}) \"threadname_\[0-9\]+\" $any" {
> +	-re ". ($decimal).$decimal  (${tdlabel_re} ${any}) \"threadname_\[0-9\]+\" $any" {
>   	    set thr_num $expect_out(1,string)
>   	    set target_id($thr_num) $expect_out(2,string)
>   	    exp_continue
> diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
> index e8004c77ad1..286bbe619bf 100644
> --- a/gdb/testsuite/gdb.python/py-thrhandle.exp
> +++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
> @@ -63,7 +63,7 @@ gdb_test "continue" \
>   # reported in the "Id" column.
>   
>   gdb_test "info threads"  \
> -	{.*[\r\n]+\* +([0-9]+) +Thread[^\r\n]* do_something \(n=\1\) at.*}
> +	[format {.*[\r\n]+\* +([0-9]+) +%s[^\r\n]* do_something \(n=\1\) at.*} $tdlabel_re]
>   
>   # Check for expected results when passing a valid thread handle to
>   # thread_from_handle().
> diff --git a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
> index cf6be64fab3..6d7a7d3f61e 100644
> --- a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
> +++ b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
> @@ -84,13 +84,13 @@ proc run_test { target_non_stop disable_feature } {
>   
>       # There should be only one thread listed at this point.
>       gdb_test_multiple "info threads" "" {
> -	-re "2 Thread.*$gdb_prompt $" {
> +	-re "2 ${tdlabel_re}.*$gdb_prompt $" {
>   	    fail $gdb_test_name
>   	}
>   	-re "has terminated.*$gdb_prompt $" {
>   	    fail $gdb_test_name
>   	}
> -	-re "\\\* 1\[\t \]*Thread\[^\r\n\]*\r\n$gdb_prompt $" {
> +	-re "\\\* 1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n$gdb_prompt $" {
>   	    pass $gdb_test_name
>   	}
>       }
> @@ -100,7 +100,7 @@ proc run_test { target_non_stop disable_feature } {
>   
>       # There should be two threads at this point with thread 1 selected.
>       gdb_test "info threads" \
> -	"\\\* 1\[\t \]*Thread\[^\r\n\]*\r\n  2\[\t \]*Thread\[^\r\n\]*" \
> +	"\\\* 1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n  2\[\t \]*${tdlabel_re}\[^\r\n\]*" \
>   	"second thread should now exist"
>   
>       # Switch threads.
> @@ -124,7 +124,7 @@ proc run_test { target_non_stop disable_feature } {
>   
>       # Check that thread 2 is still selected.
>       gdb_test "info threads" \
> -	"  1\[\t \]*Thread\[^\r\n\]*\r\n\\\* 2\[\t \]*Thread\[^\r\n\]*" \
> +	"  1\[\t \]*${tdlabel_re}\[^\r\n\]*\r\n\\\* 2\[\t \]*${tdlabel_re}\[^\r\n\]*" \
>   	"second thread should still be selected after stepi"
>   
>       # Turn scheduler locking off again so that when we continue all
> diff --git a/gdb/testsuite/gdb.threads/execl.exp b/gdb/testsuite/gdb.threads/execl.exp
> index 92c6a6c8d81..283f7ab01d2 100644
> --- a/gdb/testsuite/gdb.threads/execl.exp
> +++ b/gdb/testsuite/gdb.threads/execl.exp
> @@ -43,7 +43,7 @@ gdb_test "b [gdb_get_line_number "breakpoint here"]" \
>   
>   gdb_test "continue" ".*breakpoint here.*" "continue to exec"
>   
> -gdb_test "info threads" "1 *Thread.*2 *Thread.*3 *Thread.*" "info threads before exec"
> +gdb_test "info threads" "1 *${tdlabel_re}.*2 *${tdlabel_re}.*3 *${tdlabel_re}.*" "info threads before exec"
>   
>   # Work around PR25656, where the breakpoint above sets 2 breakpoint locations:
>   # - one on gdb.threads/execl.c:$linenumber, and
> @@ -58,11 +58,11 @@ gdb_test "continue" ".*Breakpoint 1, main.*" \
>       "continue across exec"
>   
>   gdb_test_multiple "info threads" "info threads after exec" {
> -    -re "2 *Thread .*$gdb_prompt $" {
> +    -re "2 *${tdlabel_re} .*$gdb_prompt $" {
>   	# Old threads left behind.
>   	fail "$gdb_test_name"
>       }
> -    -re "4 *Thread .*$gdb_prompt $" {
> +    -re "4 *${tdlabel_re} .*$gdb_prompt $" {
>   	# New threads registered.
>   	fail "$gdb_test_name"
>       }
> diff --git a/gdb/testsuite/gdb.threads/fork-child-threads.exp b/gdb/testsuite/gdb.threads/fork-child-threads.exp
> index d0d13a29fdf..92e2a59bf8b 100644
> --- a/gdb/testsuite/gdb.threads/fork-child-threads.exp
> +++ b/gdb/testsuite/gdb.threads/fork-child-threads.exp
> @@ -44,4 +44,4 @@ gdb_test "continue" "Breakpoint 2, start.*" "get to the spawned thread"
>   # * 3 Thread 0x40a00950 (LWP 5553)  start (arg=0x0) at ../.././gdb/testsuite/gdb.threads/fork-child-threads.c:28
>   #   2 Thread 0x2aaaaaac3000 (LWP 5552)  0x00000031674076dd in pthread_join (threadid=<optimized out>, thread_return=<optimized out>) at pthread_join.c:89
>   
> -gdb_test "info threads" " Thread .* Thread .*" "two threads found"
> +gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .*" "two threads found"
> diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.exp b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
> index 3ab2d31402c..a1f056e2035 100644
> --- a/gdb/testsuite/gdb.threads/fork-thread-pending.exp
> +++ b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
> @@ -37,7 +37,7 @@ gdb_breakpoint "start" "" "1, set breakpoint at start"
>   
>   gdb_test "continue" "Catchpoint.*" "1, get to the fork event"
>   
> -gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "1, multiple threads found"
> +gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "1, multiple threads found"
>   
>   gdb_test "thread 1" ".*" "1, switched away from event thread"
>   
> @@ -45,10 +45,10 @@ gdb_test "continue" "Not resuming.*" "1, refused to resume"
>   
>   set test "1, followed to the child, found one thread"
>   gdb_test_multiple "info threads" "metest" {
> -    -re " Thread .* Thread .*$gdb_prompt $" {
> +    -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
>   	fail "$test"
>       }
> -    -re " Thread .*$gdb_prompt $" {
> +    -re " ${tdlabel_re} .*$gdb_prompt $" {
>   	pass "$test"
>       }
>       -re "$gdb_prompt $" {
> @@ -63,10 +63,10 @@ gdb_test "continue" "Breakpoint 3, start.*" "1, get to the spawned thread in for
>   
>   set test "1, followed to the child, found two threads"
>   gdb_test_multiple "info threads" "$test" {
> -    -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
> +    -re " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
>   	fail "$test"
>       }
> -    -re " Thread .* Thread .*$gdb_prompt $" {
> +    -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
>   	pass "$test"
>       }
>       -re "$gdb_prompt $" {
> @@ -90,16 +90,16 @@ gdb_breakpoint "start"
>   
>   gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
>   
> -gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "2, multiple threads found"
> +gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "2, multiple threads found"
>   
>   gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
>   
>   set test "2, followed to the child, found two threads"
>   gdb_test_multiple "info threads" "$test" {
> -    -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
> +    -re " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
>   	fail "$test"
>       }
> -    -re " Thread .* Thread .*$gdb_prompt $" {
> +    -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
>   	pass "$test"
>       }
>       -re "$gdb_prompt $" {
> diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
> index 0614b9cd664..ce14d677c98 100644
> --- a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
> +++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
> @@ -43,8 +43,8 @@ gdb_test "list $line" \
>   gdb_test "info threads" \
>       [multi_line \
>   	 "\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*" \
> -	 "  1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
> -	 "\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*"] \
> +	 "  1 *${tdlabel_re} \[^\r\n\]* .* \[^\r\n\]*" \
> +	 "\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*"] \
>       "info threads before break"
>   
>   # Check that "break" is still operating on the same file by default.
> @@ -53,8 +53,8 @@ gdb_test "break $line" ".*${srcfile2}.*" "break on line"
>   gdb_test "info threads" \
>       [multi_line \
>   	 "\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*" \
> -	 "  1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
> -	 "\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*"] \
> +	 "  1 *${tdlabel_re} \[^\r\n\]* .* \[^\r\n\]*" \
> +	 "\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*"] \
>       "info threads before list"
>   
>   # And that so is "list".
> diff --git a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
> index 0add65d3717..24a09ce9f94 100644
> --- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
> +++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
> @@ -74,6 +74,7 @@ proc test_one_iteration {} {
>       global gdb_prompt
>       global NUM_THREADS
>       global decimal
> +    global tdlabel_re
>   
>       set saw_continuing 0
>       set test "continue -a &"
> @@ -145,7 +146,7 @@ proc test_one_iteration {} {
>       set running_count 0
>       set test "all threads are stopped"
>       return_if_nonzero [gdb_test_multiple "info threads" $test {
> -	-re "Thread \[^\r\n\]* \\(running\\)" {
> +	-re "${tdlabel_re} \[^\r\n\]* \\(running\\)" {
>   	    incr running_count
>   	    exp_continue
>   	}
> diff --git a/gdb/testsuite/gdb.threads/leader-exit.exp b/gdb/testsuite/gdb.threads/leader-exit.exp
> index 95811e975aa..feb1171b208 100644
> --- a/gdb/testsuite/gdb.threads/leader-exit.exp
> +++ b/gdb/testsuite/gdb.threads/leader-exit.exp
> @@ -34,7 +34,7 @@ gdb_breakpoint [gdb_get_line_number "break-here"]
>   gdb_continue_to_breakpoint "break-here" ".* break-here .*"
>   
>   gdb_test "info threads" \
> -	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
> +	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*" \
>   	 "single thread has been left"
>   
>   # Test that ctrl-c works even if the leader has exited.
> diff --git a/gdb/testsuite/gdb.threads/manythreads.exp b/gdb/testsuite/gdb.threads/manythreads.exp
> index 5a176519051..87e75766328 100644
> --- a/gdb/testsuite/gdb.threads/manythreads.exp
> +++ b/gdb/testsuite/gdb.threads/manythreads.exp
> @@ -112,7 +112,7 @@ interrupt_and_wait "stop threads 1"
>   set cmd "info threads"
>   set ok 0
>   gdb_test_multiple $cmd $cmd {
> -    -re " 1 *Thread " {
> +    -re " 1 *${tdlabel_re} " {
>   	set ok 1
>   	exp_continue
>       }
> diff --git a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
> index be372030cb8..3a0411ad73c 100644
> --- a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
> +++ b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
> @@ -42,7 +42,7 @@ gdb_test "continue" \
>       "continue stops when thread 2 exits"
>   
>   gdb_test "info threads" \
> -	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *Thread \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 2> has terminated.*" \
> +	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *${tdlabel_re} \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 2> has terminated.*" \
>   	 "only main thread left, thread 2 terminated"
>   
>   # Select the main thread, let the third thread start, and stop at the
> @@ -63,7 +63,7 @@ gdb_test "continue" \
>       "continue stops when the main thread exits"
>   
>   gdb_test "info threads" \
> -	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *Thread \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 1> has terminated.*" \
> +	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *${tdlabel_re} \[^\r\n\]* \[^\r\n\]*\[\r\n\]*The current thread <Thread ID 1> has terminated.*" \
>   	 "only thread 3 left, main thread terminated"
>   
>   # Make sure thread apply all works when we have exited threads in the
> diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
> index d51ae3115ef..04d34fc4e46 100644
> --- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
> +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
> @@ -26,6 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
>   
>   proc do_test { lock_sched nonstop } {
>       global executable
> +    global tdlabel_re
>   
>       save_vars { GDBFLAGS } {
>         append GDBFLAGS " -ex \"set non-stop $nonstop\""
> @@ -44,7 +45,7 @@ proc do_test { lock_sched nonstop } {
>       }
>   
>       gdb_test "info threads" \
> -	"\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
> +	"\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *${tdlabel_re} \[^\r\n\]* at \[^\r\n\]*" \
>   	"single thread left"
>   
>       # Also test with sched-lock to make sure we can follow the
> diff --git a/gdb/testsuite/gdb.threads/pthreads.exp b/gdb/testsuite/gdb.threads/pthreads.exp
> index 41a7cb3800f..241166f83f0 100644
> --- a/gdb/testsuite/gdb.threads/pthreads.exp
> +++ b/gdb/testsuite/gdb.threads/pthreads.exp
> @@ -123,11 +123,12 @@ proc test_startup {} {
>       global srcdir srcfile gdb_prompt expect_out
>       global horiz
>       global main_id thread1_id thread2_id
> +    global tdlabel_re
>   
>       # We should be able to do an info threads before starting any others.
>       set return_me 1
>       gdb_test_multiple "info threads" "info threads" {
> -	-re ".*Thread.*main.*$gdb_prompt $" {
> +	-re ".*${tdlabel_re}.*main.*$gdb_prompt $" {
>   	    pass "info threads"
>   	    set return_me 0
>   	}
> @@ -142,7 +143,7 @@ proc test_startup {} {
>   
>       # Extract the thread id number of main thread from "info threads" output.
>       gdb_test_multiple "info threads" "get main thread id" {
> -	-re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)" {
> +	-re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}main.*)($gdb_prompt $)" {
>   	}
>       }
>   
> @@ -157,7 +158,7 @@ proc test_startup {} {
>   
>       # Extract the thread id number of thread 1 from "info threads" output.
>       gdb_test_multiple "info threads" "get thread 1 id" {
> -	-re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)" {
> +	-re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}thread1.*)($gdb_prompt $)" {
>   	}
>       }
>   
> @@ -172,7 +173,7 @@ proc test_startup {} {
>   
>       # Extract the thread id number of thread 2 from "info threads" output.
>       gdb_test_multiple "info threads" "get thread 2 id" {
> -	-re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)" {
> +	-re "(\[0-9\]+)(${horiz}${tdlabel_re}${horiz}thread2.*)($gdb_prompt $)" {
>   	}
>       }
>   
> diff --git a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
> index a099dbbb974..4455d984409 100644
> --- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
> +++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
> @@ -32,7 +32,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
>   # request a signal be delivered with the "signal" command.
>   
>   proc test { step_over } {
> -    global srcfile binfile
> +    global srcfile binfile tdlabel_re
>   
>       with_test_prefix "step-over $step_over" {
>   	clean_restart ${binfile}
> @@ -59,7 +59,7 @@ proc test { step_over } {
>   
>   	gdb_test "thread 1" "Switching to thread 1.*"
>   
> -	set pattern "\\\* 1\[ \t\]+Thread.*"
> +	set pattern "\\\* 1\[ \t\]+${tdlabel_re}.*"
>   
>   	gdb_test "info threads" $pattern "thread 1 selected"
>   
> diff --git a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
> index 0802e403b5d..e808192969b 100644
> --- a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
> +++ b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
> @@ -29,7 +29,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
>   # scheduler-locking) of the test to perform.
>   
>   proc test { schedlock } {
> -    global srcfile binfile
> +    global srcfile binfile tdlabel_re
>   
>       with_test_prefix "schedlock $schedlock" {
>   	clean_restart ${binfile}
> @@ -60,7 +60,7 @@ proc test { schedlock } {
>   	gdb_test "continue" "all_threads_signalled.*" \
>   	    "continue to all_threads signalled"
>   
> -	gdb_test "info threads" "\\\* 1\[ \t\]+Thread.*" "thread 1 selected"
> +	gdb_test "info threads" "\\\* 1\[ \t\]+${tdlabel_re}.*" "thread 1 selected"
>   
>   	# With schedlock still enabled, let each thread report its
>   	# signal.
> diff --git a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
> index 3407cfa0645..b78b92f3688 100644
> --- a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
> +++ b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
> @@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
>   # with "signal 0" or "continue".
>   
>   proc test { command } {
> -    global srcfile binfile
> +    global srcfile binfile tdlabel_re
>   
>       with_test_prefix "$command" {
>   	clean_restart ${binfile}
> @@ -39,7 +39,7 @@ proc test { command } {
>   
>   	gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1"
>   
> -	set pattern "\\\* 2\[ \t\]+Thread.*"
> +	set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
>   
>   	gdb_test "info threads" $pattern "thread 2 intercepted signal"
>   
> diff --git a/gdb/testsuite/gdb.threads/signal-sigtrap.exp b/gdb/testsuite/gdb.threads/signal-sigtrap.exp
> index 1f524511ee9..f96e942ce54 100644
> --- a/gdb/testsuite/gdb.threads/signal-sigtrap.exp
> +++ b/gdb/testsuite/gdb.threads/signal-sigtrap.exp
> @@ -29,7 +29,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile \
>   # SIGTRAP.
>   
>   proc test { sigtrap_thread } {
> -    global srcfile binfile
> +    global srcfile binfile tdlabel_re
>   
>       with_test_prefix "sigtrap thread $sigtrap_thread" {
>   	clean_restart ${binfile}
> @@ -38,7 +38,7 @@ proc test { sigtrap_thread } {
>   	    return 0
>   	}
>   
> -	set pattern "\\\* 2\[ \t\]+Thread.*"
> +	set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
>   	gdb_test "info threads" $pattern "thread 2 hit breakpoint"
>   
>   	gdb_test "break sigtrap_handler" "Breakpoint .* at .*$srcfile.*"
> @@ -54,7 +54,7 @@ proc test { sigtrap_thread } {
>   	    "Continuing with signal SIGTRAP.*Breakpoint .* sigtrap_handler .*" \
>   	    "signal SIGTRAP reaches handler"
>   
> -	set pattern "\\\* $sigtrap_thread\[ \t\]+Thread.*"
> +	set pattern "\\\* $sigtrap_thread\[ \t\]+${tdlabel_re}.*"
>   	gdb_test "info threads" $pattern "right thread got the signal"
>       }
>   }
> diff --git a/gdb/testsuite/gdb.threads/staticthreads.exp b/gdb/testsuite/gdb.threads/staticthreads.exp
> index 958aa2181b1..000d1f82070 100644
> --- a/gdb/testsuite/gdb.threads/staticthreads.exp
> +++ b/gdb/testsuite/gdb.threads/staticthreads.exp
> @@ -73,7 +73,7 @@ gdb_test "continue" " .*sem_post .*" "handle $sig helps"
>   
>   set test "info threads"
>   gdb_test_multiple "info threads" "$test" {
> -    -re " Thread .*$gdb_prompt " {
> +    -re " ${tdlabel_re} .*$gdb_prompt " {
>   	pass "$test"
>       }
>       -re "$gdb_prompt " {
> diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
> index 2d1c71a68e3..575892d52c0 100644
> --- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp
> +++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
> @@ -29,11 +29,12 @@ if {[gdb_compile_pthreads \
>   
>   proc get_thread_id {func} {
>       global gdb_prompt
> +    global tdlabel_re
>   
>       set thre -1
>       set test "get $func thread id"
>       gdb_test_multiple "info threads" $test {
> -	-re "(\[0-9\]+)\[^\n\r\]*Thread\[^\n\r\]*$func.*$gdb_prompt $" {
> +	-re "(\[0-9\]+)\[^\n\r\]*${tdlabel_re}\[^\n\r\]*$func.*$gdb_prompt $" {
>   	    # Get the thread's id.
>   	    set thre $expect_out(1,string)
>   	    pass $test
> diff --git a/gdb/testsuite/gdb.threads/thread-specific.exp b/gdb/testsuite/gdb.threads/thread-specific.exp
> index 9ba98ec6290..f95e249d03d 100644
> --- a/gdb/testsuite/gdb.threads/thread-specific.exp
> +++ b/gdb/testsuite/gdb.threads/thread-specific.exp
> @@ -28,6 +28,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
>   proc get_thread_list { } {
>     global gdb_prompt
>     global expect_out
> +  global tdlabel_re
>   
>     set thr_list ""
>   
> @@ -41,11 +42,11 @@ proc get_thread_list { } {
>       -re "^ *Id *Target Id\[^\n\]*\n" {
>         exp_continue
>       }
> -    -re "^\\*  *(\[0-9\]*) *Thread \[^\n\]*main\[^\n\]*\n" {
> +    -re "^\\*  *(\[0-9\]*) *${tdlabel_re} \[^\n\]*main\[^\n\]*\n" {
>         set thr_list "$expect_out(1,string) $thr_list"
>         exp_continue
>       }
> -    -re "^  *(\[0-9\]*) *Thread \[^\n\]*\n" {
> +    -re "^  *(\[0-9\]*) *${tdlabel_re} \[^\n\]*\n" {
>         lappend thr_list $expect_out(1,string)
>         exp_continue
>       }
> diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp
> index 89f6fb89bac..f3c6288b142 100644
> --- a/gdb/testsuite/gdb.threads/tls.exp
> +++ b/gdb/testsuite/gdb.threads/tls.exp
> @@ -207,19 +207,19 @@ gdb_expect {
>       timeout { fail "continue to first thread (timeout)" }
>   }
>   
> -gdb_test "info thread" ".*Thread.*spin.*" \
> +gdb_test "info thread" ".*${tdlabel_re}.*spin.*" \
>   	"at least one th in spin while stopped at first th"
>   
>   check_thread_local "first"
>   
>   gdb_test "continue" ".*Breakpoint 2.*tls value.*" "continue to second thread"
> -gdb_test "info thread" "Thread.*spin.*" \
> +gdb_test "info thread" "${tdlabel_re}.*spin.*" \
>   	"at least one th in spin while stopped at second th"
>   
>   check_thread_local "second"
>   
>   gdb_test "continue" ".*Breakpoint 2.*tls value.*" "continue to third thread"
> -gdb_test "info thread" ".*Thread.*spin.*" \
> +gdb_test "info thread" ".*${tdlabel_re}.*spin.*" \
>   	"at least one th in spin while stopped at third th"
>   
>   check_thread_local "third"
> @@ -229,7 +229,7 @@ gdb_test "continue" ".*Breakpoint 3.*still alive.*" "continue to synch point"
>   set no_of_threads 0
>   send_gdb "info thread\n"
>   gdb_expect {
> -    -re "^info thread\[ \t\r\n\]+ *Id .*Frame\[ \t\r\n\]+.*(\[0-9\]+) *Thread\[^\r\n\]+\r\n$gdb_prompt $" {
> +    -re "^info thread\[ \t\r\n\]+ *Id .*Frame\[ \t\r\n\]+.*(\[0-9\]+) *${tdlabel_re}\[^\r\n\]+\r\n$gdb_prompt $" {
>   	   set no_of_threads $expect_out(1,string)
>   	   pass "get number of threads"
>           }
> @@ -280,10 +280,10 @@ gdb_test "continue" ".*Breakpoint 4.*before exit.*" "threads exited"
>   
>   send_gdb "info thread\n"
>   gdb_expect {
> -    -re ".* 1 *Thread.*2 *Thread.*$gdb_prompt $" {
> +    -re ".* 1 *${tdlabel_re}.*2 *${tdlabel_re}.*$gdb_prompt $" {
>           fail "too many threads left at end"
>       }
> -    -re ".*\\\* 1 *Thread.*main.*$gdb_prompt $" {
> +    -re ".*\\\* 1 *${tdlabel_re}.*main.*$gdb_prompt $" {
>           pass "expect only base thread at end"
>       }
>       -re ".*No stack.*$gdb_prompt $" {
> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
> index 14db2511d40..a5b7ccf4ba5 100644
> --- a/gdb/testsuite/gdb.trace/report.exp
> +++ b/gdb/testsuite/gdb.trace/report.exp
> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>   
>   	# There is always a thread of an inferior, either a live one or
>   	# a faked one.
> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>   	gdb_test "info inferiors" "\\* 1    process ${decimal} \[ \t\]+\[^\r\n\]*\[ \t\]+${binfile}.*"
>       }
>   }
> diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp
> index bbdd8b78619..0ee55af923f 100644
> --- a/gdb/testsuite/gdb.trace/strace.exp
> +++ b/gdb/testsuite/gdb.trace/strace.exp
> @@ -139,7 +139,7 @@ proc strace_info_marker { } {
>   	# List all the thread.  It is expected to get three threads without
>   	# any errors.
>   	gdb_test_multiple "info threads 3 2 1" "info threads" {
> -	    -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" {
> +	    -re "3\[ \t\]+${tdlabel_re} .*2\[ \t\]+${tdlabel_re} .*1\[ \t\]+${tdlabel_re} .*${gdb_prompt} $" {
>   		pass "info threads"
>   	    }
>   	}
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 7538071d1cf..3d2ead0103d 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -281,6 +281,10 @@ set octal "\[0-7\]+"
>   
>   set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
>   
> +# A regular expression that matches the first word of a thread
> +# description after the thread number info 'info threads'
> +set tdlabel_re "(Thread|LWP)"
> +
>   # A regular expression that matches a value history number.
>   # E.g., $1, $2, etc.
>   set valnum_re "\\\$$decimal"

Ping

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-04-18 20:13 [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
  2023-05-08 16:19 ` [PING] " John Baldwin
@ 2023-05-09 19:01 ` Simon Marchi via Gdb-patches
  2023-05-09 20:56   ` John Baldwin
  1 sibling, 1 reply; 11+ messages in thread
From: Simon Marchi via Gdb-patches @ 2023-05-09 19:01 UTC (permalink / raw)
  To: John Baldwin, gdb-patches

On 4/18/23 16:13, John Baldwin wrote:
> Several tests assume that the first word after a thread ID in 'info
> threads' output is "Thread".  However, several targets use "LWP"
> instead such as the FreeBSD and NetBSD native targets.  The Linux
> native target also uses "LWP" if libthread_db is not being used.
> 
> Add a tdlabel_re global variable as a regular-expression for a thread
> label in `info threads' that matches either "thread" or "LWP".
> 
> Some other tests in the tree don't require a specific word, and
> some targets may use other first words (e.g. OpenBSD uses "thread"
> and Ravenscar threads use "Ravenscar Thread").

That LGTM, I don't really see another way:

Approved-By: Simon Marchi <simon.marchi@efficios.com>

One nit is that I prefer to use the ${::tdlabel_re} notation instead of
the global keyword, but it's not a dealbreaker.

And just one question:

> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
> index 14db2511d40..a5b7ccf4ba5 100644
> --- a/gdb/testsuite/gdb.trace/report.exp
> +++ b/gdb/testsuite/gdb.trace/report.exp
> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>  
>  	# There is always a thread of an inferior, either a live one or
>  	# a faked one.
> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"

This one said "process" as well, I guess it's not important?

Simon

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-05-09 19:01 ` Simon Marchi via Gdb-patches
@ 2023-05-09 20:56   ` John Baldwin
  2023-05-12 14:15     ` John Baldwin
  2024-03-26 12:19     ` Pedro Alves
  0 siblings, 2 replies; 11+ messages in thread
From: John Baldwin @ 2023-05-09 20:56 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 5/9/23 12:01 PM, Simon Marchi wrote:
> On 4/18/23 16:13, John Baldwin wrote:
>> Several tests assume that the first word after a thread ID in 'info
>> threads' output is "Thread".  However, several targets use "LWP"
>> instead such as the FreeBSD and NetBSD native targets.  The Linux
>> native target also uses "LWP" if libthread_db is not being used.
>>
>> Add a tdlabel_re global variable as a regular-expression for a thread
>> label in `info threads' that matches either "thread" or "LWP".
>>
>> Some other tests in the tree don't require a specific word, and
>> some targets may use other first words (e.g. OpenBSD uses "thread"
>> and Ravenscar threads use "Ravenscar Thread").
> 
> That LGTM, I don't really see another way:
> 
> Approved-By: Simon Marchi <simon.marchi@efficios.com>
> 
> One nit is that I prefer to use the ${::tdlabel_re} notation instead of
> the global keyword, but it's not a dealbreaker.
> 
> And just one question:
> 
>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>> index 14db2511d40..a5b7ccf4ba5 100644
>> --- a/gdb/testsuite/gdb.trace/report.exp
>> +++ b/gdb/testsuite/gdb.trace/report.exp
>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>   
>>   	# There is always a thread of an inferior, either a live one or
>>   	# a faked one.
>> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
> 
> This one said "process" as well, I guess it's not important?

Hummm, it didn't regress on Linux, but on some other native target that
doesn't support threads it might regress I guess.  normal_pid_to_str
uses "process <PID>" and is the defalt for target::pid_to_str.

Probably tdlabel_re should permit "process" as a word as well:

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 527c84599ca..6ded65e31c4 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -283,7 +283,7 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
  
  # A regular expression that matches the first word of a thread
  # description after the thread number info 'info threads'
-set tdlabel_re "(Thread|LWP)"
+set tdlabel_re "(process|Thread|LWP)"
  
  # A regular expression that matches a value history number.
  # E.g., $1, $2, etc.

(I'd also have to reword the commit log a bit to mention this case if so.)

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-05-09 20:56   ` John Baldwin
@ 2023-05-12 14:15     ` John Baldwin
  2023-05-26 17:51       ` John Baldwin
  2024-03-26 12:19     ` Pedro Alves
  1 sibling, 1 reply; 11+ messages in thread
From: John Baldwin @ 2023-05-12 14:15 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 5/9/23 1:56 PM, John Baldwin wrote:
> On 5/9/23 12:01 PM, Simon Marchi wrote:
>> On 4/18/23 16:13, John Baldwin wrote:
>>> Several tests assume that the first word after a thread ID in 'info
>>> threads' output is "Thread".  However, several targets use "LWP"
>>> instead such as the FreeBSD and NetBSD native targets.  The Linux
>>> native target also uses "LWP" if libthread_db is not being used.
>>>
>>> Add a tdlabel_re global variable as a regular-expression for a thread
>>> label in `info threads' that matches either "thread" or "LWP".
>>>
>>> Some other tests in the tree don't require a specific word, and
>>> some targets may use other first words (e.g. OpenBSD uses "thread"
>>> and Ravenscar threads use "Ravenscar Thread").
>>
>> That LGTM, I don't really see another way:
>>
>> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>>
>> One nit is that I prefer to use the ${::tdlabel_re} notation instead of
>> the global keyword, but it's not a dealbreaker.
>>
>> And just one question:
>>
>>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>>> index 14db2511d40..a5b7ccf4ba5 100644
>>> --- a/gdb/testsuite/gdb.trace/report.exp
>>> +++ b/gdb/testsuite/gdb.trace/report.exp
>>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>>    
>>>    	# There is always a thread of an inferior, either a live one or
>>>    	# a faked one.
>>> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>>> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>>
>> This one said "process" as well, I guess it's not important?
> 
> Hummm, it didn't regress on Linux, but on some other native target that
> doesn't support threads it might regress I guess.  normal_pid_to_str
> uses "process <PID>" and is the defalt for target::pid_to_str.
> 
> Probably tdlabel_re should permit "process" as a word as well:
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 527c84599ca..6ded65e31c4 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -283,7 +283,7 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
>    
>    # A regular expression that matches the first word of a thread
>    # description after the thread number info 'info threads'
> -set tdlabel_re "(Thread|LWP)"
> +set tdlabel_re "(process|Thread|LWP)"
>    
>    # A regular expression that matches a value history number.
>    # E.g., $1, $2, etc.
> 
> (I'd also have to reword the commit log a bit to mention this case if so.)

Just to be sure, are you still ok with this patch with this tweak?

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-05-12 14:15     ` John Baldwin
@ 2023-05-26 17:51       ` John Baldwin
  2023-06-09 16:56         ` John Baldwin
  0 siblings, 1 reply; 11+ messages in thread
From: John Baldwin @ 2023-05-26 17:51 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 5/12/23 7:15 AM, John Baldwin wrote:
> On 5/9/23 1:56 PM, John Baldwin wrote:
>> On 5/9/23 12:01 PM, Simon Marchi wrote:
>>> On 4/18/23 16:13, John Baldwin wrote:
>>>> Several tests assume that the first word after a thread ID in 'info
>>>> threads' output is "Thread".  However, several targets use "LWP"
>>>> instead such as the FreeBSD and NetBSD native targets.  The Linux
>>>> native target also uses "LWP" if libthread_db is not being used.
>>>>
>>>> Add a tdlabel_re global variable as a regular-expression for a thread
>>>> label in `info threads' that matches either "thread" or "LWP".
>>>>
>>>> Some other tests in the tree don't require a specific word, and
>>>> some targets may use other first words (e.g. OpenBSD uses "thread"
>>>> and Ravenscar threads use "Ravenscar Thread").
>>>
>>> That LGTM, I don't really see another way:
>>>
>>> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>>>
>>> One nit is that I prefer to use the ${::tdlabel_re} notation instead of
>>> the global keyword, but it's not a dealbreaker.
>>>
>>> And just one question:
>>>
>>>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>>>> index 14db2511d40..a5b7ccf4ba5 100644
>>>> --- a/gdb/testsuite/gdb.trace/report.exp
>>>> +++ b/gdb/testsuite/gdb.trace/report.exp
>>>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>>>     
>>>>     	# There is always a thread of an inferior, either a live one or
>>>>     	# a faked one.
>>>> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>>>> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>>>
>>> This one said "process" as well, I guess it's not important?
>>
>> Hummm, it didn't regress on Linux, but on some other native target that
>> doesn't support threads it might regress I guess.  normal_pid_to_str
>> uses "process <PID>" and is the defalt for target::pid_to_str.
>>
>> Probably tdlabel_re should permit "process" as a word as well:
>>
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index 527c84599ca..6ded65e31c4 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -283,7 +283,7 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
>>     
>>     # A regular expression that matches the first word of a thread
>>     # description after the thread number info 'info threads'
>> -set tdlabel_re "(Thread|LWP)"
>> +set tdlabel_re "(process|Thread|LWP)"
>>     
>>     # A regular expression that matches a value history number.
>>     # E.g., $1, $2, etc.
>>
>> (I'd also have to reword the commit log a bit to mention this case if so.)
> 
> Just to be sure, are you still ok with this patch with this tweak?

Ping, here's the updated log message to match:

     gdb tests: Allow for "LWP" in thread IDs from info threads.
     
     Several tests assume that the first word after a thread ID in 'info
     threads' output is "Thread".  However, several targets use "LWP"
     instead such as the FreeBSD and NetBSD native targets.  The Linux
     native target also uses "LWP" if libthread_db is not being used.
     Targets that do not support threads use "process" as the first word
     via normal_pid_to_str.
     
     Add a tdlabel_re global variable as a regular-expression for a thread
     label in `info threads' that matches either "process", "Thread", or
     "LWP".
     
     Some other tests in the tree don't require a specific word, and
     some targets may use other first words (e.g. OpenBSD uses "thread"
     and Ravenscar threads use "Ravenscar Thread").


-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-05-26 17:51       ` John Baldwin
@ 2023-06-09 16:56         ` John Baldwin
  2023-06-30 14:21           ` [PING] " John Baldwin
  0 siblings, 1 reply; 11+ messages in thread
From: John Baldwin @ 2023-06-09 16:56 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 5/26/23 10:51 AM, John Baldwin wrote:
> On 5/12/23 7:15 AM, John Baldwin wrote:
>> On 5/9/23 1:56 PM, John Baldwin wrote:
>>> On 5/9/23 12:01 PM, Simon Marchi wrote:
>>>> On 4/18/23 16:13, John Baldwin wrote:
>>>>> Several tests assume that the first word after a thread ID in 'info
>>>>> threads' output is "Thread".  However, several targets use "LWP"
>>>>> instead such as the FreeBSD and NetBSD native targets.  The Linux
>>>>> native target also uses "LWP" if libthread_db is not being used.
>>>>>
>>>>> Add a tdlabel_re global variable as a regular-expression for a thread
>>>>> label in `info threads' that matches either "thread" or "LWP".
>>>>>
>>>>> Some other tests in the tree don't require a specific word, and
>>>>> some targets may use other first words (e.g. OpenBSD uses "thread"
>>>>> and Ravenscar threads use "Ravenscar Thread").
>>>>
>>>> That LGTM, I don't really see another way:
>>>>
>>>> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>>>>
>>>> One nit is that I prefer to use the ${::tdlabel_re} notation instead of
>>>> the global keyword, but it's not a dealbreaker.
>>>>
>>>> And just one question:
>>>>
>>>>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>>>>> index 14db2511d40..a5b7ccf4ba5 100644
>>>>> --- a/gdb/testsuite/gdb.trace/report.exp
>>>>> +++ b/gdb/testsuite/gdb.trace/report.exp
>>>>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>>>>      
>>>>>      	# There is always a thread of an inferior, either a live one or
>>>>>      	# a faked one.
>>>>> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>>>>> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>>>>
>>>> This one said "process" as well, I guess it's not important?
>>>
>>> Hummm, it didn't regress on Linux, but on some other native target that
>>> doesn't support threads it might regress I guess.  normal_pid_to_str
>>> uses "process <PID>" and is the defalt for target::pid_to_str.
>>>
>>> Probably tdlabel_re should permit "process" as a word as well:
>>>
>>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>>> index 527c84599ca..6ded65e31c4 100644
>>> --- a/gdb/testsuite/lib/gdb.exp
>>> +++ b/gdb/testsuite/lib/gdb.exp
>>> @@ -283,7 +283,7 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
>>>      
>>>      # A regular expression that matches the first word of a thread
>>>      # description after the thread number info 'info threads'
>>> -set tdlabel_re "(Thread|LWP)"
>>> +set tdlabel_re "(process|Thread|LWP)"
>>>      
>>>      # A regular expression that matches a value history number.
>>>      # E.g., $1, $2, etc.
>>>
>>> (I'd also have to reword the commit log a bit to mention this case if so.)
>>
>> Just to be sure, are you still ok with this patch with this tweak?
> 
> Ping, here's the updated log message to match:
> 
>       gdb tests: Allow for "LWP" in thread IDs from info threads.
>       
>       Several tests assume that the first word after a thread ID in 'info
>       threads' output is "Thread".  However, several targets use "LWP"
>       instead such as the FreeBSD and NetBSD native targets.  The Linux
>       native target also uses "LWP" if libthread_db is not being used.
>       Targets that do not support threads use "process" as the first word
>       via normal_pid_to_str.
>       
>       Add a tdlabel_re global variable as a regular-expression for a thread
>       label in `info threads' that matches either "process", "Thread", or
>       "LWP".
>       
>       Some other tests in the tree don't require a specific word, and
>       some targets may use other first words (e.g. OpenBSD uses "thread"
>       and Ravenscar threads use "Ravenscar Thread").

Ping, this is mostly a small change to a previously approved patch, just not
sure what the threshold is for if a fixup change is small enough to still
count as approved, etc.

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PING] [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-06-09 16:56         ` John Baldwin
@ 2023-06-30 14:21           ` John Baldwin
  2023-07-14 15:35             ` John Baldwin
  0 siblings, 1 reply; 11+ messages in thread
From: John Baldwin @ 2023-06-30 14:21 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

On 6/9/23 9:56 AM, John Baldwin wrote:
> On 5/26/23 10:51 AM, John Baldwin wrote:
>> On 5/12/23 7:15 AM, John Baldwin wrote:
>>> On 5/9/23 1:56 PM, John Baldwin wrote:
>>>> On 5/9/23 12:01 PM, Simon Marchi wrote:
>>>>> On 4/18/23 16:13, John Baldwin wrote:
>>>>>> Several tests assume that the first word after a thread ID in 'info
>>>>>> threads' output is "Thread".  However, several targets use "LWP"
>>>>>> instead such as the FreeBSD and NetBSD native targets.  The Linux
>>>>>> native target also uses "LWP" if libthread_db is not being used.
>>>>>>
>>>>>> Add a tdlabel_re global variable as a regular-expression for a thread
>>>>>> label in `info threads' that matches either "thread" or "LWP".
>>>>>>
>>>>>> Some other tests in the tree don't require a specific word, and
>>>>>> some targets may use other first words (e.g. OpenBSD uses "thread"
>>>>>> and Ravenscar threads use "Ravenscar Thread").
>>>>>
>>>>> That LGTM, I don't really see another way:
>>>>>
>>>>> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>>>>>
>>>>> One nit is that I prefer to use the ${::tdlabel_re} notation instead of
>>>>> the global keyword, but it's not a dealbreaker.
>>>>>
>>>>> And just one question:
>>>>>
>>>>>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>>>>>> index 14db2511d40..a5b7ccf4ba5 100644
>>>>>> --- a/gdb/testsuite/gdb.trace/report.exp
>>>>>> +++ b/gdb/testsuite/gdb.trace/report.exp
>>>>>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>>>>>       
>>>>>>       	# There is always a thread of an inferior, either a live one or
>>>>>>       	# a faked one.
>>>>>> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>>>>>> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>>>>>
>>>>> This one said "process" as well, I guess it's not important?
>>>>
>>>> Hummm, it didn't regress on Linux, but on some other native target that
>>>> doesn't support threads it might regress I guess.  normal_pid_to_str
>>>> uses "process <PID>" and is the defalt for target::pid_to_str.
>>>>
>>>> Probably tdlabel_re should permit "process" as a word as well:
>>>>
>>>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>>>> index 527c84599ca..6ded65e31c4 100644
>>>> --- a/gdb/testsuite/lib/gdb.exp
>>>> +++ b/gdb/testsuite/lib/gdb.exp
>>>> @@ -283,7 +283,7 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
>>>>       
>>>>       # A regular expression that matches the first word of a thread
>>>>       # description after the thread number info 'info threads'
>>>> -set tdlabel_re "(Thread|LWP)"
>>>> +set tdlabel_re "(process|Thread|LWP)"
>>>>       
>>>>       # A regular expression that matches a value history number.
>>>>       # E.g., $1, $2, etc.
>>>>
>>>> (I'd also have to reword the commit log a bit to mention this case if so.)
>>>
>>> Just to be sure, are you still ok with this patch with this tweak?
>>
>> Ping, here's the updated log message to match:
>>
>>        gdb tests: Allow for "LWP" in thread IDs from info threads.
>>        
>>        Several tests assume that the first word after a thread ID in 'info
>>        threads' output is "Thread".  However, several targets use "LWP"
>>        instead such as the FreeBSD and NetBSD native targets.  The Linux
>>        native target also uses "LWP" if libthread_db is not being used.
>>        Targets that do not support threads use "process" as the first word
>>        via normal_pid_to_str.
>>        
>>        Add a tdlabel_re global variable as a regular-expression for a thread
>>        label in `info threads' that matches either "process", "Thread", or
>>        "LWP".
>>        
>>        Some other tests in the tree don't require a specific word, and
>>        some targets may use other first words (e.g. OpenBSD uses "thread"
>>        and Ravenscar threads use "Ravenscar Thread").
> 
> Ping, this is mostly a small change to a previously approved patch, just not
> sure what the threshold is for if a fixup change is small enough to still
> count as approved, etc.
> 

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PING] [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-06-30 14:21           ` [PING] " John Baldwin
@ 2023-07-14 15:35             ` John Baldwin
  2024-03-22 20:58               ` John Baldwin
  0 siblings, 1 reply; 11+ messages in thread
From: John Baldwin @ 2023-07-14 15:35 UTC (permalink / raw)
  To: gdb-patches

On 6/30/23 7:21 AM, John Baldwin wrote:
> On 6/9/23 9:56 AM, John Baldwin wrote:
>> On 5/26/23 10:51 AM, John Baldwin wrote:
>>> On 5/12/23 7:15 AM, John Baldwin wrote:
>>>> On 5/9/23 1:56 PM, John Baldwin wrote:
>>>>> On 5/9/23 12:01 PM, Simon Marchi wrote:
>>>>>> On 4/18/23 16:13, John Baldwin wrote:
>>>>>>> Several tests assume that the first word after a thread ID in 'info
>>>>>>> threads' output is "Thread".  However, several targets use "LWP"
>>>>>>> instead such as the FreeBSD and NetBSD native targets.  The Linux
>>>>>>> native target also uses "LWP" if libthread_db is not being used.
>>>>>>>
>>>>>>> Add a tdlabel_re global variable as a regular-expression for a thread
>>>>>>> label in `info threads' that matches either "thread" or "LWP".
>>>>>>>
>>>>>>> Some other tests in the tree don't require a specific word, and
>>>>>>> some targets may use other first words (e.g. OpenBSD uses "thread"
>>>>>>> and Ravenscar threads use "Ravenscar Thread").
>>>>>>
>>>>>> That LGTM, I don't really see another way:
>>>>>>
>>>>>> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>>>>>>
>>>>>> One nit is that I prefer to use the ${::tdlabel_re} notation instead of
>>>>>> the global keyword, but it's not a dealbreaker.
>>>>>>
>>>>>> And just one question:
>>>>>>
>>>>>>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>>>>>>> index 14db2511d40..a5b7ccf4ba5 100644
>>>>>>> --- a/gdb/testsuite/gdb.trace/report.exp
>>>>>>> +++ b/gdb/testsuite/gdb.trace/report.exp
>>>>>>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>>>>>>        
>>>>>>>        	# There is always a thread of an inferior, either a live one or
>>>>>>>        	# a faked one.
>>>>>>> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>>>>>>> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>>>>>>
>>>>>> This one said "process" as well, I guess it's not important?
>>>>>
>>>>> Hummm, it didn't regress on Linux, but on some other native target that
>>>>> doesn't support threads it might regress I guess.  normal_pid_to_str
>>>>> uses "process <PID>" and is the defalt for target::pid_to_str.
>>>>>
>>>>> Probably tdlabel_re should permit "process" as a word as well:
>>>>>
>>>>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>>>>> index 527c84599ca..6ded65e31c4 100644
>>>>> --- a/gdb/testsuite/lib/gdb.exp
>>>>> +++ b/gdb/testsuite/lib/gdb.exp
>>>>> @@ -283,7 +283,7 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
>>>>>        
>>>>>        # A regular expression that matches the first word of a thread
>>>>>        # description after the thread number info 'info threads'
>>>>> -set tdlabel_re "(Thread|LWP)"
>>>>> +set tdlabel_re "(process|Thread|LWP)"
>>>>>        
>>>>>        # A regular expression that matches a value history number.
>>>>>        # E.g., $1, $2, etc.
>>>>>
>>>>> (I'd also have to reword the commit log a bit to mention this case if so.)
>>>>
>>>> Just to be sure, are you still ok with this patch with this tweak?
>>>
>>> Ping, here's the updated log message to match:
>>>
>>>         gdb tests: Allow for "LWP" in thread IDs from info threads.
>>>         
>>>         Several tests assume that the first word after a thread ID in 'info
>>>         threads' output is "Thread".  However, several targets use "LWP"
>>>         instead such as the FreeBSD and NetBSD native targets.  The Linux
>>>         native target also uses "LWP" if libthread_db is not being used.
>>>         Targets that do not support threads use "process" as the first word
>>>         via normal_pid_to_str.
>>>         
>>>         Add a tdlabel_re global variable as a regular-expression for a thread
>>>         label in `info threads' that matches either "process", "Thread", or
>>>         "LWP".
>>>         
>>>         Some other tests in the tree don't require a specific word, and
>>>         some targets may use other first words (e.g. OpenBSD uses "thread"
>>>         and Ravenscar threads use "Ravenscar Thread").
>>
>> Ping, this is mostly a small change to a previously approved patch, just not
>> sure what the threshold is for if a fixup change is small enough to still
>> count as approved, etc.
>>
> 

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PING] [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-07-14 15:35             ` John Baldwin
@ 2024-03-22 20:58               ` John Baldwin
  0 siblings, 0 replies; 11+ messages in thread
From: John Baldwin @ 2024-03-22 20:58 UTC (permalink / raw)
  To: gdb-patches

On 7/14/23 8:35 AM, John Baldwin wrote:
> On 6/30/23 7:21 AM, John Baldwin wrote:
>> On 6/9/23 9:56 AM, John Baldwin wrote:
>>> On 5/26/23 10:51 AM, John Baldwin wrote:
>>>> On 5/12/23 7:15 AM, John Baldwin wrote:
>>>>> On 5/9/23 1:56 PM, John Baldwin wrote:
>>>>>> On 5/9/23 12:01 PM, Simon Marchi wrote:
>>>>>>> On 4/18/23 16:13, John Baldwin wrote:
>>>>>>>> Several tests assume that the first word after a thread ID in 'info
>>>>>>>> threads' output is "Thread".  However, several targets use "LWP"
>>>>>>>> instead such as the FreeBSD and NetBSD native targets.  The Linux
>>>>>>>> native target also uses "LWP" if libthread_db is not being used.
>>>>>>>>
>>>>>>>> Add a tdlabel_re global variable as a regular-expression for a thread
>>>>>>>> label in `info threads' that matches either "thread" or "LWP".
>>>>>>>>
>>>>>>>> Some other tests in the tree don't require a specific word, and
>>>>>>>> some targets may use other first words (e.g. OpenBSD uses "thread"
>>>>>>>> and Ravenscar threads use "Ravenscar Thread").
>>>>>>>
>>>>>>> That LGTM, I don't really see another way:
>>>>>>>
>>>>>>> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>>>>>>>
>>>>>>> One nit is that I prefer to use the ${::tdlabel_re} notation instead of
>>>>>>> the global keyword, but it's not a dealbreaker.
>>>>>>>
>>>>>>> And just one question:
>>>>>>>
>>>>>>>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>>>>>>>> index 14db2511d40..a5b7ccf4ba5 100644
>>>>>>>> --- a/gdb/testsuite/gdb.trace/report.exp
>>>>>>>> +++ b/gdb/testsuite/gdb.trace/report.exp
>>>>>>>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>>>>>>>         
>>>>>>>>         	# There is always a thread of an inferior, either a live one or
>>>>>>>>         	# a faked one.
>>>>>>>> -	gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>>>>>>>> +	gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>>>>>>>
>>>>>>> This one said "process" as well, I guess it's not important?
>>>>>>
>>>>>> Hummm, it didn't regress on Linux, but on some other native target that
>>>>>> doesn't support threads it might regress I guess.  normal_pid_to_str
>>>>>> uses "process <PID>" and is the defalt for target::pid_to_str.
>>>>>>
>>>>>> Probably tdlabel_re should permit "process" as a word as well:
>>>>>>
>>>>>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>>>>>> index 527c84599ca..6ded65e31c4 100644
>>>>>> --- a/gdb/testsuite/lib/gdb.exp
>>>>>> +++ b/gdb/testsuite/lib/gdb.exp
>>>>>> @@ -283,7 +283,7 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
>>>>>>         
>>>>>>         # A regular expression that matches the first word of a thread
>>>>>>         # description after the thread number info 'info threads'
>>>>>> -set tdlabel_re "(Thread|LWP)"
>>>>>> +set tdlabel_re "(process|Thread|LWP)"
>>>>>>         
>>>>>>         # A regular expression that matches a value history number.
>>>>>>         # E.g., $1, $2, etc.
>>>>>>
>>>>>> (I'd also have to reword the commit log a bit to mention this case if so.)
>>>>>
>>>>> Just to be sure, are you still ok with this patch with this tweak?
>>>>
>>>> Ping, here's the updated log message to match:
>>>>
>>>>          gdb tests: Allow for "LWP" in thread IDs from info threads.
>>>>          
>>>>          Several tests assume that the first word after a thread ID in 'info
>>>>          threads' output is "Thread".  However, several targets use "LWP"
>>>>          instead such as the FreeBSD and NetBSD native targets.  The Linux
>>>>          native target also uses "LWP" if libthread_db is not being used.
>>>>          Targets that do not support threads use "process" as the first word
>>>>          via normal_pid_to_str.
>>>>          
>>>>          Add a tdlabel_re global variable as a regular-expression for a thread
>>>>          label in `info threads' that matches either "process", "Thread", or
>>>>          "LWP".
>>>>          
>>>>          Some other tests in the tree don't require a specific word, and
>>>>          some targets may use other first words (e.g. OpenBSD uses "thread"
>>>>          and Ravenscar threads use "Ravenscar Thread").
>>>
>>> Ping, this is mostly a small change to a previously approved patch, just not
>>> sure what the threshold is for if a fixup change is small enough to still
>>> count as approved, etc.

I retested this again this week and it fixed about 100 tests on FreeBSD/amd64 and
had no regressions on Linux x86-64.  Given the version without "process" was
approved by Simon previously, I'm going to go ahead and push the version with
the "process" change.

-- 
John Baldwin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-05-09 20:56   ` John Baldwin
  2023-05-12 14:15     ` John Baldwin
@ 2024-03-26 12:19     ` Pedro Alves
  1 sibling, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2024-03-26 12:19 UTC (permalink / raw)
  To: John Baldwin, Simon Marchi, gdb-patches

On 2023-05-09 21:56, John Baldwin wrote:
> On 5/9/23 12:01 PM, Simon Marchi wrote:

>> And just one question:
>>
>>> diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
>>> index 14db2511d40..a5b7ccf4ba5 100644
>>> --- a/gdb/testsuite/gdb.trace/report.exp
>>> +++ b/gdb/testsuite/gdb.trace/report.exp
>>> @@ -380,7 +380,7 @@ proc use_collected_data { data_source } {
>>>         # There is always a thread of an inferior, either a live one or
>>>       # a faked one.
>>> -    gdb_test "info threads" "\\* ${decimal}    (process|Thread) \[0-9\.\]+\[ \t\].*"
>>> +    gdb_test "info threads" "\\* ${decimal}    ${tdlabel_re} \[0-9\.\]+\[ \t\].*"
>>
>> This one said "process" as well, I guess it's not important?
> 
> Hummm, it didn't regress on Linux, 

FYI, the tracepoint tests only run when testing against gdbserver.

I definitely see FAILs if "process" isn't matched:

 $ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver" TESTS="gdb.trace/report.exp"
 ...
 Running /home/pedro/gdb/src/gdb/testsuite/gdb.trace/report.exp ...
 FAIL: gdb.trace/report.exp: tfile: info threads
 FAIL: gdb.trace/report.exp: ctf: info threads


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-03-26 12:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 20:13 [PATCH v3] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
2023-05-08 16:19 ` [PING] " John Baldwin
2023-05-09 19:01 ` Simon Marchi via Gdb-patches
2023-05-09 20:56   ` John Baldwin
2023-05-12 14:15     ` John Baldwin
2023-05-26 17:51       ` John Baldwin
2023-06-09 16:56         ` John Baldwin
2023-06-30 14:21           ` [PING] " John Baldwin
2023-07-14 15:35             ` John Baldwin
2024-03-22 20:58               ` John Baldwin
2024-03-26 12:19     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox