aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2012-11-02 18:02:01 +0000
committerPedro Alves <palves@redhat.com>2012-11-02 18:02:01 +0000
commit39c1263a21c798615b29e0a82d7020a2492d4fe8 (patch)
treeab8ba1b0ff11d522deb92a25f7ec5a6e95e73f83 /gdb/testsuite
parent339aeac6e5a4a67883ebe1bf15e9297c6745953c (diff)
downloadgdb-39c1263a21c798615b29e0a82d7020a2492d4fe8.zip
gdb-39c1263a21c798615b29e0a82d7020a2492d4fe8.tar.gz
gdb-39c1263a21c798615b29e0a82d7020a2492d4fe8.tar.bz2
2012-11-02 Pedro Alves <palves@redhat.com>
* gdb.base/foll-vfork.exp (setup_gdb): New procedure. (check_vfork_catchpoints, vfork_parent_follow_through_step) (vfork_parent_follow_to_bp): Call it. (kill_child): Delete. (vfork_and_exec_child_follow_to_main_bp) (vfork_and_exec_child_follow_through_step): Call setup_gdb. No longer call kill_child. (tcatch_vfork_then_parent_follow): Call setup_gdb. (do_vfork_and_exec_tests): Don't runto_main before calling each test procedure. (top level): Don't clean restart and set verbose before running each test procedure.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.base/foll-vfork.exp87
1 files changed, 38 insertions, 49 deletions
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index f978f8c..68934e7 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -60,10 +60,29 @@ if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} {
set oldtimeout $timeout
set timeout [expr "$timeout + 10"]
+# 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
+ }
+}
+
proc check_vfork_catchpoints {} {
global gdb_prompt
global has_vfork_catchpoints
+ setup_gdb
+
# Verify that the system supports "catch vfork".
gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint"
set has_vfork_catchpoints 0
@@ -87,6 +106,8 @@ proc vfork_parent_follow_through_step {} {
with_test_prefix "vfork parent follow, through step" {
global gdb_prompt
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
set test "step"
@@ -107,6 +128,8 @@ proc vfork_parent_follow_to_bp {} {
global gdb_prompt
global srcfile
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
set bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
@@ -125,38 +148,13 @@ proc vfork_parent_follow_to_bp {} {
exec sleep 1
}}
-# Kill child and reload symbols.
-proc kill_child {} {
- global binfile
- global gdb_prompt
-
- set test "killing inferior"
- gdb_test_multiple "kill" $test {
- -re ".*Kill the program being debugged.*y or n. $" {
- gdb_test_no_output "y" ""
- set test2 "file $binfile"
- gdb_test_multiple "file $binfile" $test2 {
- -re ".*Load new symbol table from.*y or n. $" {
- send_gdb "y\n"
- gdb_test_multiple "" "loading symbols" {
- -re "Reading symbols from.*$gdb_prompt $" {
- }
- }
- }
- -re ".*gdb_prompt $" {
- }
- }
- }
- -re ".*$gdb_prompt $" {
- }
- }
-}
-
proc vfork_and_exec_child_follow_to_main_bp {} {
with_test_prefix "vfork and exec child follow, to main bp" {
global gdb_prompt
global srcfile2
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
@@ -172,10 +170,6 @@ proc vfork_and_exec_child_follow_to_main_bp {} {
# any gdb_expected debugger output from a subsequent testpoint.
#
exec sleep 1
-
- # Explicitly kill this child, or a subsequent rerun actually runs
- # the exec'd child, not the original program...
- kill_child
}}
proc vfork_and_exec_child_follow_through_step {} {
@@ -197,6 +191,8 @@ proc vfork_and_exec_child_follow_through_step {} {
return 0
}
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
set test "step over vfork"
@@ -228,10 +224,6 @@ proc vfork_and_exec_child_follow_through_step {} {
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
-
- # Explicitly kill this child, or a subsequent rerun actually runs
- # the exec'd child, not the original program...
- kill_child
}}
proc tcatch_vfork_then_parent_follow {} {
@@ -239,6 +231,8 @@ proc tcatch_vfork_then_parent_follow {} {
global gdb_prompt
global srcfile
+ setup_gdb
+
gdb_test_no_output "set follow-fork parent"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
@@ -279,6 +273,8 @@ proc tcatch_vfork_then_child_follow {} {
global srcfile
global srcfile2
+ setup_gdb
+
gdb_test_no_output "set follow-fork child"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
@@ -323,22 +319,22 @@ proc do_vfork_and_exec_tests {} {
# Check that vfork catchpoints are supported, as an indicator for whether
# vfork-following is supported.
- if [runto_main] then { check_vfork_catchpoints }
+ check_vfork_catchpoints
# Try following the parent process by stepping through a call to
# vfork. Do this without catchpoints.
- if [runto_main] then { vfork_parent_follow_through_step }
+ vfork_parent_follow_through_step
# 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.
- if [runto_main] then { vfork_parent_follow_to_bp }
+ vfork_parent_follow_to_bp
# 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.
#
- if [runto_main] then { vfork_and_exec_child_follow_to_main_bp }
+ vfork_and_exec_child_follow_to_main_bp
# Try following the child process by stepping through a call to
# vfork. The child also executes an exec. Since the child cannot
@@ -347,15 +343,15 @@ proc do_vfork_and_exec_tests {} {
# recomputed in the exec'd child, the step through a vfork should
# land us in the "main" for the exec'd child, too.
#
- if [runto_main] then { vfork_and_exec_child_follow_through_step }
+ vfork_and_exec_child_follow_through_step
# Try catching a vfork, and stepping out to the parent.
#
- if [runto_main] then { tcatch_vfork_then_parent_follow }
+ tcatch_vfork_then_parent_follow
# Try catching a vfork, and stepping out to the child.
#
- if [runto_main] then { tcatch_vfork_then_child_follow }
+ tcatch_vfork_then_child_follow
# Test the ability to follow both child and parent of a vfork. Do
# this without catchpoints.
@@ -369,13 +365,6 @@ proc do_vfork_and_exec_tests {} {
#
}
-# Start with a fresh gdb
-clean_restart $testfile
-
-# The "Detaching..." and "Attaching..." messages may be hidden by
-# default.
-gdb_test_no_output "set verbose"
-
# This is a test of gdb's ability to follow the parent or child
# of a Unix vfork() system call. (The child will subsequently
# call a variant of a Unix exec() system call.)