From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3999 invoked by alias); 5 Jun 2008 17:10:16 -0000 Received: (qmail 3985 invoked by uid 22791); 5 Jun 2008 17:10:15 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 05 Jun 2008 17:09:56 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 8C696983F8; Thu, 5 Jun 2008 17:09:53 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id F21B99809F; Thu, 5 Jun 2008 17:09:52 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1K4IyG-000403-4r; Thu, 05 Jun 2008 13:09:52 -0400 Date: Thu, 05 Jun 2008 17:10:00 -0000 From: Daniel Jacobowitz To: Tom Tromey Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Patch to limit field name completion candidates Message-ID: <20080605170952.GJ29085@caradoc.them.org> Mail-Followup-To: Tom Tromey , gdb-patches@sources.redhat.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes 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 X-SW-Source: 2008-06/txt/msg00042.txt.bz2 On Mon, May 12, 2008 at 05:52:06PM -0600, Tom Tromey wrote: > How this works: > > I added a new expression_completer and set this as the completion > function for various things, like "p". This tries to complete a field > expression, but falls back to the old location_completer (which is > what all these commands currently use). > > The expression completer sets a global flag, in_parse_field, and then > calls the expression parser. The parsers are expected to look at this > flag and call mark_struct_expression at the right time. Then, if this > was called, the generic code extracts the left-hand-side > subexpression, gets its type, and then does field completion as you'd > expect. > > I only updated the C parser. This code works by modifying the lexer > to return a special COMPLETE token in the important cases. Note that > it completes both "p foo.TAB" and "p foo.somethingTAB" correctly -- > the former by making an expression to a field with an empty name. Hi Tom, Here's a few things I noticed. We should complete after pointers and references, not just structs. Especially true for arrow, as that is not especially useful on structs. I am concerned that relying on the parser to parse incomplete expressions will not work out. The bodies won't be run until the rule is reduced, and there may not be enough context in what the user has typed to reduce the field completion. I'm not sure that's a real problem, but I worry that it will be fragile. Still - clearly better than nothing. I tried "p (*gdb_stdout)." and got no completions. On the testcase, "p (values[0])." works so I am not sure what the problem is. Could you take a look at it? Oh, and at least a NEWS entry would be good - and probably a manual change too. > into OUTEXPR, starting at index OUTBEG. > In the process, convert it from suffix to prefix form. */ > > -static void > +static int > prefixify_subexp (struct expression *inexpr, > struct expression *outexpr, int inend, int outbeg) > { Please document the return value. Otherwise, the code looks fine. -- Daniel Jacobowitz CodeSourcery