2012-01-04 09:17:56 +01:00
|
|
|
# Copyright 1997, 1999, 2007-2012 Free Software Foundation, Inc.
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
# 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
|
2007-08-23 20:14:19 +02:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-06-29 01:04:32 +02:00
|
|
|
# (at your option) any later version.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
1999-06-29 01:04:32 +02:00
|
|
|
# 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.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
1999-06-29 01:04:32 +02:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2008-01-29 23:47:20 +01:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:10:29 +01:00
|
|
|
# Various tests of gdb's ability to follow the parent or child of a
|
|
|
|
# Unix vfork system call. A vfork parent is blocked until the child
|
|
|
|
# either execs or exits --- since those events take somewhat different
|
|
|
|
# code paths in GDB, both variants are exercised.
|
|
|
|
|
2008-01-29 23:47:20 +01:00
|
|
|
if { [is_remote target] || ![isnative] } then {
|
1999-07-27 02:51:29 +02:00
|
|
|
continue
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 04:05:15 +02:00
|
|
|
# Until "set follow-fork-mode" and "catch vfork" are implemented on
|
|
|
|
# other targets...
|
|
|
|
#
|
|
|
|
if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test to see if we are on an HP-UX 10.20 and if so,
|
|
|
|
# do not run these tests as catching vfork is disabled for
|
|
|
|
# 10.20.
|
|
|
|
|
|
|
|
if [istarget "hppa*-hp-hpux10.20"] then {
|
|
|
|
return 0
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2002-12-11 03:04:45 +01:00
|
|
|
# NOTE drow/2002-12-06: I don't know what the referenced kernel problem
|
|
|
|
# is, but it appears to be fixed in recent HP/UX versions.
|
|
|
|
|
|
|
|
##if [istarget "hppa2.0w-hp-hpux*"] {
|
|
|
|
## warning "Don't run gdb.base/foll-vfork.exp until JAGaa43495 kernel problem is fixed."
|
|
|
|
## return 0
|
|
|
|
##}
|
1999-07-27 02:51:29 +02:00
|
|
|
|
2012-11-02 18:57:04 +01:00
|
|
|
standard_testfile
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 18:57:04 +01:00
|
|
|
if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
|
|
|
|
untested "failed to compile $testfile"
|
|
|
|
return -1
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
|
2012-11-02 18:57:04 +01:00
|
|
|
set testfile2 "vforked-prog"
|
|
|
|
set srcfile2 ${testfile2}.c
|
|
|
|
|
|
|
|
if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} {
|
|
|
|
untested "failed to compile $testfile2"
|
|
|
|
return -1
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# A few of these tests require a little more time than the standard
|
|
|
|
# timeout allows.
|
|
|
|
set oldtimeout $timeout
|
|
|
|
set timeout [expr "$timeout + 10"]
|
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
# Start with a fresh GDB, with verbosity enabled, and run to main. On
|
|
|
|
# error, behave as "return", so we don't try to continue testing with
|
|
|
|
# a borked session.
|
|
|
|
proc setup_gdb {} {
|
|
|
|
global testfile
|
|
|
|
|
|
|
|
clean_restart $testfile
|
|
|
|
|
|
|
|
# The "Detaching..." and "Attaching..." messages may be hidden by
|
|
|
|
# default.
|
|
|
|
gdb_test_no_output "set verbose"
|
|
|
|
|
|
|
|
if ![runto_main] {
|
|
|
|
return -code return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-29 23:47:20 +01:00
|
|
|
proc check_vfork_catchpoints {} {
|
|
|
|
global gdb_prompt
|
|
|
|
global has_vfork_catchpoints
|
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
setup_gdb
|
|
|
|
|
2008-01-29 23:47:20 +01:00
|
|
|
# Verify that the system supports "catch vfork".
|
|
|
|
gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint"
|
|
|
|
set has_vfork_catchpoints 0
|
|
|
|
gdb_test_multiple "continue" "continue to first vfork catchpoint" {
|
2010-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com>
Convert hardware watchpoints to use breakpoint_ops.
gdb/
* breakpoint.h (breakpoint_ops) <insert>: Rename to...
<insert_location>: ... this. Return int instead of void.
Accept pointer to struct bp_location instead of pointer to
struct breakpoint. Adapt all implementations.
(breakpoint_ops) <remove>: Rename to...
<remove_location>: ... this. Accept pointer to struct bp_location
instead of pointer to struct breakpoint. Adapt all implementations.
* breakpoint.c (insert_catchpoint): Delete function.
(insert_bp_location): Call the watchpoint or catchpoint's
breakpoint_ops.insert method.
(remove_breakpoint_1): Call the watchpoint or catchpoint's
breakpoint_ops.remove method.
(insert_watchpoint, remove_watchpoint): New functions.
(watchpoint_breakpoint_ops): New structure.
(watch_command_1): Initialize the OPS field.
* inf-child.c (inf_child_insert_fork_catchpoint)
(inf_child_remove_fork_catchpoint, inf_child_insert_vfork_catchpoint)
(inf_child_remove_vfork_catchpoint, inf_child_insert_exec_catchpoint)
(inf_child_remove_exec_catchpoint, inf_child_set_syscall_catchpoint):
Delete functions.
(inf_child_target): Remove initialization of to_insert_fork_catchpoint,
to_remove_fork_catchpoint, to_insert_vfork_catchpoint,
to_remove_vfork_catchpoint, to_insert_exec_catchpoint,
to_remove_exec_catchpoint and to_set_syscall_catchpoint.
* target.c (update_current_target): Change default implementation of
to_insert_fork_catchpoint, to_remove_fork_catchpoint,
to_insert_vfork_catchpoint, to_remove_vfork_catchpoint,
to_insert_exec_catchpoint, to_remove_exec_catchpoint and
to_set_syscall_catchpoint to return_one.
(debug_to_insert_fork_catchpoint, debug_to_insert_vfork_catchpoint)
(debug_to_insert_exec_catchpoint): Report return value.
* target.h (to_insert_fork_catchpoint, to_insert_vfork_catchpoint)
(to_insert_exec_catchpoint): Change declaration to return int instead
of void.
gdb/testsuite/
* gdb.base/foll-exec.exp: Adapt to new error string when the catchpoint
type is not supported.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
2011-01-11 20:16:23 +01:00
|
|
|
-re ".*Your system does not support this type\r\nof catchpoint.*$gdb_prompt $" {
|
2008-01-29 23:47:20 +01:00
|
|
|
unsupported "continue to first vfork catchpoint"
|
|
|
|
}
|
|
|
|
-re ".*Catchpoint.*$gdb_prompt $" {
|
|
|
|
set has_vfork_catchpoints 1
|
|
|
|
pass "continue to first vfork catchpoint"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if {$has_vfork_catchpoints == 0} {
|
|
|
|
unsupported "vfork catchpoints"
|
|
|
|
return -code return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-29 01:04:32 +02:00
|
|
|
proc vfork_parent_follow_through_step {} {
|
2012-11-02 19:00:00 +01:00
|
|
|
with_test_prefix "vfork parent follow, through step" {
|
1999-06-29 01:04:32 +02:00
|
|
|
global gdb_prompt
|
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
setup_gdb
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test_no_output "set follow-fork parent"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "step"
|
2012-11-02 18:57:04 +01:00
|
|
|
gdb_test_multiple "next" $test {
|
2012-11-02 18:57:45 +01:00
|
|
|
-re "Detaching after fork from.*if \\(pid == 0\\).*$gdb_prompt " {
|
2012-11-02 19:00:00 +01:00
|
|
|
pass $test
|
2012-11-02 18:57:04 +01:00
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
# The child has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any gdb_expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
2012-11-02 19:00:00 +01:00
|
|
|
}}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
proc vfork_parent_follow_to_bp {} {
|
2012-11-02 19:00:00 +01:00
|
|
|
with_test_prefix "vfork parent follow, to bp" {
|
1999-06-29 01:04:32 +02:00
|
|
|
global gdb_prompt
|
2008-01-29 23:47:20 +01:00
|
|
|
global srcfile
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
setup_gdb
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test_no_output "set follow-fork parent"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 18:57:45 +01:00
|
|
|
set bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
|
|
|
|
gdb_test "break ${srcfile}:${bp_location}" ".*" "break, vfork to bp"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "continue to bp"
|
2012-11-02 18:57:04 +01:00
|
|
|
gdb_test_multiple "continue" $test {
|
2012-11-02 18:57:45 +01:00
|
|
|
-re ".*Detaching after fork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " {
|
2012-11-02 18:57:04 +01:00
|
|
|
pass $test
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
# The child has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
2012-11-02 19:00:00 +01:00
|
|
|
}}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:10:29 +01:00
|
|
|
proc vfork_child_follow_to_exit {} {
|
|
|
|
with_test_prefix "vfork child follow, to exit" {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
setup_gdb
|
|
|
|
|
|
|
|
gdb_test_no_output "set follow-fork child"
|
|
|
|
|
|
|
|
set test "continue to child exit"
|
|
|
|
gdb_test_multiple "continue" $test {
|
|
|
|
-re "Couldn't get registers.*$gdb_prompt " {
|
2012-11-02 19:13:37 +01:00
|
|
|
# PR gdb/14766
|
2012-11-02 19:10:29 +01:00
|
|
|
fail "$test"
|
|
|
|
}
|
|
|
|
-re "Attaching after.* vfork to.*Detaching vfork parent .* after child exit.*$gdb_prompt " {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# The parent has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any gdb_expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
|
|
|
}}
|
|
|
|
|
1999-06-29 01:04:32 +02:00
|
|
|
proc vfork_and_exec_child_follow_to_main_bp {} {
|
2012-11-02 19:00:00 +01:00
|
|
|
with_test_prefix "vfork and exec child follow, to main bp" {
|
1999-06-29 01:04:32 +02:00
|
|
|
global gdb_prompt
|
2012-11-02 18:57:45 +01:00
|
|
|
global srcfile2
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
setup_gdb
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test_no_output "set follow-fork child"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 18:57:45 +01:00
|
|
|
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "continue to bp"
|
2012-11-02 18:57:04 +01:00
|
|
|
gdb_test_multiple "continue" $test {
|
2012-11-02 18:57:45 +01:00
|
|
|
-re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
|
2012-11-02 18:57:04 +01:00
|
|
|
pass $test
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
# The parent has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any gdb_expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
2012-11-02 19:00:00 +01:00
|
|
|
}}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
proc vfork_and_exec_child_follow_through_step {} {
|
2012-11-02 19:00:00 +01:00
|
|
|
with_test_prefix "vfork and exec child follow, through step" {
|
1999-06-29 01:04:32 +02:00
|
|
|
global gdb_prompt
|
2012-11-02 18:57:45 +01:00
|
|
|
global srcfile2
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 18:58:39 +01:00
|
|
|
if { [istarget "hppa*-*-hpux*"] && ![istarget "hppa*-*-hpux11.*"] } {
|
|
|
|
# This test cannot be performed prior to HP-UX 10.30, because
|
|
|
|
# ptrace-based debugging of a vforking program basically doesn't
|
|
|
|
# allow the child to do things like hit a breakpoint between a
|
|
|
|
# vfork and exec. This means that saying "set follow-fork
|
|
|
|
# child; next" at a vfork() call won't work, because the
|
|
|
|
# implementation of "next" sets a "step resume" breakpoint at
|
|
|
|
# the return from the vfork(), which the child will hit on its
|
|
|
|
# way to exec'ing.
|
|
|
|
#
|
|
|
|
verbose "vfork child-following next test ignored for pre-HP/UX-10.30 targets."
|
1999-06-29 01:04:32 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
setup_gdb
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test_no_output "set follow-fork child"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "step over vfork"
|
2012-11-02 18:58:39 +01:00
|
|
|
if { [istarget "hppa*-*-hpux*"]} {
|
|
|
|
# Since the child cannot be debugged until after it has exec'd,
|
|
|
|
# and since there's a bp on "main" in the parent, and since the
|
|
|
|
# bp's for the parent are recomputed in the exec'd child, the
|
|
|
|
# step through a vfork should land us in the "main" for the
|
|
|
|
# exec'd child, too.
|
|
|
|
#
|
|
|
|
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
|
|
|
|
gdb_test_multiple "next" $test {
|
|
|
|
-re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
# The ideal support is to be able to debug the child even
|
|
|
|
# before it execs. Thus, "next" lands on the next line after
|
|
|
|
# the vfork.
|
|
|
|
gdb_test_multiple "next" $test {
|
|
|
|
-re "Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
|
|
|
|
pass "$test"
|
|
|
|
}
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
# The parent has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
2012-11-02 19:00:00 +01:00
|
|
|
}}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
proc tcatch_vfork_then_parent_follow {} {
|
2012-11-02 19:00:00 +01:00
|
|
|
with_test_prefix "vfork parent follow, finish after tcatch vfork" {
|
1999-06-29 01:04:32 +02:00
|
|
|
global gdb_prompt
|
|
|
|
global srcfile
|
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
setup_gdb
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test_no_output "set follow-fork parent"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
|
|
|
# HP-UX 10.20 seems to stop you in "vfork", while more recent
|
|
|
|
# HP-UXs stop you in "_vfork".
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "continue to vfork"
|
2012-11-02 18:57:04 +01:00
|
|
|
gdb_test_multiple "continue" $test {
|
|
|
|
-re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
-re "vfork \\(\\) at.*$gdb_prompt " {
|
|
|
|
pass $test
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 18:57:45 +01:00
|
|
|
set linenum [gdb_get_line_number "pid = vfork ();"]
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "finish"
|
2012-11-02 18:57:04 +01:00
|
|
|
gdb_test_multiple "finish" $test {
|
2012-11-02 18:57:45 +01:00
|
|
|
-re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:${linenum}.*$gdb_prompt " {
|
2012-11-02 18:57:04 +01:00
|
|
|
pass $test
|
|
|
|
}
|
2008-11-20 18:17:59 +01:00
|
|
|
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
|
|
|
|
send_gdb "finish\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
# The child has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
2012-11-02 19:00:00 +01:00
|
|
|
}}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:10:29 +01:00
|
|
|
proc tcatch_vfork_then_child_follow_exec {} {
|
2012-11-02 19:00:00 +01:00
|
|
|
with_test_prefix "vfork child follow, finish after tcatch vfork" {
|
1999-06-29 01:04:32 +02:00
|
|
|
global gdb_prompt
|
2008-01-29 23:47:20 +01:00
|
|
|
global srcfile
|
1999-06-29 01:04:32 +02:00
|
|
|
global srcfile2
|
|
|
|
|
2012-11-02 19:02:01 +01:00
|
|
|
setup_gdb
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test_no_output "set follow-fork child"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
|
2012-11-02 18:57:04 +01:00
|
|
|
|
|
|
|
# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
|
|
|
|
# stop you in "_vfork".
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "continue to vfork"
|
2012-11-02 18:57:04 +01:00
|
|
|
gdb_test_multiple "continue" $test {
|
|
|
|
-re "vfork \\(\\) at .*$gdb_prompt $" {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
-re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
|
|
|
|
pass $test
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
2012-11-02 18:57:04 +01:00
|
|
|
|
2012-11-02 18:57:45 +01:00
|
|
|
set linenum1 [gdb_get_line_number "pid = vfork ();"]
|
|
|
|
set linenum2 [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
|
|
|
|
|
2012-11-02 19:00:00 +01:00
|
|
|
set test "finish"
|
2012-11-02 18:57:04 +01:00
|
|
|
gdb_test_multiple "finish" $test {
|
2012-11-02 18:57:45 +01:00
|
|
|
-re "Run till exit from.*vfork.*${srcfile}:${linenum1}.*$gdb_prompt " {
|
2012-11-02 18:57:04 +01:00
|
|
|
pass $test
|
|
|
|
}
|
2008-11-20 18:17:59 +01:00
|
|
|
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
|
|
|
|
send_gdb "finish\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
2012-11-02 18:57:45 +01:00
|
|
|
-re "Run till exit from.*vfork.*${srcfile2}:${linenum2}.*$gdb_prompt " {
|
2012-11-02 18:57:04 +01:00
|
|
|
pass "$test (followed exec)"
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
}
|
|
|
|
# The parent has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
2012-11-02 19:00:00 +01:00
|
|
|
}}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:10:29 +01:00
|
|
|
proc tcatch_vfork_then_child_follow_exit {} {
|
|
|
|
with_test_prefix "vfork child follow, finish after tcatch vfork" {
|
1999-06-29 01:04:32 +02:00
|
|
|
global gdb_prompt
|
2012-11-02 19:10:29 +01:00
|
|
|
global srcfile
|
|
|
|
|
|
|
|
setup_gdb
|
|
|
|
|
|
|
|
gdb_test_no_output "set follow-fork child"
|
|
|
|
|
|
|
|
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
|
|
|
|
|
|
|
|
# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs
|
|
|
|
# stop you in "_vfork".
|
|
|
|
set test "continue to vfork"
|
|
|
|
gdb_test_multiple "continue" $test {
|
|
|
|
-re "vfork \\(\\) at .*$gdb_prompt $" {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
-re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set test "finish"
|
|
|
|
gdb_test_multiple "finish" $test {
|
|
|
|
-re "Run till exit from.*vfork.*exited normally.*$gdb_prompt " {
|
|
|
|
setup_kfail "gdb/14762" *-*-*
|
|
|
|
fail $test
|
|
|
|
}
|
|
|
|
-re "Run till exit from.*vfork.*pid = vfork \\(\\).*$gdb_prompt " {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
|
|
|
|
send_gdb "finish\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# The parent has been detached; allow time for any output it might
|
|
|
|
# generate to arrive, so that output doesn't get confused with
|
|
|
|
# any expected debugger output from a subsequent testpoint.
|
|
|
|
#
|
|
|
|
exec sleep 1
|
|
|
|
}}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:10:29 +01:00
|
|
|
proc do_vfork_and_follow_parent_tests {} {
|
|
|
|
global gdb_prompt
|
2008-01-29 23:47:20 +01:00
|
|
|
|
1999-06-29 01:04:32 +02:00
|
|
|
# Try following the parent process by stepping through a call to
|
|
|
|
# vfork. Do this without catchpoints.
|
2012-11-02 19:02:01 +01:00
|
|
|
vfork_parent_follow_through_step
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
# Try following the parent process by setting a breakpoint on the
|
|
|
|
# other side of a vfork, and running to that point. Do this
|
|
|
|
# without catchpoints.
|
2012-11-02 19:02:01 +01:00
|
|
|
vfork_parent_follow_to_bp
|
1999-06-29 01:04:32 +02:00
|
|
|
|
2012-11-02 19:10:29 +01:00
|
|
|
# Try catching a vfork, and stepping out to the parent.
|
|
|
|
#
|
|
|
|
tcatch_vfork_then_parent_follow
|
|
|
|
}
|
|
|
|
|
|
|
|
proc do_vfork_and_follow_child_tests_exec {} {
|
1999-06-29 01:04:32 +02:00
|
|
|
# Try following the child process by just continuing through the
|
|
|
|
# vfork, and letting the parent's breakpoint on "main" be auto-
|
|
|
|
# magically reset in the child.
|
|
|
|
#
|
2012-11-02 19:02:01 +01:00
|
|
|
vfork_and_exec_child_follow_to_main_bp
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
# Try following the child process by stepping through a call to
|
|
|
|
# vfork. The child also executes an exec. Since the child cannot
|
|
|
|
# be debugged until after it has exec'd, and since there's a bp on
|
|
|
|
# "main" in the parent, and since the bp's for the parent are
|
|
|
|
# recomputed in the exec'd child, the step through a vfork should
|
|
|
|
# land us in the "main" for the exec'd child, too.
|
|
|
|
#
|
2012-11-02 19:02:01 +01:00
|
|
|
vfork_and_exec_child_follow_through_step
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
# Try catching a vfork, and stepping out to the child.
|
|
|
|
#
|
2012-11-02 19:10:29 +01:00
|
|
|
tcatch_vfork_then_child_follow_exec
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
# Test the ability to follow both child and parent of a vfork. Do
|
|
|
|
# this without catchpoints.
|
|
|
|
# ??rehrauer: NYI. Will add testpoints here when implemented.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Test the ability to have the debugger ask the user at vfork-time
|
|
|
|
# whether to follow the parent, child or both. Do this without
|
|
|
|
# catchpoints.
|
|
|
|
# ??rehrauer: NYI. Will add testpoints here when implemented.
|
|
|
|
#
|
|
|
|
}
|
|
|
|
|
2012-11-02 19:10:29 +01:00
|
|
|
proc do_vfork_and_follow_child_tests_exit {} {
|
|
|
|
# Try following the child process by just continuing through the
|
|
|
|
# vfork, and letting the child exit.
|
|
|
|
#
|
|
|
|
vfork_child_follow_to_exit
|
|
|
|
|
|
|
|
# Try catching a vfork, and stepping out to the child.
|
|
|
|
#
|
|
|
|
tcatch_vfork_then_child_follow_exit
|
|
|
|
}
|
|
|
|
|
|
|
|
with_test_prefix "check vfork support" {
|
|
|
|
# Check that vfork catchpoints are supported, as an indicator for
|
|
|
|
# whether vfork-following is supported.
|
|
|
|
check_vfork_catchpoints
|
|
|
|
}
|
|
|
|
|
|
|
|
# Follow parent and follow child vfork tests with a child that execs.
|
|
|
|
with_test_prefix "exec" {
|
|
|
|
# These are tests of gdb's ability to follow the parent of a Unix
|
|
|
|
# vfork system call. The child will subsequently call a variant
|
|
|
|
# of the Unix exec system call.
|
|
|
|
do_vfork_and_follow_parent_tests
|
|
|
|
|
|
|
|
# These are tests of gdb's ability to follow the child of a Unix
|
|
|
|
# vfork system call. The child will subsequently call a variant
|
|
|
|
# of a Unix exec system call.
|
|
|
|
#
|
|
|
|
do_vfork_and_follow_child_tests_exec
|
|
|
|
}
|
|
|
|
|
|
|
|
# Switch to test the case of the child exiting. We can't use
|
|
|
|
# standard_testfile here because we don't want to overwrite the binary
|
|
|
|
# of the previous tests.
|
|
|
|
set testfile "foll-vfork-exit"
|
|
|
|
set srcfile ${testfile}.c
|
|
|
|
set binfile [standard_output_file ${testfile}]
|
|
|
|
|
|
|
|
if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
|
|
|
|
untested "failed to build $testfile"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# Follow parent and follow child vfork tests with a child that exits.
|
|
|
|
with_test_prefix "exit" {
|
|
|
|
# These are tests of gdb's ability to follow the parent of a Unix
|
|
|
|
# vfork system call. The child will subsequently exit.
|
|
|
|
do_vfork_and_follow_parent_tests
|
|
|
|
|
|
|
|
# These are tests of gdb's ability to follow the child of a Unix
|
|
|
|
# vfork system call. The child will subsequently exit.
|
|
|
|
#
|
|
|
|
do_vfork_and_follow_child_tests_exit
|
|
|
|
}
|
1999-06-29 01:04:32 +02:00
|
|
|
|
|
|
|
set timeout $oldtimeout
|
|
|
|
return 0
|