* Re: [PATCH v2 16/18] Make the completion API completely opaque.
@ 2015-05-21 23:52 Doug Evans
0 siblings, 0 replies; 2+ messages in thread
From: Doug Evans @ 2015-05-21 23:52 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
Keith Seitz writes:
> Now that the completion API is passing around a structure holding
> its internal data, there is no need to expose any of this data and
> other settings to other modules.
>
> This patch removes global access to max_completions and
> introduces a new API function, get_maximum_completions (void), which
> other modules may use to query the current completion maximum.
>
> The API will be expanded as necessary in subsequent patches.
>
> gdb/ChangeLog
>
> * cli/cli-cmds.c (complete_command): Use get_maximum_completions
> instead of accessing the global max_completions.
> * completer.c (max_completions): Move definition earlier and
> make static.
> (get_maximum_completions): New function.
> (throw_max_completions_reached_error): Add comment.
> * completer.h (max_completions): Remove declaration.
> (get_maximum_completions): New declaration.
LGTM.
Note though that it's not uncommon to expose gdb parameters
via a global.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2 00/18] Implement full completer limiting
@ 2015-05-04 19:18 Keith Seitz
2015-05-04 19:18 ` [PATCH v2 16/18] Make the completion API completely opaque Keith Seitz
0 siblings, 1 reply; 2+ messages in thread
From: Keith Seitz @ 2015-05-04 19:18 UTC (permalink / raw)
To: gdb-patches
Subject: Implement full completer limiting
This series (v2) of patches is essentially a rewrite of the completion API
to enable better/more consistent completion-limiting.
Currently completer functions are not required to implement completion-
limiting. These functions will compute all possible completions and then
rely on complete_line to limit the result.
The main goal of this patchset is to require completer functions to
implement proper completion-limiting using maybe_add_completion. This
actually cleans up the completer API significantly and fixes at least one
serious bug (an assertion failure, gdb/17960).
The new API requires all completions to be added to the completion
list using maybe_add_completion:
void
my_completer_function (struct completer_data *cdata,
struct cmd_list_element *cmd,
const char *text, const char *prefix)
{
while (/* there are more completions to look for */)
{
char *match = xstrdup (a_completion_match);
if (add_completion (cdata, match)
== ADD_COMPLETION_MAX_REACHED)
return;
}
}
Each patch of the set has been tested regression-free against x86_64
linux, native and native-gdbserver.
---
Keith Seitz (18):
Add struct completer_data to the completion API.
Remove completion_tracker_t from the public completion API.
Implement completion limiting for complete_on_cmdlist.
Implement completion limiting for add_filename_to_list.
Implement completion limiting for ada_make_symbol_completion_list.
Implement completion limiting for condition_completer.
Implement completion limiting for filename_completer.
Implement completion limiting for signal_completer.
Implement completion limiting for interpreter_completer.
Implement completion limiting for cmdpy_completer.
Implement completion limiting for reg_or_group_completer.
Implement completion limiting for sim_command_completer.
Implement completion limiting for complete_on_enum.
Implement completion limiting in add_struct_fields.
Implement completion limiting for scmcmd_add_completion.
Make the completion API completely opaque.
Use the hashtable to accumulate completion results.
Remove the vector return result from the completion API.
gdb/ada-lang.c | 62 ++--
gdb/break-catch-syscall.c | 11 -
gdb/breakpoint.c | 22 +
gdb/cli/cli-cmds.c | 4
gdb/cli/cli-decode.c | 40 +-
gdb/command.h | 17 +
gdb/completer.c | 471 +++++++++++++++++-----------
gdb/completer.h | 110 +++----
gdb/corefile.c | 7
gdb/cp-abi.c | 7
gdb/f-lang.c | 8
gdb/guile/scm-cmd.c | 33 +-
gdb/infrun.c | 15 -
gdb/interps.c | 12 -
gdb/language.h | 8
gdb/python/py-cmd.c | 24 +
gdb/remote-sim.c | 10 -
gdb/symtab.c | 256 ++++++---------
gdb/symtab.h | 47 ++-
gdb/testsuite/gdb.ada/complete.exp | 144 ++++++++-
gdb/testsuite/gdb.ada/complete/foo.adb | 4
gdb/testsuite/gdb.ada/complete/pck.ads | 12 +
gdb/testsuite/gdb.base/break.c | 14 +
gdb/testsuite/gdb.base/break.exp | 4
gdb/testsuite/gdb.base/completion.exp | 206 ++++++++++++
gdb/testsuite/gdb.base/condbreak.exp | 70 ++++
gdb/testsuite/gdb.base/filesym.c | 4
gdb/testsuite/gdb.base/filesym.exp | 84 +++++
gdb/testsuite/gdb.base/filesym2.c | 24 +
gdb/testsuite/gdb.base/filesym3.c | 24 +
gdb/testsuite/gdb.base/filesym4.c | 24 +
gdb/testsuite/gdb.base/filesym5.c | 22 +
gdb/testsuite/gdb.cp/cpcompletion.exp | 55 +++
gdb/testsuite/gdb.cp/pr9594.cc | 28 ++
gdb/testsuite/gdb.guile/scm-cmd.exp | 24 +
gdb/testsuite/gdb.python/py-completion.exp | 45 +++
gdb/value.c | 14 -
gdb/value.h | 3
38 files changed, 1404 insertions(+), 565 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/filesym2.c
create mode 100644 gdb/testsuite/gdb.base/filesym3.c
create mode 100644 gdb/testsuite/gdb.base/filesym4.c
create mode 100644 gdb/testsuite/gdb.base/filesym5.c
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2 16/18] Make the completion API completely opaque.
2015-05-04 19:18 [PATCH v2 00/18] Implement full completer limiting Keith Seitz
@ 2015-05-04 19:18 ` Keith Seitz
0 siblings, 0 replies; 2+ messages in thread
From: Keith Seitz @ 2015-05-04 19:18 UTC (permalink / raw)
To: gdb-patches
Now that the completion API is passing around a structure holding
its internal data, there is no need to expose any of this data and
other settings to other modules.
This patch removes global access to max_completions and
introduces a new API function, get_maximum_completions (void), which
other modules may use to query the current completion maximum.
The API will be expanded as necessary in subsequent patches.
gdb/ChangeLog
* cli/cli-cmds.c (complete_command): Use get_maximum_completions
instead of accessing the global max_completions.
* completer.c (max_completions): Move definition earlier and
make static.
(get_maximum_completions): New function.
(throw_max_completions_reached_error): Add comment.
* completer.h (max_completions): Remove declaration.
(get_maximum_completions): New declaration.
---
gdb/cli/cli-cmds.c | 4 ++--
gdb/completer.c | 22 +++++++++++++++++-----
gdb/completer.h | 8 ++++----
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 2ec2dd3..a73a655 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -248,7 +248,7 @@ complete_command (char *arg, int from_tty)
dont_repeat ();
- if (max_completions == 0)
+ if (get_maximum_completions () == 0)
{
/* Only print this for non-mi frontends. An MI frontend may not
be able to handle this. */
@@ -307,7 +307,7 @@ complete_command (char *arg, int from_tty)
xfree (prev);
VEC_free (char_ptr, completions);
- if (size == max_completions)
+ if (size == get_maximum_completions ())
{
/* ARG_PREFIX and POINT are included in the output so that emacs
will include the message in the output. */
diff --git a/gdb/completer.c b/gdb/completer.c
index 44dd7e7..9a7af74 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -42,6 +42,13 @@
#include "completer.h"
+/* Maximum number of candidates to consider before the completer
+ bails by throwing MAX_COMPLETIONS_REACHED_ERROR. Negative values
+ disable limiting. */
+
+#define DEFAULT_MAX_COMPLETIONS 200
+static int max_completions = DEFAULT_MAX_COMPLETIONS;
+
/* Prototypes for local functions. */
static
char *line_completion_function (const char *text, int matches,
@@ -833,11 +840,6 @@ complete_line_internal (struct completer_data *cdata,
return list;
}
-/* See completer.h. */
-
-#define DEFAULT_MAX_COMPLETIONS 200
-int max_completions = DEFAULT_MAX_COMPLETIONS;
-
/* Allocate a new completer data structure. */
static struct completer_data *
@@ -901,6 +903,14 @@ maybe_add_completion (struct completer_data *cdata, char *name)
/* See completer.h. */
+int
+get_maximum_completions (void)
+{
+ return max_completions;
+}
+
+/* See completer.h. */
+
enum add_completion_status
add_completion (struct completer_data *cdata, VEC (char_ptr) **result,
char *name)
@@ -927,6 +937,8 @@ add_completion (struct completer_data *cdata, VEC (char_ptr) **result,
return ADD_COMPLETION_OK;
}
+/* See completer.h. */
+
void
throw_max_completions_reached_error (void)
{
diff --git a/gdb/completer.h b/gdb/completer.h
index 8b20ca5..29ff2e9 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -122,11 +122,11 @@ extern const char *skip_quoted_chars (const char *, const char *,
extern const char *skip_quoted (const char *);
-/* Maximum number of candidates to consider before the completer
- bails by throwing MAX_COMPLETIONS_REACHED_ERROR. Negative values
- disable limiting. */
+/* Get the maximum number of completions that are permitted before the
+ completer throws a MAX_COMPLETIONS_REACHED_ERROR. Negative values
+ mean completion limiting is entirely disabled. */
-extern int max_completions;
+extern int get_maximum_completions (void);
/* Return values for add_completion. */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-21 23:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21 23:52 [PATCH v2 16/18] Make the completion API completely opaque Doug Evans
-- strict thread matches above, loose matches on Subject: below --
2015-05-04 19:18 [PATCH v2 00/18] Implement full completer limiting Keith Seitz
2015-05-04 19:18 ` [PATCH v2 16/18] Make the completion API completely opaque Keith Seitz
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).