bdc03d431664690a95a7fedc5a40b5573f9a7638
[platform/upstream/gdb.git] / gdb / testsuite / gdb.threads / staticthreads.exp
1 # static.exp -- test script, for GDB, the GNU debugger.
2
3 # Copyright 2004-2014 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
22 standard_testfile
23 set static_flag "-static"
24
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     }
35 }
36
37 clean_restart ${binfile}
38 gdb_test_no_output "set print sevenbit-strings"
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" {
47     -re "Breakpoint .*, .*sem_post .*$gdb_prompt " {
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
59 set sig "SIG32"
60
61 # SIGRTMIN is 37 on hppa-linux and hpux
62 if [istarget hppa*-*-*] {
63   set sig "SIG37"
64 }
65
66 rerun_to_main
67 gdb_test "handle $sig nostop noprint pass"
68 set test "Handle $sig helps"
69 gdb_test "continue" " .*sem_post .*" "handle $sig helps"
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" {
89     -re "Quit anyway\\? \\(y or n\\) $" {
90         send_gdb "y\n"
91         exp_continue
92     }
93     eof {
94         pass "$test"
95     }
96 }
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" ".*"
108     # Unwind to main.
109     gdb_test "up 10" " in main .*"
110     gdb_test "p tlsvar" " = 1" "tlsvar in main"
111 }