--- gdb-6.8/gdb/symtab.c 2008-02-05 17:17:40.000000000 -0500 +++ gdb-6.8.new/gdb/symtab.c 2008-11-28 18:43:46.000000000 -0500 @@ -58,6 +58,16 @@ #include "gdb_assert.h" #include "solist.h" +unsigned int max_completion_results = UINT_MAX; +static void +show_max_completion_results (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("\ +The maximum number of command-line completion results that will be printed is %s.\n"), + value); +} + /* Prototypes for local functions */ static void completion_list_add_name (char *, char *, int, char *, char *); @@ -3357,6 +3373,7 @@ /* Helper routine for make_symbol_completion_list. */ +static unsigned int return_val_max; static int return_val_size; static int return_val_index; static char **return_val; @@ -3378,10 +3395,11 @@ /* clip symbols that cannot match */ + if (return_val_index == return_val_max) + return; + if (strncmp (symname, sym_text, sym_text_len) != 0) - { - return; - } + return; /* We have a match for a completion, so add SYMNAME to the current list of matches. Note that the name is moved to freshly malloc'd space. */ @@ -3598,6 +3616,8 @@ sym_text_len = strlen (sym_text); + + return_val_max = max_completion_results; return_val_size = 100; return_val_index = 0; return_val = (char **) xmalloc ((return_val_size + 1) * sizeof (char *)); @@ -3784,6 +3804,7 @@ sym_text_len = strlen (sym_text); + return_val_max = max_completion_results; return_val_size = 10; return_val_index = 0; return_val = (char **) xmalloc ((return_val_size + 1) * sizeof (char *)); @@ -4381,6 +4406,8 @@ void _initialize_symtab (void) { + struct cmd_list_element *cmd; + add_info ("variables", variables_info, _("\ All global and static variable names, or those matching REGEXP.")); if (dbx_commands) @@ -4408,6 +4435,13 @@ add_com ("rbreak", class_breakpoint, rbreak_command, _("Set a breakpoint for all functions matching REGEXP.")); + add_setshow_uinteger_cmd ("max-completion-results", class_obscure, &max_completion_results, _("\ +Set the maximum number of entries to be returned from a completion operation."), _("\ +Show the maximum number of entries to be returned from a completion operation."), NULL, + NULL, + show_max_completion_results, + &setlist, &showlist); + if (xdb_commands) { add_com ("lf", class_info, sources_info, --- gdb-6.8/gdb/cp-support.c 2008-01-01 17:53:09.000000000 -0500 +++ gdb-6.8.new/gdb/cp-support.c 2008-11-28 18:20:59.000000000 -0500 @@ -38,6 +38,8 @@ #define d_left(dc) (dc)->u.s_binary.left #define d_right(dc) (dc)->u.s_binary.right +extern unsigned int max_completion_results; + /* Functions related to demangled name parsing. */ static unsigned int cp_find_first_component_aux (const char *name, @@ -47,6 +49,7 @@ /* Functions/variables related to overload resolution. */ +static unsigned int sym_return_val_max; static int sym_return_val_size; static int sym_return_val_index; static struct symbol **sym_return_val; @@ -638,6 +641,9 @@ int i; char *sym_name; + if (sym_return_val_index >= sym_return_val_max) + return; + /* If there is no type information, we can't do anything, so skip */ if (SYMBOL_TYPE (sym) == NULL) return; @@ -682,6 +688,7 @@ { struct cleanup *old_cleanups; + sym_return_val_max = max_completion_results; sym_return_val_size = 100; sym_return_val_index = 0; sym_return_val = xmalloc ((sym_return_val_size + 1) *