]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/print-threads.exp
Updated copyright notices for most files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / print-threads.exp
CommitLineData
0fb0cc75 1# Copyright (C) 1996, 1997, 2002, 2003, 2007, 2008, 2009
9b254dd1 2# Free Software Foundation, Inc.
0312286c
DJ
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
0312286c 7# (at your option) any later version.
e22f8b7c 8#
0312286c
DJ
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
0312286c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
0312286c 16
0312286c
DJ
17# This file was written by Daniel Jacobowitz <drow@mvista.com>
18# (parts based on pthreads.exp by Fred Fish (fnf@cygnus.com).
19#
20# It tests miscellaneous actions with multiple threads, including
21# handling for thread exit.
22
23if $tracelevel then {
24 strace $tracelevel
25}
26
27set prms_id 0
28set bug_id 0
29
30set testfile "print-threads"
31set srcfile ${testfile}.c
32set binfile ${objdir}/${subdir}/${testfile}
33
34# regexp for "horizontal" text (i.e. doesn't include newline or
35# carriage return)
36set horiz "\[^\n\r\]*"
37
b5ab8ff3 38if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
0312286c
DJ
39 return -1
40}
41
42# Now we can proceed with the real testing.
43
44# Start with a fresh gdb.
45
46gdb_exit
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
49gdb_load ${binfile}
50
51gdb_test "set print sevenbit-strings" ""
52#gdb_test "set print address off" ""
53gdb_test "set width 0" ""
54
55# We'll need this when we send_gdb a ^C to GDB. Need to do it before we
56# run the program and gdb starts saving and restoring tty states.
57# On Ultrix, we don't need it and it is really slow (because shell_escape
58# doesn't use vfork).
59if ![istarget "*-*-ultrix*"] then {
60 gdb_test "shell stty intr '^C'" ""
61}
62
63proc test_all_threads { name kill } {
64 global gdb_prompt
65
66 set i 0
67 set j 0
68 send_gdb "continue\n"
69 gdb_expect {
70 -re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" {
71 set i [expr $i + 1]
72 pass "Hit thread_function breakpoint, $i ($name)"
73 send_gdb "continue\n"
74 exp_continue
75 }
76 -re "Breakpoint \[0-9\]+, .* kill \\(.*\\) .*$gdb_prompt" {
77 set j [expr $j + 1]
78 if { $kill == 1 } {
79 pass "Hit kill breakpoint, $j ($name)"
80 } else {
81 fail "Hit kill breakpoint, $j ($name) (unexpected)"
82 }
83 send_gdb "continue\n"
84 exp_continue
85 }
86 -re "Program exited normally\\.\[\r\n\]+$gdb_prompt" {
87 pass "program exited normally"
88 if {$i == 5} {
89 pass "all threads ran once ($name)"
90 } else {
91 fail "all threads ran once ($name) (total $i threads ran)"
92 }
93 }
027c0295 94 -re "Program received signal SIGTRAP.*(Thread \[-0-9a-fx\]* \\(zombie\\)|0x00000000 in ).*$gdb_prompt $" {
f56973f8
DJ
95 if { $kill == 1 } {
96 kfail "gdb/1265" "Running threads ($name) (zombie thread)"
97 } else {
98 fail "Running threads ($name) (unknown output)"
99 }
100 }
0312286c
DJ
101 -re "$gdb_prompt" {
102 fail "Running threads ($name) (unknown output)"
103 }
104 timeout {
105 fail "Running threads ($name) (timeout)"
106 }
107 }
108}
109
110runto_main
111gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\."
112gdb_test "set var slow = 0" ""
113test_all_threads "fast" 0
114
115runto_main
116gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (2)"
117gdb_test "set var slow = 1" ""
118test_all_threads "slow" 0
119
120runto_main
121gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (3)"
122gdb_test "set var slow = 1" "" "set var slow = 1 (2)"
6afcfa39 123gdb_breakpoint "kill"
0312286c
DJ
124test_all_threads "slow with kill breakpoint" 1
125
126return 0