]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/vfork-follow-parent.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / vfork-follow-parent.exp
CommitLineData
213516ef 1# Copyright 2021-2023 Free Software Foundation, Inc.
b6535766
SM
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# Test running into vfork while "detach-on-fork" is off and "follow-fork-mode"
17# is parent. This shows a "Can not resume the parent process..." message. If
18# the user wants to resume execution, they have to use either "set
19# schedule-multiple on" or "set detach-on-fork on". Test these two resolution
20# methods.
21
22standard_testfile
23
24if { [build_executable "failed to prepare" \
25 ${testfile} ${srcfile}] } {
26 return
27}
28
29# Test running to the "Can not resume the parent..." message. Then, resolve
30# the situation using the method in RESOLUTION_METHOD, either "detach-on-fork"
31# or "schedule-multiple" (the two alternatives the message suggests to the
32# user).
33
34proc do_test { resolution_method } {
35 clean_restart $::binfile
36
37 gdb_test_no_output "set detach-on-fork off"
38
39 if { ![runto_main] } {
40 return
41 }
42
43 gdb_test "break break_parent"
44
45 gdb_test "continue" \
46 "Can not resume the parent process over vfork .*" \
47 "continue to vfork"
48
49 # Try to continue again from there, expecting the same message. It
50 # exercises a different code path in GDB.
51 gdb_test "continue" \
52 "Can not resume the parent process over vfork .*" \
53 "try to continue from vfork"
54
55 # Unblock the execution using the specified resolution method.
56 if { $resolution_method == "detach-on-fork" } {
57 # Make GDB detach the child.
58 gdb_test "set detach-on-fork on"
b8b5466f 59 gdb_test "print unblock_parent = 1" " = 1"
b6535766
SM
60 } elseif { $resolution_method == "schedule-multiple" } {
61 # Make GDB resume both inferiors. The parent is blocked while the
62 # children executes, so the continue will make the child reach the
63 # end.
64 gdb_test "set schedule-multiple on"
65 gdb_test "continue" "$::inferior_exited_re normally.*" \
66 "continue to end of inferior 2"
67 gdb_test "inferior 1" ".*Switching to inferior 1.*"
b8b5466f 68 gdb_test "print unblock_parent = 1" " = 1"
b6535766
SM
69 } else {
70 error "invalid resolution method: $resolution_method"
71 }
72
73 # Continue from the vfork call to the breakpoint.
74 gdb_test "continue" "Breakpoint $::decimal, break_parent .*" \
75 "continue to break_parent"
76}
77
78foreach_with_prefix resolution_method {detach-on-fork schedule-multiple} {
79 do_test $resolution_method
80}