Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] thread tests, linux/gdbserver
@ 2006-09-25 22:26 Michael Snyder
  2006-10-05 21:51 ` PING " Michael Snyder
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2006-09-25 22:26 UTC (permalink / raw)
  To: GDB Patches ML

[-- Attachment #1: Type: text/plain, Size: 328 bytes --]

Several thread tests contain patterns that explicitly look 
for the string "Thread" (capitalized) in the info threads
output.  

But target remote prints it as "thread" (lower case), and 
so even though these tests can be run against gdbserver, 
they will fail.

This patch just substitutes a pattern "\[Tt\]hread".

Seem OK?



[-- Attachment #2: threadremote --]
[-- Type: text/plain, Size: 7532 bytes --]

2006-09-25  Michael Snyder  <michael.snyder@localhost.localdomain>

	* gdb.threads/linux-dp.exp: Relax patterns for remote targets.
	* gdb.threads/manythreads.exp: Ditto.
	* gdb.threads/pthreads.exp: Ditto.
	* gdb.threads/staticthreads.exp: Ditto.

Index: linux-dp.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/linux-dp.exp,v
retrieving revision 1.11
diff -p -r1.11 linux-dp.exp
*** linux-dp.exp	4 May 2005 21:21:42 -0000	1.11
--- linux-dp.exp	25 Sep 2006 22:15:51 -0000
*************** gdb_breakpoint [gdb_get_line_number "lin
*** 111,120 ****
  gdb_continue_to_breakpoint "main thread's sleep"
  set info_threads_ptn ""
  for {set i $nthreads} {$i > 0} {incr i -1} {
!     append info_threads_ptn "$i Thread .*"
  }
  append info_threads_ptn "\[\r\n\]+$gdb_prompt $"
! set info_threads_manager_ptn "[expr $nthreads + 1] Thread .*$info_threads_ptn"
  
  gdb_test_multiple "info threads" "info threads 2" {
      -re "$info_threads_manager_ptn" {
--- 111,120 ----
  gdb_continue_to_breakpoint "main thread's sleep"
  set info_threads_ptn ""
  for {set i $nthreads} {$i > 0} {incr i -1} {
!     append info_threads_ptn "$i \[Tt\]hread .*"
  }
  append info_threads_ptn "\[\r\n\]+$gdb_prompt $"
! set info_threads_manager_ptn "[expr $nthreads + 1] \[Tt\]hread .*$info_threads_ptn"
  
  gdb_test_multiple "info threads" "info threads 2" {
      -re "$info_threads_manager_ptn" {
*************** for {set i 0} {$only_five > 0 && $i < 10
*** 178,184 ****
      gdb_continue_to_breakpoint "thread 5's print, pass: $i"
      send_gdb "info threads\n"
      gdb_expect {
! 	-re "\\* 5 Thread .*  print_philosopher .*\r\n$gdb_prompt $" {
  	    # Okay this time.
  	}
  	-re ".*$gdb_prompt $" {
--- 178,184 ----
      gdb_continue_to_breakpoint "thread 5's print, pass: $i"
      send_gdb "info threads\n"
      gdb_expect {
! 	-re "\\* 5 \[Tt\]hread .*  print_philosopher .*\r\n$gdb_prompt $" {
  	    # Okay this time.
  	}
  	-re ".*$gdb_prompt $" {
Index: manythreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/manythreads.exp,v
retrieving revision 1.2
diff -p -r1.2 manythreads.exp
*** manythreads.exp	3 Jun 2004 22:10:56 -0000	1.2
--- manythreads.exp	25 Sep 2006 22:15:51 -0000
*************** gdb_test_multiple "" "stop threads 1" {
*** 70,76 ****
    -re "\\\[\[^\]\]* exited\\\]\r\n" {
      exp_continue
    }
!   -re "Thread \[^\n\]* executing\r\n" {
      exp_continue
    }
    -re "Program received signal SIGINT.*$gdb_prompt $" {
--- 70,76 ----
    -re "\\\[\[^\]\]* exited\\\]\r\n" {
      exp_continue
    }
!     -re "\[Tt\]hread \[^\n\]* executing\r\n" {
      exp_continue
    }
    -re "Program received signal SIGINT.*$gdb_prompt $" {
*************** gdb_test_multiple "" "stop threads 1" {
*** 81,87 ****
    }
  }
  
! gdb_test "info threads" ".*1 Thread.*.LWP.*"
  
  set message "second continue"
  gdb_test_multiple "continue" "second continue" {
--- 81,87 ----
    }
  }
  
! gdb_test "info threads" ".*1 \[Tt\]hread.*"
  
  set message "second continue"
  gdb_test_multiple "continue" "second continue" {
*************** gdb_test_multiple "" "stop threads 2" {
*** 104,114 ****
    -re "\\\[\[^\]\]* exited\\\]\r\n" {
      exp_continue
    }
!   -re "Thread \[^\n\]* executing\r\n" {
      exp_continue
    }
    -re "Program received signal SIGINT.*$gdb_prompt $" {
!     pass "stop threads 2"
    }
  } 
  
--- 104,117 ----
    -re "\\\[\[^\]\]* exited\\\]\r\n" {
      exp_continue
    }
!     -re "\[Tt\]hread \[^\n\]* executing\r\n" {
      exp_continue
    }
    -re "Program received signal SIGINT.*$gdb_prompt $" {
!     pass "$message"
!   }
!   timeout {
!     fail "$message (timeout)"
    }
  } 
  
Index: pthreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/pthreads.exp,v
retrieving revision 1.12
diff -p -r1.12 pthreads.exp
*** pthreads.exp	4 Jun 2004 23:27:50 -0000	1.12
--- pthreads.exp	25 Sep 2006 22:15:51 -0000
*************** proc test_startup {} {
*** 172,178 ****
      # We should be able to do an info threads before starting any others.
      send_gdb "info threads\n"
      gdb_expect {
! 	-re ".*Thread.*main.*$gdb_prompt $" {
  	    pass "info threads"
  	}
  	-re "\r\n$gdb_prompt $" {
--- 172,178 ----
      # We should be able to do an info threads before starting any others.
      send_gdb "info threads\n"
      gdb_expect {
! 	-re ".*\[Tt\]hread.*main.*$gdb_prompt $" {
  	    pass "info threads"
  	}
  	-re "\r\n$gdb_prompt $" {
*************** proc test_startup {} {
*** 183,189 ****
  
      # Extract the thread id number of main thread from "info threads" output.
      send_gdb "info threads\n"
!     gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)"
      set main_id $expect_out(1,string)
  
      # Check that we can continue and create the first thread.
--- 183,189 ----
  
      # Extract the thread id number of main thread from "info threads" output.
      send_gdb "info threads\n"
!     gdb_expect -re "(\[0-9\]+)(${horiz}\[Tt\]hread${horiz}main.*)($gdb_prompt $)"
      set main_id $expect_out(1,string)
  
      # Check that we can continue and create the first thread.
*************** proc test_startup {} {
*** 195,201 ****
  
      # Extract the thread id number of thread 1 from "info threads" output.
      send_gdb "info threads\n"
!     gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)"
      set thread1_id $expect_out(1,string)
  
      # Check that we can continue and create the second thread,
--- 195,201 ----
  
      # Extract the thread id number of thread 1 from "info threads" output.
      send_gdb "info threads\n"
!     gdb_expect -re "(\[0-9\]+)(${horiz}\[Tt\]hread${horiz}thread1.*)($gdb_prompt $)"
      set thread1_id $expect_out(1,string)
  
      # Check that we can continue and create the second thread,
*************** proc test_startup {} {
*** 207,213 ****
  
      # Extract the thread id number of thread 2 from "info threads" output.
      send_gdb "info threads\n"
!     gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)"
      set thread2_id $expect_out(1,string)
  
      return 1
--- 207,213 ----
  
      # Extract the thread id number of thread 2 from "info threads" output.
      send_gdb "info threads\n"
!     gdb_expect -re "(\[0-9\]+)(${horiz}\[Tt\]hread${horiz}thread2.*)($gdb_prompt $)"
      set thread2_id $expect_out(1,string)
  
      return 1
Index: staticthreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/staticthreads.exp,v
retrieving revision 1.2
diff -p -r1.2 staticthreads.exp
*** staticthreads.exp	30 Apr 2005 19:56:47 -0000	1.2
--- staticthreads.exp	25 Sep 2006 22:15:51 -0000
*************** gdb_test "continue" " .*sem_post .*" "ha
*** 79,85 ****
  
  set test "info threads"
  gdb_test_multiple "info threads" "$test" {
!     -re " Thread .*$gdb_prompt " {
  	pass "$test"
      }
      -re "$gdb_prompt " {
--- 79,85 ----
  
  set test "info threads"
  gdb_test_multiple "info threads" "$test" {
!     -re " \[Tt\]hread .*$gdb_prompt " {
  	pass "$test"
      }
      -re "$gdb_prompt " {

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

* PING Re: [RFC] thread tests, linux/gdbserver
  2006-09-25 22:26 [RFC] thread tests, linux/gdbserver Michael Snyder
@ 2006-10-05 21:51 ` Michael Snyder
  2006-10-06 10:53   ` Mark Kettenis
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2006-10-05 21:51 UTC (permalink / raw)
  To: GDB Patches ML; +Cc: Daniel Jacobowitz

Any objections to this patch?

On Mon, 2006-09-25 at 15:26 -0700, Michael Snyder wrote:
> Several thread tests contain patterns that explicitly look 
> for the string "Thread" (capitalized) in the info threads
> output.  
> 
> But target remote prints it as "thread" (lower case), and 
> so even though these tests can be run against gdbserver, 
> they will fail.
> 
> This patch just substitutes a pattern "\[Tt\]hread".
> 
> Seem OK?
> 
> 


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

* Re: PING Re: [RFC] thread tests, linux/gdbserver
  2006-10-05 21:51 ` PING " Michael Snyder
@ 2006-10-06 10:53   ` Mark Kettenis
  2006-10-06 18:31     ` Michael Snyder
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Kettenis @ 2006-10-06 10:53 UTC (permalink / raw)
  To: Michael Snyder; +Cc: GDB Patches ML, Daniel Jacobowitz

>  Any objections to this patch?

Hmm, I must have missed the origional mail, but I think we should actually
fix our code to print these things in a more consistent manner.

>  On Mon, 2006-09-25 at 15:26 -0700, Michael Snyder wrote:
> > Several thread tests contain patterns that explicitly look
> > for the string "Thread" (capitalized) in the info threads
> > output.
> >
> > But target remote prints it as "thread" (lower case), and
> > so even though these tests can be run against gdbserver,
> > they will fail.
> >
> > This patch just substitutes a pattern "\[Tt\]hread".
> >
> > Seem OK?
> >
> >
>



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

* Re: PING Re: [RFC] thread tests, linux/gdbserver
  2006-10-06 10:53   ` Mark Kettenis
@ 2006-10-06 18:31     ` Michael Snyder
  2006-10-17 15:46       ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2006-10-06 18:31 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: GDB Patches ML, Daniel Jacobowitz

On Fri, 2006-10-06 at 12:53 +0200, Mark Kettenis wrote:
> >  Any objections to this patch?
> 
> Hmm, I must have missed the origional mail, but I think we should actually
> fix our code to print these things in a more consistent manner.

It comes from target_pid_to_str, which is a target method.
We don't officially control what it looks like, since a target
is free to say anything it likes.

Of course, we do control the remote target, which is all I'm
immediately concerned with here.  It would be a one-line 
change, I think, to capitalize it...



> 
> >  On Mon, 2006-09-25 at 15:26 -0700, Michael Snyder wrote:
> > > Several thread tests contain patterns that explicitly look
> > > for the string "Thread" (capitalized) in the info threads
> > > output.
> > >
> > > But target remote prints it as "thread" (lower case), and
> > > so even though these tests can be run against gdbserver,
> > > they will fail.
> > >
> > > This patch just substitutes a pattern "\[Tt\]hread".
> > >
> > > Seem OK?
> > >
> > >
> >
> 
> 


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

* Re: PING Re: [RFC] thread tests, linux/gdbserver
  2006-10-06 18:31     ` Michael Snyder
@ 2006-10-17 15:46       ` Daniel Jacobowitz
  2006-10-17 15:53         ` Daniel Jacobowitz
  2006-10-17 20:08         ` Michael Snyder
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2006-10-17 15:46 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Mark Kettenis, GDB Patches ML

On Fri, Oct 06, 2006 at 11:31:16AM -0700, Michael Snyder wrote:
> On Fri, 2006-10-06 at 12:53 +0200, Mark Kettenis wrote:
> > >  Any objections to this patch?
> > 
> > Hmm, I must have missed the origional mail, but I think we should actually
> > fix our code to print these things in a more consistent manner.
> 
> It comes from target_pid_to_str, which is a target method.
> We don't officially control what it looks like, since a target
> is free to say anything it likes.
> 
> Of course, we do control the remote target, which is all I'm
> immediately concerned with here.  It would be a one-line 
> change, I think, to capitalize it...

In fact, I was working on gdbserver support for tls.exp this morning,
and that's one of the affected tests.  So I made this change,
tested it with x86-64 gdbserver, and committed it.

It fixes a bunch of failures in linux-dp.exp and thread-specific.exp,
and lets more tests run for pthreads.exp.

-- 
Daniel Jacobowitz
CodeSourcery

2006-10-17  Daniel Jacobowitz  <dan@codesourcery.com>

	* remote.c (remote_pid_to_str): Capitalize "Thread".

Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.232
diff -u -p -r1.232 remote.c
--- remote.c	16 Oct 2006 03:08:37 -0000	1.232
+++ remote.c	17 Oct 2006 14:34:35 -0000
@@ -5834,7 +5834,7 @@ remote_pid_to_str (ptid_t ptid)
 {
   static char buf[32];
 
-  xsnprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid));
+  xsnprintf (buf, sizeof buf, "Thread %d", ptid_get_pid (ptid));
   return buf;
 }
 


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

* Re: PING Re: [RFC] thread tests, linux/gdbserver
  2006-10-17 15:46       ` Daniel Jacobowitz
@ 2006-10-17 15:53         ` Daniel Jacobowitz
  2006-10-17 20:08         ` Michael Snyder
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2006-10-17 15:53 UTC (permalink / raw)
  To: Michael Snyder, Mark Kettenis, GDB Patches ML

On Tue, Oct 17, 2006 at 11:46:11AM -0400, Daniel Jacobowitz wrote:
> It fixes a bunch of failures in linux-dp.exp and thread-specific.exp,
> and lets more tests run for pthreads.exp.

I noticed that Michael's patch fixed manythreads.exp, but I didn't see
that in my changes.  So I looked closer: it wasn't being run at all,
because it wasn't 64-bit safe, and then it had an additional
assumption.

I tested and committed the attached obvious fixups.

-- 
Daniel Jacobowitz
CodeSourcery

2006-10-17  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.threads/manythreads.c (thread_function, main): Don't cast
	int to pointer or pointer to int.
	* gdb.threads/manythreads.exp: Don't expect the string "LWP".

Index: testsuite/gdb.threads/manythreads.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/manythreads.c,v
retrieving revision 1.3
diff -u -p -r1.3 manythreads.c
--- testsuite/gdb.threads/manythreads.c	23 Apr 2004 19:01:17 -0000	1.3
+++ testsuite/gdb.threads/manythreads.c	17 Oct 2006 15:50:27 -0000
@@ -1,5 +1,5 @@
 /* Manythreads test program.
-   Copyright 2004
+   Copyright 2004, 2006
    Free Software Foundation, Inc.
 
    Written by Jeff Johnston <jjohnstn@redhat.com> 
@@ -29,7 +29,7 @@
 void *
 thread_function (void *arg)
 {
-  int x = (int)arg;
+  int x = * (int *) arg;
 
   printf ("Thread <%d> executing\n", x);
 
@@ -41,6 +41,7 @@ main (int argc, char **argv)
 {
   pthread_attr_t attr;
   pthread_t threads[256];
+  int args[256];
   int i, j;
 
   pthread_attr_init (&attr);
@@ -52,8 +53,8 @@ main (int argc, char **argv)
     {
       for (j = 0; j < 256; ++j)
 	{
-	  pthread_create (&threads[j], &attr, thread_function, 
-			  (void *)(i * 1000 + j));
+	  args[j] = i * 1000 + j;
+	  pthread_create (&threads[j], &attr, thread_function, &args[j]);
 	}
 
       for (j = 0; j < 256; ++j)
Index: testsuite/gdb.threads/manythreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/manythreads.exp,v
retrieving revision 1.2
diff -u -p -r1.2 manythreads.exp
--- testsuite/gdb.threads/manythreads.exp	3 Jun 2004 22:10:56 -0000	1.2
+++ testsuite/gdb.threads/manythreads.exp	17 Oct 2006 15:50:27 -0000
@@ -1,5 +1,5 @@
 # manythreads.exp -- Expect script to test stopping many threads
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -81,7 +81,7 @@ gdb_test_multiple "" "stop threads 1" {
   }
 }
 
-gdb_test "info threads" ".*1 Thread.*.LWP.*"
+gdb_test "info threads" ".*1 Thread .*"
 
 set message "second continue"
 gdb_test_multiple "continue" "second continue" {


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

* Re: PING Re: [RFC] thread tests, linux/gdbserver
  2006-10-17 15:46       ` Daniel Jacobowitz
  2006-10-17 15:53         ` Daniel Jacobowitz
@ 2006-10-17 20:08         ` Michael Snyder
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Snyder @ 2006-10-17 20:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Mark Kettenis, GDB Patches ML

On Tue, 2006-10-17 at 11:46 -0400, Daniel Jacobowitz wrote:
> On Fri, Oct 06, 2006 at 11:31:16AM -0700, Michael Snyder wrote:
> > On Fri, 2006-10-06 at 12:53 +0200, Mark Kettenis wrote:
> > > >  Any objections to this patch?
> > > 
> > > Hmm, I must have missed the origional mail, but I think we should actually
> > > fix our code to print these things in a more consistent manner.
> > 
> > It comes from target_pid_to_str, which is a target method.
> > We don't officially control what it looks like, since a target
> > is free to say anything it likes.
> > 
> > Of course, we do control the remote target, which is all I'm
> > immediately concerned with here.  It would be a one-line 
> > change, I think, to capitalize it...
> 
> In fact, I was working on gdbserver support for tls.exp this morning,
> and that's one of the affected tests.  So I made this change,
> tested it with x86-64 gdbserver, and committed it.
> 
> It fixes a bunch of failures in linux-dp.exp and thread-specific.exp,
> and lets more tests run for pthreads.exp.

Cool!  Then consider this patch withdrawn.



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

end of thread, other threads:[~2006-10-17 20:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-25 22:26 [RFC] thread tests, linux/gdbserver Michael Snyder
2006-10-05 21:51 ` PING " Michael Snyder
2006-10-06 10:53   ` Mark Kettenis
2006-10-06 18:31     ` Michael Snyder
2006-10-17 15:46       ` Daniel Jacobowitz
2006-10-17 15:53         ` Daniel Jacobowitz
2006-10-17 20:08         ` Michael Snyder

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