From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Andreas Arnez <arnez@linux.vnet.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Provide useful completer for "info registers"
Date: Fri, 28 Nov 2014 20:39:00 -0000 [thread overview]
Message-ID: <87vblz6owf.fsf@redhat.com> (raw)
In-Reply-To: <87vblzp4zb.fsf@br87z6lw.de.ibm.com> (Andreas Arnez's message of "Fri, 28 Nov 2014 19:14:32 +0100")
On Friday, November 28 2014, Andreas Arnez wrote:
>> Hm, this should be "strlen (word)".
>>
>> The "text" will hold the entire line that is being completed, and "word"
>> will hold just the last word, according to the breaking characters being
>> used for this specific completer. For example, consider:
>>
>> (gdb) info registers rsp es
>>
>> In this case, "text" will be "rsp es", and "word" will be "es". Most of
>> the time, you will only be interested in using "word" for the
>> completion.
>>
>> Therefore, the "len" variable should hold "strlen (word)". Also, later
>> in the code you are comparing each register name against "text", but you
>> should be comparing against "word", for the reason explained above.
>>
>> Yeah, it can be confusing :-/.
>
> First I actually had used 'word' here, but then I noticed that the
> completer's notion of words doesn't match how the command parses its
> arguments. If using 'word', the completer behaves like this:
>
> (gdb) complete info registers hello,g
> info registers hello,general
>
> Which I consider a bit strange. However, I realize this may not be a
> real problem for users, and being able to expand multiple arguments
> probably beats this flaw, so I'll use 'word', as suggested.
Yeah. This is a problem with our completer scheme; you can see this
behavior happening also for other commands:
(gdb) complete break hello,ma
break hello,mabort
break hello,madvise
...
And I agree that this may not be a real problem for users (since this
problem exists for a long time apparently).
>> [...]
>>
>> While I understand and like this approach, we have a function that does
>> the "strncmp" dance for you. All you need to do is provide a list of
>> possible candidates (char **), and the word being completed. I gave it
>> a try and hacked your patch to do that. The resulting patch is
>> attached, feel free to use it if you like the approach.
>
> Thanks for the patch! Indeed I didn't know about complete_on_enum()
> before. But after weighing pros and cons, I still prefer the "strncmp
> dance": It's not longer and needs somewhat less logic, e.g. only two
> instead of three loops and no temporary xmalloc'd buffer. Also, I think
> the code is easier to maintain if signal_completer and
> reg_or_group_completer use the same approach.
Agreed :-). Although complete_on_enum exists, its interface is in dire
need of a revamp; besides, using it on your function does not make the
code simpler or clearer as you pointed.
> But since it's a short function, I will dissolve the sub-blocks and move
> the variable declarations to the top instead, like your patch does.
Thanks.
>> I'd say this patch also needs a testcase :-). I know that this is
>> architecture specific, so I'd personally be happy with something very
>> simple, maybe testing only one or two architectures would be enough.
>
> Yes, a test case would probably be adequate. I'll try it in an
> architecture-independent way and include it in the next version.
>
>> Other than that, it is fine by me (not an approval). Thanks for doing
>> that.
>
> Thanks for looking at this, and for your feedback. Much appreciated.
No, thank you! :-)
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
next prev parent reply other threads:[~2014-11-28 20:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 17:28 Andreas Arnez
2014-11-26 20:54 ` Sergio Durigan Junior
2014-11-26 21:52 ` Sergio Durigan Junior
2014-11-28 18:14 ` Andreas Arnez
2014-11-28 20:39 ` Sergio Durigan Junior [this message]
2014-12-04 17:34 ` Pedro Alves
2014-12-10 17:36 ` Andreas Arnez
2014-12-10 18:21 ` Pedro Alves
2014-12-04 17:38 ` Pedro Alves
2014-12-10 17:48 ` Andreas Arnez
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=87vblz6owf.fsf@redhat.com \
--to=sergiodj@redhat.com \
--cc=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).