From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8992 invoked by alias); 17 Jan 2008 06:37:34 -0000 Received: (qmail 8983 invoked by uid 22791); 17 Jan 2008 06:37:33 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate1.de.ibm.com (HELO mtagate1.de.ibm.com) (195.212.29.150) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 17 Jan 2008 06:37:06 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.8/8.13.8) with ESMTP id m0H6b2h4196204 for ; Thu, 17 Jan 2008 06:37:02 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m0H6b2o32961544 for ; Thu, 17 Jan 2008 07:37:02 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m0H6b2vu021505 for ; Thu, 17 Jan 2008 07:37:02 +0100 Received: from bbkeks.de.ibm.com (dyn-9-152-248-46.boeblingen.de.ibm.com [9.152.248.46]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m0H6b0LD021477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 Jan 2008 07:37:02 +0100 Message-ID: <478EF71D.4060007@de.ibm.com> Date: Thu, 17 Jan 2008 06:37:00 -0000 From: Markus Deuling User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Joel Brobecker CC: gdb-patches@sourceware.org Subject: Re: [RFA] new set/show multiple-choice-auto-select commands (take 2) References: <20080116135551.GE20837@adacore.com> In-Reply-To: <20080116135551.GE20837@adacore.com> Content-Type: multipart/mixed; boundary="------------000805080502090104040800" 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/msg00430.txt.bz2 This is a multi-part message in MIME format. --------------000805080502090104040800 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 3346 Joel Brobecker schrieb: > 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. > Hi Joel, I integrated my patch to use your command and it works fine ;-) (gdb) br foo2 Breakpoint 2 at 0xf86444: file /home/deuling/gdb/dev/gdb/testsuite/gdb.base/solib-symbol-lib.c, line 29. (gdb) set multiple-choice-auto-select all (gdb) br foo2 [0] cancel [1] all [2] foo2 at /home/deuling/gdb/dev/gdb/testsuite/gdb.base/solib-symbol-main.c:39 [3] foo2 at /home/deuling/gdb/dev/gdb/testsuite/gdb.base/solib-symbol-lib.c:29 > 2 3 Breakpoint 3 at 0x8048523: file /home/deuling/gdb/dev/gdb/testsuite/gdb.base/solib-symbol-main.c, line 39. Note: breakpoint 2 also set at pc 0xf86444. Breakpoint 4 at 0xf86444: file /home/deuling/gdb/dev/gdb/testsuite/gdb.base/solib-symbol-lib.c, line 29. warning: Multiple breakpoints were set. Use the "delete" command to delete unwanted breakpoints. (gdb) I only see one issue. The the commands state is either off or all (I now ignore cancel). If set to all, my routines offer the user choice but doesn't choose all symbols right now !. Would it be possible to add a "on" state to the command which then would give the user a choice. I would adapt my patch then a bit. If set to "all" automagically all symbols found are taken, if set to "on" the user is given a choice. What do you think? I attached the adapted patch in the current version. Regards, Markus -- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com --------------000805080502090104040800 Content-Type: text/plain; name="new-diff-user-choice-symbols" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="new-diff-user-choice-symbols" Content-length: 2287 diff -urpN src/gdb/linespec.c dev/gdb/linespec.c --- src/gdb/linespec.c 2008-01-01 23:53:11.000000000 +0100 +++ dev/gdb/linespec.c 2008-01-17 07:19:54.000000000 +0100 @@ -1725,8 +1725,36 @@ decode_variable (char *copy, int funfirs struct symbol *sym; /* The symtab that SYM was found in. */ struct symtab *sym_symtab; - struct minimal_symbol *msymbol; + const char *auto_select = multiple_choice_auto_select_mode (); + + + if (auto_select == auto_select_all && !file_symtab) + { + int nelts; + struct symbol_search *symbols, *p; + struct cleanup *chain; + struct symbol **sym_arr; + + search_symbols (copy, FUNCTIONS_DOMAIN, 0, (char **) NULL, &symbols); + chain = make_cleanup_free_search_symbols (symbols); + + nelts = count_symbols (symbols); + if (nelts > 1) + { + int idx = 0; + sym_arr = xmalloc ((nelts) * sizeof (struct symbol *)); + make_cleanup (xfree, sym_arr); + + for (p = symbols; p != NULL; p = p->next) + if (p->symbol) + sym_arr[idx++] = p->symbol; + + return decode_line_2 (sym_arr, idx, funfirstline, + canonical); + } + } + sym = lookup_symbol (copy, (file_symtab diff -urpN src/gdb/symtab.c dev/gdb/symtab.c --- src/gdb/symtab.c 2008-01-03 22:30:13.000000000 +0100 +++ dev/gdb/symtab.c 2008-01-17 07:22:07.000000000 +0100 @@ -2778,6 +2802,22 @@ file_matches (char *file, char *files[], return 0; } + +/* Returns number of elements in search reusult SYMBOLS. */ + +int +count_symbols (struct symbol_search *symbols) +{ + struct symbol_search *p; + int nr = 0; + + for (p = symbols; p != NULL; p = p->next) + nr++; + + return nr; +} + + /* Free any memory associated with a search. */ void free_search_symbols (struct symbol_search *symbols) diff -urpN src/gdb/symtab.h dev/gdb/symtab.h --- src/gdb/symtab.h 2008-01-01 23:53:13.000000000 +0100 +++ dev/gdb/symtab.h 2008-01-17 07:22:45.000000000 +0100 @@ -1385,6 +1391,7 @@ struct symbol_search extern void search_symbols (char *, domain_enum, int, char **, struct symbol_search **); +extern int count_symbols (struct symbol_search *); extern void free_search_symbols (struct symbol_search *); extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search *); --------------000805080502090104040800--