]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/fork-thread-pending.exp
382e5375226b07ef316f04893da54fa2a5a8c79a
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / fork-thread-pending.exp
1 # Copyright (C) 2009, 2010 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 # There's no support for `set follow-fork-mode' in the remote
17 # protocol.
18 if { [is_remote target] } {
19 return 0
20 }
21
22 # Only GNU/Linux is known to support `set follow-fork-mode child'.
23 #
24 if { ! [istarget "*-*-linux*"] } {
25 return 0
26 }
27
28 set testfile fork-thread-pending
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
31
32 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33 return -1
34 }
35
36 gdb_exit
37 gdb_start
38 gdb_reinitialize_dir $srcdir/$subdir
39
40 gdb_load ${binfile}
41 if ![runto_main] then {
42 fail "Can't run to main"
43 return 0
44 }
45
46 gdb_test_no_output "set follow-fork-mode child" "1, set follow-fork-mode child"
47 gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "1, insert fork catchpoint"
48 gdb_breakpoint "start" "" "1, set breakpoint at start"
49
50 gdb_test "continue" "Catchpoint.*" "1, get to the fork event"
51
52 gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "1, multiple threads found"
53
54 gdb_test "thread 2" ".*" "1, switched away from event thread"
55
56 gdb_test "continue" "Not resuming.*" "1, refused to resume"
57
58 set test "1, followed to the child, found one thread"
59 gdb_test_multiple "info threads" "metest" {
60 -re " Thread .* Thread .*$gdb_prompt $" {
61 fail "$test"
62 }
63 -re " Thread .*$gdb_prompt $" {
64 pass "$test"
65 }
66 -re "$gdb_prompt $" {
67 fail "$test (unknown output)"
68 }
69 timeout {
70 fail "$test (timeout)"
71 }
72 }
73
74 gdb_test "continue" "Breakpoint 3, start.*" "1, get to the spawned thread in fork child"
75
76 set test "1, followed to the child, found two threads"
77 gdb_test_multiple "info threads" "$test" {
78 -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
79 fail "$test"
80 }
81 -re " Thread .* Thread .*$gdb_prompt $" {
82 pass "$test"
83 }
84 -re "$gdb_prompt $" {
85 fail "$test (unknown output)"
86 }
87 timeout {
88 fail "$test (timeout)"
89 }
90 }
91
92 # Start over, but this time, don't switch away from the fork event thread.
93
94 gdb_exit
95 gdb_start
96 gdb_reinitialize_dir $srcdir/$subdir
97
98 gdb_load ${binfile}
99 if ![runto_main] then {
100 fail "Can't run to main"
101 return 0
102 }
103
104 gdb_test_no_output "set follow-fork-mode child" "2, set follow-fork-mode child"
105 gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "2, insert fork catchpoint"
106 gdb_breakpoint "start"
107
108 gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
109
110 gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "2, multiple threads found"
111
112 gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
113
114 set test "2, followed to the child, found two threads"
115 gdb_test_multiple "info threads" "$test" {
116 -re " Thread .* Thread .* Thread .*$gdb_prompt $" {
117 fail "$test"
118 }
119 -re " Thread .* Thread .*$gdb_prompt $" {
120 pass "$test"
121 }
122 -re "$gdb_prompt $" {
123 fail "$test (unknown output)"
124 }
125 timeout {
126 fail "$test (timeout)"
127 }
128 }