public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <xdje42@gmail.com>
To: Gary Benson <gbenson@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3 v2] Implement completion limiting
Date: Mon, 24 Nov 2014 06:09:00 -0000	[thread overview]
Message-ID: <m3ioi5b06d.fsf@sspiff.org> (raw)
In-Reply-To: <1415271046-4957-4-git-send-email-gbenson@redhat.com> (Gary	Benson's message of "Thu, 6 Nov 2014 10:50:46 +0000")

Gary Benson <gbenson@redhat.com> writes:
> This commit adds a new exception, TOO_MANY_COMPLETIONS_ERROR, to be
> thrown whenever the completer has generated too many possibilities to
> be useful.  A new user-settable variable, "max_completions", is added
> to control this behaviour.  A top-level completion limit is added to
> complete_line_internal, as the final check to ensure the user never
> sees too many completions.  An additional limit is added to
> default_make_symbol_completion_list_break_on, to halt time-consuming
> symbol table expansions.
>
> gdb/ChangeLog:
>
> 	PR cli/9007
> 	PR cli/11920
> 	PR cli/15548
> 	* common/common-exceptions.h (enum errors)
> 	<TOO_MANY_COMPLETIONS_ERROR>: New value.
> 	* completer.h (completion_tracker_t): New typedef.
> 	(new_completion_tracker): New declaration.
> 	(make_cleanup_free_completion_tracker): Likewise.
> 	(maybe_limit_completions): Likewise.
> 	* completer.c [TUI]: Include tui/tui.h and tui/tui-io.h.
> 	(max_completions): New static variable.
> 	(new_completion_tracker): New function.
> 	(make_cleanup_free_completion_tracker): Likewise.
> 	(maybe_limit_completions): Likewise.
> 	(complete_line_internal): Do not generate any completions if
> 	max_completions = 0.  Limit the number of completions if
> 	max_completions >= 0.
> 	(line_completion_function): Handle TOO_MANY_COMPLETIONS_ERROR.
> 	(_initialize_completer): New declaration and function.
> 	* symtab.c: Include completer.h.
> 	(completion_tracker): New static variable.
> 	(completion_list_add_name): Call maybe_limit_completions.
> 	(default_make_symbol_completion_list_break_on): Maintain
> 	completion_tracker across calls to completion_list_add_name.
> 	* NEWS (New Options): Mention set/show max-completions.

Hi.

I only skimmed this patch set.
I want to give it a more thorough look
once the patch has been updated to apply
to current HEAD.

Thanks very much for working on this!

> +void
> +maybe_limit_completions (completion_tracker_t tracker, char *name)
> +{
> +  if (max_completions < 0)
> +    return;
> +
> +  if (tracker != NULL)
> +    {
> +      void **slot = htab_find_slot (tracker, name, INSERT);
> +
> +      if (*slot != HTAB_EMPTY_ENTRY)
> +	return;
> +
> +      if (htab_elements (tracker) <= max_completions)
> +	{
> +	  *slot = name;
> +	  return;
> +	}
> +    }
> +
> +  throw_error (TOO_MANY_COMPLETIONS_ERROR,
> +	       _("Too many possibilities."));
> +}

This will throw an error if tracker == NULL.
Is that intended?

  parent reply	other threads:[~2014-11-24  6:09 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-06 10:50 [PATCH 0/3 v2] Limit tab-completion result when list is large Gary Benson
2014-11-06 10:51 ` [PATCH 2/3 v2] Interleave completion list building with symbol table expansion Gary Benson
2014-11-06 10:51 ` [PATCH 1/3 v2] Add expansion_notify callback to expand_symtabs_matching Gary Benson
2014-11-06 10:51 ` [PATCH 3/3 v2] Implement completion limiting Gary Benson
2014-11-06 16:28   ` Eli Zaretskii
2014-11-21 10:46     ` Gary Benson
2014-11-24  6:09   ` Doug Evans [this message]
2014-11-27 13:16 [PATCH 0/3 v2] Abort completion when list becomes large Gary Benson
2014-11-27 13:16 ` [PATCH 3/3 v2] Implement completion limiting Gary Benson
2014-11-27 16:25   ` Eli Zaretskii
2014-12-05 23:54   ` Doug Evans
2014-12-10 12:22     ` Gary Benson
2014-12-10 16:25       ` Doug Evans
2015-01-03  2:09         ` Doug Evans
2015-01-07  8:44           ` Gary Benson
2015-01-09  1:29             ` Doug Evans
2015-01-10  2:32             ` Doug Evans
2015-01-10  9:23               ` Eli Zaretskii
2015-01-12 18:50                 ` Doug Evans
2015-01-15 15:39                   ` Gary Benson
2015-01-23  7:32                     ` Doug Evans
2015-01-23 10:59                       ` Eli Zaretskii
2015-01-23 16:38                         ` Doug Evans
2015-01-23 16:49                           ` Eli Zaretskii
2015-01-23 20:28                             ` Doug Evans
2015-01-24  1:55                               ` Eli Zaretskii
2015-01-24  8:50                                 ` Doug Evans
2015-01-24 14:12                                   ` Eli Zaretskii
2015-01-25 15:55                                     ` Doug Evans
2015-01-25 19:14                                       ` Eli Zaretskii

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=m3ioi5b06d.fsf@sspiff.org \
    --to=xdje42@gmail.com \
    --cc=gbenson@redhat.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).