Compare commits

...

1 Commits

Author SHA1 Message Date
Keith Seitz
d8b79a1f24 gdb testsuite: Introduce allow_fork_tests and use it throughout
Cygwin debugging does not support follow fork.  There is currently no
interface between the debugger and the Cygwin runtime to be able to
intercept forks and execs.  Consequently, testcases that try to
exercise fork/exec all FAIL, and several hit long cascading timeouts.

Add a new allow_fork_tests procedure, meant be be used with require,
and sprinkle it throughout testcases that exercise fork.

Note that some tests currently are skipped on targets other than
Linux, with something like:

 # Until "set follow-fork-mode" and "catch vfork" are implemented on
 # other targets...
 #
 if {![istarget "*-linux*"]} {
     continue
 }

However, some BSD ports also support fork debugging nowadays, and the
testcases were never adjusted...  That is why the new allow_fork_tests
procedure doesn't look for linux.

With this patch, on Cygwin, I get this:

 $ make check TESTS="*/*fork*.exp"

 ...
		 === gdb Summary ===

 # of expected passes            6
 # of untested testcases         1
 # of unsupported tests          31

Change-Id: I0c5e8c574d1f61b28d370c22a0b0b6bc3efaf978
2025-06-06 09:17:34 -07:00
31 changed files with 57 additions and 29 deletions

View File

@@ -32,6 +32,8 @@
standard_testfile
require allow_fork_tests
# Build two programs -- one for fork, and another for vfork.
set testfile_fork "${testfile}-fork"
set testfile_vfork "${testfile}-vfork"

View File

@@ -21,9 +21,7 @@
# ld.so probes before reaching main, and ptrace flags were set then. But a
# static executable would just keep running and never catch the fork.
# Until "catch fork" is implemented on other targets...
#
require {is_any_target "*-*-linux*" "*-*-openbsd*"}
require allow_fork_tests
# Reusing foll-fork.c since it's a simple forking program.
standard_testfile foll-fork.c

View File

@@ -17,6 +17,8 @@
# enabled as it will be redirected to the log.
require !gdb_debug_enabled
require allow_fork_tests
standard_testfile
if {[build_executable "failed to prepare" $testfile $srcfile debug]} {

View File

@@ -18,12 +18,7 @@
# either execs or exits --- since those events take somewhat different
# code paths in GDB, both variants are exercised.
# Until "set follow-fork-mode" and "catch vfork" are implemented on
# other targets...
#
if {![istarget "*-linux*"]} {
continue
}
require allow_fork_tests
standard_testfile .c -exit.c vforked-prog.c

View File

@@ -23,6 +23,7 @@
# in the source of the shlib, and "list" should display the source where
# the program stopped.
require allow_fork_tests
require allow_shlib_tests
standard_testfile .c -shlib.c

View File

@@ -19,6 +19,8 @@
# inferior-events [on,off]', 'set follow-fork-mode [child,parent]' and
# 'set detach-on-fork [on,off]' are the correct ones.
require allow_fork_tests
# This test relies on "run", so it cannot run on target remote stubs.
require !use_gdb_stub

View File

@@ -17,6 +17,8 @@
# in non-stop). GDB used to miss updating the parent/child running
# states after a fork.
require allow_fork_tests
standard_testfile
# The test proper.

View File

@@ -13,10 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Until "set follow-fork-mode" and "catch fork" are implemented on
# other targets...
#
require {istarget "*-*-linux*"}
require allow_fork_tests
require support_displaced_stepping

View File

@@ -16,6 +16,8 @@
# Make sure that we can interrupt an inferior that forks and moves to
# its own session.
require allow_fork_tests
standard_testfile
if {[build_executable "failed to build" $testfile $srcfile {debug}]} {

View File

@@ -15,6 +15,7 @@
# Test fork handling of an inferior that has JIT-ed objfiles.
require allow_fork_tests
require allow_shlib_tests
load_lib jit-elf-helpers.exp

View File

@@ -13,11 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Until "set follow-fork-mode" and "catch fork" are implemented on
# other targets...
#
require {istarget "*-*-linux*"}
require allow_fork_tests
standard_testfile .c

View File

@@ -16,6 +16,8 @@
# Test that we can follow forks properly when the executable is
# position-independent.
require allow_fork_tests
standard_testfile
set opts [list debug pie]

View File

@@ -13,11 +13,14 @@
# 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
# Test a thread is doing step-over a syscall instruction which is exit,
# and GDBserver should cleanup its state of step-over properly.
# The testcase relies on follow-fork-mode child.
require allow_fork_tests
standard_testfile
set syscall_insn ""
# Define the syscall instruction for each target.

View File

@@ -19,6 +19,8 @@
# schedule-multiple on" or "set detach-on-fork on". Test these two resolution
# methods.
require allow_fork_tests
standard_testfile .c vforked-prog.c
set binfile ${testfile}-exit

View File

@@ -20,6 +20,8 @@
# This test uses "awatch".
require allow_hw_watchpoint_access_tests
require allow_fork_tests
standard_testfile
if {[build_executable "failed to prepare" $testfile $srcfile debug]} {

View File

@@ -17,6 +17,8 @@
standard_testfile .c
require allow_fork_tests
if { [build_executable ${testfile}.exp ${testfile} $srcfile {debug}] } {
untested "failed to compile"
return -1

View File

@@ -17,6 +17,8 @@
# watchpoints don't end up with stale locations, preventing resumption
# of other inferiors.
require allow_fork_tests
standard_testfile
if {[build_executable "failed to build" $testfile $srcfile {debug}]} {

View File

@@ -17,6 +17,8 @@
# another thread, in different combinations of "set follow-fork
# parent/child", and other execution modes.
require allow_fork_tests
standard_testfile
# Line where to stop the main thread.

View File

@@ -13,10 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Only GNU/Linux is known to support `set follow-fork-mode child'.
if { ! [istarget "*-*-linux*"] } {
return 0
}
require allow_fork_tests
standard_testfile

View File

@@ -20,6 +20,8 @@
#
# See https://sourceware.org/bugzilla/show_bug.cgi?id=18600
require allow_fork_tests
# In remote mode, we cannot continue debugging after all
# inferiors have terminated, and this test requires that.
if { [target_info exists gdb_protocol]

View File

@@ -13,11 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Only GNU/Linux is known to support `set follow-fork-mode child'.
#
if { ! [istarget "*-*-linux*"] } {
return 0
}
require allow_fork_tests
standard_testfile

View File

@@ -16,6 +16,8 @@
# This test verifies that several threads forking while another thread
# is constantly stepping over a breakpoint is properly handled.
require allow_fork_tests
standard_testfile
set linenum [gdb_get_line_number "set break here"]

View File

@@ -25,6 +25,8 @@
# 20.04.5 LTS with 32-bit kernel + 32-bit userland. It was NOT reproducible
# using a circa 2023 Raspberry Pi OS w/ 64-bit kernel and 32-bit userland.
require allow_fork_tests
standard_testfile
# Line where to stop the main thread.

View File

@@ -16,6 +16,8 @@
# Test doing a "next" on a thread during which forks or vforks happen in other
# threads.
require allow_fork_tests
standard_testfile
# Line where to stop the main thread.

View File

@@ -29,6 +29,8 @@
# parent thread from waitpid'ing it, preventing the main thread from joining
# it, prevent it from writing the flag file, failing the test.
require allow_fork_tests
standard_testfile
if { [is_remote target] } {

View File

@@ -34,6 +34,8 @@
# event, and erroneously create a new inferior for it. Once fixed, the child
# process' thread is hidden by whoever holds the pending fork event.
require allow_fork_tests
standard_testfile .c -touch-file.c
set touch_file_bin $binfile-touch-file

View File

@@ -16,6 +16,8 @@
# Test following a vfork child that execs, when the vfork parent is a
# threaded program, and it's a non-main thread that vforks.
require allow_fork_tests
standard_testfile
if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} {

View File

@@ -16,6 +16,8 @@
# Test following a vfork child that exits, when the vfork parent is a
# threaded program, and it's a non-main thread that vforks.
require allow_fork_tests
standard_testfile
if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} {

View File

@@ -25,6 +25,8 @@
# To catch the bug, this test verifies that we can hit a breakpoint after a
# vfork call, while a second inferior runs in the background.
require allow_fork_tests
require !use_gdb_stub
standard_testfile .c -sleep.c

View File

@@ -30,6 +30,8 @@
# breakpoints are removed, so the main thread would miss the breakpoint and run
# until exit.
require allow_fork_tests
standard_testfile
if { [build_executable "failed to prepare" ${testfile} ${srcfile} {debug pthreads}] } {

View File

@@ -21,6 +21,8 @@
# must be done before starting the test so as to not disrupt the execution
# of the actual test.
require allow_fork_tests
set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests]
set testfile watchpoint-fork