gdb: test vfork + follow parent + detach-on-fork off
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / vfork-follow-parent.exp
CommitLineData
da0b6974
SM
1# Copyright 2020-2021 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# This serves as a template for writing new test cases. Replace this with
17# a description of what this test case tests.
18
19standard_testfile
20
21if { [build_executable "failed to prepare" \
22 ${testfile} ${srcfile}] } {
23 return
24}
25
26proc do_test { method } {
27 clean_restart $::binfile
28
29 gdb_test_no_output "set detach-on-fork off"
30
31 if { ![runto_main] } {
32 return
33 }
34
35 gdb_test "break break_parent"
36
37 gdb_test "continue" \
38 "Can not resume the parent process over vfork .*" \
39 "continue to vfork"
40
41 # Try to continue again from there, expecting the same message. It takes a
42 # different code path in GDB.
43 gdb_test "continue" \
44 "Can not resume the parent process over vfork .*" \
45 "try to continue from vfork"
46
47 if { $method == "detach-on-fork" } {
48 gdb_test "set detach-on-fork on"
49 } elseif { $method == "schedule-multiple" } {
50 gdb_test "set schedule-multiple on"
51 gdb_test "continue" "$::inferior_exited_re normally.*" \
52 "continue to end of inferior 2"
53 gdb_test "inferior 1" ".*Switching to inferior 1.*"
54 } else {
55 error "invalid method: $method"
56 }
57
58 gdb_test "p release_parent = 1" " = 1"
59 gdb_test "continue" "Breakpoint $::decimal, break_parent .*" \
60 "continue to break_parent"
61}
62
63foreach_with_prefix method {detach-on-fork schedule-multiple} {
64 do_test $method
65}
This page took 0.027392 seconds and 4 git commands to generate.