]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/tls-shared.exp
* defs.h (strlen_paddr, paddr, paddr_nz): Remove.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / tls-shared.exp
CommitLineData
0fb0cc75 1# Copyright 2003, 2007, 2008, 2009 Free Software Foundation, Inc.
8bc2021f
EZ
2
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
8bc2021f 6# (at your option) any later version.
e22f8b7c 7#
8bc2021f
EZ
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.
e22f8b7c 12#
8bc2021f 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
8bc2021f 15
8bc2021f
EZ
16# tls-shared.exp -- Expect script to test thread local storage in gdb, with
17# shared libraries.
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
23set testfile tls-main
24set libfile tls-shared
25set srcfile ${testfile}.c
26set binfile ${objdir}/${subdir}/${testfile}
27
28remote_exec build "rm -f ${binfile}"
29
30# get the value of gcc_compiled
31if [get_compiler_info ${binfile}] {
32 return -1
33}
34
35if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } {
36 return -1
37}
38
39# Build the shared libraries this test case needs.
40#
41
42if {$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"
48 } else {
49 # don't know what the compiler is...
50 set additional_flags ""
51 }
52} else {
53 if { ([istarget "powerpc*-*-aix*"]
54 || [istarget "rs6000*-*-aix*"]) } {
55 set additional_flags ""
56 } else {
57 set additional_flags "additional_flags=-fpic"
58 }
59}
60
61set additional_flags "$additional_flags -shared"
62if {[gdb_compile_pthreads "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.so" executable [list debug $additional_flags "incdir=${objdir}"]] != ""} {
63 return -1
64}
65
66if { ($gcc_compiled
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}"
72} else {
73 set additional_flags ""
74}
75
76if {[gdb_compile_pthreads "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.so" "${binfile}" executable [list debug $additional_flags]] != ""} {
4ee6625b 77 return -1
8bc2021f
EZ
78}
79
80
81gdb_exit
82gdb_start
83gdb_reinitialize_dir $srcdir/$subdir
84gdb_load ${binfile}
85
86if ![runto_main] then {
87 fail "Can't run to main"
88 return 0
89}
90
91gdb_test "print i_tls" "2" "print thread local storage variable"
92
93gdb_test "ptype i_tls" "int" "ptype of thread local storage variable"
94
95gdb_test "info address i_tls" \
5af949e3 96 "Symbol \\\"i_tls\\\" is a thread-local variable at offset 0x0 in the thread-local storage for .*tls-main.." \
8bc2021f
EZ
97 "print storage info for thread local storage variable"
98
99set line_number [gdb_get_line_number "break here to check result"]
100
101gdb_test "break $line_number" \
102 "Breakpoint.*at.*file.*tls-main.c.*line ${line_number}." \
103 "break at and of main"
104gdb_test "continue" \
105 "main .* at .*:.*return 0.*break here to check result.*" \
106 "continue to break"
107# This is more of a gcc/glibc test, really.
108#
109gdb_test "print result" "3" "print result"
110
111