]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/fork-thread-pending.exp
ld: Change -z one-rosegment to --rosegment in comments
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / fork-thread-pending.exp
1 # Copyright (C) 2009-2024 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" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "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 " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
49 fail "$test"
50 }
51 -re " ${tdlabel_re} .*$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 " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
67 fail "$test"
68 }
69 -re " ${tdlabel_re} .* ${tdlabel_re} .*$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 clean_restart $binfile
83 if {![runto_main]} {
84 return 0
85 }
86
87 gdb_test_no_output "set follow-fork-mode child" "2, set follow-fork-mode child"
88 gdb_test "catch fork" "Catchpoint \[0-9\]* \\(fork\\)" "2, insert fork catchpoint"
89 gdb_breakpoint "start"
90
91 gdb_test "continue" "Catchpoint.*" "2, get to the fork event"
92
93 gdb_test "info threads" " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*" "2, multiple threads found"
94
95 gdb_test "continue" "Breakpoint 3, start.*" "2, get to the spawned thread in fork child"
96
97 set test "2, followed to the child, found two threads"
98 gdb_test_multiple "info threads" "$test" {
99 -re " ${tdlabel_re} .* ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
100 fail "$test"
101 }
102 -re " ${tdlabel_re} .* ${tdlabel_re} .*$gdb_prompt $" {
103 pass "$test"
104 }
105 -re "$gdb_prompt $" {
106 fail "$test (unknown output)"
107 }
108 timeout {
109 fail "$test (timeout)"
110 }
111 }