From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126954 invoked by alias); 5 Oct 2019 15:38:43 -0000 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 Received: (qmail 125245 invoked by uid 89); 5 Oct 2019 15:38:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=(unknown) X-HELO: mail-wm1-f68.google.com Received: from mail-wm1-f68.google.com (HELO mail-wm1-f68.google.com) (209.85.128.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 05 Oct 2019 15:38:40 +0000 Received: by mail-wm1-f68.google.com with SMTP id r19so8509270wmh.2 for ; Sat, 05 Oct 2019 08:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wZJKGn6iqXcgWeiHb5gTxGqKF7ZoFGptGAKYGSbpuBg=; b=V5+t/1eWxNucn8lAAfkKIdnxzNAH0OFA2BPC6Tdc77diwgYswVO8vLc8Hra/W6E3eW HojlXwB4FrHk5XJICAj+tcU/oKRFAL5QpcWMkAzm02zjHfl0X2Q37ppQYp5+Z1q3v73R 1rVMORq3vncJVr5dJEpv6AdRjxWi3lW2k4EgBzjLf2e0bEIww7gvxZ/24Hs+rJFI9CVM z/nK7YwtMfA5J7n35ilv4eU31V6dSLiSNOs7Iy5E5u3EKVs9Mn3gxppsi7IMsvnXC2ve mUTr7jBRwxq4IvUOJGtkqu3M0WmRemQy56lgVOtragKcCmb5c1fgb177gDpBtI1ZG9xo dbEA== Return-Path: Received: from localhost (188.29.165.252.threembb.co.uk. [188.29.165.252]) by smtp.gmail.com with ESMTPSA id w9sm17392918wrt.62.2019.10.05.08.38.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Oct 2019 08:38:37 -0700 (PDT) Date: Sat, 05 Oct 2019 15:38:00 -0000 From: Andrew Burgess To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH][gdb/testsuite] Add -cooked pattern flag to gdb_test_multiple Message-ID: <20191005153835.GL4962@embecosm.com> References: <20190919111322.GA29391@delia> <20190919161846.GC4962@embecosm.com> <62b20c8f-6792-c17e-621a-946002df6df9@suse.de> <20190919192423.GF4962@embecosm.com> <86b5c1b8-ac35-5c7e-1a5d-89b8563ab761@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86b5c1b8-ac35-5c7e-1a5d-89b8563ab761@suse.de> X-Fortune: Put cats in the coffee and mice in the tea! X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00172.txt.bz2 * Tom de Vries [2019-10-05 08:05:03 +0200]: > [ was: Re: [PATCH][gdb/testsuite] Introduce gdb_test_ext ] > > On 19-09-19 21:24, Andrew Burgess wrote: > > On further thought, I actually think there's no need for an extra > > function at all, we can get all the benefit (as I see it) by possibly > > updating gdb_test_multiple. I'm travelling right now so can't code > > this up, but I think a solution that does something like this: > > > > gdb_test_multiple "command" "test name" { > > -re "full regexp here$gdb_prompt" { > > pass $gdb_test_multiple_name > > } > > -output "pattern without prompt" { > > fail $gdb_test_multiple_name > > } > > } > > > > So using '-re' and '-output' to specialise the behaviour of > > gdb_test_multiple, and adding in the $gdb_test_multiple_name variable. > > > > When I get back to my desk I'll try to code this up. > > Hi, > > I took a stab at this. I'm not sure about the naming though. > > For the pattern flag I used the name -cooked. Perhaps -wrap is better? > Any better suggestions? > > I used gdb_test_multiple_message (using the 'message' postfix because it > matched the name of the gdb_test_multiple argument) for the convenience > variable, but it's a tad long, perhaps we could abbreviate to > 'gtm_message'? This duplicates work in this patch: https://sourceware.org/ml/gdb-patches/2019-10/msg00023.html I was just about to merge that patch, but I'll leave it for a couple of days in case you'd like to provide feedback. Pedro's suggestion, which I was going to adopt was 'gdb_test_name'. Thanks, Andrew > > Thanks, > - Tom > [gdb/testsuite] Add -cooked pattern flag to gdb_test_multiple > > Currently, in order to rewrite: > ... > gdb_test > ... > using gdb_test_multiple, we get: > ... > set msg > gdb_test_multiple $msg { > -re "\[\r\n\]*(?:)\[\r\n\]+$gdb_prompt $" { > pass $msg > } > } > ... > > Add to gdb_test_multiple: > - a '-cooked' pattern flag, that wraps the regexp pattern as gdb_test wraps > its message argument. > - a convenience variable gdb_test_multiple_message > > This allows us to rewrite into the more compact: > ... > gdb_test_multiple { > -re -cooked { > pass $gdb_test_multiple_message > } > } > ... > > Tested on x86_64-linux. > > gdb/testsuite/ChangeLog: > > 2019-10-04 Tom de Vries > > * lib/gdb.exp (gdb_test_multiple): Add -cooked pattern flag and > convenience variable gdb_test_multiple_message. > * gdb.reverse/step-precsave.exp: Rewrite gdb_test_multiple containing > kfail using -cooked pattern flag and convenience variable > gdb_test_multiple_message. > > --- > gdb/testsuite/gdb.reverse/step-precsave.exp | 13 +++++-------- > gdb/testsuite/lib/gdb.exp | 25 ++++++++++++++++++++++++- > 2 files changed, 29 insertions(+), 9 deletions(-) > > diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp > index 2073b8a1542..aaddd3b4ada 100644 > --- a/gdb/testsuite/gdb.reverse/step-precsave.exp > +++ b/gdb/testsuite/gdb.reverse/step-precsave.exp > @@ -46,15 +46,12 @@ gdb_test "break $end_of_main" \ > > # This can take awhile. > with_timeout_factor 20 { > - set test "run to end of main" > - set pass_pattern "Breakpoint .* end of main .*" > - set kfail_pattern "Process record does not support instruction 0xc5 at.*" > - gdb_test_multiple "continue" $test { > - -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { > - pass $test > + gdb_test_multiple "continue" "run to end of main" { > + -re -cooked "Breakpoint .* end of main .*" { > + pass $gdb_test_multiple_message > } > - -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { > - kfail "record/23188" $test > + -re -cooked "Process record does not support instruction 0xc5 at.*" { > + kfail "record/23188" $gdb_test_multiple_message > } > } > } > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 3a1f053cf8a..4a47ddc9d37 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -772,6 +772,11 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { > error "Invalid newline in \"$message\" test" > } > > + upvar 1 gdb_test_multiple_message gdb_test_multiple_message > + if { [info exists gdb_test_multiple_message] } { > + set gdb_test_multiple_message_save $gdb_test_multiple_message > + } > + > if {$use_gdb_stub > && [regexp -nocase {^\s*(r|run|star|start|at|att|atta|attac|attach)\M} \ > $command]} { > @@ -807,6 +812,7 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { > set patterns "" > set expecting_action 0 > set expecting_arg 0 > + set cooked 0 > foreach item $user_code subst_item $subst_code { > if { $item == "-n" || $item == "-notransfer" || $item == "-nocase" } { > lappend processed_code $item > @@ -821,6 +827,10 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { > lappend processed_code $item > continue > } > + if { $item == "-cooked" } { > + set cooked 1 > + continue > + } > if { $expecting_arg } { > set expecting_arg 0 > lappend processed_code $subst_item > @@ -834,7 +844,14 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { > continue > } > set expecting_action 1 > - lappend processed_code $subst_item > + if { $cooked } { > + # Wrap subst_item as is done for the gdb_test PATTERN argument. > + lappend processed_code \ > + "\[\r\n\]*(?:$subst_item)\[\r\n\]+$gdb_prompt $" > + set cooked 0 > + } else { > + lappend processed_code $subst_item > + } > if {$patterns != ""} { > append patterns "; " > } > @@ -1038,8 +1055,14 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } { > } > } > > + set gdb_test_multiple_message $message > set result 0 > set code [catch {gdb_expect $code} string] > + if { [info exists gdb_test_multiple_message_save] } { > + set gdb_test_multiple_message $gdb_test_multiple_message_save > + } else { > + unset gdb_test_multiple_message > + } > if {$code == 1} { > global errorInfo errorCode > return -code error -errorinfo $errorInfo -errorcode $errorCode $string