Fix TLS access for -static -pthread
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / staticthreads.exp
index 67f43f883ea420cd85129d8e96bd93fcd06be109..9fa625a83ca047d3a3891d02adaaa6c16868e953 100644 (file)
@@ -1,6 +1,6 @@
 # static.exp -- test script, for GDB, the GNU debugger.
 
-# Copyright 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+# Copyright 2004-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # Based on manythreads written by Jeff Johnston, contributed by Red
 # Hat.
 
-if $tracelevel then {
-       strace $tracelevel
-}
-
 
-set testfile "staticthreads"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 set static_flag "-static"
 
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
-        executable \
-        [list debug "incdir=${objdir}" "additional_flags=${static_flag}" \
-            ]] != "" } {
-    return -1
+foreach have_tls { "-DHAVE_TLS" "" } {
+    if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+            executable \
+            [list debug "additional_flags=${static_flag} ${have_tls}" \
+                ]] == "" } {
+       break
+    }
+    if { $have_tls == "" } {
+       return -1
+    }
 }
 
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 
 
@@ -97,3 +94,18 @@ gdb_test_multiple "quit" "$test" {
         pass "$test"
     }
 }
+clean_restart ${binfile}
+
+
+if { "$have_tls" != "" } {
+    if ![runto_main] {
+       return -1
+    }
+    gdb_breakpoint [gdb_get_line_number "tlsvar-is-set"]
+    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.
+    gdb_test "up 10" " in main .*"
+    gdb_test "p tlsvar" " = 1" "tlsvar in main"
+}
This page took 0.028775 seconds and 4 git commands to generate.