]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/fork-thread-pending.exp
merge from gcc
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / fork-thread-pending.exp
CommitLineData
4c38e0a4 1# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
e58b0e63
PA
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.
18if { [is_remote target] } {
19 return 0
20}
21
22# Only GNU/Linux is known to support `set follow-fork-mode child'.
23#
24if { ! [istarget "*-*-linux*"] } {
25 return 0
26}
27
28set testfile fork-thread-pending
29set srcfile ${testfile}.c
30set binfile ${objdir}/${subdir}/${testfile}
31
32if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33 return -1
34}
35
36gdb_exit
37gdb_start
38gdb_reinitialize_dir $srcdir/$subdir
39
40gdb_load ${binfile}
41if ![runto_main] then {
42 fail "Can't run to main"
43 return 0
44}
45
12b5d08a 46gdb_test_no_output "set follow-fork-mode child" "1, set follow-fork-mode child"
e58b0e63
PA
47gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "1, insert fork catchpoint"
48gdb_breakpoint "start" "" "1, set breakpoint at start"
49
50gdb_test "continue" "Catchpoint.*" "1, get to the fork event"
51
52gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "1, multiple threads found"
53
54gdb_test "thread 2" "" "1, switched away from event thread"
55
56gdb_test "continue" "Not resuming.*" "1, refused to resume"
57
58set test "1, followed to the child, found one thread"
59gdb_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
74gdb_test "continue" "Breakpoint 3, start.*" "1, get to the spawned thread in fork child"
75
76set test "1, followed to the child, found two threads"
77gdb_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
94gdb_exit
95gdb_start
96gdb_reinitialize_dir $srcdir/$subdir
97
98gdb_load ${binfile}
99if ![runto_main] then {
100 fail "Can't run to main"
101 return 0
102}
103
12b5d08a 104gdb_test_no_output "set follow-fork-mode child" "2, set follow-fork-mode child"
e58b0e63
PA
105gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "2, insert fork catchpoint"
106gdb_breakpoint "start"
107
108gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
109
110gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "2, multiple threads found"
111
112gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
113
114set test "2, followed to the child, found two threads"
115gdb_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}