Commit | Line | Data |
---|---|---|
7339a42e JJ |
1 | # manythreads.exp -- Expect script to test stopping many threads |
2 | # Copyright (C) 2004 Free Software Foundation, Inc. | |
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 | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
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. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # bug-gdb@prep.ai.mit.edu | |
20 | ||
21 | # This file was written by Jeff Johnston. (jjohnstn@redhat.com) | |
22 | ||
23 | if $tracelevel then { | |
24 | strace $tracelevel | |
25 | } | |
26 | ||
27 | set prms_id 0 | |
28 | set bug_id 0 | |
29 | ||
30 | set testfile "manythreads" | |
31 | set srcfile ${testfile}.c | |
32 | set binfile ${objdir}/${subdir}/${testfile} | |
33 | ||
34 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } { | |
35 | return -1 | |
36 | } | |
37 | ||
38 | gdb_start | |
39 | gdb_reinitialize_dir $srcdir/$subdir | |
40 | gdb_load ${binfile} | |
41 | gdb_test "set print sevenbit-strings" "" | |
42 | runto_main | |
43 | ||
44 | # We'll need this when we send_gdb a ^C to GDB. Need to do it before we | |
45 | # run the program and gdb starts saving and restoring tty states. | |
46 | # On Ultrix, we don't need it and it is really slow (because shell_escape | |
47 | # doesn't use vfork). | |
48 | if ![istarget "*-*-ultrix*"] then { | |
49 | gdb_test "shell stty intr '^C'" "" | |
50 | } | |
51 | ||
52 | set message "first continue" | |
53 | gdb_test_multiple "continue" "first continue" { | |
54 | -re "error:.*$gdb_prompt $" { | |
55 | fail "$message" | |
56 | } | |
57 | -re "Continuing" { | |
58 | pass "$message" | |
59 | } | |
60 | } | |
61 | ||
62 | # Send a Ctrl-C and verify that we can do info threads and continue | |
63 | after 1000 {send_gdb "\003"} | |
64 | set message "stop threads 1" | |
65 | gdb_test_multiple "" "stop threads 1" { | |
66 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
67 | exp_continue | |
68 | } | |
69 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
70 | exp_continue | |
71 | } | |
72 | -re "Thread \[^\n\]* executing\r\n" { | |
73 | exp_continue | |
74 | } | |
75 | -re "Program received signal SIGINT.*$gdb_prompt $" { | |
76 | pass "$message" | |
77 | } | |
78 | timeout { | |
79 | fail "$message (timeout)" | |
80 | } | |
81 | } | |
82 | ||
83 | gdb_test "info threads" ".*1 Thread.*.LWP.*" | |
84 | ||
85 | set message "second continue" | |
86 | gdb_test_multiple "continue" "second continue" { | |
87 | -re "error:.*$gdb_prompt $" { | |
88 | fail "$message" | |
89 | } | |
90 | -re "Continuing" { | |
91 | pass "$message" | |
92 | } | |
93 | } | |
94 | ||
95 | # Send another Ctrl-C and verify that we can do info threads and quit | |
96 | after 1000 {send_gdb "\003"} | |
97 | set message "stop threads 2" | |
98 | gdb_test_multiple "" "stop threads 2" { | |
99 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
100 | exp_continue | |
101 | } | |
102 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
103 | exp_continue | |
104 | } | |
105 | -re "Thread \[^\n\]* executing\r\n" { | |
106 | exp_continue | |
107 | } | |
108 | -re "Program received signal SIGINT.*$gdb_prompt $" { | |
109 | pass "stop threads 2" | |
110 | } | |
111 | } | |
112 | ||
113 | gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" { | |
114 | -re "The program is running. Exit anyway\\? \\(y or n\\) $" { | |
115 | send_gdb "y\n" | |
116 | exp_continue | |
117 | } | |
118 | eof { | |
119 | pass "GDB exits after stopping multithreaded program" | |
120 | } | |
121 | timeout { | |
122 | fail "GDB exits after stopping multithreaded program (timeout)" | |
123 | } | |
124 | } | |
125 |