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