From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2835 invoked by alias); 24 Nov 2014 06:09:21 -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 2823 invoked by uid 89); 24 Nov 2014 06:09:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f181.google.com Received: from mail-pd0-f181.google.com (HELO mail-pd0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 24 Nov 2014 06:09:19 +0000 Received: by mail-pd0-f181.google.com with SMTP id z10so9035424pdj.26 for ; Sun, 23 Nov 2014 22:09:18 -0800 (PST) X-Received: by 10.68.220.169 with SMTP id px9mr29977783pbc.146.1416809357954; Sun, 23 Nov 2014 22:09:17 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id j10sm1553573pdr.92.2014.11.23.22.09.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Nov 2014 22:09:16 -0800 (PST) From: Doug Evans To: Gary Benson Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/3 v2] Implement completion limiting References: <1415271046-4957-1-git-send-email-gbenson@redhat.com> <1415271046-4957-4-git-send-email-gbenson@redhat.com> Date: Mon, 24 Nov 2014 06:09:00 -0000 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") Message-ID: 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/msg00597.txt.bz2 Gary Benson 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) > : 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?