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