From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure.
Date: Thu, 25 Oct 2012 17:42:00 -0000 [thread overview]
Message-ID: <20121025174233.13324.49018.stgit@brno.lan> (raw)
In-Reply-To: <20121025174002.13324.8164.stgit@brno.lan>
All the individual tests in foll-vfork.exp currently run under the
same GDB, and each test relies on the previous test cleaning up things
correctly. E.g., killing the fork child, and switching back to the
main executable (after the child having execed another executable).
This isn't very robust. It's also annoying if a test wants to do
"info inferiors", as after a few of these procedures are run we end up
with more than a few inferiors in the list. Always restarting GDB
makes sure things are always nice and tidy between the individual
tests. There are more than a few sleep 1's in the file which dominate
over any slowdown this could introduce.
gdb/testsuite/
2012-10-25 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.
---
gdb/testsuite/gdb.base/foll-vfork.exp | 85 ++++++++++++++-------------------
1 file changed, 36 insertions(+), 49 deletions(-)
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index f978f8c..31477ef 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -60,10 +60,27 @@ 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
+
+ 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 +104,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 +126,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 +146,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 +168,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 +189,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 +222,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 +229,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 +271,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 +317,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 +341,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 +363,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.)
next prev parent reply other threads:[~2012-10-25 17:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-25 17:42 [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Pedro Alves
2012-10-25 17:42 ` [PATCH 3/8] foll-vfork.exp: Expose more testing on non-HP/UX targets Pedro Alves
2012-10-25 17:42 ` [PATCH 4/8] foll-vfork.c/vforked-prog.c: Add copyright headers Pedro Alves
2012-10-25 17:42 ` [PATCH 1/8] foll-vfork.exp: Modernize Pedro Alves
2012-10-25 17:42 ` Pedro Alves [this message]
2012-11-02 18:18 ` [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure Pedro Alves
2012-10-25 17:42 ` [PATCH 2/8] foll-vfork.exp: Don't hard code line numbers Pedro Alves
2012-10-25 17:42 ` [PATCH 7/8] foll-vfork.exp: Also test following vfork when the child exits Pedro Alves
2012-10-25 17:42 ` [PATCH 8/8] Fix PR gdb/14766 - vfork child exit with "set follow-fork-mode child" broken Pedro Alves
2012-10-25 17:49 ` Pedro Alves
2012-10-25 17:42 ` [PATCH 5/8] foll-vfork.exp: Use with_test_prefix Pedro Alves
2012-10-30 20:50 ` [PATCH 0/8] Fix PR gdb/14766; cleanup foll-vfork.exp and extend it Tom Tromey
2012-11-02 18:15 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121025174233.13324.49018.stgit@brno.lan \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox