]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.rocm / fork-exec-non-gpu-to-gpu.exp
1 # Copyright 2021-2024 Free Software Foundation, Inc.
2
3 # This file is part of GDB.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # Verify that we can debug a GPU program in a child after a (v)fork + exec.
19
20 load_lib rocm.exp
21
22 require allow_hipcc_tests
23
24 standard_testfile -execer.cpp -execee.cpp
25
26 set srcfile_execer "$srcfile"
27 set srcfile_execee "$srcfile2"
28 set binfile_execee "$binfile-execee"
29
30 # Compile two versions of execer, one that uses fork and one that uses vfork.
31 foreach_with_prefix fork_func { fork vfork } {
32 set opts [list additional_flags=-DFORK=$fork_func \
33 additional_flags=-DEXECEE="${::binfile_execee}"]
34 if {[build_executable "failed to prepare" ${::binfile}-execer-${fork_func} \
35 $srcfile_execer $opts]} {
36 return
37 }
38 }
39
40 if {[build_executable "failed to prepare" $binfile_execee $srcfile_execee \
41 {debug hip}]} {
42 return
43 }
44
45 proc do_test { detach-on-fork follow-fork-mode fork_func } {
46 # In this case, the parent can't execute, as it's blocked in
47 # vfork. Skip it.
48 if { ${detach-on-fork} == "off"
49 && ${follow-fork-mode} == "parent"
50 && ${fork_func} == "vfork" } {
51 return
52 }
53
54 with_rocm_gpu_lock {
55 clean_restart ${::binfile}-execer-${fork_func}
56
57 gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
58 gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}"
59
60 if { ${follow-fork-mode} == "parent" } {
61 runto break_here_execer allow-pending message
62 gdb_continue_to_end "continue parent to end" "continue" 1
63
64 if { ${detach-on-fork} == "off" } {
65 gdb_test "inferior 2" "Switching to inferior 2 .*"
66 gdb_continue_to_end "continue child to end" "continue" 1
67 }
68 } elseif { ${follow-fork-mode} == "child" } {
69 runto break_here_execee allow-pending message
70 gdb_continue_to_end "continue child to end" "continue" 1
71
72 if { ${detach-on-fork} == "off" } {
73 gdb_test "inferior 1" "Switching to inferior 1 .*"
74 gdb_continue_to_end "continue parent to end" "continue" 1
75 }
76 } else {
77 error "unexpected follow-fork-mode value: ${follow-fork-mode}"
78 }
79 }
80 }
81
82 foreach_with_prefix detach-on-fork { on off } {
83 foreach_with_prefix follow-fork-mode { parent child } {
84 foreach_with_prefix fork_func { fork vfork } {
85 do_test ${detach-on-fork} ${follow-fork-mode} $fork_func
86 }
87 }
88 }