Implement completion limiting

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.

gdb/doc/ChangeLog:

	* gdb.texinfo (Command Completion): Document new
	"set/show max-completions" option.

gdb/testsuite/ChangeLog:

	* gdb.base/completion.exp: Disable completion limiting for
	existing tests.  Add new tests to check completion limiting.
	* gdb.linespec/ls-errs.exp: Disable completion limiting.