OSDN Git Service

2012-01-16 Pedro Alves <palves@redhat.com>
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.threads / tls-shared.exp
1 # Copyright 2003, 2007-2012 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
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/>.  */
15
16 # tls-shared.exp -- Expect script to test thread local storage in gdb, with
17 # shared libraries.
18
19 set testfile tls-main
20 set libfile tls-shared
21 set srcfile ${testfile}.c
22 set binfile ${objdir}/${subdir}/${testfile}
23 set srcfile_lib ${libfile}.c
24 set binfile_lib ${objdir}/${subdir}/${libfile}.so
25
26 remote_exec build "rm -f ${binfile}"
27
28 # get the value of gcc_compiled
29 if [get_compiler_info ${binfile}] {
30     return -1
31 }
32
33
34 if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != ""
35      || [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable [list debug shlib=${binfile_lib}]] != ""} {
36     return -1
37 }
38
39
40 gdb_exit
41 gdb_start
42 gdb_reinitialize_dir $srcdir/$subdir
43 gdb_load ${binfile}
44 gdb_load_shlibs ${binfile_lib}
45
46 if ![runto_main] then {
47     fail "Can't run to main"
48     return 0
49 }
50
51 gdb_test "print i_tls" "2" "print thread local storage variable"
52
53 gdb_test "ptype i_tls" "int" "ptype of thread local storage variable"
54
55 gdb_test "info address i_tls" \
56         "Symbol \\\"i_tls\\\" is a thread-local variable at offset 0x0 in the thread-local storage for .*tls-main.." \
57         "print storage info for thread local storage variable"
58
59 set line_number [gdb_get_line_number "break here to check result"]
60
61 gdb_test "break $line_number" \
62         "Breakpoint.*at.*file.*tls-main.c.*line ${line_number}." \
63         "break at and of main"
64 gdb_test "continue" \
65         "main .* at .*:.*return 0.*break here to check result.*" \
66         "continue to break"
67 # This is more of a gcc/glibc test, really. 
68 #
69 gdb_test "print result" "3" "print result"
70
71