This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] new set/show multiple-choice-auto-select commands (take 2)
- From: Markus Deuling <deuling at de dot ibm dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 17 Jan 2008 07:35:09 +0100
- Subject: Re: [RFA] new set/show multiple-choice-auto-select commands (take 2)
- References: <20080116135551.GE20837@adacore.com>
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 <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.
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
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
*);