Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa/testsuite] gdb.threads/tls.{exp,c} fixes
@ 2003-07-29 20:44 Michael Elizabeth Chastain
  2003-07-29 21:13 ` Elena Zannoni
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Elizabeth Chastain @ 2003-07-29 20:44 UTC (permalink / raw)
  To: ezannoni, gdb-patches

This patch fixes all the ERRORs that I see with
native i686-pc-linux-gnu, red hat 8.0, glibc 2.2.93-5-rh.
All the results are now PASS, FAIL, KFAIL, and UNSUPPORTED.

The tls.exp change is a one-liner to initialize a variable
in all cases (not just the PASS case).

The tls.c change is the calls to sem_wait.  The current code
calls sem_wait and then tests errno.  My code calls sem_wait
and tests errno only if sem_wait failed.  This is important,
because I have observed a lot of test suite hangs caused by
return_value = 0, errno = EINTR (happens about 75% to 90% of
the time in my test bed).

Tested on native i686-pc-linux-gnu, red hat 8.0, glibc 2.2.93-5-rh,
with a variety of gcc's and binutils.

OK to apply?

Michael C

2003-07-29  Michael C  <mec@shout.net>

	* gdb.threads/tls.c (spin): Check errno only if sem_wait
	actually failed.
	(do_pass): Likewise.
	* gdb.threads/tls.exp: Always initialize no_of_threads.

Index: gdb.threads/tls.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/tls.c,v
retrieving revision 1.1
diff -c -3 -p -r1.1 tls.c
*** gdb.threads/tls.c	22 Jul 2003 15:49:45 -0000	1.1
--- gdb.threads/tls.c	29 Jul 2003 20:28:16 -0000
*************** void *spin( vp )
*** 89,114 ****
      fprintf (stderr, "th %d post on tell main\n", me);
  #endif
  
!     do
        {
-         errno = 0;
  #ifdef START_DEBUG
          fprintf (stderr, "th %d start wait on tell_thread\n", me);
  #endif
!         if (sem_wait (&tell_thread) == -1)
!          {
!             if (errno != EINTR)
!              {  
!                fprintf (stderr, "th %d wait on sem tell_thread failed\n", me);
!                print_error ();
!                return;
!              }
  #ifdef START_DEBUG
!            fprintf (stderr, "th %d wait tell_thread got EINTR, rewaiting\n", me);
  #endif
           }
        }
-       while (errno == EINTR);
  
  #ifdef START_DEBUG
        fprintf (stderr, "th %d Wait on tell_thread\n", me);
--- 89,116 ----
      fprintf (stderr, "th %d post on tell main\n", me);
  #endif
  
!     while (1)
        {
  #ifdef START_DEBUG
          fprintf (stderr, "th %d start wait on tell_thread\n", me);
  #endif
!         if (sem_wait (&tell_thread) == 0)
!           break;
! 
!         if (errno == EINTR)
!           {
  #ifdef START_DEBUG
!             fprintf (stderr, "th %d wait tell_thread got EINTR, rewaiting\n", me);
  #endif
+             continue;
+           }
+         else
+           {  
+             fprintf (stderr, "th %d wait on sem tell_thread failed\n", me);
+             print_error ();
+             return;
           }
        }
  
  #ifdef START_DEBUG
        fprintf (stderr, "th %d Wait on tell_thread\n", me);
*************** do_pass()
*** 151,183 ****
       }
  
      for( i = 0; i < N_THREADS; i++ )
!      {
!        do
!          {
!            errno = 0;
! 
! #ifdef START_DEBUG
!            fprintf (stderr, "main %d start wait on tell_main\n", i);
! #endif
!            if (sem_wait (&tell_main) == -1)
!             {
!               if (errno != EINTR)
!                {
!                  fprintf (stderr, "main %d wait on sem tell_main failed\n", i);
!                  print_error ();
!                  return;
!                }
  #ifdef START_DEBUG
!               fprintf (stderr, "main %d wait tell_main got EINTR, rewaiting\n", i);
  #endif
!             }
!          }
!          while (errno == EINTR);
  
! #ifdef START_DEBUG
!       fprintf (stderr, "main %d wait on tell_main\n",i);
! #endif
!      }
  
  #ifdef START_DEBUG
      fprintf (stderr, "main done waiting on tell_main\n");
--- 153,182 ----
       }
  
      for( i = 0; i < N_THREADS; i++ )
!       {
!         while (1)
!           {
  #ifdef START_DEBUG
!             fprintf (stderr, "main %d start wait on tell_main\n", i);
  #endif
!             if (sem_wait (&tell_main) == 0)
!               break;
  
!             if (errno == EINTR)
!               {
! #ifdef START_DEBUG
!                 fprintf (stderr, "main %d wait tell_main got EINTR, rewaiting\n", i);
! #endif
!                 continue;
!               }
!             else
!               {
!                 fprintf (stderr, "main %d wait on sem tell_main failed\n", i);
!                 print_error ();
!                 return;
!               }
!             }
!        }
  
  #ifdef START_DEBUG
      fprintf (stderr, "main done waiting on tell_main\n");
Index: gdb.threads/tls.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/tls.exp,v
retrieving revision 1.3
diff -c -3 -p -r1.3 tls.exp
*** gdb.threads/tls.exp	28 Jul 2003 00:57:29 -0000	1.3
--- gdb.threads/tls.exp	29 Jul 2003 20:28:17 -0000
*************** check_thread_local "third"
*** 212,217 ****
--- 212,218 ----
  
  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\]+(\[0-9\]+) Thread.*$gdb_prompt $" {


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

* Re: [rfa/testsuite] gdb.threads/tls.{exp,c} fixes
  2003-07-29 20:44 [rfa/testsuite] gdb.threads/tls.{exp,c} fixes Michael Elizabeth Chastain
@ 2003-07-29 21:13 ` Elena Zannoni
  2003-07-29 21:19   ` tls test maintainer, was " Michael Snyder
  0 siblings, 1 reply; 4+ messages in thread
From: Elena Zannoni @ 2003-07-29 21:13 UTC (permalink / raw)
  To: Michael Elizabeth Chastain; +Cc: ezannoni, gdb-patches

Michael Elizabeth Chastain writes:
 > This patch fixes all the ERRORs that I see with
 > native i686-pc-linux-gnu, red hat 8.0, glibc 2.2.93-5-rh.
 > All the results are now PASS, FAIL, KFAIL, and UNSUPPORTED.
 > 
 > The tls.exp change is a one-liner to initialize a variable
 > in all cases (not just the PASS case).
 > 
 > The tls.c change is the calls to sem_wait.  The current code
 > calls sem_wait and then tests errno.  My code calls sem_wait
 > and tests errno only if sem_wait failed.  This is important,
 > because I have observed a lot of test suite hangs caused by
 > return_value = 0, errno = EINTR (happens about 75% to 90% of
 > the time in my test bed).
 > 
 > Tested on native i686-pc-linux-gnu, red hat 8.0, glibc 2.2.93-5-rh,
 > with a variety of gcc's and binutils.
 > 

thanks, seems to work for me too.

elena


 > OK to apply?
 > 
 > Michael C
 > 
 > 2003-07-29  Michael C  <mec@shout.net>
 > 
 > 	* gdb.threads/tls.c (spin): Check errno only if sem_wait
 > 	actually failed.
 > 	(do_pass): Likewise.
 > 	* gdb.threads/tls.exp: Always initialize no_of_threads.
 > 
 > Index: gdb.threads/tls.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/tls.c,v
 > retrieving revision 1.1
 > diff -c -3 -p -r1.1 tls.c
 > *** gdb.threads/tls.c	22 Jul 2003 15:49:45 -0000	1.1
 > --- gdb.threads/tls.c	29 Jul 2003 20:28:16 -0000
 > *************** void *spin( vp )
 > *** 89,114 ****
 >       fprintf (stderr, "th %d post on tell main\n", me);
 >   #endif
 >   
 > !     do
 >         {
 > -         errno = 0;
 >   #ifdef START_DEBUG
 >           fprintf (stderr, "th %d start wait on tell_thread\n", me);
 >   #endif
 > !         if (sem_wait (&tell_thread) == -1)
 > !          {
 > !             if (errno != EINTR)
 > !              {  
 > !                fprintf (stderr, "th %d wait on sem tell_thread failed\n", me);
 > !                print_error ();
 > !                return;
 > !              }
 >   #ifdef START_DEBUG
 > !            fprintf (stderr, "th %d wait tell_thread got EINTR, rewaiting\n", me);
 >   #endif
 >            }
 >         }
 > -       while (errno == EINTR);
 >   
 >   #ifdef START_DEBUG
 >         fprintf (stderr, "th %d Wait on tell_thread\n", me);
 > --- 89,116 ----
 >       fprintf (stderr, "th %d post on tell main\n", me);
 >   #endif
 >   
 > !     while (1)
 >         {
 >   #ifdef START_DEBUG
 >           fprintf (stderr, "th %d start wait on tell_thread\n", me);
 >   #endif
 > !         if (sem_wait (&tell_thread) == 0)
 > !           break;
 > ! 
 > !         if (errno == EINTR)
 > !           {
 >   #ifdef START_DEBUG
 > !             fprintf (stderr, "th %d wait tell_thread got EINTR, rewaiting\n", me);
 >   #endif
 > +             continue;
 > +           }
 > +         else
 > +           {  
 > +             fprintf (stderr, "th %d wait on sem tell_thread failed\n", me);
 > +             print_error ();
 > +             return;
 >            }
 >         }
 >   
 >   #ifdef START_DEBUG
 >         fprintf (stderr, "th %d Wait on tell_thread\n", me);
 > *************** do_pass()
 > *** 151,183 ****
 >        }
 >   
 >       for( i = 0; i < N_THREADS; i++ )
 > !      {
 > !        do
 > !          {
 > !            errno = 0;
 > ! 
 > ! #ifdef START_DEBUG
 > !            fprintf (stderr, "main %d start wait on tell_main\n", i);
 > ! #endif
 > !            if (sem_wait (&tell_main) == -1)
 > !             {
 > !               if (errno != EINTR)
 > !                {
 > !                  fprintf (stderr, "main %d wait on sem tell_main failed\n", i);
 > !                  print_error ();
 > !                  return;
 > !                }
 >   #ifdef START_DEBUG
 > !               fprintf (stderr, "main %d wait tell_main got EINTR, rewaiting\n", i);
 >   #endif
 > !             }
 > !          }
 > !          while (errno == EINTR);
 >   
 > ! #ifdef START_DEBUG
 > !       fprintf (stderr, "main %d wait on tell_main\n",i);
 > ! #endif
 > !      }
 >   
 >   #ifdef START_DEBUG
 >       fprintf (stderr, "main done waiting on tell_main\n");
 > --- 153,182 ----
 >        }
 >   
 >       for( i = 0; i < N_THREADS; i++ )
 > !       {
 > !         while (1)
 > !           {
 >   #ifdef START_DEBUG
 > !             fprintf (stderr, "main %d start wait on tell_main\n", i);
 >   #endif
 > !             if (sem_wait (&tell_main) == 0)
 > !               break;
 >   
 > !             if (errno == EINTR)
 > !               {
 > ! #ifdef START_DEBUG
 > !                 fprintf (stderr, "main %d wait tell_main got EINTR, rewaiting\n", i);
 > ! #endif
 > !                 continue;
 > !               }
 > !             else
 > !               {
 > !                 fprintf (stderr, "main %d wait on sem tell_main failed\n", i);
 > !                 print_error ();
 > !                 return;
 > !               }
 > !             }
 > !        }
 >   
 >   #ifdef START_DEBUG
 >       fprintf (stderr, "main done waiting on tell_main\n");
 > Index: gdb.threads/tls.exp
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/tls.exp,v
 > retrieving revision 1.3
 > diff -c -3 -p -r1.3 tls.exp
 > *** gdb.threads/tls.exp	28 Jul 2003 00:57:29 -0000	1.3
 > --- gdb.threads/tls.exp	29 Jul 2003 20:28:17 -0000
 > *************** check_thread_local "third"
 > *** 212,217 ****
 > --- 212,218 ----
 >   
 >   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\]+(\[0-9\]+) Thread.*$gdb_prompt $" {


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

* tls test maintainer, was Re: [rfa/testsuite] gdb.threads/tls.{exp,c} fixes
  2003-07-29 21:13 ` Elena Zannoni
@ 2003-07-29 21:19   ` Michael Snyder
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Snyder @ 2003-07-29 21:19 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: Michael Elizabeth Chastain, gdb-patches

Elena Zannoni wrote:

>Michael Elizabeth Chastain writes:
> > This patch fixes all the ERRORs that I see with
> > native i686-pc-linux-gnu, red hat 8.0, glibc 2.2.93-5-rh.
> > All the results are now PASS, FAIL, KFAIL, and UNSUPPORTED.
> > 
> > The tls.exp change is a one-liner to initialize a variable
> > in all cases (not just the PASS case).
> > 
> > The tls.c change is the calls to sem_wait.  The current code
> > calls sem_wait and then tests errno.  My code calls sem_wait
> > and tests errno only if sem_wait failed.  This is important,
> > because I have observed a lot of test suite hangs caused by
> > return_value = 0, errno = EINTR (happens about 75% to 90% of
> > the time in my test bed).
> > 
> > Tested on native i686-pc-linux-gnu, red hat 8.0, glibc 2.2.93-5-rh,
> > with a variety of gcc's and binutils.
> > 
>
>thanks, seems to work for me too.
>
>elena
>
BTW, although this test is in the gdb.threads directory, of which I'm
listed as the maintainer of record, I'd like to recognize Elena as the
de facto maintainer of this test. ;-)






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

* Re: [rfa/testsuite] gdb.threads/tls.{exp,c} fixes
@ 2003-07-29 21:53 Michael Elizabeth Chastain
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Elizabeth Chastain @ 2003-07-29 21:53 UTC (permalink / raw)
  To: ezannoni, gdb-patches, mec, msnyder

Committed.

Michael C

2003-07-29  Michael C  <mec@shout.net>

	* gdb.threads/tls.c (spin): Check errno only if sem_wait
	actually failed.
	(do_pass): Likewise.
	* gdb.threads/tls.exp: Always initialize no_of_threads.


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

end of thread, other threads:[~2003-07-29 21:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29 20:44 [rfa/testsuite] gdb.threads/tls.{exp,c} fixes Michael Elizabeth Chastain
2003-07-29 21:13 ` Elena Zannoni
2003-07-29 21:19   ` tls test maintainer, was " Michael Snyder
2003-07-29 21:53 Michael Elizabeth Chastain

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