From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8589 invoked by alias); 16 Jan 2008 13:56:31 -0000 Received: (qmail 8577 invoked by uid 22791); 16 Jan 2008 13:56:30 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 16 Jan 2008 13:56:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 0CFE52A9644 for ; Wed, 16 Jan 2008 08:56:01 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GoM2jGFqR86n for ; Wed, 16 Jan 2008 08:56:00 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 385D92A9643 for ; Wed, 16 Jan 2008 08:55:59 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id D0D63E7ACB; Wed, 16 Jan 2008 05:55:51 -0800 (PST) Date: Wed, 16 Jan 2008 13:56:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA] new set/show multiple-choice-auto-select commands (take 2) Message-ID: <20080116135551.GE20837@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="UugvWAfsgieZRqgk" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00401.txt.bz2 --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1987 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 * 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 --UugvWAfsgieZRqgk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="auto-select.diff" Content-length: 3209 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")); --UugvWAfsgieZRqgk--