gdb: fix vfork with multiple threads
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / next-fork-other-thread.exp
diff --git a/gdb/testsuite/gdb.threads/next-fork-other-thread.exp b/gdb/testsuite/gdb.threads/next-fork-other-thread.exp
new file mode 100644 (file)
index 0000000..3a53301
--- /dev/null
@@ -0,0 +1,77 @@
+# Copyright 2020-2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+set break_here_line [gdb_get_line_number "break here"]
+
+set timeout 99999
+
+foreach_with_prefix fork_func {fork vfork} {
+    set opts [list debug pthreads additional_flags=-DFORK_FUNC=${fork_func}]
+    if { [build_executable "failed to prepare" \
+           ${testfile}-${fork_func} ${srcfile} $opts] } {
+       return
+    }
+}
+
+proc do_test { fork_func target-non-stop non-stop displaced-stepping } {
+    save_vars { ::GDBFLAGS } {
+       append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\" -ex \"set non-stop ${non-stop}\""
+       clean_restart ${::binfile}-${fork_func}
+    }
+    #gdb_test "set debug infrun"
+    #gdb_test "set debug remote-packet-max-chars 4096"
+    #gdb_test "set debug remote 1"
+    #gdb_test "set remotetimeout 300"
+
+    gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
+
+    if { ![runto_main] } {
+       return
+    }
+
+    # The "Detached after (v)fork" messages get in the way in non-stop, disable them.
+    gdb_test_no_output "set print inferior-events off"
+
+    gdb_test "break $::break_here_line" "Breakpoint $::decimal at $::hex.*"
+    gdb_test "continue" "hit Breakpoint $::decimal, main.*"
+
+    for { set i 0 } { $i < 20 } { incr i } {
+       with_test_prefix "i=$i" {
+           if { [gdb_test "next" "other line.*" "next to other line"] != 0 } {
+               return
+           }
+
+           if { [gdb_test "next" "for loop.*" "next to for loop"] != 0 } {
+               return
+           }
+
+           if { [gdb_test "next" "break here.*" "next to break here"] != 0} {
+               return
+           }
+       }
+    }
+}
+
+foreach_with_prefix fork_func {fork vfork} {
+    foreach_with_prefix target-non-stop {auto on off} {
+       foreach_with_prefix non-stop {off on} {
+           foreach_with_prefix displaced-stepping {auto on off} {
+               do_test ${fork_func} ${target-non-stop} ${non-stop} ${displaced-stepping}
+           }
+       }
+    }
+}
This page took 0.032887 seconds and 4 git commands to generate.