xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/staticthreads.exp (revision f3cfa6f6ce31685c6c4a758bc430e69eb99f50a4)
1# static.exp -- test script, for GDB, the GNU debugger.
2
3# Copyright 2004-2017 Free Software Foundation, Inc.
4
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.
9#
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.
14#
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/>.
17
18# Based on manythreads written by Jeff Johnston, contributed by Red
19# Hat.
20
21
22standard_testfile
23set static_flag "-static"
24
25foreach have_tls { "-DHAVE_TLS" "" } {
26    if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
27	     executable \
28	     [list debug "additional_flags=${static_flag} ${have_tls}" \
29		 ]] == "" } {
30	break
31    }
32    if { $have_tls == "" } {
33	return -1
34    }
35}
36
37clean_restart ${binfile}
38gdb_test_no_output "set print sevenbit-strings"
39
40
41# See if the static multi-threaded program runs.
42
43runto_main
44gdb_test "break sem_post"
45set test "continue to main's call of sem_post"
46gdb_test_multiple "continue" "$test" {
47    -re "Breakpoint .*, .*sem_post .*$gdb_prompt " {
48	pass "$test"
49    }
50    -re " received signal .*$gdb_prompt " {
51	kfail gdb/1328 "$test"
52    }
53}
54
55
56# See if handle SIG32 helps (a little) with a static multi-threaded
57# program.
58
59set sig "SIG32"
60
61# SIGRTMIN is 37 on hppa-linux
62if [istarget hppa*-*-*] {
63  set sig "SIG37"
64}
65
66rerun_to_main
67gdb_test "handle $sig nostop noprint pass"
68set test "handle $sig helps"
69gdb_test "continue" " .*sem_post .*" "handle $sig helps"
70
71
72# See if info threads produces anything approaching a thread list.
73
74set test "info threads"
75gdb_test_multiple "info threads" "$test" {
76    -re " Thread .*$gdb_prompt " {
77	pass "$test"
78    }
79    -re "$gdb_prompt " {
80	kfail gdb/1328 "$test"
81    }
82}
83
84
85# Check that the program can be quit.
86
87set test "GDB exits with static thread program"
88gdb_test_multiple "quit" "$test" {
89    -re "Quit anyway\\? \\(y or n\\) $" {
90	send_gdb "y\n"
91	exp_continue
92    }
93    eof {
94        pass "$test"
95    }
96}
97clean_restart ${binfile}
98
99
100if { "$have_tls" != "" } {
101    if ![runto_main] {
102	return -1
103    }
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" ".*"
108    # Unwind to main.
109    gdb_test "up 10" " in main .*"
110    gdb_test "p tlsvar" " = 1" "tlsvar in main"
111}
112