Index: symtab.c =================================================================== --- symtab.c (revision 131) +++ symtab.c (revision 132) @@ -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_off; + +/* 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; @@ -4418,6 +4442,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 131) +++ symtab.h (revision 132) @@ -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 131) +++ ada-lang.c (revision 132) @@ -3362,12 +3362,22 @@ 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 + || (auto_select == auto_select_all && max_results <= 1)) + 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 == auto_select_all) + return nsyms; + printf_unfiltered (_("[0] cancel\n")); if (max_results > 1) printf_unfiltered (_("[1] all\n"));