]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - 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
1 # Copyright (C) 2009-2019 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 # Only GNU/Linux is known to support `set follow-fork-mode child'.
17 #
18 if { ! [istarget "*-*-linux*"] } {
19 return 0
20 }
21
22 standard_testfile
23
24 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
25 return -1
26 }
27
28 clean_restart ${binfile}
29
30 if ![runto_main] then {
31 fail "can't run to main"
32 return 0
33 }
34
35 gdb_test_no_output "set follow-fork-mode child" "1, set follow-fork-mode child"
36 gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "1, insert fork catchpoint"
37 gdb_breakpoint "start" "" "1, set breakpoint at start"
38
39 gdb_test "continue" "Catchpoint.*" "1, get to the fork event"
40
41 gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "1, multiple threads found"
42
43 gdb_test "thread 1" ".*" "1, switched away from event thread"
44
45 gdb_test "continue" "Not resuming.*" "1, refused to resume"
46
47 set test "1, followed to the child, found one thread"
48 gdb_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
63 gdb_test "continue" "Breakpoint 3, start.*" "1, get to the spawned thread in fork child"
64
65 set test "1, followed to the child, found two threads"
66 gdb_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
83 gdb_exit
84 gdb_start
85 gdb_reinitialize_dir $srcdir/$subdir
86
87 gdb_load ${binfile}
88 if ![runto_main] then {
89 fail "can't run to main"
90 return 0
91 }
92
93 gdb_test_no_output "set follow-fork-mode child" "2, set follow-fork-mode child"
94 gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "2, insert fork catchpoint"
95 gdb_breakpoint "start"
96
97 gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
98
99 gdb_test "info threads" " Thread .* Thread .* Thread .* Thread .*" "2, multiple threads found"
100
101 gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
102
103 set test "2, followed to the child, found two threads"
104 gdb_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 }