]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2019-2024 Free Software Foundation, Inc. |
b73715df TV |
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 following a vfork child that execs, when the vfork parent is a | |
17 | # threaded program, and it's a non-main thread that vforks. | |
18 | ||
19 | standard_testfile | |
20 | ||
21 | if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} { | |
22 | return -1 | |
23 | } | |
24 | ||
25 | # DETACH indicates whether "set detach-on-fork" is enabled. It is | |
26 | # either "on" or "off". | |
27 | ||
28 | proc test_vfork {detach} { | |
29 | global binfile | |
30 | ||
31 | clean_restart $binfile | |
32 | ||
b8ffa8b3 | 33 | if {![runto_main]} { |
b73715df TV |
34 | return 0 |
35 | } | |
36 | ||
37 | delete_breakpoints | |
38 | ||
39 | gdb_test_no_output "set follow-fork-mode child" | |
40 | gdb_test_no_output "set detach-on-fork $detach" | |
41 | ||
42 | if {$detach == "off"} { | |
43 | gdb_test "continue" \ | |
44 | [multi_line \ | |
45 | "Attaching after .* vfork to child .*" \ | |
46 | ".*New inferior 2 .*" \ | |
47 | ".* is executing new program: .*" \ | |
48 | ".*Inferior 2 .* exited normally.*"] | |
49 | } else { | |
50 | gdb_test "continue" \ | |
51 | [multi_line \ | |
52 | "Attaching after .* vfork to child .*" \ | |
53 | ".*New inferior 2 .*" \ | |
54 | ".*Detaching vfork parent process .* after child exec.*" \ | |
55 | ".*Inferior 1 .* detached.*" \ | |
56 | ".*is executing new program: .*" \ | |
57 | ".*Inferior 2 .*exited normally.*"] | |
58 | } | |
59 | } | |
60 | ||
61 | foreach_with_prefix detach-on-fork {"off" "on"} { | |
62 | test_vfork ${detach-on-fork} | |
63 | } |