From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26789 invoked by alias); 25 Oct 2012 17:42:11 -0000 Received: (qmail 26765 invoked by uid 22791); 25 Oct 2012 17:42:09 -0000 X-SWARE-Spam-Status: No, hits=-8.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,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; Thu, 25 Oct 2012 17:42:00 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9PHg075013315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Oct 2012 13:42:00 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9PHfxMF014020 for ; Thu, 25 Oct 2012 13:41:59 -0400 Subject: [PATCH 1/8] foll-vfork.exp: Modernize. To: gdb-patches@sourceware.org From: Pedro Alves Date: Thu, 25 Oct 2012 17:42:00 -0000 Message-ID: <20121025174158.13324.95694.stgit@brno.lan> In-Reply-To: <20121025174002.13324.8164.stgit@brno.lan> References: <20121025174002.13324.8164.stgit@brno.lan> User-Agent: StGit/0.16 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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-10/txt/msg00505.txt.bz2 I wanted to extend this file, but it is a bit crufty... Clean it up first. gdb/testsuite/ 2012-10-25 Pedro Alves Modernise. * gdb.base/foll-vfork.exp: Use standard_testfile and build_executable. Pass descriptive string to untested. (vfork_parent_follow_through_step, vfork_parent_follow_to_bp) (vfork_and_exec_child_follow_to_main_bp) (vfork_and_exec_child_follow_through_step) (tcatch_vfork_then_parent_follow, tcatch_vfork_then_child_follow) (do_vfork_and_exec_tests): Use gdb_test/gdb_test_multiple instead of send_gdb/gdb_expect. (kill_child): New procedure. (vfork_and_exec_child_follow_to_main_bp) (vfork_and_exec_child_follow_through_step): Use it. --- gdb/testsuite/gdb.base/foll-vfork.exp | 294 ++++++++++++++------------------- 1 file changed, 127 insertions(+), 167 deletions(-) diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index 7a3c04e..73be334 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -40,22 +40,19 @@ if [istarget "hppa*-hp-hpux10.20"] then { ## return 0 ##} -global srcfile -set testfile "foll-vfork" -set testfile2 "vforked-prog" -set srcfile ${testfile}.c -set srcfile2 ${testfile2}.c -set binfile ${objdir}/${subdir}/${testfile} -set binfile2 ${objdir}/${subdir}/${testfile2} +standard_testfile -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested foll-vfork.exp - return -1 +if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} { + untested "failed to compile $testfile" + return -1 } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } { - untested foll-vfork.exp - return -1 +set testfile2 "vforked-prog" +set srcfile2 ${testfile2}.c + +if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} { + untested "failed to compile $testfile2" + return -1 } # A few of these tests require a little more time than the standard @@ -89,17 +86,14 @@ proc check_vfork_catchpoints {} { proc vfork_parent_follow_through_step {} { global gdb_prompt - send_gdb "set follow-fork parent\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork parent, vfork through step"} - timeout {fail "set follow-fork parent, vfork through step"} - } - send_gdb "next\n" - gdb_expect { - -re "Detaching after fork from.*13.*$gdb_prompt "\ - {pass "vfork parent follow, through step"} - -re "$gdb_prompt $" {fail "vfork parent follow, through step"} - timeout {fail "(timeout) vfork parent follow, through step" } + gdb_test_no_output "set follow-fork parent" \ + "set follow-fork parent, vfork through step" + + set test "vfork parent follow, through step" + gdb_test_multiple "next" $test { + -re "Detaching after fork from.*13.*$gdb_prompt " { + pass "vfork parent follow, through step" + } } # The child has been detached; allow time for any output it might # generate to arrive, so that output doesn't get confused with @@ -112,22 +106,16 @@ proc vfork_parent_follow_to_bp {} { global gdb_prompt global srcfile - send_gdb "set follow-fork parent\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork parent, vfork to bp"} - timeout {fail "set follow-fork parent, vfork to bp"} - } - send_gdb "break ${srcfile}:18\n" - gdb_expect { - -re "$gdb_prompt $" {pass "break, vfork to bp"} - timeout {fail "break, vfork to bp"} - } - send_gdb "continue\n" - gdb_expect { - -re ".*Detaching after fork from child process.*Breakpoint.*18.*$gdb_prompt "\ - {pass "vfork parent follow, to bp"} - -re "$gdb_prompt $" {fail "vfork parent follow, to bp"} - timeout {fail "(timeout) vfork parent follow, to bp" } + gdb_test_no_output "set follow-fork parent" \ + "set follow-fork parent, vfork to bp" + + gdb_test "break ${srcfile}:18" ".*" "break, vfork to bp" + + set test "vfork parent follow, to bp" + gdb_test_multiple "continue" $test { + -re ".*Detaching after fork from child process.*Breakpoint.*18.*$gdb_prompt " { + pass $test + } } # The child has been detached; allow time for any output it might # generate to arrive, so that output doesn't get confused with @@ -136,21 +124,45 @@ 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 {} { global gdb_prompt - global binfile - send_gdb "set follow-fork child\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork child, vfork and exec to main bp"} - timeout {fail "set follow-fork child, vfork and exec to main bp"} - } - send_gdb "continue\n" - gdb_expect { - -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt "\ - {pass "vfork and exec child follow, to main bp"} - -re "$gdb_prompt $" {fail "vfork and exec child follow, to main bp"} - timeout {fail "(timeout) vfork and exec child follow, to main bp" } + gdb_test_no_output \ + "set follow-fork child" \ + "set follow-fork child, vfork and exec to main bp" + + set test "vfork and exec child follow, to main bp" + gdb_test_multiple "continue" $test { + -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:9.*$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 @@ -160,31 +172,11 @@ proc vfork_and_exec_child_follow_to_main_bp {} { # Explicitly kill this child, or a subsequent rerun actually runs # the exec'd child, not the original program... - send_gdb "kill\n" - gdb_expect { - -re ".*Kill the program being debugged.*y or n. $" { - gdb_test_no_output "y" "" - send_gdb "file $binfile\n" - gdb_expect { - -re ".*Load new symbol table from.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "Reading symbols from.*$gdb_prompt $" {} - timeout { fail "loading symbols (timeout)"; return } - } - } - -re ".*gdb_prompt $" {} - timeout { fail "loading symbols (timeout)"; return } - } - } - -re ".*$gdb_prompt $" {} - timeout { fail "killing inferior (timeout)" ; return } - } + kill_child } proc vfork_and_exec_child_follow_through_step {} { global gdb_prompt - global binfile # 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 @@ -198,17 +190,15 @@ proc vfork_and_exec_child_follow_through_step {} { return 0 } - send_gdb "set follow-fork child\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork child, vfork and exec through step"} - timeout {fail "set follow-fork child, vfork and exec through step"} - } - send_gdb "next\n" - gdb_expect { - -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt "\ - {pass "vfork and exec child follow, through step"} - -re "$gdb_prompt $" {fail "vfork and exec child follow, through step"} - timeout {fail "(timeout) vfork and exec child follow, through step" } + gdb_test_no_output \ + "set follow-fork child" \ + "set follow-fork child, vfork and exec through step" + + set test "vfork and exec child follow, through step" + gdb_test_multiple "next" $test { + -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:9.*$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 @@ -218,65 +208,42 @@ proc vfork_and_exec_child_follow_through_step {} { # Explicitly kill this child, or a subsequent rerun actually runs # the exec'd child, not the original program... - send_gdb "kill\n" - gdb_expect { - -re ".*Kill the program being debugged.*y or n. $" { - gdb_test_no_output "y" "" - send_gdb "file $binfile\n" - gdb_expect { - -re ".*Load new symbol table from.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "Reading symbols from.*$gdb_prompt $" {} - timeout { fail "loading symbols (timeout)"; return } - } - } - -re ".*gdb_prompt $" {} - timeout { fail "loading symbols (timeout)"; return } - } - } - -re ".*$gdb_prompt $" {} - timeout { fail "killing inferior (timeout)" ; return } - } + kill_child } proc tcatch_vfork_then_parent_follow {} { global gdb_prompt global srcfile - send_gdb "set follow-fork parent\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork parent, tcatch vfork"} - timeout {fail "set follow-fork parent, tcatch vfork"} - } - send_gdb "tcatch vfork\n" - gdb_expect { - -re "Catchpoint .*(vfork).*$gdb_prompt $"\ - {pass "vfork parent follow, set tcatch vfork"} - -re "$gdb_prompt $" {fail "vfork parent follow, set tcatch vfork"} - timeout {fail "(timeout) vfork parent follow, set tcatch vfork"} - } - send_gdb "continue\n" -# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs -# stop you in "_vfork". - gdb_expect { - -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt "\ - {pass "vfork parent follow, tcatch vfork"} - -re "vfork \\(\\) at.*$gdb_prompt "\ - {pass "vfork parent follow, tcatch vfork"} - -re "$gdb_prompt $" {fail "vfork parent follow, tcatch vfork"} - timeout {fail "(timeout) vfork parent follow, tcatch vfork"} + gdb_test_no_output \ + "set follow-fork parent" \ + "set follow-fork parent, tcatch vfork" + + gdb_test "tcatch vfork" \ + "Catchpoint .*(vfork).*" \ + "vfork parent follow, set tcatch vfork" + + # HP-UX 10.20 seems to stop you in "vfork", while more recent + # HP-UXs stop you in "_vfork". + set test "vfork parent follow, tcatch vfork" + 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 + } } - send_gdb "finish\n" - gdb_expect { - -re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:12.*$gdb_prompt "\ - {pass "vfork parent follow, finish after tcatch vfork"} + + set test "vfork parent follow, finish after tcatch vfork" + gdb_test_multiple "finish" $test { + -re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:12.*$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 } - -re "$gdb_prompt $" {fail "vfork parent follow, finish after tcatch vfork"} - timeout {fail "(timeout) vfork parent follow, finish after tcatch vfork" } } # The child has been detached; allow time for any output it might # generate to arrive, so that output doesn't get confused with @@ -290,41 +257,38 @@ proc tcatch_vfork_then_child_follow {} { global srcfile global srcfile2 - send_gdb "set follow-fork child\n" - gdb_expect { - -re "$gdb_prompt $" {pass "set follow-fork child, tcatch vfork"} - timeout {fail "set follow-fork child, tcatch vfork"} - } - send_gdb "tcatch vfork\n" - gdb_expect { - -re "Catchpoint .*(vfork).*$gdb_prompt $"\ - {pass "vfork child follow, set tcatch vfork"} - -re "$gdb_prompt $" {fail "vfork child follow, set tcatch vfork"} - timeout {fail "(timeout) vfork child follow, set tcatch vfork"} - } - send_gdb "continue\n" -# HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs -# stop you in "_vfork". - gdb_expect { - -re "vfork \\(\\) at .*$gdb_prompt $"\ - {pass "vfork child follow, tcatch vfork"} - -re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt "\ - {pass "vfork child follow, tcatch vfork"} - -re "$gdb_prompt $" {fail "vfork child follow, tcatch vfork"} - timeout {fail "(timeout) vfork child follow, tcatch vfork"} + gdb_test_no_output \ + "set follow-fork child" \ + "set follow-fork child, tcatch vfork" + + gdb_test "tcatch vfork" \ + "Catchpoint .*(vfork).*" \ + "vfork child follow, set tcatch vfork" + + # HP-UX 10.20 seems to stop you in "vfork", while more recent HP-UXs + # stop you in "_vfork". + set test "vfork child follow, tcatch 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 + } } - send_gdb "finish\n" - gdb_expect { - -re "Run till exit from.*vfork.*${srcfile}:12.*$gdb_prompt "\ - {pass "vfork child follow, finish after tcatch vfork"} + + set test "vfork child follow, finish after tcatch vfork" + gdb_test_multiple "finish" $test { + -re "Run till exit from.*vfork.*${srcfile}:12.*$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 } - -re "Run till exit from.*vfork.*${srcfile2}:9.*$gdb_prompt "\ - {pass "vfork child follow, finish after tcatch vfork (followed exec)"} - -re "$gdb_prompt $" {fail "vfork child follow, finish after tcatch vfork"} - timeout {fail "(timeout) vfork child follow, finish after tcatch vfork" } + -re "Run till exit from.*vfork.*${srcfile2}:9.*$gdb_prompt " { + pass "$test (followed exec)" + } } # The parent has been detached; allow time for any output it might # generate to arrive, so that output doesn't get confused with @@ -385,11 +349,7 @@ proc do_vfork_and_exec_tests {} { } # Start with a fresh gdb - -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} +clean_restart $testfile # The "Detaching..." and "Attaching..." messages may be hidden by # default.