Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright (C) 1996-2013 Free Software Foundation, Inc. |
0312286c DJ |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
0312286c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
0312286c DJ |
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. | |
e22f8b7c | 12 | # |
0312286c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0312286c | 15 | |
0312286c DJ |
16 | # This file was written by Daniel Jacobowitz <drow@mvista.com> |
17 | # (parts based on pthreads.exp by Fred Fish (fnf@cygnus.com). | |
18 | # | |
19 | # It tests miscellaneous actions with multiple threads, including | |
20 | # handling for thread exit. | |
21 | ||
0312286c | 22 | |
0efbbabc | 23 | standard_testfile |
0312286c DJ |
24 | |
25 | # regexp for "horizontal" text (i.e. doesn't include newline or | |
26 | # carriage return) | |
27 | set horiz "\[^\n\r\]*" | |
28 | ||
0efbbabc | 29 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } { |
0312286c DJ |
30 | return -1 |
31 | } | |
32 | ||
33 | # Now we can proceed with the real testing. | |
34 | ||
0efbbabc | 35 | clean_restart ${binfile} |
0312286c | 36 | |
12b5d08a MS |
37 | gdb_test_no_output "set print sevenbit-strings" |
38 | #gdb_test_no_output "set print address off" | |
39 | gdb_test_no_output "set width 0" | |
0312286c DJ |
40 | |
41 | # We'll need this when we send_gdb a ^C to GDB. Need to do it before we | |
42 | # run the program and gdb starts saving and restoring tty states. | |
43 | # On Ultrix, we don't need it and it is really slow (because shell_escape | |
44 | # doesn't use vfork). | |
45 | if ![istarget "*-*-ultrix*"] then { | |
f6978de9 | 46 | gdb_test "shell stty intr '^C'" ".*" |
0312286c DJ |
47 | } |
48 | ||
49 | proc test_all_threads { name kill } { | |
fda326dd | 50 | global gdb_prompt inferior_exited_re |
0312286c DJ |
51 | |
52 | set i 0 | |
53 | set j 0 | |
9db70545 | 54 | gdb_test_multiple "continue" "all threads ran once" { |
0312286c DJ |
55 | -re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" { |
56 | set i [expr $i + 1] | |
57 | pass "Hit thread_function breakpoint, $i ($name)" | |
58 | send_gdb "continue\n" | |
59 | exp_continue | |
60 | } | |
61 | -re "Breakpoint \[0-9\]+, .* kill \\(.*\\) .*$gdb_prompt" { | |
62 | set j [expr $j + 1] | |
63 | if { $kill == 1 } { | |
64 | pass "Hit kill breakpoint, $j ($name)" | |
65 | } else { | |
66 | fail "Hit kill breakpoint, $j ($name) (unexpected)" | |
67 | } | |
68 | send_gdb "continue\n" | |
69 | exp_continue | |
70 | } | |
fda326dd | 71 | -re "$inferior_exited_re normally.\[\r\n\]+$gdb_prompt" { |
0312286c DJ |
72 | pass "program exited normally" |
73 | if {$i == 5} { | |
74 | pass "all threads ran once ($name)" | |
75 | } else { | |
76 | fail "all threads ran once ($name) (total $i threads ran)" | |
77 | } | |
78 | } | |
027c0295 | 79 | -re "Program received signal SIGTRAP.*(Thread \[-0-9a-fx\]* \\(zombie\\)|0x00000000 in ).*$gdb_prompt $" { |
f56973f8 DJ |
80 | if { $kill == 1 } { |
81 | kfail "gdb/1265" "Running threads ($name) (zombie thread)" | |
82 | } else { | |
83 | fail "Running threads ($name) (unknown output)" | |
84 | } | |
85 | } | |
0312286c DJ |
86 | } |
87 | } | |
88 | ||
a4b5b48a DE |
89 | # Record the old timeout, we need to extend it for slower tests. |
90 | set oldtimeout $timeout | |
91 | ||
0312286c DJ |
92 | runto_main |
93 | gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." | |
12b5d08a | 94 | gdb_test_no_output "set var slow = 0" |
0312286c DJ |
95 | test_all_threads "fast" 0 |
96 | ||
97 | runto_main | |
98 | gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (2)" | |
12b5d08a | 99 | gdb_test_no_output "set var slow = 1" |
a4b5b48a DE |
100 | # Extend the timeout for slower tests. |
101 | set timeout [expr $oldtimeout + 120] | |
0312286c | 102 | test_all_threads "slow" 0 |
a4b5b48a | 103 | set timeout $oldtimeout |
0312286c DJ |
104 | |
105 | runto_main | |
106 | gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (3)" | |
12b5d08a | 107 | gdb_test_no_output "set var slow = 1" "set var slow = 1 (2)" |
6afcfa39 | 108 | gdb_breakpoint "kill" |
a4b5b48a DE |
109 | # Extend the timeout for slower tests. |
110 | set timeout [expr $oldtimeout + 120] | |
0312286c | 111 | test_all_threads "slow with kill breakpoint" 1 |
a4b5b48a | 112 | set timeout $oldtimeout |
0312286c DJ |
113 | |
114 | return 0 |