Update years in copyright notice for the GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / tls.exp
index 8bb8f7a71b26a806ad8cb1f4c99dfef233726800..5f983aa3964474db63ac7a86e980504c2864b0f2 100644 (file)
@@ -1,26 +1,20 @@
 # tls.exp -- Expect script to test thread-local storage
-# Copyright (C) 1992, 2003, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1992-2013 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
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
-
-set testfile tls
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile tls.c tls2.c
 
 if [istarget "*-*-linux"] then {
     set target_cflags "-D_MIT_POSIX_THREADS"
@@ -28,7 +22,7 @@ if [istarget "*-*-linux"] then {
     set target_cflags ""
 }
 
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" "${binfile}" executable [list c++ debug]] != "" } {
     return -1
 }
 
@@ -76,7 +70,7 @@ proc check_thread_local {number} {
            "= $expected_value" \
            "${number} thread local storage"
 
-    gdb_test "p another_thread_local" \
+    gdb_test "p K::another_thread_local" \
            "= $me_variable" \
            "${number} another thread local storage"
 
@@ -84,7 +78,7 @@ proc check_thread_local {number} {
            ".*a_thread_local.*a thread-local variable at offset.*" \
            "${number} info address a_thread_local"
 
-    gdb_test "info address another_thread_local" \
+    gdb_test "info address K::another_thread_local" \
            ".*another_thread_local.*a thread-local variable at offset.*" \
            "${number} info address another_thread_local"
 }
@@ -144,11 +138,7 @@ proc check_thread_stack {number spin_threads spin_threads_level} {
     }
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-gdb_load ${binfile}
+clean_restart ${binfile}
 if ![runto_main] then {
    fail "Can't run to main"
    return 0
@@ -178,7 +168,7 @@ gdb_expect {
         unsupported "continue to first thread: system does not support TLS"
         return -1
     }
-    -re ".*Program exited normally.*$gdb_prompt $" {
+    -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
         fail "continue to first thread: program runaway"
     }
     -re ".*Pass 0 done.*Pass 1 done.*$gdb_prompt $" {
@@ -215,7 +205,7 @@ gdb_test "continue" ".*Breakpoint 3.*still alive.*" "continue to synch point"
 set no_of_threads 0
 send_gdb "info thread\n"
 gdb_expect {
-       -re "^info thread\[ \t\r\n\]+(\[0-9\]+) Thread.*$gdb_prompt $" {
+    -re "^info thread\[ \t\r\n\]+ *Id .*Frame\[ \t\r\n\]+(\[0-9\]+) *Thread.*$gdb_prompt $" {
           set no_of_threads $expect_out(1,string)
           pass "get number of threads"
         }
@@ -263,10 +253,10 @@ gdb_test "continue" ".*Breakpoint 4.*before exit.*" "threads exited"
 
 send_gdb "info thread\n" 
 gdb_expect {
-    -re ".* 1 Thread.*2 Thread.*$gdb_prompt $" {
+    -re ".* 1 *Thread.*2 *Thread.*$gdb_prompt $" {
         fail "Too many threads left at end"
     }
-    -re ".*\\\* 1 Thread.*main.*$gdb_prompt $" {
+    -re ".*\\\* 1 *Thread.*main.*$gdb_prompt $" {
         pass "Expect only base thread at end"
     }
     -re ".*No stack.*$gdb_prompt $" {
@@ -285,8 +275,22 @@ runto spin
 gdb_test "info address a_global" \
        ".*a_global.*static storage at address.*" "info address a_global"
 
-setup_kfail "gdb/1294" "*-*-*"
-gdb_test "info address me" ".*me.*is a variable at offset.*" "info address me"
+gdb_test "info address me" ".*me.*is a (complex DWARF expression:|variable).*" \
+    "info address me"
+
+
+# Test LOC_UNRESOLVED references resolving for `extern' TLS variables.
+
+gdb_test "p a_thread_local" " = \[0-9\]+"
+# Here it could crash with: Cannot access memory at address 0x0
+gdb_test "p file2_thread_local" " = \[0-9\]+"
+# Depending on the current lookup scope we get LOC_UNRESOLVED or LOC_COMPUTED
+# both printing:
+# Symbol "file2_thread_local" is a thread-local variable at offset 8 in the thread-local storage for `.../gdb.threads/tls'.
+gdb_test "info address file2_thread_local" "Symbol \"file2_thread_local\" is a thread-local variable.*"
+# Here it could also crash with: Cannot access memory at address 0x0
+gdb_test "p a_thread_local" " = \[0-9\]+" "p a_thread_local second time"
+gdb_test "info address a_thread_local" "Symbol \"a_thread_local\" is a thread-local variable.*"
 
 # Done!
 #
This page took 0.026968 seconds and 4 git commands to generate.