Fix TLS access for -static -pthread

Message ID 5390387C.7050308@codesourcery.com
State Committed
Headers

Commit Message

Yao Qi June 5, 2014, 9:29 a.m. UTC
  On 06/05/2014 04:06 PM, Jan Kratochvil wrote:
>> This patch is to set another breakpoint at the end of main, so that
>> > main thread will hit it, and we can check the value of tlsvar then.
>> > It is safe and we don't have to worry about whether gdb is able to
>> > unwind from pthread library to main function or not.
> I have to warn that it may be a bit weaker test, it never tests both threads
> TLS access during the same stop, it tests only the current thread.
> 
> But it still tests the patch works so I am fine with it (not an approval).
> 

The patch below is to keep testing TLS access in one stop, and
work around the bug of unwinding clone.  WDYT?
  

Comments

Jan Kratochvil June 5, 2014, 9:39 a.m. UTC | #1
On Thu, 05 Jun 2014 11:29:32 +0200, Yao Qi wrote:
> The patch below is to keep testing TLS access in one stop, and
> work around the bug of unwinding clone.  WDYT?

Great idea, I like this one more.


Jan
  
Yao Qi June 5, 2014, 2:18 p.m. UTC | #2
On 06/05/2014 05:39 PM, Jan Kratochvil wrote:
> On Thu, 05 Jun 2014 11:29:32 +0200, Yao Qi wrote:
>> The patch below is to keep testing TLS access in one stop, and
>> work around the bug of unwinding clone.  WDYT?
> 
> Great idea, I like this one more.
> 

Can I check it in?
  
Pedro Alves June 5, 2014, 3:23 p.m. UTC | #3
On 06/05/2014 03:18 PM, Yao Qi wrote:
> On 06/05/2014 05:39 PM, Jan Kratochvil wrote:
>> On Thu, 05 Jun 2014 11:29:32 +0200, Yao Qi wrote:
>>> The patch below is to keep testing TLS access in one stop, and
>>> work around the bug of unwinding clone.  WDYT?
>>
>> Great idea, I like this one more.
>>
> 
> Can I check it in?

Sure, thanks.
  
Yao Qi June 6, 2014, 2:24 a.m. UTC | #4
On 06/05/2014 11:23 PM, Pedro Alves wrote:
>> Can I check it in?
> Sure, thanks.

Patch is pushed in.
  

Patch

diff --git a/gdb/testsuite/gdb.threads/staticthreads.c b/gdb/testsuite/gdb.threads/staticthreads.c
index 5c8eabe..db78063 100644
--- a/gdb/testsuite/gdb.threads/staticthreads.c
+++ b/gdb/testsuite/gdb.threads/staticthreads.c
@@ -38,7 +38,6 @@  thread_function (void *arg)
 #ifdef HAVE_TLS
   tlsvar = 2;
 #endif
-  printf ("Thread executing\n"); /* tlsvar-is-set */
   while (sem_wait (&semaphore) != 0)
     {
       if (errno != EINTR)
@@ -47,6 +46,7 @@  thread_function (void *arg)
 	  return NULL;
 	}
     }
+  printf ("Thread executing\n"); /* tlsvar-is-set */
   return NULL;
 }
 
diff --git a/gdb/testsuite/gdb.threads/staticthreads.exp b/gdb/testsuite/gdb.threads/staticthreads.exp
index 9fa625a..bdc03d4 100644
--- a/gdb/testsuite/gdb.threads/staticthreads.exp
+++ b/gdb/testsuite/gdb.threads/staticthreads.exp
@@ -105,7 +105,7 @@  if { "$have_tls" != "" } {
     gdb_continue_to_breakpoint "tlsvar-is-set" ".* tlsvar-is-set .*"
     gdb_test "p tlsvar" " = 2" "tlsvar in thread"
     gdb_test "thread 1" ".*"
-    # Unwind from pthread_join.
+    # Unwind to main.
     gdb_test "up 10" " in main .*"
     gdb_test "p tlsvar" " = 1" "tlsvar in main"
 }