[RFA] Improve completion of locations

Eli Zaretskii eliz@is.elta.co.il
Fri May 11 23:03:00 GMT 2001


> From: Elena Zannoni <ezannoni@cygnus.com>
> Date: Sat, 12 May 2001 00:17:54 -0400
> 
> I was wondering how readline would get this right in case of
> completion on filenames. I had a closer look, and also in that case it
> gets it wrong. '.' is a word-break character, but not a filename-break
> character. The first time rl_complete() is invoked by pressing TAB,
> readline has the set of work-break characters installed. So it ends up
> calling line_completion_function() with an empty string, just like
> above.  But line completion function switches the set of break chars
> from under readline's nose, installing the file-break ones, and
> basically redoing what readline got wrong before. So later on, gdb
> will try to complete on 'symtab.' and get it right. Fascinating.

Indeed.  What this means is the the M-TAB completion, which doesn't
get the second chance, sometimes gets its act wrong.  This problem was
there since day one.

> BTW, I was playing with an older gdb, and a TAB after 'symtab.'
> wasn't doing anything. Somehow the behavior has changed in the last
> year.

What version of GDB was that?  I tried all the way down to 4.18, and
it still offers all the possible symbols given "symtab.<TAB>".  It
just that older versions take about forever to grind through all the
symbols, so you might think GDB is just sitting there idling.  Dan's
patch about a month ago made that code much, much faster.

>  > I'd be glad to make this more smart, but it's not simple.  By far the
>  > nastiest problem is that Readline decides what is the word which is
>  > being completed on _before_ our completion function is called.  This
>  > defeats many nifty tricks we could do using the context of the
>  > completion.
> 
> Yes. If we could decide what set of break characters to install before the
> tab is hit, it would be already a step in the right direction.
> Or make readline's find_completion_word() a hook for a gdb function.

Something like that.  Readline must cooperate with GDB better, for our
completion to be less error prone.  Right now, Readline does not
support the kind of mode that GDB needs, where it completes on
different types of objects and therefore needs to change the
word-constituent characters.  Bash completes only on file names, so it
never needs these complications.

I think we need to ask Readline maintainers to add a couple of
features in the next releases.

> Anyway, now that I've looked stuff over more in detail, I think this
> can go in. (With the fix for the ':').  But Fernando is the
> completer.c maintainer, so we must give him a chance to go over the
> patch as well.

Yes, I'm waiting for Fernando's approval.



More information about the Gdb-patches mailing list