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