From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3275 invoked by alias); 2 Nov 2012 18:18:19 -0000 Received: (qmail 3266 invoked by uid 22791); 2 Nov 2012 18:18:17 -0000 X-SWARE-Spam-Status: No, hits=-7.9 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Nov 2012 18:18:11 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA2IIBRu007113 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Nov 2012 14:18:11 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA2II94i003168 for ; Fri, 2 Nov 2012 14:18:10 -0400 Message-ID: <50940E61.7020709@redhat.com> Date: Fri, 02 Nov 2012 18:18:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: [PATCH 6/8] foll-vfork.exp: Clean restart gdb before each test procedure. References: <20121025174002.13324.8164.stgit@brno.lan> <20121025174233.13324.49018.stgit@brno.lan> In-Reply-To: <20121025174233.13324.49018.stgit@brno.lan> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-11/txt/msg00059.txt.bz2 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 * 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.)