Commit | Line | Data |
---|---|---|
c72b934c AC |
1 | # static.exp -- test script, for GDB, the GNU debugger. |
2 | ||
32d0add0 | 3 | # Copyright 2004-2015 Free Software Foundation, Inc. |
c72b934c AC |
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 | |
e22f8b7c | 7 | # the Free Software Foundation; either version 3 of the License, or |
c72b934c | 8 | # (at your option) any later version. |
e22f8b7c | 9 | # |
c72b934c AC |
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. | |
e22f8b7c | 14 | # |
c72b934c | 15 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c72b934c AC |
17 | |
18 | # Based on manythreads written by Jeff Johnston, contributed by Red | |
19 | # Hat. | |
20 | ||
c72b934c | 21 | |
0efbbabc | 22 | standard_testfile |
c72b934c AC |
23 | set static_flag "-static" |
24 | ||
5876f503 JK |
25 | foreach 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 | } | |
c72b934c AC |
35 | } |
36 | ||
0efbbabc | 37 | clean_restart ${binfile} |
12b5d08a | 38 | gdb_test_no_output "set print sevenbit-strings" |
c72b934c AC |
39 | |
40 | ||
41 | # See if the static multi-threaded program runs. | |
42 | ||
43 | runto_main | |
44 | gdb_test "break sem_post" | |
45 | set test "Continue to main's call of sem_post" | |
46 | gdb_test_multiple "continue" "$test" { | |
aba471f5 | 47 | -re "Breakpoint .*, .*sem_post .*$gdb_prompt " { |
c72b934c AC |
48 | pass "$test" |
49 | } | |
50 | -re "Program 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 | ||
1690f9cf DJ |
59 | set sig "SIG32" |
60 | ||
61 | # SIGRTMIN is 37 on hppa-linux and hpux | |
62 | if [istarget hppa*-*-*] { | |
63 | set sig "SIG37" | |
64 | } | |
65 | ||
c72b934c | 66 | rerun_to_main |
1690f9cf DJ |
67 | gdb_test "handle $sig nostop noprint pass" |
68 | set test "Handle $sig helps" | |
69 | gdb_test "continue" " .*sem_post .*" "handle $sig helps" | |
c72b934c AC |
70 | |
71 | ||
72 | # See if info threads produces anything approaching a thread list. | |
73 | ||
74 | set test "info threads" | |
75 | gdb_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 | ||
87 | set test "GDB exits with static thread program" | |
88 | gdb_test_multiple "quit" "$test" { | |
b8fa0bfa | 89 | -re "Quit anyway\\? \\(y or n\\) $" { |
c72b934c AC |
90 | send_gdb "y\n" |
91 | exp_continue | |
92 | } | |
93 | eof { | |
94 | pass "$test" | |
95 | } | |
96 | } | |
5876f503 JK |
97 | clean_restart ${binfile} |
98 | ||
99 | ||
100 | if { "$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" ".*" | |
b8b91e98 | 108 | # Unwind to main. |
5876f503 JK |
109 | gdb_test "up 10" " in main .*" |
110 | gdb_test "p tlsvar" " = 1" "tlsvar in main" | |
111 | } |