From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89793 invoked by alias); 14 May 2019 14:59:00 -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 89523 invoked by uid 89); 14 May 2019 14:59:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.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=HX-Received:9689 X-HELO: mail-wm1-f67.google.com Received: from mail-wm1-f67.google.com (HELO mail-wm1-f67.google.com) (209.85.128.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 May 2019 14:58:58 +0000 Received: by mail-wm1-f67.google.com with SMTP id j187so3167331wmj.1 for ; Tue, 14 May 2019 07:58:58 -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=Lh/ea1VXNBP3a19O69KLzaD1bBLEJist//d/UswliSs=; b=HXTmmTDlPRmiAZJRrbkh7vXgGT0X8uhS1TfWUEOkoK9DChuCXrEhhfMbioJki+oGPS MMflxFAnWIzpTWsobSQZR5VEVPtM6qG7lQYBCaLpn1+LC0+5h/F2gOzH2FoJW/Xd2JeQ qVx64p8huaaCpO4kLHLZMlCecv7G5Ohmi7Cczr9b47Zm/gKhkXJXK+/bjqsGChiUz0z7 wfpJYL2aeX+ILPsawvHdwRq3c0csoNe9xyCoDdWhOowf1WfLq20YIQK4vQZjfwevYiJG lXZzEnjtvPH/RptC/lg/1ZfaOvWSxKBWEyshCb/FgwDzc5uvBYHpJUDTKUH31xUlPrv9 pFEg== Return-Path: Received: from localhost (host86-180-62-212.range86-180.btcentralplus.com. [86.180.62.212]) by smtp.gmail.com with ESMTPSA id l12sm3653447wmj.0.2019.05.14.07.58.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 07:58:55 -0700 (PDT) Date: Tue, 14 May 2019 14:59:00 -0000 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Add "style" proc to the test suite Message-ID: <20190514145854.GM2568@embecosm.com> References: <20190514140536.11845-1-tromey@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190514140536.11845-1-tromey@adacore.com> X-Fortune: Lost interest? It's so bad I've lost apathy. 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-05/txt/msg00322.txt.bz2 * Tom Tromey [2019-05-14 08:05:36 -0600]: > This adds a "style" helper proc to the test suite, and updates > existing style tests to use it. Thanks to Sergio for the idea. > > Tested on x86-64 Fedora 29. > > gdb/testsuite/ChangeLog > 2019-05-14 Tom Tromey > > * gdb.base/info-shared.exp (check_info_shared): Use "style". > * gdb.base/style.exp: Use "style". > * lib/gdb-utils.exp (style): New proc. > --- > gdb/testsuite/ChangeLog | 6 ++++++ > gdb/testsuite/gdb.base/info-shared.exp | 4 ++-- > gdb/testsuite/gdb.base/style.exp | 13 +++++++------ > gdb/testsuite/lib/gdb-utils.exp | 18 ++++++++++++++++++ > 4 files changed, 33 insertions(+), 8 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/info-shared.exp b/gdb/testsuite/gdb.base/info-shared.exp > index e1314bf5dd7..42295ce7367 100644 > --- a/gdb/testsuite/gdb.base/info-shared.exp > +++ b/gdb/testsuite/gdb.base/info-shared.exp > @@ -161,8 +161,8 @@ with_test_prefix styled { > > # Simple test for "info sharedlibrary" styling. Look for styled > # addresses and file name. > - set addr "\033\\\[34m${hex}\033\\\[m" > - set sofile "\033\\\[32m\[^\033\]+\033\\\[m" > + set addr [style $hex address] > + set sofile [style "\[^\033\]+" file] I wonder if there's a nice way to get rid of the \033 here? Two thoughts I had was a different proc so we could maybe write this: set sofile [styled-string file] Alternatively, I wondered if we could special case this: set sofile [styled ".*" file] So that if we pass exactly ".*" it is changed into "\[^\033\]+" inside the style proc. Just thought it might be nice to try and remove more of the escape sequences. Thanks, Andrew > gdb_test_no_output "set style enabled on" > gdb_test "info sharedlibrary" \ > "$addr\[ \t\]+$addr.*$sofile\r\n.*" > diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp > index 369c1f59a88..15de05cdafb 100644 > --- a/gdb/testsuite/gdb.base/style.exp > +++ b/gdb/testsuite/gdb.base/style.exp > @@ -41,10 +41,10 @@ save_vars { env(TERM) } { > > gdb_test_no_output "set style enabled on" > > - set main_expr "\033\\\[33mmain\033\\\[m" > - set base_file_expr "\033\\\[32m.*style\\.c\033\\\[m" > + set main_expr [style main function] > + set base_file_expr [style ".*style\\.c" file] > set file_expr "$base_file_expr:\[0-9\]" > - set arg_expr "\033\\\[36marg.\033\\\[m" > + set arg_expr [style "arg." variable] > > gdb_test "frame" \ > "$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*" > @@ -58,7 +58,7 @@ save_vars { env(TERM) } { > > gdb_test "break main" "file $base_file_expr.*" > > - gdb_test "print &main" " = .* \033\\\[34m$hex\033\\\[m <$main_expr>" > + gdb_test "print &main" " = .* [style $hex address] <$main_expr>" > > # Regression test for a bug where line-wrapping would occur at the > # wrong spot with styling. There were different bugs at different > @@ -86,11 +86,12 @@ save_vars { env(TERM) } { > gdb_exit > gdb_spawn > > - gdb_test "" "\033\\\[35;1mGNU gdb.*\033\\\[m.*" \ > + set vers [style "GNU gdb.*" "35;1"] > + gdb_test "" "${vers}.*" \ > "version is styled" > > set quoted [string_to_regexp $binfile] > gdb_test "file $binfile" \ > - "Reading symbols from \033\\\[32m${quoted}\033\\\[m..." \ > + "Reading symbols from [style $quoted file]..." \ > "filename is styled when loading symbol file" > } > diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp > index 26bbbf593c6..a6567884426 100644 > --- a/gdb/testsuite/lib/gdb-utils.exp > +++ b/gdb/testsuite/lib/gdb-utils.exp > @@ -37,3 +37,21 @@ proc string_to_regexp {str} { > regsub -all {[]*+.|(){}^$\[\\]} $str {\\&} result > return $result > } > + > +# Wrap STR in an ANSI terminal escape sequences -- one to set the > +# style to STYLE, and one to reset the style to the default. The > +# return value is suitable for use as a regular expression. > + > +# STYLE can either be the payload part of an ANSI terminal sequence, > +# or a shorthand for one of the gdb standard styles: "file", > +# "function", "variable", or "address". > + > +proc style {str style} { > + switch -exact -- $style { > + file { set style 32 } > + function { set style 33 } > + variable { set style 36 } > + address { set style 34 } > + } > + return "\033\\\[${style}m${str}\033\\\[m" > +} > -- > 2.20.1 >