1 # Copyright 2003, 2007, 2008, 2009 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 # tls-shared.exp -- Expect script to test thread local storage in gdb, with
24 set libfile tls-shared
25 set srcfile ${testfile}.c
26 set binfile ${objdir}/${subdir}/${testfile}
28 remote_exec build "rm -f ${binfile}"
30 # get the value of gcc_compiled
31 if [get_compiler_info ${binfile}] {
35 if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } {
39 # Build the shared libraries this test case needs.
42 if {$gcc_compiled == 0} {
43 if [istarget "hppa*-hp-hpux*"] then {
44 set additional_flags "additional_flags=+z"
45 } elseif { [istarget "mips-sgi-irix*"] } {
46 # Disable SGI compiler's implicit -Dsgi
47 set additional_flags "additional_flags=-Usgi"
49 # don't know what the compiler is...
50 set additional_flags ""
53 if { ([istarget "powerpc*-*-aix*"]
54 || [istarget "rs6000*-*-aix*"]) } {
55 set additional_flags ""
57 set additional_flags "additional_flags=-fpic"
61 set additional_flags "$additional_flags -shared"
62 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.so" executable [list debug $additional_flags "incdir=${objdir}"]] != ""} {
67 && ([istarget "powerpc*-*-aix*"]
68 || [istarget "rs6000*-*-aix*"] )) } {
69 set additional_flags "additional_flags=-L${objdir}/${subdir}"
70 } elseif { [istarget "mips-sgi-irix*"] } {
71 set additional_flags "additional_flags=-rpath ${objdir}/${subdir}"
73 set additional_flags ""
76 if {[gdb_compile_pthreads "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.so" "${binfile}" executable [list debug $additional_flags]] != ""} {
83 gdb_reinitialize_dir $srcdir/$subdir
86 if ![runto_main] then {
87 fail "Can't run to main"
91 gdb_test "print i_tls" "2" "print thread local storage variable"
93 gdb_test "ptype i_tls" "int" "ptype of thread local storage variable"
95 gdb_test "info address i_tls" \
96 "Symbol \\\"i_tls\\\" is a thread-local variable at offset 0 in the thread-local storage for .*tls-main.." \
97 "print storage info for thread local storage variable"
99 set line_number [gdb_get_line_number "break here to check result"]
101 gdb_test "break $line_number" \
102 "Breakpoint.*at.*file.*tls-main.c.*line ${line_number}." \
103 "break at and of main"
104 gdb_test "continue" \
105 "main .* at .*:.*return 0.*break here to check result.*" \
107 # This is more of a gcc/glibc test, really.
109 gdb_test "print result" "3" "print result"