Index: symtab.c =================================================================== --- symtab.c (revision 141) +++ symtab.c (revision 142) @@ -124,6 +124,30 @@ void _initialize_symtab (void); /* */ +/* Allow the user to configure the debugger behavior with respect + to multiple-choice menus when more than one symbol matches during + a symbol lookup. */ + +const char const auto_select_off[] = "off"; +const char const auto_select_all[] = "all"; +const char const auto_select_cancel[] = "cancel"; +static const char *auto_select_modes[] = +{ + auto_select_off, + auto_select_all, + auto_select_cancel, + NULL +}; +static const char *auto_select_mode = auto_select_all; + +/* Read-only accessor to AUTO_SELECT_MODE. */ + +const char * +multiple_choice_auto_select_mode (void) +{ + return auto_select_mode; +} + /* The single non-language-specific builtin type */ struct type *builtin_type_error; @@ -4417,6 +4441,15 @@ All global and static variable names, or All global and static variable names, or those matching REGEXP.")); } + add_setshow_enum_cmd ("multiple-choice-auto-select", no_class, + auto_select_modes, &auto_select_mode, + _("\ +Set the debugger behavior when part of a command is ambiguous and\n\ +a multiple-choice menu would normally be printed."), _("\ +Show how the debugger handles ambiguities in commands."), _("\ +Valid values are \"off\", \"all\", \"cancel\", and the default is \"off\"."), + NULL, NULL, &setlist, &showlist); + /* Initialize the one built-in type that isn't language dependent... */ builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0, "", (struct objfile *) NULL); Index: symtab.h =================================================================== --- symtab.h (revision 141) +++ symtab.h (revision 142) @@ -1005,6 +1005,12 @@ extern int asm_demangle; /* symtab.c lookup functions */ +extern const char const auto_select_off[]; +extern const char const auto_select_all[]; +extern const char const auto_select_cancel[]; + +const char *multiple_choice_auto_select_mode (void); + /* lookup a symbol table by source file name */ extern struct symtab *lookup_symtab (const char *); Index: ada-lang.c =================================================================== --- ada-lang.c (revision 141) +++ ada-lang.c (revision 142) @@ -3362,12 +3362,24 @@ user_select_syms (struct ada_symbol_info int *chosen = (int *) alloca (sizeof (int) * nsyms); int n_chosen; int first_choice = (max_results == 1) ? 1 : 2; + const char *auto_select = multiple_choice_auto_select_mode (); if (max_results < 1) error (_("Request to select 0 symbols!")); if (nsyms <= 1) return nsyms; + if (auto_select == auto_select_cancel) + error (_("\ +canceled because the command is ambiguous and the multiple-choice menu\n\ +has been deactivated. See set/show multiple-choice-auto-select.")); + + /* If auto_select_mode is "all", then return all possible symbols. + Only do that if more than one symbol can be selected, of course. + Otherwise, display the menu as usual. */ + if (auto_select == auto_select_all && max_results > 1) + return nsyms; + printf_unfiltered (_("[0] cancel\n")); if (max_results > 1) printf_unfiltered (_("[1] all\n")); Index: linespec.c =================================================================== --- linespec.c (revision 141) +++ linespec.c (revision 142) @@ -492,7 +492,13 @@ decode_line_2 (struct symbol *sym_arr[], char *symname; struct cleanup *old_chain; char **canonical_arr = (char **) NULL; + const char *auto_select = multiple_choice_auto_select_mode (); + if (auto_select == auto_select_cancel) + error (_("\ +canceled because the command is ambiguous and the multiple-choice menu\n\ +has been deactivated. See set/show multiple-choice-auto-select.")); + values.sals = (struct symtab_and_line *) alloca (nelts * sizeof (struct symtab_and_line)); return_values.sals = (struct symtab_and_line *) @@ -508,38 +514,52 @@ decode_line_2 (struct symbol *sym_arr[], } i = 0; - printf_unfiltered (_("[0] cancel\n[1] all\n")); while (i < nelts) { init_sal (&return_values.sals[i]); /* Initialize to zeroes. */ init_sal (&values.sals[i]); if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) - { - values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); - if (values.sals[i].symtab) - printf_unfiltered ("[%d] %s at %s:%d\n", - (i + 2), - SYMBOL_PRINT_NAME (sym_arr[i]), - values.sals[i].symtab->filename, - values.sals[i].line); - else - printf_unfiltered (_("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n"), - (i + 2), - SYMBOL_PRINT_NAME (sym_arr[i]), - values.sals[i].line); - - } - else - printf_unfiltered (_("?HERE\n")); + values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); i++; } - prompt = getenv ("PS2"); - if (prompt == NULL) + /* If auto_select_mode is "all", then do not print the multiple-choice + menu and act as if the user had chosen choice "1" (all). */ + if (auto_select == auto_select_all) + args = "1"; + else { - prompt = "> "; + i = 0; + printf_unfiltered (_("[0] cancel\n[1] all\n")); + while (i < nelts) + { + if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) + { + if (values.sals[i].symtab) + printf_unfiltered ("[%d] %s at %s:%d\n", + (i + 2), + SYMBOL_PRINT_NAME (sym_arr[i]), + values.sals[i].symtab->filename, + values.sals[i].line); + else + printf_unfiltered (_("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n"), + (i + 2), + SYMBOL_PRINT_NAME (sym_arr[i]), + values.sals[i].line); + + } + else + printf_unfiltered (_("?HERE\n")); + i++; + } + + prompt = getenv ("PS2"); + if (prompt == NULL) + { + prompt = "> "; + } + args = command_line_input (prompt, 0, "overload-choice"); } - args = command_line_input (prompt, 0, "overload-choice"); if (args == 0 || *args == 0) error_no_arg (_("one or more choice numbers"));