From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2114 invoked by alias); 1 Jan 2008 14:36:56 -0000 Received: (qmail 2105 invoked by uid 22791); 1 Jan 2008 14:36:55 -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; Tue, 01 Jan 2008 14:36:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 81EC82A962F for ; Tue, 1 Jan 2008 09:36:30 -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 30rI3bY2gmxS for ; Tue, 1 Jan 2008 09:36:30 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id CF0E32A95F8 for ; Tue, 1 Jan 2008 09:36:28 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id A6041E7ACB; Tue, 1 Jan 2008 06:36:21 -0800 (PST) Date: Tue, 01 Jan 2008 14:36:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA] new set/show multiple-choice-auto-select commands Message-ID: <20080101143621.GC24843@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="GPJrCs/72TxItFYR" 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/msg00007.txt.bz2 --GPJrCs/72TxItFYR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1962 Hello, The user sometimes enters an expression which is ambiguous. For instance, the name of a function or a variable which has homonyms... In that case, the debugger is expected to display the list of possibilities and ask the user to choose which one he meant (with an additional 2 possible choices: "all" and "cancel"). This has been a very practical solution when in interactive mode (ie when a user is driving the session), but an annoyance when driving the debugger with a tool. So we added a new set/show command that allowed the user to configure the behavior of the debugger so that: 1. Either the menu is still displayed (default behavior); 2. The choice "all" is always automatically selected; 3. The choice "cancel" is always automatically selected. Some of the AdaCore engineers actually disliked the menu and started using this new command to always select all options, even in interactive mode. The syntax is as follow: (gdb) set multiple-choice-auto-select (off|all|cancel) (gdb) show multiple-choice-auto-select As said above, the default is "off", which preserves the current behavior by default. The reason why I am proposing this as an RFA is that I'm wondering if others might be interested in sharing this setting. I noticed from a comment that Paul wrote that menus are also printed by linespec:decode_line_2. Otherwise, I'm happy to keep it in ada-lang.c (less work for me :-). 2008-01-01 Joel Brobecker * ada-lang.c (auto_select_off, auto_select_all, auto_select_cancel) (auto_select_choices, auto_select_choice): New static global variables. (user_select_syms): Add handling of new multiple-choice-auto-select setting. (_initialize_ada_language): Add new multiple-choice-auto-select option. Tested on x86-linux. No regression. A testcase and documentation will follow as soon as we agree on the patch itself. Thoughts? Thanks, -- Joel --GPJrCs/72TxItFYR Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="auto-select.diff" Content-length: 2125 Index: ada-lang.c =================================================================== --- ada-lang.c (revision 32) +++ ada-lang.c (revision 33) @@ -293,6 +293,21 @@ static void ada_forward_operator_length /* Maximum-sized dynamic type. */ static unsigned int varsize_limit; +/* Allow the user to configure the debugger behavior with respect + to multiple-choice menus. */ + +static const char auto_select_off[] = "off"; +static const char auto_select_all[] = "all"; +static const char auto_select_cancel[] = "cancel"; +static const char *auto_select_choices[] = +{ + auto_select_off, + auto_select_all, + auto_select_cancel, + NULL +}; +static const char *auto_select_choice = auto_select_off; + /* FIXME: brobecker/2003-09-17: No longer a const because it is returned by a function that does not return a const char *. */ static char *ada_completer_word_break_characters = @@ -3341,6 +3356,15 @@ user_select_syms (struct ada_symbol_info if (nsyms <= 1) return nsyms; + if (auto_select_choice == auto_select_cancel + || (auto_select_choice == 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_choice == auto_select_all) + return nsyms; + printf_unfiltered (_("[0] cancel\n")); if (max_results > 1) printf_unfiltered (_("[1] all\n")); @@ -10993,6 +11017,15 @@ _initialize_ada_language (void) varsize_limit = 65536; + add_setshow_enum_cmd ("multiple-choice-auto-select", no_class, + auto_select_choices, &auto_select_choice, + _("\ +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); + obstack_init (&symbol_list_obstack); decoded_names_store = htab_create_alloc --GPJrCs/72TxItFYR--