From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27151 invoked by alias); 25 Oct 2012 17:42:17 -0000 Received: (qmail 27079 invoked by uid 22791); 25 Oct 2012 17:42:15 -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:08 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9PHg7qa013075 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Oct 2012 13:42:07 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9PHg6La017793 for ; Thu, 25 Oct 2012 13:42:06 -0400 Subject: [PATCH 2/8] foll-vfork.exp: Don't hard code line numbers. To: gdb-patches@sourceware.org From: Pedro Alves Date: Thu, 25 Oct 2012 17:42:00 -0000 Message-ID: <20121025174205.13324.4808.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/msg00506.txt.bz2 The test hard codes line numbers, which makes it fragile wrt to changes to the test's sources. This replaces all the hard-coded numbers with something else. gdb/testsuite/ 2012-10-25 Pedro Alves Don't hard code line numbers. * gdb.base/foll-vfork.exp (vfork_parent_follow_through_step): Expect text from the sources instead of a line number. (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): Use gdb_get_line_number. --- gdb/testsuite/gdb.base/foll-vfork.exp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index 73be334..67d077d 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -91,7 +91,7 @@ proc vfork_parent_follow_through_step {} { set test "vfork parent follow, through step" gdb_test_multiple "next" $test { - -re "Detaching after fork from.*13.*$gdb_prompt " { + -re "Detaching after fork from.*if \\(pid == 0\\).*$gdb_prompt " { pass "vfork parent follow, through step" } } @@ -109,11 +109,12 @@ proc 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 bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"] + gdb_test "break ${srcfile}:${bp_location}" ".*" "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 " { + -re ".*Detaching after fork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " { pass $test } } @@ -153,14 +154,17 @@ proc kill_child {} { proc vfork_and_exec_child_follow_to_main_bp {} { global gdb_prompt + global srcfile2 gdb_test_no_output \ "set follow-fork child" \ "set follow-fork child, vfork and exec to main bp" + set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}] + 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 " { + -re "Attaching after.* vfork to.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " { pass $test } } @@ -177,6 +181,7 @@ proc vfork_and_exec_child_follow_to_main_bp {} { proc vfork_and_exec_child_follow_through_step {} { global gdb_prompt + global srcfile2 # 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 @@ -195,8 +200,9 @@ proc vfork_and_exec_child_follow_through_step {} { "set follow-fork child, vfork and exec through step" set test "vfork and exec child follow, through step" + set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}] gdb_test_multiple "next" $test { - -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:9.*$gdb_prompt " { + -re "Attaching after fork to.*Executing new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " { pass "$test" } } @@ -235,9 +241,10 @@ proc tcatch_vfork_then_parent_follow {} { } } + set linenum [gdb_get_line_number "pid = 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 " { + -re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:${linenum}.*$gdb_prompt " { pass $test } -re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " { @@ -277,16 +284,19 @@ proc tcatch_vfork_then_child_follow {} { } } + set linenum1 [gdb_get_line_number "pid = vfork ();"] + set linenum2 [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}] + set test "vfork child follow, finish after tcatch vfork" gdb_test_multiple "finish" $test { - -re "Run till exit from.*vfork.*${srcfile}:12.*$gdb_prompt " { + -re "Run till exit from.*vfork.*${srcfile}:${linenum1}.*$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 " { + -re "Run till exit from.*vfork.*${srcfile2}:${linenum2}.*$gdb_prompt " { pass "$test (followed exec)" } }