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