This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfa/testsuite] gdb.threads/tls.{exp,c} fixes
- From: Michael Elizabeth Chastain <mec at shout dot net>
- To: ezannoni at redhat dot com, gdb-patches at sources dot redhat dot com
- Date: Tue, 29 Jul 2003 16:44:52 -0400
- Subject: [rfa/testsuite] gdb.threads/tls.{exp,c} fixes
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 $" {