gdb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / tls.exp
index 2c475776f246ce061a50fae701cb2a94c40af8e6..d7dce0dbf055415f0c9d4a261e6ebdb55a206a95 100644 (file)
@@ -1,5 +1,6 @@
 # tls.exp -- Expect script to test thread-local storage
-# Copyright (C) 1992, 2003, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 1992, 2003, 2007, 2008, 2009, 2010, 2011
+# 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
 # You should have received a copy of the GNU General Public License
 # 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 testfile2 tls2
 set srcfile ${testfile}.c
+set srcfile2 ${testfile2}.c
 set binfile ${objdir}/${subdir}/${testfile}
 
 if [istarget "*-*-linux"] then {
@@ -27,7 +27,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 "incdir=${objdir}"]] != "" } {
     return -1
 }
 
@@ -75,7 +75,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"
 
@@ -83,7 +83,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"
 }
@@ -177,7 +177,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 $" {
@@ -214,7 +214,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"
         }
@@ -262,10 +262,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 $" {
@@ -284,8 +284,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.025444 seconds and 4 git commands to generate.