xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/tls-shared.exp (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1# Copyright 2003-2023 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
19standard_testfile tls-main.c
20set libfile tls-shared
21set srcfile_lib ${libfile}.c
22set binfile_lib [standard_output_file ${libfile}.so]
23
24remote_exec build "rm -f ${binfile}"
25
26if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != ""
27     || [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable [list debug shlib=${binfile_lib}]] != ""} {
28    return -1
29}
30
31
32clean_restart ${binfile}
33gdb_load_shlib ${binfile_lib}
34
35if {![runto_main]} {
36    return 0
37}
38
39gdb_test "print i_tls" "2" "print thread local storage variable"
40
41gdb_test "ptype i_tls" "int" "ptype of thread local storage variable"
42
43gdb_test "info address i_tls" \
44	"Symbol \\\"i_tls\\\" is a thread-local variable at offset 0x0 in the thread-local storage for .*tls-shared.." \
45	"print storage info for thread local storage variable"
46
47set line_number [gdb_get_line_number "break here to check result"]
48
49gdb_test "break $line_number" \
50	"Breakpoint.*at.*file.*tls-main.c.*line ${line_number}." \
51	"break at and of main"
52gdb_test "continue" \
53	"main .* at .*:.*return 0.*break here to check result.*" \
54        "continue to break"
55# This is more of a gcc/glibc test, really.
56#
57gdb_test "print result" "3"
58