This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFA: Search for symbol names the same way they're hashed.
On Wed, 2 Oct 2002 14:05:15 -0400, Daniel Jacobowitz <drow@mvista.com> said:
> (What is the right solution? Simple. While lookup_block_symbol
> presumably only returns one symbol, all of GDB needs to be aware
> that lookup_symbol can find more than one. We need a way to
> distinguish them (for static functions in multiple files - often all
> with the same filename! This happens in BFD) and a way to collapse
> them (for cloned constructors, breaking on one should probably break
> on all of them).
Yup. For what it's worth, in my current version of the dictionary
stuff for blocks, I've basically given up on having a dict_lookup
function that returns "the" match: instead, I have
dict_iter_name_{first,next} that allow you to iterate through all
entries in a dictionary whose SYMBOL_BEST_NAME strcmp_iw's to what
you're looking for.
Of course, I still have lookup_block_symbol return a single value, so,
for example, the relevant code in the non-function case for my version
of lookup_block_symbol looks like this:
if (!BLOCK_FUNCTION (block))
{
for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
sym; sym = dict_iter_name_next (name, &iter))
{
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
? strcmp (SYMBOL_NAME (sym), mangled_name) == 0 : 1))
return sym;
}
return NULL;
}
(the BLOCK_FUNCTION (block) case is a little more complicated), but it
should be friendly to adding variants that might find multiple
symbols.
David Carlton
carlton@math.stanford.edu