This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Patch to limit field name completion candidates


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).<tab>" and got no completions.  On the
testcase, "p (values[0]).<tab>" 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]