Blame SOURCES/gdb-rhbz1080657-tls-variable-static-linked-binary-3of3.patch

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