[RFA] new set/show multiple-choice-auto-select commands (take 2)
Joel Brobecker
brobecker@adacore.com
Wed Jan 16 13:56:00 GMT 2008
Hello,
This is a followup on:
[RFA] new set/show multiple-choice-auto-select commands
http://www.sourceware.org/ml/gdb-patches/2008-01/msg00007.html
I posted a patch that introduced this new option for Ada, but saying
that there was no reason to keep this option ada-specific.
Users sometimes enter expressions that are ambiguous. For instance,
printing the value of a variable that has homonyms. In that case,
the debugger doesn't know which of the variables the user meant,
and needs to ask the user by displaying a multiple-choice menu.
This option allows the user to configure the behavior of the debugger
so that, either:
1. The menu is still displayed as before (default behavior)
and the debugger waits for the user to select the choice he wants;
2. The menu is not displayed, and the choice "all" is assumed
(or an error is triggered if the choice "all" is not available);
3. The menu is not displayed and the choice "cancel" is always
assumed (resulting in an error).
The syntax is as follow:
(gdb) set multiple-choice-auto-select (off|all|cancel)
(gdb) show multiple-choice-auto-select
Markus will also be using this option for another case where
a multiple-choice menu might be useful.
2008-01-16 Joel Brobecker <brobecker@adacore.com>
* symtab.c (auto_select_off, auto_select_all, auto_select_cancel):
New constants.
(auto_select_modes, auto_select_mode): New static globals.
(multiple_choice_auto_select_mode): New function.
(_initialize_symtab): Add new multiple-choice-auto-select command.
* symtab.h (auto_select_off, auto_select_all, auto_select_cancel)
(multiple_choice_auto_select_mode): Add declarations.
* ada-lang.c (user_select_syms): Add handling of new
multiple-choice-auto-select setting.
Tested on x86-linux, no regression.
Documentation and a testcase will be send when this patch is approved.
OK to commit?
Thanks,
--
Joel
-------------- next part --------------
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,
"<unknown type>", (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"));
More information about the Gdb-patches
mailing list