1 # Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
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.
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.
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/>.
16 # There's no support for `set follow-fork-mode' in the remote
18 if { [is_remote target] } {
22 # Only GNU/Linux is known to support `set follow-fork-mode child'.
24 if { ! [istarget "*-*-linux*"] } {
28 set testfile fork-thread-pending
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
32 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
38 gdb_reinitialize_dir $srcdir/$subdir
41 if ![runto_main] then {
42 fail "Can't run to main"
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"
50 gdb_test "continue" "Catchpoint.*" "1, get to the fork event"
52 gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "1, multiple threads found"
54 gdb_test "thread 2" ".*" "1, switched away from event thread"
56 gdb_test "continue" "Not resuming.*" "1, refused to resume"
58 set test "1, followed to the child, found one thread"
59 gdb_test_multiple "info threads" "metest" {
60 -re " Thread .* Thread .*$gdb_prompt $" {
63 -re " Thread .*$gdb_prompt $" {
67 fail "$test (unknown output)"
70 fail "$test (timeout)"
74 gdb_test "continue" "Breakpoint 3, start.*" "1, get to the spawned thread in fork child"
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 $" {
81 -re " Thread .* Thread .*$gdb_prompt $" {
85 fail "$test (unknown output)"
88 fail "$test (timeout)"
92 # Start over, but this time, don't switch away from the fork event thread.
96 gdb_reinitialize_dir $srcdir/$subdir
99 if ![runto_main] then {
100 fail "Can't run to main"
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"
108 gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
110 gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "2, multiple threads found"
112 gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
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 $" {
119 -re " Thread .* Thread .*$gdb_prompt $" {
122 -re "$gdb_prompt $" {
123 fail "$test (unknown output)"
126 fail "$test (timeout)"