From patchwork Fri Sep 12 15:27:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 2787 Received: (qmail 22864 invoked by alias); 12 Sep 2014 15:27:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 22851 invoked by uid 89); 12 Sep 2014 15:27:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_50, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 12 Sep 2014 15:27:40 +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 s8CFRWAj030797 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Sep 2014 11:27:32 -0400 Received: from [127.0.0.1] (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 s8CFRTow008078; Fri, 12 Sep 2014 11:27:30 -0400 Message-ID: <541310E1.5000806@redhat.com> Date: Fri, 12 Sep 2014 16:27:29 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: Joel Brobecker CC: Edjunior Barbosa Machado , gdb-patches@sourceware.org, Ulrich Weigand , Sergio Durigan Junior Subject: [PATCH] after gdb_run_cmd, gdb_expect -> gdb_test_multiple/gdb_test References: <1410490007-19756-1-git-send-email-emachado@linux.vnet.ibm.com> <5412C3F0.9000703@redhat.com> <20140912130051.GA4871@adacore.com> <5412F714.3040500@redhat.com> <20140912135012.GC4871@adacore.com> <54130176.1070208@gmail.com> In-Reply-To: <54130176.1070208@gmail.com> On 09/12/2014 03:21 PM, Pedro Alves wrote: > On 09/12/2014 02:50 PM, Joel Brobecker wrote: >>> We still need to use gdb_run_cmd to cover remote testing, >>> so that'd be: >>> >>> gdb_test "" "Program received signal SIGSEGV.*" "run until SIGSEGV" >>> >>> ISTR that gdb_test doesn't allow empty command, but I may well >>> be mistaken. And if it doesn't, maybe it should. >> >> This is me pretending that I had noticed that the command was empty >> and knowing that this was still OK :-). But once you mentioned it, >> I knew I had already done something like that. See gdb.ada/bp_reset.exp: >> >> gdb_run_cmd >> gdb_test "" "Breakpoint $decimal, foo\\.nested_sub \\(\\).*" >> >> Doing a quick grep, we have a number of occurences where we use >> an empty command when calling gdb_test. And looking at gdb_test's >> implementation, it just passes the first argument to gdb_test_multiple, >> so it should indeed be equivalent. (phew, that was close! ;-)). > > :-) > > I'm writing a test that converts all gdb_run_cmd -> gdb_expect > cases to avoid this from spreading further. Patch pasted below. In a2-run.exp I converted one vxworks path, but left the others in place... I'm tempted to nuke most of that vxworks stuff out of the testsuite. Does anyone still care about it? Most of the vxworks tweaks seem like either stuff that better belong in a board file and target testsuite support code, like timeout handling, missing functions, etc. and out of place for the tests themselves. And then again, we have a ton of tests likely would need the same tweak, but don't... -------------- Subject: [PATCH] after gdb_run_cmd, gdb_expect -> gdb_test_multiple/gdb_test See: https://sourceware.org/ml/gdb-patches/2014-09/msg00404.html We have a number of places that do gdb_run_cmd followed by gdb_expect, when it would be better to use gdb_test_multiple or gdb_test. This converts all that "grep gdb_run_cmd -A 2 | grep gdb_expect" found. Tested on x86_64 Fedora 20, native and gdbserver. gdb/testsuite/ 2014-09-12 Pedro Alves * gdb.arch/gdb1558.exp: Replace uses of gdb_expect after gdb_run_cmd with gdb_test_multiple or gdb_test throughout. * gdb.arch/i386-size-overlap.exp: Likewise. * gdb.arch/i386-size.exp: Likewise. * gdb.arch/i386-unwind.exp: Likewise. * gdb.base/a2-run.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/charset.exp: Likewise. * gdb.base/chng-syms.exp: Likewise. * gdb.base/commands.exp: Likewise. * gdb.base/dbx.exp: Likewise. * gdb.base/find.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/jit-simple.exp: Likewise. * gdb.base/reread.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/step-bt.exp: Likewise. * gdb.cp/mb-inline.exp: Likewise. * gdb.cp/mb-templates.exp: Likewise. * gdb.objc/basicclass.exp: Likewise. * gdb.threads/killed.exp: Likewise. --- gdb/testsuite/gdb.arch/gdb1558.exp | 13 ++-- gdb/testsuite/gdb.arch/i386-size-overlap.exp | 13 +--- gdb/testsuite/gdb.arch/i386-size.exp | 13 +--- gdb/testsuite/gdb.arch/i386-unwind.exp | 13 +--- gdb/testsuite/gdb.base/a2-run.exp | 78 +++++------------------- gdb/testsuite/gdb.base/break.exp | 48 +++++---------- gdb/testsuite/gdb.base/charset.exp | 13 +--- gdb/testsuite/gdb.base/chng-syms.exp | 33 +++-------- gdb/testsuite/gdb.base/commands.exp | 19 +----- gdb/testsuite/gdb.base/dbx.exp | 13 ++-- gdb/testsuite/gdb.base/find.exp | 12 +--- gdb/testsuite/gdb.base/funcargs.exp | 89 +++++++--------------------- gdb/testsuite/gdb.base/jit-simple.exp | 9 +-- gdb/testsuite/gdb.base/reread.exp | 60 ++----------------- gdb/testsuite/gdb.base/sepdebug.exp | 36 +++-------- gdb/testsuite/gdb.base/step-bt.exp | 14 +---- gdb/testsuite/gdb.cp/mb-inline.exp | 24 +------- gdb/testsuite/gdb.cp/mb-templates.exp | 48 ++------------- gdb/testsuite/gdb.objc/basicclass.exp | 7 +-- gdb/testsuite/gdb.threads/killed.exp | 9 +-- 20 files changed, 101 insertions(+), 463 deletions(-) diff --git a/gdb/testsuite/gdb.arch/gdb1558.exp b/gdb/testsuite/gdb.arch/gdb1558.exp index 42bb277..3f07a64 100644 --- a/gdb/testsuite/gdb.arch/gdb1558.exp +++ b/gdb/testsuite/gdb.arch/gdb1558.exp @@ -50,17 +50,12 @@ gdb_test "b sub2" "Breakpoint 3.*" "set breakpoint at sub2" gdb_run_cmd -gdb_expect 30 { +set test "Hits breakpoint at main after function called from main" +gdb_test_multiple "" $test { -re "Breakpoint 1.*main .*$gdb_prompt $" { - pass "Hits breakpoint at main after function called from main" + pass $test } -re "Breakpoint 2.*sub1 .*$gdb_prompt $" { - kfail "gdb/1558" "Hits breakpoint at main after function called from main" - } - -re "$gdb_prompt $" { - fail "Hits breakpoint at main after function called from main" - } - timeout { - fail "Hits breakpoint at main after function called from main (timeout)" + kfail "gdb/1558" $test } } diff --git a/gdb/testsuite/gdb.arch/i386-size-overlap.exp b/gdb/testsuite/gdb.arch/i386-size-overlap.exp index 0f9ba75..3b130c2 100644 --- a/gdb/testsuite/gdb.arch/i386-size-overlap.exp +++ b/gdb/testsuite/gdb.arch/i386-size-overlap.exp @@ -41,18 +41,7 @@ gdb_load ${binfile} # We use gdb_run_cmd so this stands a chance to work for remote # targets too. gdb_run_cmd - -gdb_expect { - -re "Program received signal SIGTRAP.*$gdb_prompt $" { - pass "run past main" - } - -re ".*$gdb_prompt $" { - fail "run past main" - } - timeout { - fail "run past main (timeout)" - } -} +gdb_test "" "Program received signal SIGTRAP.*" "run past main" set message "backtrace shows the outer function" gdb_test_multiple "backtrace 10" $message { diff --git a/gdb/testsuite/gdb.arch/i386-size.exp b/gdb/testsuite/gdb.arch/i386-size.exp index 6d63976..39e5b50 100644 --- a/gdb/testsuite/gdb.arch/i386-size.exp +++ b/gdb/testsuite/gdb.arch/i386-size.exp @@ -46,18 +46,7 @@ gdb_load ${binfile} # We use gdb_run_cmd so this stands a chance to work for remote # targets too. gdb_run_cmd - -gdb_expect { - -re "Program received signal SIGTRAP.*$gdb_prompt $" { - pass "run past main" - } - -re ".*$gdb_prompt $" { - fail "run past main" - } - timeout { - fail "run past main (timeout)" - } -} +gdb_test "" "Program received signal SIGTRAP.*" "run past main" set message "backtrace shows no function" gdb_test_multiple "backtrace 10" $message { diff --git a/gdb/testsuite/gdb.arch/i386-unwind.exp b/gdb/testsuite/gdb.arch/i386-unwind.exp index c329dd6..69f802a 100644 --- a/gdb/testsuite/gdb.arch/i386-unwind.exp +++ b/gdb/testsuite/gdb.arch/i386-unwind.exp @@ -46,18 +46,7 @@ gdb_load ${binfile} # We use gdb_run_cmd so this stands a chance to work for remote # targets too. gdb_run_cmd - -gdb_expect { - -re "Program received signal SIGTRAP.*$gdb_prompt $" { - pass "run past gdb1435" - } - -re ".*$gdb_prompt $" { - fail "run past gdb1435" - } - timeout { - fail "run past gdb1435 (timeout)" - } -} +gdb_test "" "Program received signal SIGTRAP.*" "run past gdb1435" gdb_test "backtrace 10" \ "#1\[ \t]*$hex in gdb1435.*\r\n#2\[ \t\]*$hex in main.*" \ diff --git a/gdb/testsuite/gdb.base/a2-run.exp b/gdb/testsuite/gdb.base/a2-run.exp index 49fcb92..10aaf67 100644 --- a/gdb/testsuite/gdb.base/a2-run.exp +++ b/gdb/testsuite/gdb.base/a2-run.exp @@ -34,48 +34,28 @@ if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } { # On VxWorks this justs make sure the program was run. gdb_run_cmd +set test "run \"$testfile\" with no args" + if [istarget "*-*-vxworks*"] then { - set timeout 120 - verbose "Timeout is now $timeout seconds" 2 - gdb_expect { - "$inferior_exited_re normally" { - unresolved "run \"$testfile\" with no args" - } - -re "usage: factorial " { - pass "run \"$testfile\" with no args" - } - timeout { - fail "(timeout) run \"$testfile\" with no args" - } - } - set timeout 10 - verbose "Timeout is now $timeout seconds" 2 - gdb_expect -re "$gdb_prompt $" {} + gdb_test "" "usage: factorial .*" $test } else { - gdb_expect { + gdb_test_multiple "" $test { -re ".*usage: factorial .*$inferior_exited_re with code 01.\r\n$gdb_prompt $" { - pass "run \"$testfile\" with no args" + pass $test pass "no spurious messages at program exit" } -re ".*usage: factorial .*$inferior_exited_re with code 01.*$gdb_prompt $" { - pass "run \"$testfile\" with no args" + pass $test fail "no spurious messages at program exit" } -re ".*usage: factorial .* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" { - pass "run \"$testfile\" with no args (exit wrapper)" + pass "$test (exit wrapper)" pass "no spurious messages at program exit" } -re ".*usage: factorial .* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" { - pass "run \"$testfile\" with no args (exit wrapper)" + pass "$test (exit wrapper)" fail "no spurious messages at program exit" } - -re ".*$gdb_prompt $" { - fail "run \"$testfile\" with no args" - verbose "expect_out is $expect_out(buffer)" 2 - } - timeout { - fail "(timeout) run \"$testfile\" no args" - } } } @@ -107,14 +87,9 @@ if [istarget "*-*-vxworks*"] then { verbose "Timeout is now $timeout seconds" 2 gdb_expect -re "$gdb_prompt $" {} } else { - setup_xfail "arm-*-coff" - gdb_run_cmd 5 - gdb_expect { - -re ".*120.*$gdb_prompt $"\ - { pass "run \"$testfile\" with arg" } - -re ".*$gdb_prompt $" { fail "run \"$testfile\" with arg" } - timeout { fail "(timeout) run \"$testfile\" with arg" } - } + setup_xfail "arm-*-coff" + gdb_run_cmd 5 + gdb_test "" "120.*" "run \"$testfile\" with arg" } # Run again with same arguments. @@ -135,12 +110,7 @@ if [istarget "*-*-vxworks*"] then { gdb_expect -re "$gdb_prompt $" {} } else { setup_xfail "arm-*-coff" - gdb_expect { - -re ".*120.*$gdb_prompt $"\ - { pass "run \"$testfile\" again with same args" } - -re ".*$gdb_prompt $" { fail "run \"$testfile\" again with same args" } - timeout { fail "(timeout) run \"$testfile\" again with same args" } - } + gdb_test "" "120.*" "run \"$testfile\" again with same args" } # Use "set args" command to specify no arguments as default and run again. @@ -170,17 +140,7 @@ if [istarget "*-*-vxworks*"] then { verbose "Timeout is now $timeout seconds" 2 gdb_expect -re "$gdb_prompt $" {} } else { - gdb_expect { - -re ".*usage: factorial .*$gdb_prompt $" { - pass "run after setting args to nil" - } - -re ".*$gdb_prompt $" { - fail "run after setting args to nil" - } - timeout { - fail "(timeout) run after setting args to nil" - } - } + gdb_test "" "usage: factorial .*" "run after setting args to nil" } # Use "set args" command to specify an argument and run again. @@ -211,17 +171,7 @@ if [istarget "*-*-vxworks*"] then { gdb_expect -re "$gdb_prompt $" {} } else { setup_xfail "arm-*-coff" - gdb_expect { - -re ".*720.*$gdb_prompt $" { - pass "run \"$testfile\" again after setting args" - } - -re ".*$gdb_prompt $" { - fail "run \"$testfile\" again after setting args" - } - timeout { - fail "(timeout) run \"$testfile\" again after setting args" - } - } + gdb_test "" "720.*" "run \"$testfile\" again after setting args" } # GOAL: Test that shell is being used with "run". For remote debugging diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index beab99a..1870ad5 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -358,17 +358,9 @@ gdb_test "disable \$1foo" \ # run until the breakpoint at main is hit. For non-stubs-using targets. # gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { - pass "run until function breakpoint" - } - -re "$gdb_prompt $" { - fail "run until function breakpoint" - } - timeout { - fail "run until function breakpoint (timeout)" - } -} +gdb_test "" \ + "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*" \ + "run until function breakpoint" # Test the 'list' commands sets current file for the 'break LINENO' command. set bp_marker1 [gdb_get_line_number "set breakpoint 16 here" ${srcfile1}] @@ -773,14 +765,7 @@ proc test_next_with_recursion {} { # Run until we call factorial with 6 gdb_run_cmd - gdb_expect { - -re "Break.* factorial .value=6. .*$gdb_prompt $" {} - -re ".*$gdb_prompt $" { - fail "run to factorial(6)" - gdb_suppress_tests - } - timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests } - } + gdb_test "" "Break.* factorial .value=6. .*" "run to factorial(6)" # Continue until we call factorial recursively with 5. @@ -871,18 +856,14 @@ gdb_test "break marker4" \ # run until the breakpoint at main is hit. For non-stubs-using targets. # gdb_run_cmd -gdb_expect { + +set test "run until function breakpoint, optimized file" +gdb_test_multiple "" $test { -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { - pass "run until function breakpoint, optimized file" + pass $test } -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" { - pass "run until function breakpoint, optimized file (code motion)" - } - -re "$gdb_prompt $" { - fail "run until function breakpoint, optimized file" - } - timeout { - fail "run until function breakpoint, optimized file (timeout)" + pass "$test (code motion)" } } @@ -945,15 +926,14 @@ gdb_test "rbreak main" \ # Run to a breakpoint. Fail if we see "Junk at end of arguments". gdb_run_cmd -gdb_expect { + +set test "rbreak junk" +gdb_test_multiple "" $test { -re "Junk at end of arguments" { - fail "rbreak junk" + fail $test } -re ".*Breakpoint \[0-9\]+,.*$gdb_prompt $" { - pass "rbreak junk" - } - timeout { - fail "rbreak junk (timeout)" + pass $test } } diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp index cc3a579..0378a65 100644 --- a/gdb/testsuite/gdb.base/charset.exp +++ b/gdb/testsuite/gdb.base/charset.exp @@ -324,18 +324,7 @@ gdb_test "break ${srcfile}:[gdb_get_line_number "all strings initialized"]" \ ".*Breakpoint.* at .*" \ "set breakpoint after all strings have been initialized" gdb_run_cmd -gdb_expect { - -re "Breakpoint.*all strings initialized.*$gdb_prompt $" { - pass "run until all strings have been initialized" - } - -re "$gdb_prompt $" { - fail "run until all strings have been initialized" - } - timeout { - fail "run until all strings have been initialized (timeout)" - } -} - +gdb_test "" "Breakpoint.*all strings initialized.*" "run until all strings have been initialized" # We only try the wide character tests on machines where the wchar_t # typedef in the test case has the right size. diff --git a/gdb/testsuite/gdb.base/chng-syms.exp b/gdb/testsuite/gdb.base/chng-syms.exp index ac69c50..b5b7d78 100644 --- a/gdb/testsuite/gdb.base/chng-syms.exp +++ b/gdb/testsuite/gdb.base/chng-syms.exp @@ -30,25 +30,10 @@ set timeout 10 verbose "Timeout is now 10 seconds" 2 proc expect_to_stop_here { ident } { - global gdb_prompt - global decimal - # the "at foo.c:36" output we get with -g. # the "in func" output we get without -g. - gdb_expect { - -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" { - return 1 - } - -re "$gdb_prompt $" { - fail "running to stop_here $ident" - return 0 - } - timeout { - fail "running to stop_here $ident (timeout)" - return 0 - } - } - return 1 + + gdb_test "" "Breakpoint \[0-9\]*, stop_here .*" "running to stop_here $ident" } clean_restart ${binfile} @@ -83,18 +68,14 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb } else { gdb_run_cmd - gdb_expect { + + set test "running with invalidated bpt condition after executable changes" + gdb_test_multiple "" $test { -re ".*$inferior_exited_re normally.*$gdb_prompt $" { - pass "running with invalidated bpt condition after executable changes" + pass $test } -re ".*Breakpoint .*,( 0x.* in)? (\[^ \]*)exit .*$gdb_prompt $" { - pass "running with invalidated bpt condition after executable changes" - } - -re "$gdb_prompt $" { - fail "running with invalidated bpt condition after executable changes" - } - timeout { - fail "(timeout) running with invalidated bpt condition after executable changes" + pass $test } } diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index 74eb306..ef86059 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -493,16 +493,7 @@ proc bp_deleted_in_command_test {} { "end commands" gdb_run_cmd - gdb_expect { - -re ".*factorial command-list executed.*$gdb_prompt $" { - pass "run factorial until breakpoint" - } - -re ".*$gdb_prompt $" { - fail "run factorial until breakpoint" - } - default { fail "(timeout) run factorial until breakpoint" } - timeout { fail "(timeout) run factorial until breakpoint" } - } + gdb_test "" "factorial command-list executed.*" "run factorial until breakpoint" } proc temporary_breakpoint_commands {} { @@ -551,12 +542,8 @@ proc temporary_breakpoint_commands {} { "end tbreak commands" gdb_run_cmd - gdb_expect { - -re ".*factorial tbreak commands executed.*$gdb_prompt $" { - pass "run factorial until temporary breakpoint" - } - timeout { fail "(timeout) run factorial until temporary breakpoint" } - } + gdb_test "" "factorial tbreak commands executed.*" \ + "run factorial until temporary breakpoint" } # Test that GDB can handle $arg0 outside of user functions without diff --git a/gdb/testsuite/gdb.base/dbx.exp b/gdb/testsuite/gdb.base/dbx.exp index 06638c7..4383e79 100644 --- a/gdb/testsuite/gdb.base/dbx.exp +++ b/gdb/testsuite/gdb.base/dbx.exp @@ -258,11 +258,14 @@ proc test_assign { } { global gdb_prompt gdb_run_cmd - gdb_expect 30 { - -re "Break.* at .*:$decimal.*$gdb_prompt $" { pass "running to main" } - -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" { pass "running to main" } - -re "$gdb_prompt $" { fail "running to main" } - timeout { fail "running to main (timeout)" } + set test "running to main" + gdb_test_multiple "" $test { + -re "Break.* at .*:$decimal.*$gdb_prompt $" { + pass $test + } + -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" { + pass $test + } } send_gdb "assign first=1\n" gdb_expect { diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp index edddb3d..d46e421 100644 --- a/gdb/testsuite/gdb.base/find.exp +++ b/gdb/testsuite/gdb.base/find.exp @@ -29,17 +29,7 @@ gdb_test "break $srcfile:stop_here" \ "breakpoint function in file" gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*stop_here.* at .*$srcfile:.*$gdb_prompt $" { - pass "run until function breakpoint" - } - -re "$gdb_prompt $" { - fail "run until function breakpoint" - } - timeout { - fail "run until function breakpoint (timeout)" - } -} +gdb_test "" "Breakpoint \[0-9\]+,.*stop_here.* at .*$srcfile:.*" "run until function breakpoint" # We've now got the target program in a state where we can test "find". diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp index b6de3d2..5cbd789 100644 --- a/gdb/testsuite/gdb.base/funcargs.exp +++ b/gdb/testsuite/gdb.base/funcargs.exp @@ -54,13 +54,7 @@ proc integral_args {} { # Run; should stop at call0a and print actual arguments. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_run_cmd - gdb_expect { - -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$gdb_prompt $" { - pass "run to call0a" - } - -re "$gdb_prompt $" { fail "run to call0a" ; gdb_suppress_tests } - timeout { fail "(timeout) run to call0a" ; gdb_suppress_tests } - } + gdb_test "" " call0a \\(c=97 'a', s=1, i=2, l=3\\) .*" "run to call0a" # Print each arg as a double check to see if we can print # them here as well as with backtrace. @@ -111,13 +105,7 @@ proc unsigned_integral_args {} { # Run; should stop at call1a and print actual arguments. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_run_cmd - gdb_expect { - -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$gdb_prompt $" { - pass "run to call1a" - } - -re "$gdb_prompt $" { fail "run to call1a" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to call1a" ; gdb_suppress_tests; } - } + gdb_test "" " call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*" "run to call1a" # Print each arg as a double check to see if we can print # them here as well as with backtrace. @@ -172,11 +160,14 @@ proc float_and_integral_args {} { if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } gdb_run_cmd - gdb_expect { - -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { pass "run to call2a" } - -re ".* call2a \\(c=97 'a', f1=.*, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { xfail "run to call2a" } - -re "$gdb_prompt $" { fail "run to call2a" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to call2a" ; gdb_suppress_tests; } + set test "run to call2a" + gdb_test_multiple "" $test { + -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { + pass $test + } + -re ".* call2a \\(c=97 'a', f1=.*, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { + xfail $test + } } # Print each arg as a double check to see if we can print @@ -257,10 +248,8 @@ proc complex_args {} { # Run; should stop at call1a and print actual arguments. gdb_run_cmd - gdb_expect { - -re ".* callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*$gdb_prompt $" { pass "run to call2a" } - timeout { fail "(timeout) run to callca" ; gdb_suppress_tests; } - } + gdb_test "" " callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*" "run to call2a" + gdb_test "cont" ".* callcb \\(d1=3 \\+ 4 \\* I, d2=3 \\+ 4 \\* I, d3=3 \\+ 4 \\* I\\) .*" "continue to callcb" gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6 \\* I, ld2=5 \\+ 6 \\* I, ld3=5 \\+ 6 \\* I\\) .*" "continue to callcc" gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "continue to callcd" @@ -282,10 +271,8 @@ proc complex_integral_args {} { # Run; should stop at call1a and print actual arguments. gdb_run_cmd - gdb_expect { - -re ".* callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc1a" } - timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; } - } + gdb_test "" " callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "run to callc1a" + gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6 \\* I\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2 \\* I, ui=7, l=3, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc1b" } @@ -302,10 +289,8 @@ proc complex_float_integral_args {} { # Run; should stop at call1a and print actual arguments. gdb_run_cmd - gdb_expect { - -re ".* callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc2a" } - timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; } - } + gdb_test "" " callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "run to callc2a" + gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2 \\* I, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6 \\* I\\, l=3, f=4, d=5, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc2b" } @@ -328,11 +313,7 @@ proc pointer_args {} { # Try dereferencing the arguments. gdb_run_cmd - gdb_expect { - -re ".* call3a \\(cp=$hex \"a.*\", sp=$hex , ip=$hex , lp=$hex \\) .*$gdb_prompt $" { pass "run to call3a" } - -re "$gdb_prompt $" { fail "run to call3a" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to call3a" ; gdb_suppress_tests; } - } + gdb_test "" " call3a \\(cp=$hex \"a.*\", sp=$hex , ip=$hex , lp=$hex \\) .*" "run to call3a" gdb_test "print *cp" ".* = 97 'a'" gdb_test "print *sp" ".* = 1" @@ -384,13 +365,7 @@ proc structs_by_reference {} { # Try dereferencing the arguments. gdb_run_cmd - gdb_expect { - -re ".* call4a \\(stp=$hex \\) .*$gdb_prompt $" { - pass "run to call4a" - } - -re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to call4a" ; gdb_suppress_tests; } - } + gdb_test "" " call4a \\(stp=$hex \\) .*" "run to call4a" gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}" @@ -440,13 +415,7 @@ proc structs_by_value {} { # Try dereferencing the arguments. gdb_run_cmd - gdb_expect { - -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" { - pass "run to call5a" - } - -re "$gdb_prompt $" { fail "run to call5a" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to call5a" ; gdb_suppress_tests; } - } + gdb_test "" " call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*" "run to call5a" gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}" @@ -513,11 +482,7 @@ proc discard_and_shuffle {} { # Print backtrace. gdb_run_cmd - gdb_expect { - -re ".*Breakpoint $decimal, call6a .*$gdb_prompt $" { pass "run to call6a" } - -re "$gdb_prompt $" { fail "run to call6a" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to call6a" ; gdb_suppress_tests; } - } + gdb_test "" "Breakpoint $decimal, call6a .*" "run to call6a" setup_xfail "rs6000-*-*" @@ -743,13 +708,7 @@ proc shuffle_round_robin {} { # Print backtrace. gdb_run_cmd - gdb_expect { - -re ".*Breakpoint $decimal, call7a .*$gdb_prompt $" { - pass "run to call7a" - } - -re "$gdb_prompt $" { fail "run to call7a" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to call7a" ; gdb_suppress_tests; } - } + gdb_test "" "Breakpoint $decimal, call7a .*" "run to call7a" if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } gdb_test_multiple "backtrace 100" "backtrace from call7a" { @@ -939,11 +898,7 @@ proc recursive_structs_by_value {} { # Run; should stop at hitbottom and print actual arguments. # Print backtrace. gdb_run_cmd - gdb_expect { - -re ".*Breakpoint $decimal, hitbottom .*$gdb_prompt $" { pass "run to hitbottom" } - -re "$gdb_prompt $" { fail "run to hitbottom" ; gdb_suppress_tests; } - timeout { fail "(timeout) run to hitbottom" ; gdb_suppress_tests; } - } + gdb_test "" "Breakpoint $decimal, hitbottom .*" "run to hitbottom" if ![istarget sparclet-*-*] { gdb_test_sequence "backtrace 100" "recursive passing of structs by value" { diff --git a/gdb/testsuite/gdb.base/jit-simple.exp b/gdb/testsuite/gdb.base/jit-simple.exp index 1c815bf..ce65964 100644 --- a/gdb/testsuite/gdb.base/jit-simple.exp +++ b/gdb/testsuite/gdb.base/jit-simple.exp @@ -40,14 +40,7 @@ proc jit_run {msg} { global decimal gdb_prompt gdb_run_cmd - gdb_expect { - -re "Inferior .* exited.*$gdb_prompt $" { - pass $msg - } - -re ".*$gdb_prompt $" { - fail $msg - } - } + gdb_test "" "Inferior .* exited.*" $msg } # Test re-running an inferior with a JIT descriptor, where the JIT diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp index 88abb17..e2900b0 100644 --- a/gdb/testsuite/gdb.base/reread.exp +++ b/gdb/testsuite/gdb.base/reread.exp @@ -62,17 +62,7 @@ gdb_test "break foo" \ # Run, should see "Breakpoint 1, foo () at hello1.c:14" gdb_run_cmd - -gdb_expect { - -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" { - pass "run to foo()" - } - -re ".*$gdb_prompt $" { - fail "run to foo()" - gdb_suppress_tests - } - timeout { fail "run to foo() (timeout)" ; gdb_suppress_tests } -} +gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" "run to foo()" # Restore first executable to its original name, and move # second executable into its place. Ensure that the new @@ -87,24 +77,12 @@ gdb_touch_execfile ${binfile} # and reset the breakpoints correctly. # Should see "Breakpoint 1, foo () at reread2.c:9" +set test "run to foo() second time" if [is_remote target] { - unsupported "run to foo() second time " + unsupported $test } else { gdb_run_cmd - gdb_expect { - # -re ".*re-reading symbols.*Breakpoint.* foo .* at .*$srcfile2:9.*$gdb_prompt $" {} - -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" { - pass "run to foo() second time " - } - -re ".*$gdb_prompt $" { - fail "run to foo() second time" - gdb_suppress_tests - } - timeout { - fail "run to foo() second time (timeout)" - gdb_suppress_tests - } - } + gdb_test "" "Breakpoint.* foo .* at .*:9.*" $test } @@ -127,19 +105,7 @@ if [is_remote target] { "Breakpoint.*at.* file .*$srcfile1, line 14.*" \ "second pass: breakpoint foo in first file" gdb_run_cmd - gdb_expect { - -re ".*Breakpoint.* foo .* at .*$srcfile1:14.*$gdb_prompt $" { - pass "second pass: run to foo()" - } - -re ".*$gdb_prompt $" { - fail "second pass: run to foo()" - gdb_suppress_tests - } - timeout { - fail "second pass: run to foo() (timeout)" - gdb_suppress_tests - } - } + gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" "second pass: run to foo()" # This time, let the program run to completion. If GDB checks the # executable file's timestamp now, it won't notice any change. @@ -151,23 +117,9 @@ if [is_remote target] { gdb_rename_execfile ${binfile} ${binfile1} gdb_rename_execfile ${binfile2} ${binfile} gdb_run_cmd - gdb_expect { - -re ".*Breakpoint.* foo .* at .*:9.*$gdb_prompt $" { - pass "second pass: run to foo() second time " - } - -re ".*$gdb_prompt $" { - fail "second pass: run to foo() second time" - gdb_suppress_tests - } - timeout { - fail "second pass: run to foo() second time (timeout)" - gdb_suppress_tests - } - } + gdb_test "" "Breakpoint.* foo .* at .*:9.*" "second pass: run to foo() second time" } # End of tests. -gdb_stop_suppressing_tests - return 0 diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp index fe16521..c5e019b 100644 --- a/gdb/testsuite/gdb.base/sepdebug.exp +++ b/gdb/testsuite/gdb.base/sepdebug.exp @@ -177,17 +177,9 @@ gdb_test "info break" \ # run until the breakpoint at main is hit. For non-stubs-using targets. # gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { - pass "run until function breakpoint" - } - -re "$gdb_prompt $" { - fail "run until function breakpoint" - } - timeout { - fail "run until function breakpoint (timeout)" - } -} +gdb_test "" \ + "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*" \ + "run until function breakpoint" # # run until the breakpoint at a line number @@ -574,14 +566,7 @@ proc test_next_with_recursion {} { # Run until we call factorial with 6 gdb_run_cmd - gdb_expect { - -re "Break.* factorial .value=6. .*$gdb_prompt $" {} - -re ".*$gdb_prompt $" { - fail "run to factorial(6)" - gdb_suppress_tests - } - timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests } - } + gdb_test "" "Break.* factorial .value=6. .*" "run to factorial(6)" # Continue until we call factorial recursively with 5. @@ -686,18 +671,13 @@ proc test_different_dir {type test_different_dir xfail} { if {$xfail} { setup_xfail "*-*-*" } - gdb_expect { + set test "run until function breakpoint, optimized file" + gdb_test_multiple "" $test { -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { - pass "run until function breakpoint, optimized file" + pass $test } -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" { - pass "run until function breakpoint, optimized file (code motion)" - } - -re "$gdb_prompt $" { - fail "run until function breakpoint, optimized file" - } - timeout { - fail "run until function breakpoint, optimized file (timeout)" + pass "$test (code motion)" } } diff --git a/gdb/testsuite/gdb.base/step-bt.exp b/gdb/testsuite/gdb.base/step-bt.exp index e521456..2469c2b 100644 --- a/gdb/testsuite/gdb.base/step-bt.exp +++ b/gdb/testsuite/gdb.base/step-bt.exp @@ -29,19 +29,7 @@ gdb_test "break *hello" \ "breakpoint at first instruction of hello()" gdb_run_cmd -gdb_expect { - -re ".*Breakpoint.* hello .* at .*$srcfile:.*$gdb_prompt $" { - pass "run to hello()" - } - -re ".*$gdb_prompt $" { - fail "run to hello()" - return -1 - } - timeout { - fail "run to hello() (timeout)" - return -1 - } -} +gdb_test "" "Breakpoint.* hello .* at .*$srcfile:.*" "run to hello()" gdb_test "stepi" \ ".*" \ diff --git a/gdb/testsuite/gdb.cp/mb-inline.exp b/gdb/testsuite/gdb.cp/mb-inline.exp index 803151a..f83d0bf 100644 --- a/gdb/testsuite/gdb.cp/mb-inline.exp +++ b/gdb/testsuite/gdb.cp/mb-inline.exp @@ -46,17 +46,7 @@ gdb_test "info break" \ "\[\r\n\]1\.1.* y .* at .*$hdrfile:$bp_location.*\[\r\n\]1\.2.* y .* at .*$hdrfile:$bp_location.*" gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { - pass "run to breakpoint" - } - -re "$gdb_prompt $" { - fail "run to breakpoint" - } - timeout { - fail "run to breakpoint (timeout)" - } -} +gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*" "run to breakpoint" gdb_test "continue" \ ".*Breakpoint.*foo \\(i=1\\).*" \ @@ -69,17 +59,7 @@ gdb_test "continue" \ gdb_test_no_output "disable 1.2" "disabling location: disable" gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { - pass "disabling location: run to breakpoint" - } - -re "$gdb_prompt $" { - fail "disabling location: run to breakpoint" - } - timeout { - fail "disabling location: run to breakpoint (timeout)" - } -} +gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*" "disabling location: run to breakpoint" gdb_test_multiple "info break" "disabled breakpoint 1.2" { -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.cp/mb-templates.exp b/gdb/testsuite/gdb.cp/mb-templates.exp index 3a7fbc9..edc1631 100644 --- a/gdb/testsuite/gdb.cp/mb-templates.exp +++ b/gdb/testsuite/gdb.cp/mb-templates.exp @@ -72,17 +72,7 @@ gdb_test_no_output {condition $bpnum i==1} \ "separate condition: set condition" gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*foo \\(i=1\\).*$gdb_prompt $" { - pass "separate condition: run to breakpoint" - } - -re "$gdb_prompt $" { - fail "separate condition: run to breakpoint" - } - timeout { - fail "separate condition: run to breakpoint (timeout)" - } -} +gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=1\\).*" "separate condition: run to breakpoint" gdb_test "continue" \ ".*Breakpoint.*foo \\(i=1\\).*" \ @@ -94,17 +84,7 @@ gdb_test "continue" \ gdb_test_no_output {disable $bpnum.1} "disabling location: disable" gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*foo \\(i=1\\).*$gdb_prompt $" { - pass "disabling location: run to breakpoint" - } - -re "$gdb_prompt $" { - fail "disabling location: run to breakpoint" - } - timeout { - fail "disabling location: run to breakpoint (timeout)" - } -} +gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=1\\).*" "disabling location: run to breakpoint" # Try disabling entire breakpoint gdb_test_no_output {enable $bpnum.1} "disabling location: enable" @@ -113,17 +93,7 @@ gdb_test_no_output {enable $bpnum.1} "disabling location: enable" gdb_test_no_output {disable $bpnum} "disable breakpoint: disable" gdb_run_cmd -gdb_expect { - -re "$inferior_exited_re normally.*$gdb_prompt $" { - pass "disable breakpoint: run to breakpoint" - } - -re "$gdb_prompt $" { - fail "disable breakpoint: run to breakpoint" - } - timeout { - fail "disable breakpoint: run to breakpoint (timeout)" - } -} +gdb_test "" "$inferior_exited_re normally.*" "disable breakpoint: run to breakpoint" # Make sure breakpoint can be set on a specific instantion. delete_breakpoints @@ -132,17 +102,7 @@ gdb_test "break 'void foo(int)'" ".*" \ gdb_run_cmd -gdb_expect { - -re ".*Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { - pass "instantiation: run to breakpoint" - } - -re "$gdb_prompt $" { - fail "instantiation: run to breakpoint" - } - timeout { - fail "instantiation: run to breakpoint (timeout)" - } -} +gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*" "instantiation: run to breakpoint" gdb_test "continue" \ ".*Breakpoint.*foo \\(i=1\\).*" \ diff --git a/gdb/testsuite/gdb.objc/basicclass.exp b/gdb/testsuite/gdb.objc/basicclass.exp index 96badd2..37f1b15 100644 --- a/gdb/testsuite/gdb.objc/basicclass.exp +++ b/gdb/testsuite/gdb.objc/basicclass.exp @@ -119,12 +119,7 @@ gdb_test continue \ # Test resetting breakpoints when re-running program # gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\ - { pass "resetting breakpoints when rerunning" } - -re ".*$gdb_prompt $" { fail "resetting breakpoints when rerunning" } - timeout { fail "resetting breakpoints when rerunning" } -} +gdb_test "" "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*" "resetting breakpoints when r # # Continue until breakpoint (test re-setting breakpoint) diff --git a/gdb/testsuite/gdb.threads/killed.exp b/gdb/testsuite/gdb.threads/killed.exp index d29454f..bacd52a 100644 --- a/gdb/testsuite/gdb.threads/killed.exp +++ b/gdb/testsuite/gdb.threads/killed.exp @@ -65,14 +65,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab clean_restart ${binfile} gdb_run_cmd -gdb_expect { - -re "$gdb_prompt $" { - pass "run program to completion" - } - timeout { - fail "run program to completion (timeout)" - } -} +gdb_test "" "" "run program to completion" # Try to quit. send_gdb "quit\n"