OLD | NEW |
1 # tls.exp -- Expect script to test thread-local storage | 1 # tls.exp -- Expect script to test thread-local storage |
2 # Copyright (C) 1992, 2003, 2007-2012 Free Software Foundation, Inc. | 2 # Copyright (C) 1992, 2003, 2007-2012 Free Software Foundation, Inc. |
3 | 3 |
4 # This program is free software; you can redistribute it and/or modify | 4 # This program is free software; you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License as published by | 5 # it under the terms of the GNU General Public License as published by |
6 # the Free Software Foundation; either version 3 of the License, or | 6 # the Free Software Foundation; either version 3 of the License, or |
7 # (at your option) any later version. | 7 # (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 15 # along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
16 | 16 |
17 set testfile tls | 17 standard_testfile tls.c tls2.c |
18 set testfile2 tls2 | |
19 set srcfile ${testfile}.c | |
20 set srcfile2 ${testfile2}.c | |
21 set binfile ${objdir}/${subdir}/${testfile} | |
22 | 18 |
23 if [istarget "*-*-linux"] then { | 19 if [istarget "*-*-linux"] then { |
24 set target_cflags "-D_MIT_POSIX_THREADS" | 20 set target_cflags "-D_MIT_POSIX_THREADS" |
25 } else { | 21 } else { |
26 set target_cflags "" | 22 set target_cflags "" |
27 } | 23 } |
28 | 24 |
29 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${
srcfile2}" "${binfile}" executable [list c++ debug "incdir=${objdir}"]] != "" }
{ | 25 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${
srcfile2}" "${binfile}" executable [list c++ debug]] != "" } { |
30 return -1 | 26 return -1 |
31 } | 27 } |
32 | 28 |
33 ### Compute the value of the a_thread_local variable. | 29 ### Compute the value of the a_thread_local variable. |
34 proc compute_expected_value {value} { | 30 proc compute_expected_value {value} { |
35 set expected_value 0 | 31 set expected_value 0 |
36 set i 0 | 32 set i 0 |
37 while { $i <= $value} { | 33 while { $i <= $value} { |
38 incr expected_value $i | 34 incr expected_value $i |
39 incr i | 35 incr i |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 set tarr($number) 0 | 131 set tarr($number) 0 |
136 set tarrl($number) 0 | 132 set tarrl($number) 0 |
137 pass "backtrace of thread number $number not relevant" | 133 pass "backtrace of thread number $number not relevant" |
138 } | 134 } |
139 timeout { | 135 timeout { |
140 fail "backtrace of thread number $number (timeout)" | 136 fail "backtrace of thread number $number (timeout)" |
141 } | 137 } |
142 } | 138 } |
143 } | 139 } |
144 | 140 |
145 gdb_exit | 141 clean_restart ${binfile} |
146 gdb_start | |
147 gdb_reinitialize_dir $srcdir/$subdir | |
148 | |
149 gdb_load ${binfile} | |
150 if ![runto_main] then { | 142 if ![runto_main] then { |
151 fail "Can't run to main" | 143 fail "Can't run to main" |
152 return 0 | 144 return 0 |
153 } | 145 } |
154 | 146 |
155 # Set a breakpoint at the "spin" routine to | 147 # Set a breakpoint at the "spin" routine to |
156 # test the thread local's value. | 148 # test the thread local's value. |
157 # | 149 # |
158 gdb_test "b [gdb_get_line_number "here we know tls value"]" \ | 150 gdb_test "b [gdb_get_line_number "here we know tls value"]" \ |
159 ".*Breakpoint 2.*tls.*" "set breakpoint at all threads" | 151 ".*Breakpoint 2.*tls.*" "set breakpoint at all threads" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 gdb_test "info address file2_thread_local" "Symbol \"file2_thread_local\" is a t
hread-local variable.*" | 290 gdb_test "info address file2_thread_local" "Symbol \"file2_thread_local\" is a t
hread-local variable.*" |
299 # Here it could also crash with: Cannot access memory at address 0x0 | 291 # Here it could also crash with: Cannot access memory at address 0x0 |
300 gdb_test "p a_thread_local" " = \[0-9\]+" "p a_thread_local second time" | 292 gdb_test "p a_thread_local" " = \[0-9\]+" "p a_thread_local second time" |
301 gdb_test "info address a_thread_local" "Symbol \"a_thread_local\" is a thread-lo
cal variable.*" | 293 gdb_test "info address a_thread_local" "Symbol \"a_thread_local\" is a thread-lo
cal variable.*" |
302 | 294 |
303 # Done! | 295 # Done! |
304 # | 296 # |
305 gdb_exit | 297 gdb_exit |
306 | 298 |
307 return 0 | 299 return 0 |
OLD | NEW |