1 # Copyright 2020-2021 Free Software Foundation, Inc.
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.
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.
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/>.
18 set break_here_line [gdb_get_line_number "break here"]
22 foreach_with_prefix fork_func {fork vfork} {
23 set opts [list debug pthreads additional_flags=-DFORK_FUNC=${fork_func}]
24 if { [build_executable "failed to prepare" \
25 ${testfile}-${fork_func} ${srcfile} $opts] } {
30 proc do_test { fork_func target-non-stop non-stop displaced-stepping } {
31 save_vars { ::GDBFLAGS } {
32 append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\" -ex \"set non-stop ${non-stop}\""
33 clean_restart ${::binfile}-${fork_func}
35 #gdb_test "set debug infrun"
36 #gdb_test "set debug remote-packet-max-chars 4096"
37 #gdb_test "set debug remote 1"
38 #gdb_test "set remotetimeout 300"
40 gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
42 if { ![runto_main] } {
46 # The "Detached after (v)fork" messages get in the way in non-stop, disable them.
47 gdb_test_no_output "set print inferior-events off"
49 gdb_test "break $::break_here_line" "Breakpoint $::decimal at $::hex.*"
50 gdb_test "continue" "hit Breakpoint $::decimal, main.*"
52 for { set i 0 } { $i < 20 } { incr i } {
53 with_test_prefix "i=$i" {
54 if { [gdb_test "next" "other line.*" "next to other line"] != 0 } {
58 if { [gdb_test "next" "for loop.*" "next to for loop"] != 0 } {
62 if { [gdb_test "next" "break here.*" "next to break here"] != 0} {
69 foreach_with_prefix fork_func {fork vfork} {
70 foreach_with_prefix target-non-stop {auto on off} {
71 foreach_with_prefix non-stop {off on} {
72 foreach_with_prefix displaced-stepping {auto on off} {
73 do_test ${fork_func} ${target-non-stop} ${non-stop} ${displaced-stepping}