|
|
7ab123 |
commit b8b91e982ec3235a24ce052cbd8bb0e4fe1464e0
|
|
|
7ab123 |
Author: Yao Qi <yao@codesourcery.com>
|
|
|
7ab123 |
Date: Thu Jun 5 15:07:47 2014 +0800
|
|
|
7ab123 |
|
|
|
7ab123 |
Fix the race in gdb.threads/staticthreads.exp
|
|
|
7ab123 |
|
|
|
7ab123 |
The code in gdb.threads/staticthreads.exp about checking the value of
|
|
|
7ab123 |
tlsvar in main thread is racy, because when child thread hits
|
|
|
7ab123 |
breakpoint, the main thread may not go into pthread_join yet, and
|
|
|
7ab123 |
may not be unwind to main.
|
|
|
7ab123 |
|
|
|
7ab123 |
This patch is to move the line setting breakpoint on after sem_wait,
|
|
|
7ab123 |
so that the child thread will hit breakpoint after main thread calls
|
|
|
7ab123 |
sem_post. IOW, when child thread hits breakpoint, the main thread is
|
|
|
7ab123 |
in either sem_post or pthread_join. "up 10" can unwind main thread to
|
|
|
7ab123 |
main.
|
|
|
7ab123 |
|
|
|
7ab123 |
gdb/testsuite:
|
|
|
7ab123 |
|
|
|
7ab123 |
2014-06-06 Yao Qi <yao@codesourcery.com>
|
|
|
7ab123 |
|
|
|
7ab123 |
* gdb.threads/staticthreads.c (thread_function): Move the line
|
|
|
7ab123 |
setting breakpoint on forward.
|
|
|
7ab123 |
* gdb.threads/staticthreads.exp: Update comments.
|
|
|
7ab123 |
|
|
|
7ab123 |
Message-ID: <5390387C.7050308@codesourcery.com>
|
|
|
7ab123 |
|
|
|
7ab123 |
Index: gdb-7.6.1/gdb/testsuite/gdb.threads/staticthreads.c
|
|
|
7ab123 |
===================================================================
|
|
|
7ab123 |
--- gdb-7.6.1.orig/gdb/testsuite/gdb.threads/staticthreads.c
|
|
|
7ab123 |
+++ gdb-7.6.1/gdb/testsuite/gdb.threads/staticthreads.c
|
|
|
7ab123 |
@@ -38,7 +38,6 @@ thread_function (void *arg)
|
|
|
7ab123 |
#ifdef HAVE_TLS
|
|
|
7ab123 |
tlsvar = 2;
|
|
|
7ab123 |
#endif
|
|
|
7ab123 |
- printf ("Thread executing\n"); /* tlsvar-is-set */
|
|
|
7ab123 |
while (sem_wait (&semaphore) != 0)
|
|
|
7ab123 |
{
|
|
|
7ab123 |
if (errno != EINTR)
|
|
|
7ab123 |
@@ -47,6 +46,7 @@ thread_function (void *arg)
|
|
|
7ab123 |
return;
|
|
|
7ab123 |
}
|
|
|
7ab123 |
}
|
|
|
7ab123 |
+ printf ("Thread executing\n"); /* tlsvar-is-set */
|
|
|
7ab123 |
return NULL;
|
|
|
7ab123 |
}
|
|
|
7ab123 |
|
|
|
7ab123 |
Index: gdb-7.6.1/gdb/testsuite/gdb.threads/staticthreads.exp
|
|
|
7ab123 |
===================================================================
|
|
|
7ab123 |
--- gdb-7.6.1.orig/gdb/testsuite/gdb.threads/staticthreads.exp
|
|
|
7ab123 |
+++ gdb-7.6.1/gdb/testsuite/gdb.threads/staticthreads.exp
|
|
|
7ab123 |
@@ -112,7 +112,7 @@ if { "$have_tls" != "" } {
|
|
|
7ab123 |
gdb_continue_to_breakpoint "tlsvar-is-set" ".* tlsvar-is-set .*"
|
|
|
7ab123 |
gdb_test "p tlsvar" " = 2" "tlsvar in thread"
|
|
|
7ab123 |
gdb_test "thread 1" ".*"
|
|
|
7ab123 |
- # Unwind from pthread_join.
|
|
|
7ab123 |
+ # Unwind to main.
|
|
|
7ab123 |
gdb_test "up 10" " in main .*"
|
|
|
7ab123 |
gdb_test "p tlsvar" " = 1" "tlsvar in main"
|
|
|
7ab123 |
}
|