public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Various test suite fixes (mostly thread related)
@ 2023-02-17 20:38 John Baldwin
  2023-02-17 20:38 ` [PATCH 1/5] gdb.threads/multi-create: Double the existing stack size John Baldwin
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: John Baldwin @ 2023-02-17 20:38 UTC (permalink / raw)
  To: gdb-patches

I've been working on a series of patches for the FreeBSD native target
to fix various issues with multiprocessing over the past month or two.
During that time I have fixed a few issues in various tests I've
observed so far.  This series is just some of the test fixes.

Patch 1 fixes a Linux-specific assumption about PTHREAD_STACK_MIN.
There are a couple of other tests that also hardcoded
PTHREAD_STACK_MIN*2, but I haven't observed crashes with those on
FreeBSD so haven't adjusted those.  However, it might be more correct
to apply this same logic to the other tests as well.

Patch 2 fixes some Linux-specific assumptions about system call
catching.  The test still has some failures on FreeBSD that I might
need to adjust in the FreeBSD native target (FreeBSD reports a single
event for exec for example that is just the TARGET_WAITKIND_EXECD but
not a separate syscall exit event, and I think a similar issue might
also exist for fork events.)  However, FreeBSD now passes at least
some of the tests compared to passing zero before.

Patches 3 and 4 fix synchronization issues where tests were assuming
that if the main thread calls pthread_create and then exits, the new
thread will start executing bofore the main thread exits.  That isn't
guaranteed to be true as a given kernel scheduler may create the new
thread and place it on a run queue but not preempt to it and return to
the main thread letting it exit before the new thread runs and reports
an event to say it has been born.  Use a pthread_barrier to ensure the
requirements of the test instead.  There are likely other instances of
this, these are just the two I've noticed so far.  I wonder if Linux
reports thread creation events when the thread is created rather than
when it starts executing which might explain why these tests have this
assumption?

The last patch is a bit more of a RFC and probably not really the way
we want to fix the issue.  Some tests assume that the format of 'info
threads' is to have thread identifiers start with "Thread".  However,
some targets use a different format.  For example FreeBSD's native
target refers to threads as "LWP <nnnn>".  There are some existing
tests that use a looser regex here already rather than requiring the
word "Thread".  I wonder if we want to define a helper macro or
variable or like to contain the regex to use for matching on a valid
thread identifier instead?

John Baldwin (5):
  gdb.threads/multi-create: Double the existing stack size.
  gdb.base/catch-syscall.exp: Remove some Linux-only assumptions.
  gdb.threads/execl.c: Ensure all threads are started before execl.
  gdb.threads/next-bp-other-thread.c: Ensure child thread is started.
  gdb tests: Allow for "LWP" in thread IDs from info threads.

 gdb/testsuite/gdb.base/catch-syscall.c        |  4 ++
 gdb/testsuite/gdb.base/catch-syscall.exp      | 48 +++++++++++++++++--
 .../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.c             |  8 ++++
 gdb/testsuite/gdb.threads/execl.exp           |  6 +--
 .../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 |  2 +-
 gdb/testsuite/gdb.threads/leader-exit.exp     |  2 +-
 gdb/testsuite/gdb.threads/manythreads.exp     |  2 +-
 gdb/testsuite/gdb.threads/multi-create.c      |  8 +++-
 .../gdb.threads/next-bp-other-thread.c        |  9 ++++
 .../gdb.threads/no-unwaited-for-left.exp      |  4 +-
 gdb/testsuite/gdb.threads/non-ldr-exc-2.exp   |  2 +-
 gdb/testsuite/gdb.threads/pthreads.exp        |  8 ++--
 .../signal-command-handle-nopass.exp          |  2 +-
 ...ignal-command-multiple-signals-pending.exp |  2 +-
 .../signal-delivered-right-thread.exp         |  2 +-
 gdb/testsuite/gdb.threads/signal-sigtrap.exp  |  4 +-
 gdb/testsuite/gdb.threads/staticthreads.exp   |  2 +-
 .../gdb.threads/thread-specific-bp.exp        |  2 +-
 gdb/testsuite/gdb.threads/thread-specific.exp |  4 +-
 gdb/testsuite/gdb.threads/tls.exp             | 12 ++---
 gdb/testsuite/gdb.trace/report.exp            |  2 +-
 gdb/testsuite/gdb.trace/strace.exp            |  2 +-
 28 files changed, 120 insertions(+), 55 deletions(-)

-- 
2.38.1


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

* [PATCH 1/5] gdb.threads/multi-create: Double the existing stack size.
  2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
@ 2023-02-17 20:38 ` John Baldwin
  2023-02-17 20:38 ` [PATCH 2/5] gdb.base/catch-syscall.exp: Remove some Linux-only assumptions John Baldwin
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Baldwin @ 2023-02-17 20:38 UTC (permalink / raw)
  To: gdb-patches

Setting the stack size to 2*PTHREAD_STACK_MIN actually lowered the
stack on FreeBSD rather than raising it causing non-main threads in
the test program to overflow their stack and crash.  Double the
existing stack size rather than assuming that the initial stack size
is PTHREAD_STACK_MIN.
---
 gdb/testsuite/gdb.threads/multi-create.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/multi-create.c b/gdb/testsuite/gdb.threads/multi-create.c
index f4a47c36e1d..9944ba5957a 100644
--- a/gdb/testsuite/gdb.threads/multi-create.c
+++ b/gdb/testsuite/gdb.threads/multi-create.c
@@ -39,11 +39,13 @@ create_function (void *arg)
   pthread_attr_t attr;
   pthread_t threads[NUM_THREAD];
   int args[NUM_THREAD];
+  size_t stacksize;
   int i = * (int *) arg;
   int j;
 
   pthread_attr_init (&attr); /* set breakpoint 1 here.  */
-  pthread_attr_setstacksize (&attr, 2*PTHREAD_STACK_MIN);
+  pthread_attr_getstacksize (&attr, &stacksize);
+  pthread_attr_setstacksize (&attr, 2 * stacksize);
 
   /* Create a ton of quick-executing threads, then wait for them to
      complete.  */
@@ -67,10 +69,12 @@ main (int argc, char **argv)
   pthread_attr_t attr;
   pthread_t threads[NUM_CREATE];
   int args[NUM_CREATE];
+  size_t stacksize;
   int n, i;
 
   pthread_attr_init (&attr);
-  pthread_attr_setstacksize (&attr, 2*PTHREAD_STACK_MIN);
+  pthread_attr_getstacksize (&attr, &stacksize);
+  pthread_attr_setstacksize (&attr, 2 * stacksize);
 
   for (n = 0; n < 100; ++n)
     {
-- 
2.38.1


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

* [PATCH 2/5] gdb.base/catch-syscall.exp: Remove some Linux-only assumptions.
  2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
  2023-02-17 20:38 ` [PATCH 1/5] gdb.threads/multi-create: Double the existing stack size John Baldwin
@ 2023-02-17 20:38 ` John Baldwin
  2023-02-17 20:38 ` [PATCH 3/5] gdb.threads/execl.c: Ensure all threads are started before execl John Baldwin
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Baldwin @ 2023-02-17 20:38 UTC (permalink / raw)
  To: gdb-patches

- Some OS's use a different syscall for exit().  For example, the
  BSD's use SYS_exit rather than SYS_exit_group.  Update the C source
  file and the expect script to support SYS_exit as an alternative to
  SYS_exit_group.

- The cross-arch syscall number tests are all Linux-specific with
  hardcoded syscall numbers specific to Linux kernels.  Skip these
  tests on non-Linux systems.  FreeBSD kernels for example use the
  same system call numbers on all platforms, so the test is also not
  relevant on FreeBSD.
---
 gdb/testsuite/gdb.base/catch-syscall.c   |  4 ++
 gdb/testsuite/gdb.base/catch-syscall.exp | 48 ++++++++++++++++++++++--
 2 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c
index 8c252a06b20..070c0122e45 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.c
+++ b/gdb/testsuite/gdb.base/catch-syscall.c
@@ -38,7 +38,11 @@ int unknown_syscall = 0x0f07ff;
 #else
 int unknown_syscall = 123456789;
 #endif
+#ifdef SYS_exit_group
 int exit_group_syscall = SYS_exit_group;
+#else
+int exit_syscall = SYS_exit;
+#endif
 
 /* Set by the test when it wants execve.  */
 int do_execve = 0;
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index 22181bc884e..4a9302fb9b7 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -63,7 +63,7 @@ set all_syscalls_numbers { }
 # The last syscall (exit()) does not return, so
 # we cannot expect the catchpoint to be triggered
 # twice.  It is a special case.
-set last_syscall "exit_group"
+set last_syscall { }
 set last_syscall_number { }
 
 set vfork_syscalls "(vfork|clone2?)"
@@ -494,7 +494,7 @@ proc do_syscall_tests {} {
 
     # Testing if the 'catch syscall' command works when switching to
     # different architectures on-the-fly (PR gdb/10737).
-    if {[runto_main]} { test_catch_syscall_multi_arch }
+    if {[istarget *-linux*] && [runto_main]} { test_catch_syscall_multi_arch }
 
     # Testing the 'catch' syscall command for a group of syscalls.
     if {[runto_main]} { test_catch_syscall_group }
@@ -677,13 +677,12 @@ proc do_syscall_tests_without_xml {} {
 # This procedure fills the vector "all_syscalls_numbers" with the proper
 # numbers for the used syscalls according to the architecture.
 proc fill_all_syscalls_numbers {} {
-    global all_syscalls_numbers last_syscall_number unknown_syscall_number all_syscalls
+    global all_syscalls_numbers unknown_syscall_number all_syscalls
 
     foreach syscall $all_syscalls {
 	lappend all_syscalls_numbers [get_integer_valueof "${syscall}_syscall" -1]
     }
 
-    set last_syscall_number [get_integer_valueof "exit_group_syscall" -1]
     set unknown_syscall_number [get_integer_valueof "unknown_syscall" -1]
 }
 
@@ -693,6 +692,7 @@ proc setup_all_syscalls {} {
     global all_syscalls
     global gdb_prompt
     global decimal
+    global last_syscall last_syscall_number
 
     # They are ordered according to the file, so do not change this.
     lappend all_syscalls "close"
@@ -769,6 +769,46 @@ proc setup_all_syscalls {} {
     lappend all_syscalls "write"
     lappend all_syscalls "read"
 
+    # Determine the right syscall to use for exit()
+    set test "check SYS_exit"
+    set have_SYS_exit 0
+    set SYS_exit -1
+    gdb_test_multiple "p exit_syscall" $test {
+	-re -wrap " = ($decimal)" {
+	    pass $test
+	    set have_SYS_exit 1
+	    set SYS_exit $expect_out(1,string)
+	}
+	-re -wrap "No symbol .*" {
+	    pass $test
+	}
+    }
+
+    set test "check SYS_exit_group"
+    set have_SYS_exit_group 0
+    set SYS_exit_group -1
+    gdb_test_multiple "p exit_group_syscall" $test {
+	-re -wrap " = ($decimal)" {
+	    pass $test
+	    set have_SYS_exit_group 1
+	    set SYS_exit_group $expect_out(1,string)
+	}
+	-re -wrap "No symbol .*" {
+	    pass $test
+	}
+    }
+
+    if { $have_SYS_exit == 0 && $have_SYS_exit_group == 0 } {
+	return 0
+    }
+
+    if { $have_SYS_exit } {
+	set last_syscall "exit"
+	set last_syscall_number $SYS_exit
+    } else {
+	set last_syscall "exit_group"
+	set last_syscall_number $SYS_exit_group
+    }
     return 1
 }
 
-- 
2.38.1


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

* [PATCH 3/5] gdb.threads/execl.c: Ensure all threads are started before execl.
  2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
  2023-02-17 20:38 ` [PATCH 1/5] gdb.threads/multi-create: Double the existing stack size John Baldwin
  2023-02-17 20:38 ` [PATCH 2/5] gdb.base/catch-syscall.exp: Remove some Linux-only assumptions John Baldwin
@ 2023-02-17 20:38 ` John Baldwin
  2023-02-17 20:38 ` [PATCH 4/5] gdb.threads/next-bp-other-thread.c: Ensure child thread is started John Baldwin
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Baldwin @ 2023-02-17 20:38 UTC (permalink / raw)
  To: gdb-patches

Use a pthread_barrier to ensure all threads are started before
proceeding to the breakpoint where info threads output is checked.
---
 gdb/testsuite/gdb.threads/execl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/testsuite/gdb.threads/execl.c b/gdb/testsuite/gdb.threads/execl.c
index 8fb42e7e9ed..b9b42a29247 100644
--- a/gdb/testsuite/gdb.threads/execl.c
+++ b/gdb/testsuite/gdb.threads/execl.c
@@ -26,9 +26,13 @@
 #include <string.h>
 #include <stdlib.h>
 
+static pthread_barrier_t threads_started_barrier;
+
 void *
 thread_function (void *arg)
 {
+  pthread_barrier_wait (&threads_started_barrier);
+
   while (1)
     sleep (100);
   return NULL;
@@ -41,9 +45,13 @@ main (int argc, char* argv[])
   pthread_t thread2;
   char *new_image;
 
+  pthread_barrier_init (&threads_started_barrier, NULL, 3);
+
   pthread_create (&thread1, NULL, thread_function, NULL);
   pthread_create (&thread2, NULL, thread_function, NULL);
 
+  pthread_barrier_wait (&threads_started_barrier);
+
   new_image = malloc (strlen (argv[0]) + 2);
   strcpy (new_image, argv[0]);
   strcat (new_image, "1");
-- 
2.38.1


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

* [PATCH 4/5] gdb.threads/next-bp-other-thread.c: Ensure child thread is started.
  2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
                   ` (2 preceding siblings ...)
  2023-02-17 20:38 ` [PATCH 3/5] gdb.threads/execl.c: Ensure all threads are started before execl John Baldwin
@ 2023-02-17 20:38 ` John Baldwin
  2023-02-17 20:38 ` [PATCH 5/5] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: John Baldwin @ 2023-02-17 20:38 UTC (permalink / raw)
  To: gdb-patches

Use a pthread_barrier to ensure the child thread is started before
the main thread gets to the first breakpoint.
---
 gdb/testsuite/gdb.threads/next-bp-other-thread.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/gdb.threads/next-bp-other-thread.c b/gdb/testsuite/gdb.threads/next-bp-other-thread.c
index 60aa029464c..33c6ec11982 100644
--- a/gdb/testsuite/gdb.threads/next-bp-other-thread.c
+++ b/gdb/testsuite/gdb.threads/next-bp-other-thread.c
@@ -22,9 +22,13 @@
 /* Always zero, used in breakpoint condition.  */
 volatile int global_zero;
 
+static pthread_barrier_t threads_started_barrier;
+
 void *
 child_function (void *arg)
 {
+  pthread_barrier_wait (&threads_started_barrier);
+
   while (1)
     {
       usleep (1); /* set breakpoint child here */
@@ -39,7 +43,12 @@ main (void)
   pthread_t child_thread;
   int res;
 
+  pthread_barrier_init (&threads_started_barrier, NULL, 2);
+
   res = pthread_create (&child_thread, NULL, child_function, NULL);
+
+  pthread_barrier_wait (&threads_started_barrier);
+
   sleep (2); /* set wait-thread breakpoint here */
   exit (EXIT_SUCCESS);
 }
-- 
2.38.1


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

* [PATCH 5/5] gdb tests: Allow for "LWP" in thread IDs from info threads.
  2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
                   ` (3 preceding siblings ...)
  2023-02-17 20:38 ` [PATCH 4/5] gdb.threads/next-bp-other-thread.c: Ensure child thread is started John Baldwin
@ 2023-02-17 20:38 ` John Baldwin
  2023-03-03 17:59 ` [PING] [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
  2023-03-03 19:16 ` Tom Tromey
  6 siblings, 0 replies; 8+ messages in thread
From: John Baldwin @ 2023-02-17 20:38 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.

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    |  2 +-
 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      |  2 +-
 gdb/testsuite/gdb.threads/pthreads.exp           |  8 ++++----
 .../gdb.threads/signal-command-handle-nopass.exp |  2 +-
 .../signal-command-multiple-signals-pending.exp  |  2 +-
 .../signal-delivered-right-thread.exp            |  2 +-
 gdb/testsuite/gdb.threads/signal-sigtrap.exp     |  4 ++--
 gdb/testsuite/gdb.threads/staticthreads.exp      |  2 +-
 gdb/testsuite/gdb.threads/thread-specific-bp.exp |  2 +-
 gdb/testsuite/gdb.threads/thread-specific.exp    |  4 ++--
 gdb/testsuite/gdb.threads/tls.exp                | 12 ++++++------
 gdb/testsuite/gdb.trace/report.exp               |  2 +-
 gdb/testsuite/gdb.trace/strace.exp               |  2 +-
 23 files changed, 49 insertions(+), 49 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..1b937be7a2b 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  ((Thread|LWP) ${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..6c249d9f22d 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.*}
+	{.*[\r\n]+\* +([0-9]+) +(Thread|LWP)[^\r\n]* do_something \(n=\1\) at.*}
 
 # 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 20d45ba17da..01a67923027 100644
--- a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
+++ b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
@@ -78,13 +78,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 (Thread|LWP).*$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 \]*(Thread|LWP)\[^\r\n\]*\r\n$gdb_prompt $" {
 	    pass $gdb_test_name
 	}
     }
@@ -94,7 +94,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 \]*(Thread|LWP)\[^\r\n\]*\r\n  2\[\t \]*(Thread|LWP)\[^\r\n\]*" \
 	"second thread should now exist"
 
     # Switch threads.
@@ -118,7 +118,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 \]*(Thread|LWP)\[^\r\n\]*\r\n\\\* 2\[\t \]*(Thread|LWP)\[^\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 ef4f1ea9c8d..545cca19072 100644
--- a/gdb/testsuite/gdb.threads/execl.exp
+++ b/gdb/testsuite/gdb.threads/execl.exp
@@ -40,7 +40,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 *(Thread|LWP).*2 *(Thread|LWP).*3 *(Thread|LWP).*" "info threads before exec"
 
 # Work around PR25656, where the breakpoint above sets 2 breakpoint locations:
 # - one on gdb.threads/execl.c:$linenumber, and
@@ -55,11 +55,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 *(Thread|LWP) .*$gdb_prompt $" {
 	# Old threads left behind.
 	fail "$gdb_test_name"
     }
-    -re "4 *Thread .*$gdb_prompt $" {
+    -re "4 *(Thread|LWP) .*$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..2b02ec6ef99 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" " (Thread|LWP) .* (Thread|LWP) .*" "two threads found"
diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.exp b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
index db72fb2679b..03f35665c0c 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" " (Thread|LWP) .* (Thread|LWP) .* (Thread|LWP) .* (Thread|LWP) .*" "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 " (Thread|LWP) .* (Thread|LWP) .*$gdb_prompt $" {
 	fail "$test"
     }
-    -re " Thread .*$gdb_prompt $" {
+    -re " (Thread|LWP) .*$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 " (Thread|LWP) .* (Thread|LWP) .* (Thread|LWP) .*$gdb_prompt $" {
 	fail "$test"
     }
-    -re " Thread .* Thread .*$gdb_prompt $" {
+    -re " (Thread|LWP) .* (Thread|LWP) .*$gdb_prompt $" {
 	pass "$test"
     }
     -re "$gdb_prompt $" {
@@ -94,16 +94,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" " (Thread|LWP) .* (Thread|LWP) .* (Thread|LWP) .* (Thread|LWP) .*" "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 " (Thread|LWP) .* (Thread|LWP) .* (Thread|LWP) .*$gdb_prompt $" {
 	fail "$test"
     }
-    -re " Thread .* Thread .*$gdb_prompt $" {
+    -re " (Thread|LWP) .* (Thread|LWP) .*$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..ba7575b93f9 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 *(Thread|LWP) \[^\r\n\]* .* \[^\r\n\]*" \
+	 "\\* 2 *(Thread|LWP) \[^\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 *(Thread|LWP) \[^\r\n\]* .* \[^\r\n\]*" \
+	 "\\* 2 *(Thread|LWP) \[^\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..4756bc9782b 100644
--- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
+++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
@@ -145,7 +145,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 "(Thread|LWP) \[^\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 df392c7b635..57805ec24cb 100644
--- a/gdb/testsuite/gdb.threads/leader-exit.exp
+++ b/gdb/testsuite/gdb.threads/leader-exit.exp
@@ -37,7 +37,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 *(Thread|LWP) \[^\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 da3f66a810b..a6b8113ae8a 100644
--- a/gdb/testsuite/gdb.threads/manythreads.exp
+++ b/gdb/testsuite/gdb.threads/manythreads.exp
@@ -115,7 +115,7 @@ interrupt_and_wait "stop threads 1"
 set cmd "info threads"
 set ok 0
 gdb_test_multiple $cmd $cmd {
-    -re " 1 *Thread " {
+    -re " 1 *(Thread|LWP) " {
 	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..4a28cc00c58 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 *(Thread|LWP) \[^\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 *(Thread|LWP) \[^\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..993369fd9c3 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
@@ -44,7 +44,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 *(Thread|LWP) \[^\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 acd073cd5e9..92f32bda03a 100644
--- a/gdb/testsuite/gdb.threads/pthreads.exp
+++ b/gdb/testsuite/gdb.threads/pthreads.exp
@@ -130,7 +130,7 @@ proc test_startup {} {
     # 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 ".*(Thread|LWP).*main.*$gdb_prompt $" {
 	    pass "info threads"
 	    set return_me 0
 	}
@@ -145,7 +145,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}(Thread|LWP)${horiz}main.*)($gdb_prompt $)" {
 	}
     }
 
@@ -160,7 +160,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}(Thread|LWP)${horiz}thread1.*)($gdb_prompt $)" {
 	}
     }
 
@@ -175,7 +175,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}(Thread|LWP)${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 ed03e7ae77a..7ffa221aeae 100644
--- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
+++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
@@ -62,7 +62,7 @@ proc test { step_over } {
 
 	gdb_test "thread 1" "Switching to thread 1.*"
 
-	set pattern "\\\* 1\[ \t\]+Thread.*"
+	set pattern "\\\* 1\[ \t\]+(Thread|LWP).*"
 
 	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 ac391ea77fd..27c3c4d392d 100644
--- a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
+++ b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
@@ -63,7 +63,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\]+(Thread|LWP).*" "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 fb4cbb0ec57..748f1188d74 100644
--- a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
+++ b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
@@ -42,7 +42,7 @@ proc test { command } {
 
 	gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1"
 
-	set pattern "\\\* 2\[ \t\]+Thread.*"
+	set pattern "\\\* 2\[ \t\]+(Thread|LWP).*"
 
 	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 b452731f277..460f333c9de 100644
--- a/gdb/testsuite/gdb.threads/signal-sigtrap.exp
+++ b/gdb/testsuite/gdb.threads/signal-sigtrap.exp
@@ -41,7 +41,7 @@ proc test { sigtrap_thread } {
 	    return 0
 	}
 
-	set pattern "\\\* 2\[ \t\]+Thread.*"
+	set pattern "\\\* 2\[ \t\]+(Thread|LWP).*"
 	gdb_test "info threads" $pattern "thread 2 hit breakpoint"
 
 	gdb_test "break sigtrap_handler" "Breakpoint .* at .*$srcfile.*"
@@ -57,7 +57,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\]+(Thread|LWP).*"
 	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..5aacdffe594 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 " (Thread|LWP) .*$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 f603b24fa31..febc0de1983 100644
--- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
@@ -35,7 +35,7 @@ proc get_thread_id {func} {
     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\]*(Thread|LWP)\[^\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 3c3055e5dbc..d2fa4b08f74 100644
--- a/gdb/testsuite/gdb.threads/thread-specific.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific.exp
@@ -41,11 +41,11 @@ proc get_thread_list { } {
     -re "^ *Id *Target Id\[^\n\]*\n" {
       exp_continue
     }
-    -re "^\\*  *(\[0-9\]*) *Thread \[^\n\]*main\[^\n\]*\n" {
+    -re "^\\*  *(\[0-9\]*) *(Thread|LWP) \[^\n\]*main\[^\n\]*\n" {
       set thr_list "$expect_out(1,string) $thr_list"
       exp_continue
     }
-    -re "^  *(\[0-9\]*) *Thread \[^\n\]*\n" {
+    -re "^  *(\[0-9\]*) *(Thread|LWP) \[^\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 99e9951f1f6..776376b34f9 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" ".*(Thread|LWP).*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" "(Thread|LWP).*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" ".*(Thread|LWP).*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\]+) *(Thread|LWP)\[^\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 *(Thread|LWP).*2 *(Thread|LWP).*$gdb_prompt $" {
         fail "too many threads left at end"
     }
-    -re ".*\\\* 1 *Thread.*main.*$gdb_prompt $" {
+    -re ".*\\\* 1 *(Thread|LWP).*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 33bccaa1a6a..12a379002d7 100644
--- a/gdb/testsuite/gdb.trace/report.exp
+++ b/gdb/testsuite/gdb.trace/report.exp
@@ -385,7 +385,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}    (process|Thread|LWP) \[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..c01f9a66106 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\]+(Thread|LWP) .*2\[ \t\]+(Thread|LWP) .*1\[ \t\]+(Thread|LWP) .*${gdb_prompt} $" {
 		pass "info threads"
 	    }
 	}
-- 
2.38.1


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

* [PING] [PATCH 0/5] Various test suite fixes (mostly thread related)
  2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
                   ` (4 preceding siblings ...)
  2023-02-17 20:38 ` [PATCH 5/5] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
@ 2023-03-03 17:59 ` John Baldwin
  2023-03-03 19:16 ` Tom Tromey
  6 siblings, 0 replies; 8+ messages in thread
From: John Baldwin @ 2023-03-03 17:59 UTC (permalink / raw)
  To: gdb-patches

On 2/17/23 12:38 PM, John Baldwin wrote:
> I've been working on a series of patches for the FreeBSD native target
> to fix various issues with multiprocessing over the past month or two.
> During that time I have fixed a few issues in various tests I've
> observed so far.  This series is just some of the test fixes.
> 
> Patch 1 fixes a Linux-specific assumption about PTHREAD_STACK_MIN.
> There are a couple of other tests that also hardcoded
> PTHREAD_STACK_MIN*2, but I haven't observed crashes with those on
> FreeBSD so haven't adjusted those.  However, it might be more correct
> to apply this same logic to the other tests as well.
> 
> Patch 2 fixes some Linux-specific assumptions about system call
> catching.  The test still has some failures on FreeBSD that I might
> need to adjust in the FreeBSD native target (FreeBSD reports a single
> event for exec for example that is just the TARGET_WAITKIND_EXECD but
> not a separate syscall exit event, and I think a similar issue might
> also exist for fork events.)  However, FreeBSD now passes at least
> some of the tests compared to passing zero before.
> 
> Patches 3 and 4 fix synchronization issues where tests were assuming
> that if the main thread calls pthread_create and then exits, the new
> thread will start executing bofore the main thread exits.  That isn't
> guaranteed to be true as a given kernel scheduler may create the new
> thread and place it on a run queue but not preempt to it and return to
> the main thread letting it exit before the new thread runs and reports
> an event to say it has been born.  Use a pthread_barrier to ensure the
> requirements of the test instead.  There are likely other instances of
> this, these are just the two I've noticed so far.  I wonder if Linux
> reports thread creation events when the thread is created rather than
> when it starts executing which might explain why these tests have this
> assumption?
> 
> The last patch is a bit more of a RFC and probably not really the way
> we want to fix the issue.  Some tests assume that the format of 'info
> threads' is to have thread identifiers start with "Thread".  However,
> some targets use a different format.  For example FreeBSD's native
> target refers to threads as "LWP <nnnn>".  There are some existing
> tests that use a looser regex here already rather than requiring the
> word "Thread".  I wonder if we want to define a helper macro or
> variable or like to contain the regex to use for matching on a valid
> thread identifier instead?
> 
> John Baldwin (5):
>    gdb.threads/multi-create: Double the existing stack size.
>    gdb.base/catch-syscall.exp: Remove some Linux-only assumptions.
>    gdb.threads/execl.c: Ensure all threads are started before execl.
>    gdb.threads/next-bp-other-thread.c: Ensure child thread is started.
>    gdb tests: Allow for "LWP" in thread IDs from info threads.
> 
>   gdb/testsuite/gdb.base/catch-syscall.c        |  4 ++
>   gdb/testsuite/gdb.base/catch-syscall.exp      | 48 +++++++++++++++++--
>   .../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.c             |  8 ++++
>   gdb/testsuite/gdb.threads/execl.exp           |  6 +--
>   .../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 |  2 +-
>   gdb/testsuite/gdb.threads/leader-exit.exp     |  2 +-
>   gdb/testsuite/gdb.threads/manythreads.exp     |  2 +-
>   gdb/testsuite/gdb.threads/multi-create.c      |  8 +++-
>   .../gdb.threads/next-bp-other-thread.c        |  9 ++++
>   .../gdb.threads/no-unwaited-for-left.exp      |  4 +-
>   gdb/testsuite/gdb.threads/non-ldr-exc-2.exp   |  2 +-
>   gdb/testsuite/gdb.threads/pthreads.exp        |  8 ++--
>   .../signal-command-handle-nopass.exp          |  2 +-
>   ...ignal-command-multiple-signals-pending.exp |  2 +-
>   .../signal-delivered-right-thread.exp         |  2 +-
>   gdb/testsuite/gdb.threads/signal-sigtrap.exp  |  4 +-
>   gdb/testsuite/gdb.threads/staticthreads.exp   |  2 +-
>   .../gdb.threads/thread-specific-bp.exp        |  2 +-
>   gdb/testsuite/gdb.threads/thread-specific.exp |  4 +-
>   gdb/testsuite/gdb.threads/tls.exp             | 12 ++---
>   gdb/testsuite/gdb.trace/report.exp            |  2 +-
>   gdb/testsuite/gdb.trace/strace.exp            |  2 +-
>   28 files changed, 120 insertions(+), 55 deletions(-)

Ping.

-- 
John Baldwin


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

* Re: [PATCH 0/5] Various test suite fixes (mostly thread related)
  2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
                   ` (5 preceding siblings ...)
  2023-03-03 17:59 ` [PING] [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
@ 2023-03-03 19:16 ` Tom Tromey
  6 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2023-03-03 19:16 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches

John> I've been working on a series of patches for the FreeBSD native target
John> to fix various issues with multiprocessing over the past month or two.
John> During that time I have fixed a few issues in various tests I've
John> observed so far.  This series is just some of the test fixes.

Thank you for doing this.

John> Patches 3 and 4 fix synchronization issues where tests were assuming
John> that if the main thread calls pthread_create and then exits, the new
John> thread will start executing bofore the main thread exits.

I like the barrier technique.

John> The last patch is a bit more of a RFC and probably not really the way
John> we want to fix the issue.  Some tests assume that the format of 'info
John> threads' is to have thread identifiers start with "Thread".  However,
John> some targets use a different format.  For example FreeBSD's native
John> target refers to threads as "LWP <nnnn>".  There are some existing
John> tests that use a looser regex here already rather than requiring the
John> word "Thread".  I wonder if we want to define a helper macro or
John> variable or like to contain the regex to use for matching on a valid
John> thread identifier instead?

I think a helper variable would be fine.  We already have a few of these
in gdb.exp, like 'octal' or 'bkptno_numopt_re'.

I think patches 1-4 are OK as-is.

thanks,
Tom

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

end of thread, other threads:[~2023-03-03 19:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
2023-02-17 20:38 ` [PATCH 1/5] gdb.threads/multi-create: Double the existing stack size John Baldwin
2023-02-17 20:38 ` [PATCH 2/5] gdb.base/catch-syscall.exp: Remove some Linux-only assumptions John Baldwin
2023-02-17 20:38 ` [PATCH 3/5] gdb.threads/execl.c: Ensure all threads are started before execl John Baldwin
2023-02-17 20:38 ` [PATCH 4/5] gdb.threads/next-bp-other-thread.c: Ensure child thread is started John Baldwin
2023-02-17 20:38 ` [PATCH 5/5] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
2023-03-03 17:59 ` [PING] [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
2023-03-03 19:16 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).