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