From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114478 invoked by alias); 8 Jun 2017 23:27:55 -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 114458 invoked by uid 89); 8 Jun 2017 23:27:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:D*polymtl.ca X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Jun 2017 23:27:52 +0000 Received: by mail-pf0-f195.google.com with SMTP id y7so6677321pfd.3 for ; Thu, 08 Jun 2017 16:27:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wcw6fgu+SIUMunTLwHoyrlfQiGvjblw0LPL7ZzQzGSM=; b=qAH7oj9XCGbim6hQHL5Jkjk1xWw8eJxJy7QKAWAAVnyjWocwa1a4KrbKcm5Hu88Ctd SBDBEXZy9ABUSd7we6zKgfH8PqnxmqjHNLrkPI0j3p8Q9qbb4ch/vs8i9C6e7DUH/q9U WpKUZwfnY5TL2/UhTU+QIfF3VRLUdgjrZhK6S3cq4xx4WFMlGpcNrEPdxHYd4IhtSawn jlJ7k9QDYUpW/ZzvhpYBz1Awq+/g+UIII/MYhwHWsP/qV0p9Pswfpg502cgJox/9JSob +1eC/UU6KaMsKF289X0R85c2hcK7ksAoYPsYP82Z+f08xEKgGyXJHk7C1pIxFU7NjolG HXqg== X-Gm-Message-State: AODbwcBttmDvLE7FNPXtk27gUkFT0L3Xn5zaJKt/5RvRecewJMts4l0Z NQl0uHKaw5vQ6CrjlIE= X-Received: by 10.98.101.6 with SMTP id z6mr39526138pfb.221.1496964474893; Thu, 08 Jun 2017 16:27:54 -0700 (PDT) Received: from localhost (g212.61-193-241.ppp.wakwak.ne.jp. [61.193.241.212]) by smtp.gmail.com with ESMTPSA id m81sm12019344pfj.121.2017.06.08.16.27.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Jun 2017 16:27:54 -0700 (PDT) Date: Thu, 08 Jun 2017 23:27:00 -0000 From: Stafford Horne To: Simon Marchi Cc: GDB patches Subject: Re: [PATCH 1/3] reggroups: Add test and docs for `info reg $reggroup` feature Message-ID: <20170608232752.GA8558@lianli.shorne-pla.net> References: <83413241fe0897c873b1cc6e18ccbec78a7a2a25.1496871270.git.shorne@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00222.txt.bz2 On Thu, Jun 08, 2017 at 10:31:56PM +0200, Simon Marchi wrote: > On 2017-06-08 00:15, Stafford Horne wrote: > > Until now this feature has existed but was not documented. Adding docs > > and tests. > > Hi Stafford, > > Thanks for doing this! It would be cool if you could improve the > documentation printed by "help info registers", while at it. > > > gdb/ChangeLog: > > > > 2017-06-06 Stafford Horne > > > > * doc/gdb.texinfo: Document info reg $reggroup feature. > > > > gdb/testsuite/ChangeLog: > > > > 2017-06-06 Stafford Horne > > > > * gdb.base/reggroups.c: New file. > > * gdb.base/reggroups.exp: New file. > > --- > > gdb/doc/gdb.texinfo | 5 +++ > > gdb/testsuite/gdb.base/reggroups.c | 4 ++ > > gdb/testsuite/gdb.base/reggroups.exp | 71 > > ++++++++++++++++++++++++++++++++++++ > > 3 files changed, 80 insertions(+) > > create mode 100644 gdb/testsuite/gdb.base/reggroups.c > > create mode 100644 gdb/testsuite/gdb.base/reggroups.exp > > > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > > index 9fb70f6..a11db0c 100644 > > --- a/gdb/doc/gdb.texinfo > > +++ b/gdb/doc/gdb.texinfo > > @@ -10878,6 +10878,11 @@ and vector registers (in the selected stack > > frame). > > Print the names and values of all registers, including floating-point > > and vector registers (in the selected stack frame). > > > > +@item info registers @var{reggroup} @dots{} > > +Print the name and value of the restiers in each of the specified > > Do you mean "registers"? Yes. will fix > > +@var{reggroup}. The @var{reggoup} can be any of those returned by > > +@code{maint print reggroups}. > > + > > @item info registers @var{regname} @dots{} > > Print the @dfn{relativized} value of each specified register > > @var{regname}. > > As discussed in detail below, register values are normally relative to > > diff --git a/gdb/testsuite/gdb.base/reggroups.c > > b/gdb/testsuite/gdb.base/reggroups.c > > new file mode 100644 > > index 0000000..f8b643a > > --- /dev/null > > +++ b/gdb/testsuite/gdb.base/reggroups.c > > @@ -0,0 +1,4 @@ > > +int main() > > We try to use the GDB formatting style for the test code as well, so here it > would be: > > int > main () > { > return 0; > } OK > > +{ > > + return 0; > > +} > > diff --git a/gdb/testsuite/gdb.base/reggroups.exp > > b/gdb/testsuite/gdb.base/reggroups.exp > > new file mode 100644 > > index 0000000..fd51c50 > > --- /dev/null > > +++ b/gdb/testsuite/gdb.base/reggroups.exp > > @@ -0,0 +1,71 @@ > > +# This testcase is part of GDB, the GNU debugger. > > + > > +# Copyright 2014-2017 Free Software Foundation, Inc. > > Should it be 2017 only? Yes. will fix > > + > > +# This program is free software; you can redistribute it and/or modify > > +# it under the terms of the GNU General Public License as published by > > +# the Free Software Foundation; either version 3 of the License, or > > +# (at your option) any later version. > > +# > > +# This program is distributed in the hope that it will be useful, > > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > +# GNU General Public License for more details. > > +# > > +# You should have received a copy of the GNU General Public License > > +# along with this program. If not, see . > > + > > +# Test listing reggroups and the registers in each group. > > + > > +standard_testfile > > + > > +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} > > { > > + return -1 > > +} > > + > > +if ![runto_main] then { > > + fail "can't run to main" > > + return 0 > > +} > > + > > +proc fetch_reggroups {test} { > > + global gdb_prompt > > + global expect_out > > + > > + set reggroups {} > > + set bad -1 > > + gdb_test_multiple "maint print reggroups" "get reggroups" { > > + -re "maint print reggroups\r\n" { > > + exp_continue > > + } > > + -re "^ Group\[ \t\]+Type\[ \t\]+\r\n" { > > + exp_continue > > + } > > + -re "^ (\[0-9a-zA-Z\-\]+)\[ \t\]+(user|internal)\[ \t\]+\r\n" { > > + lappend reggroups $expect_out(1,string) > > + exp_continue > > + } > > + -re ".*$gdb_prompt $" { > > + if { [llength $reggroups] != 0 } { > > + incr bad > > + } else { > > + set bad 1 > > + } > > I don't quite understand this. Why not simply "set bad 1"? > > Another option would be to call error to throw an exception, which will end > the test abruptly: > > error "maint print reggroups: unexpected output" Alright, I was copying this pattern from other test, I did think it was a bit strange but it makese a bit of sense if you want to capture the failure condition but continue with other tests. Ill change it as you suggest. > You could also assert that there is at least one reggroup with something > like: > > gdb_assert { [llength $reggroups] > 0 } "at least one reggroup" OK, ill look at that. > > + } > > + } > > + > > + if {$bad} { > > + fail $test > > + return {} > > + } > > > > + > > + pass $test > > + return $reggroups > > +} > > + > > +set reggroups [fetch_reggroups "fetch reggroups"] > > +set reggroup "" > > You don't need to declare reggroup. OK > > + > > +foreach reggroup [lrange $reggroups 0 end] { > > And this can be simply: > > foreach reggroup $reggroups OK > > + gdb_test "info reg $reggroup" ".*" "info reg $reggroup" > > +} Thanks for reviewing, I dont write much expect code, this is helpful. -Stafford