From patchwork Fri Dec 12 15:20:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 4219 Received: (qmail 21378 invoked by alias); 12 Dec 2014 15:20:34 -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 21363 invoked by uid 89); 12 Dec 2014 15:20:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp12.uk.ibm.com Received: from e06smtp12.uk.ibm.com (HELO e06smtp12.uk.ibm.com) (195.75.94.108) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 12 Dec 2014 15:20:29 +0000 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 12 Dec 2014 15:20:26 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 12 Dec 2014 15:20:23 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4120717D8043 for ; Fri, 12 Dec 2014 15:20:46 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sBCFKNMX54329400 for ; Fri, 12 Dec 2014 15:20:23 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sBCFKMfA007443 for ; Fri, 12 Dec 2014 08:20:23 -0700 Received: from br87z6lw.de.ibm.com (dyn-9-152-212-196.boeblingen.de.ibm.com [9.152.212.196]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sBCFKMlb007426; Fri, 12 Dec 2014 08:20:22 -0700 From: Andreas Arnez To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v4 2/2] Provide completer for "info registers" References: <1418298589-23120-1-git-send-email-arnez@linux.vnet.ibm.com> <1418298589-23120-3-git-send-email-arnez@linux.vnet.ibm.com> <548AEB86.60809@redhat.com> Date: Fri, 12 Dec 2014 16:20:21 +0100 In-Reply-To: <548AEB86.60809@redhat.com> (Pedro Alves's message of "Fri, 12 Dec 2014 13:20:06 +0000") Message-ID: <877fxwnbd6.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14121215-0009-0000-0000-0000025C158E X-IsSubscribed: yes On Fri, Dec 12 2014, Pedro Alves wrote: > On 12/11/2014 11:49 AM, Andreas Arnez wrote: > >> +set regs_output [capture_command_output "mt print registers" \ >> + ".*Name.*Nr.*Rel.*Offset.*Size.*Type.\[^\n\]*\n"] >> +append regs_output "\n" >> +append regs_output [capture_command_output "mt print reggroups" \ >> + ".*Group.*Type\[^\n]*\n"] >> +set all_regs {} >> +foreach {-> reg} [regexp -all -inline -line {^\s+(\w+\S*)} $regs_output] { > > This "->" here confused me a little. AFAIK, $- is a more common "don't care" > variable (and what foreach's documentation suggests). Any reason to > pick -> instead? I think I've borrowed this from an example in the regexp's documentation: regexp {\mfoo(?!bar\M)(\w*)} $string -> restOfWord Admittedly, in the foreach case this does not look as nicely. So I will change it to "-", as suggested. > Also, why do we need the "\S*" ? I'd assume {^\s+(\w+)} works just as well. OK, all existing register and reggroup names consist wholly of alphanumeric and underscore characters. So I will change the pattern as suggested. > >> + lappend all_regs $reg >> +} >> + >> +set regs_output [capture_command_output "mt print user-registers" \ >> + ".*Nr.*Name\[^\n]*\n"] >> +foreach {-> reg} [regexp -all -inline -line {\d+\s+(\w+\S*)} $regs_output] { > > Likewise. Yes. And looking at it again, I think that this pattern should be more consistent with the one above and match the whole beginning of a line. Thus I will rephrase it to {^\s+\d+\s+(\w+)}. In this way the command can add more columns in the future without having to adjust the pattern here. > Otherwise this looks good to me. Thanks. Will push this then with changes below. --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -146,13 +146,13 @@ append regs_output "\n" append regs_output [capture_command_output "mt print reggroups" \ ".*Group.*Type\[^\n]*\n"] set all_regs {} -foreach {-> reg} [regexp -all -inline -line {^\s+(\w+\S*)} $regs_output] { +foreach {- reg} [regexp -all -inline -line {^\s+(\w+)} $regs_output] { lappend all_regs $reg } set regs_output [capture_command_output "mt print user-registers" \ ".*Nr.*Name\[^\n]*\n"] -foreach {-> reg} [regexp -all -inline -line {\d+\s+(\w+\S*)} $regs_output] { +foreach {- reg} [regexp -all -inline -line {^\s+\d+\s+(\w+)} $regs_output] { lappend all_regs $reg }