gdb: fix vfork with multiple threads
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / next-fork-other-thread.exp
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 standard_testfile
17
18 set break_here_line [gdb_get_line_number "break here"]
19
20 set timeout 99999
21
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] } {
26 return
27 }
28 }
29
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}
34 }
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"
39
40 gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
41
42 if { ![runto_main] } {
43 return
44 }
45
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"
48
49 gdb_test "break $::break_here_line" "Breakpoint $::decimal at $::hex.*"
50 gdb_test "continue" "hit Breakpoint $::decimal, main.*"
51
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 } {
55 return
56 }
57
58 if { [gdb_test "next" "for loop.*" "next to for loop"] != 0 } {
59 return
60 }
61
62 if { [gdb_test "next" "break here.*" "next to break here"] != 0} {
63 return
64 }
65 }
66 }
67 }
68
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}
74 }
75 }
76 }
77 }
This page took 0.031802 seconds and 4 git commands to generate.