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

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