mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 04:49:54 +08:00
Fix the race in gdb.threads/staticthreads.exp
The code in gdb.threads/staticthreads.exp about checking the value of tlsvar in main thread is racy, because when child thread hits breakpoint, the main thread may not go into pthread_join yet, and may not be unwind to main. This patch is to move the line setting breakpoint on after sem_wait, so that the child thread will hit breakpoint after main thread calls sem_post. IOW, when child thread hits breakpoint, the main thread is in either sem_post or pthread_join. "up 10" can unwind main thread to main. gdb/testsuite: 2014-06-06 Yao Qi <yao@codesourcery.com> * gdb.threads/staticthreads.c (thread_function): Move the line setting breakpoint on forward. * gdb.threads/staticthreads.exp: Update comments.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2014-06-06 Yao Qi <yao@codesourcery.com>
|
||||||
|
|
||||||
|
* gdb.threads/staticthreads.c (thread_function): Move the line
|
||||||
|
setting breakpoint on forward.
|
||||||
|
* gdb.threads/staticthreads.exp: Update comments.
|
||||||
|
|
||||||
2014-06-05 Ludovic Courtès <ludo@gnu.org>
|
2014-06-05 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
|
||||||
* gdb.guile/scm-value.exp (test_value_in_inferior): Add test
|
* gdb.guile/scm-value.exp (test_value_in_inferior): Add test
|
||||||
|
@ -38,7 +38,6 @@ thread_function (void *arg)
|
|||||||
#ifdef HAVE_TLS
|
#ifdef HAVE_TLS
|
||||||
tlsvar = 2;
|
tlsvar = 2;
|
||||||
#endif
|
#endif
|
||||||
printf ("Thread executing\n"); /* tlsvar-is-set */
|
|
||||||
while (sem_wait (&semaphore) != 0)
|
while (sem_wait (&semaphore) != 0)
|
||||||
{
|
{
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
@ -47,6 +46,7 @@ thread_function (void *arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf ("Thread executing\n"); /* tlsvar-is-set */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ if { "$have_tls" != "" } {
|
|||||||
gdb_continue_to_breakpoint "tlsvar-is-set" ".* tlsvar-is-set .*"
|
gdb_continue_to_breakpoint "tlsvar-is-set" ".* tlsvar-is-set .*"
|
||||||
gdb_test "p tlsvar" " = 2" "tlsvar in thread"
|
gdb_test "p tlsvar" " = 2" "tlsvar in thread"
|
||||||
gdb_test "thread 1" ".*"
|
gdb_test "thread 1" ".*"
|
||||||
# Unwind from pthread_join.
|
# Unwind to main.
|
||||||
gdb_test "up 10" " in main .*"
|
gdb_test "up 10" " in main .*"
|
||||||
gdb_test "p tlsvar" " = 1" "tlsvar in main"
|
gdb_test "p tlsvar" " = 1" "tlsvar in main"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user