From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13642 invoked by alias); 28 Nov 2014 20:39:20 -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 13632 invoked by uid 89); 28 Nov 2014 20:39:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 28 Nov 2014 20:39:17 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sASKdDEx005674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 28 Nov 2014 15:39:13 -0500 Received: from localhost (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sASKdCGj003875 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 28 Nov 2014 15:39:13 -0500 From: Sergio Durigan Junior To: Andreas Arnez Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Provide useful completer for "info registers" References: <87h9xnqje8.fsf@br87z6lw.de.ibm.com> <87ioi1bs3x.fsf@redhat.com> <87vblzp4zb.fsf@br87z6lw.de.ibm.com> X-URL: http://blog.sergiodj.net Date: Fri, 28 Nov 2014 20:39:00 -0000 In-Reply-To: <87vblzp4zb.fsf@br87z6lw.de.ibm.com> (Andreas Arnez's message of "Fri, 28 Nov 2014 19:14:32 +0100") Message-ID: <87vblz6owf.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-11/txt/msg00721.txt.bz2 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/