Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v4 2/2] Provide completer for "info registers"
Date: Fri, 12 Dec 2014 15:20:00 -0000	[thread overview]
Message-ID: <877fxwnbd6.fsf@br87z6lw.de.ibm.com> (raw)
In-Reply-To: <548AEB86.60809@redhat.com> (Pedro Alves's message of "Fri, 12	Dec 2014 13:20:06 +0000")

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
 }


  reply	other threads:[~2014-12-12 15:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-11 11:49 [PATCH v4 0/2] Provide useful " Andreas Arnez
2014-12-11 11:49 ` [PATCH v4 1/2] Add new GDB command "maint print user-registers" Andreas Arnez
2014-12-12 13:19   ` Pedro Alves
2014-12-11 11:49 ` [PATCH v4 2/2] Provide completer for "info registers" Andreas Arnez
2014-12-12 13:20   ` Pedro Alves
2014-12-12 15:20     ` Andreas Arnez [this message]
2014-12-12 15:30       ` Pedro Alves
2014-12-12 17:45       ` Doug Evans
2014-12-12 19:04         ` Andreas Arnez
2014-12-15 12:41           ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877fxwnbd6.fsf@br87z6lw.de.ibm.com \
    --to=arnez@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox