Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 2003, 2007 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 EZ |
15 | |
16 | # Please email any bugs, comments, and/or additions to this file to: | |
17 | # bug-gdb@prep.ai.mit.edu | |
18 | ||
19 | # tls-shared.exp -- Expect script to test thread local storage in gdb, with | |
20 | # shared libraries. | |
21 | ||
22 | if $tracelevel then { | |
23 | strace $tracelevel | |
24 | } | |
25 | ||
26 | set testfile tls-main | |
27 | set libfile tls-shared | |
28 | set srcfile ${testfile}.c | |
29 | set binfile ${objdir}/${subdir}/${testfile} | |
30 | ||
31 | remote_exec build "rm -f ${binfile}" | |
32 | ||
33 | # get the value of gcc_compiled | |
34 | if [get_compiler_info ${binfile}] { | |
35 | return -1 | |
36 | } | |
37 | ||
38 | if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } { | |
39 | return -1 | |
40 | } | |
41 | ||
42 | # Build the shared libraries this test case needs. | |
43 | # | |
44 | ||
45 | if {$gcc_compiled == 0} { | |
46 | if [istarget "hppa*-hp-hpux*"] then { | |
47 | set additional_flags "additional_flags=+z" | |
48 | } elseif { [istarget "mips-sgi-irix*"] } { | |
49 | # Disable SGI compiler's implicit -Dsgi | |
50 | set additional_flags "additional_flags=-Usgi" | |
51 | } else { | |
52 | # don't know what the compiler is... | |
53 | set additional_flags "" | |
54 | } | |
55 | } else { | |
56 | if { ([istarget "powerpc*-*-aix*"] | |
57 | || [istarget "rs6000*-*-aix*"]) } { | |
58 | set additional_flags "" | |
59 | } else { | |
60 | set additional_flags "additional_flags=-fpic" | |
61 | } | |
62 | } | |
63 | ||
64 | set additional_flags "$additional_flags -shared" | |
65 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.so" executable [list debug $additional_flags "incdir=${objdir}"]] != ""} { | |
66 | return -1 | |
67 | } | |
68 | ||
69 | if { ($gcc_compiled | |
70 | && ([istarget "powerpc*-*-aix*"] | |
71 | || [istarget "rs6000*-*-aix*"] )) } { | |
72 | set additional_flags "additional_flags=-L${objdir}/${subdir}" | |
73 | } elseif { [istarget "mips-sgi-irix*"] } { | |
74 | set additional_flags "additional_flags=-rpath ${objdir}/${subdir}" | |
75 | } else { | |
76 | set additional_flags "" | |
77 | } | |
78 | ||
79 | if {[gdb_compile_pthreads "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.so" "${binfile}" executable [list debug $additional_flags]] != ""} { | |
4ee6625b | 80 | return -1 |
8bc2021f EZ |
81 | } |
82 | ||
83 | ||
84 | gdb_exit | |
85 | gdb_start | |
86 | gdb_reinitialize_dir $srcdir/$subdir | |
87 | gdb_load ${binfile} | |
88 | ||
89 | if ![runto_main] then { | |
90 | fail "Can't run to main" | |
91 | return 0 | |
92 | } | |
93 | ||
94 | gdb_test "print i_tls" "2" "print thread local storage variable" | |
95 | ||
96 | gdb_test "ptype i_tls" "int" "ptype of thread local storage variable" | |
97 | ||
98 | gdb_test "info address i_tls" \ | |
99 | "Symbol \\\"i_tls\\\" is a thread-local variable at offset 0 in the thread-local storage for .*tls-main.." \ | |
100 | "print storage info for thread local storage variable" | |
101 | ||
102 | set line_number [gdb_get_line_number "break here to check result"] | |
103 | ||
104 | gdb_test "break $line_number" \ | |
105 | "Breakpoint.*at.*file.*tls-main.c.*line ${line_number}." \ | |
106 | "break at and of main" | |
107 | gdb_test "continue" \ | |
108 | "main .* at .*:.*return 0.*break here to check result.*" \ | |
109 | "continue to break" | |
110 | # This is more of a gcc/glibc test, really. | |
111 | # | |
112 | gdb_test "print result" "3" "print result" | |
113 | ||
114 |