1 # static.exp -- test script, for GDB, the GNU debugger.
3 # Copyright 2004-2024 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Based on manythreads written by Jeff Johnston, contributed by Red
23 set static_flag "-static"
25 foreach_with_prefix have_tls { "-DHAVE_TLS" "" } {
26 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
28 [list debug "additional_flags=${static_flag} ${have_tls}" \
32 if { $have_tls == "" } {
37 clean_restart ${binfile}
38 gdb_test_no_output "set print sevenbit-strings"
41 # See if the static multi-threaded program runs.
44 gdb_test "break sem_post"
45 set test "continue to main's call of sem_post"
46 gdb_test_multiple "continue" "$test" {
47 -re "Breakpoint .*, .*sem_post .*$gdb_prompt " {
50 -re " received signal .*$gdb_prompt " {
51 kfail gdb/1328 "$test"
56 # See if handle SIG32 helps (a little) with a static multi-threaded
61 # SIGRTMIN is 37 on hppa-linux
62 if [istarget hppa*-*-*] {
67 gdb_test "handle $sig nostop noprint pass"
68 set test "handle $sig helps"
69 gdb_test "continue" " .*sem_post .*" "handle $sig helps"
72 # See if info threads produces anything approaching a thread list.
74 set test "info threads"
75 gdb_test_multiple "info threads" "$test" {
76 -re " ${tdlabel_re} .*$gdb_prompt " {
80 kfail gdb/1328 "$test"
85 # Check that the program can be quit.
87 set test "GDB exits with static thread program"
88 gdb_test_multiple "quit" "$test" {
89 -re "Quit anyway\\? \\(y or n\\) $" {
97 clean_restart ${binfile}
100 if { "$have_tls" != "" } {
104 gdb_breakpoint [gdb_get_line_number "tlsvar-is-set"]
105 gdb_continue_to_breakpoint "tlsvar-is-set" ".* tlsvar-is-set .*"
106 gdb_test "p tlsvar" " = 2" "tlsvar in thread"
107 gdb_test "thread 1" ".*"
109 gdb_test "up 10" " in main .*"
110 gdb_test "p tlsvar" " = 1" "tlsvar in main"