[patch]: User choice for multiply-defined symbols

Markus Deuling deuling@de.ibm.com
Mon May 5 08:36:00 GMT 2008


Hello,

the following patch makes use of the new "multiple-symbols" command introduced by Joel.

If there is more than one symbol associated with a name and the multiple-symbols flag is set
to "ask", the user is asked to choose which of the symbols to use:

(gdb) break foo
[0] cancel
[1] all
[2] foo at ../../../../src/gdb/testsuite/gdb.base/multiple_symbols_mod.c:5
[3] foo at ../../../../src/gdb/testsuite/gdb.base/multiple_symbols.c:14
> 3
Breakpoint 6 at 0x100004b0: file ../../../../src/gdb/testsuite/gdb.base/multiple_symbols.c, line 14.

I extended "search_symbols" by a distinct flag. If set the new function "distinct_search_syms" is called
before returning the search result. As the name says, this function removes duplicates from the search result.

For exmaple:

If GDB debugs a threaded application with a symbol "foo" in every thread, there would be a user choice like:

[0] cancel
[1] all
[2] foo at ../../../../src/gdb/testsuite/gdb.base/multiple_symbols_mod.c:5
[3] foo at ../../../../src/gdb/testsuite/gdb.base/multiple_symbols_mod.c:5
[4] foo at ../../../../src/gdb/testsuite/gdb.base/multiple_symbols_mod.c:5

If the user then chooses for example 2, a new breakpoint for "multiple_symbols_mod.c:5" would be set, which results
in a multi-location breakpoint in every thread. This is not such a big problem, but if the user chooses all symbols,
a multi-location breakpoint is created for each of the symbols above :-) This results in n*n breakpoints.

This patch also contains a new testcase to cover this functionality. I'd like to hear your opinion about this feature.
Is it ok for mainline?


ChangeLog:

	* linespec.c (decode_variable): Allow user to choose multiply-defined
	symbols if found.
	* symtab.c (symbol_search_equal, distinct_search_syms): New function.
	(search_symbols): Add new parameter distinct. Call distinct_search_syms
	if set. Update caller.
	* symtab.h (search_symbols): Add new parameter distinct.

ChangeLog Testsuite:

	* gdb.base/multiple_symbols.exp: New testcase for multiply-definded
	symbols.
	* gdb.base/multiple_symbols.c: Likewise.
	* gdb.base/multiple_symbols_mod.c: Likewise.

Regards,
Markus

-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diff-multi-symbol
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080505/55473d9d/attachment.ksh>


More information about the Gdb-patches mailing list