This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure.


On 10/25/2012 06:42 PM, Pedro Alves wrote:

> +# 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
> +    }
> +}

...

> -# The "Detaching..." and "Attaching..." messages may be hidden by
> -# default.
> -gdb_test_no_output "set verbose"

I noticed I lost this comment just before committing.  This is the
patch that I ended up applying.  It moves that comment to setup_gdb.
Nothing else changed.

gdb/testsuite/
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.
---
 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.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]