This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 5 Dec 2014 16:15:04 +0100
- Subject: Re: [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs
- Authentication-results: sourceware.org; auth=none
- References: <20141203170703 dot GC25020 at host2 dot jankratochvil dot net> <87d27ygtmn dot fsf at codesourcery dot com>
On Fri, 05 Dec 2014 13:37:20 +0100, Yao Qi wrote:
> Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> > - sym = block_lookup_symbol (block, name, domain);
>
> We are using 'block_lookup_symbol' here...
>
> > - if (sym)
> > - {
> > - block_found = block;
> > - return fixup_symbol_section (sym, objfile);
> > - }
> > - }
> > +
> > + sym = lookup_symbol_in_objfile_symtabs (objfile, GLOBAL_BLOCK, name,
> > + domain);
>
> ... but lookup_symbol_in_objfile_symtabs calls
> 'block_lookup_symbol_primary'.
It has changed yesterday by:
commit ba715d7fe49c8a59660fbd571b935b29eb7cfbdb
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Accelerate lookup_symbol_aux_objfile 85x
- sym = block_lookup_symbol (block, name, domain);
+ sym = block_lookup_symbol_primary (block, name, domain);
> Is it because we are iterating COMPUNITS
> (primary symtab?) so block_lookup_symbol is equivalent to
> block_lookup_symbol_primary under this context?
That's right, block_lookup_symbol_primary()'s additional requirement over
block_lookup_symbol() is:
Function is useful if one iterates all global/static blocks of an
objfile.
Which is satisfied both in lookup_symbol_in_objfile_symtabs() and in
lookup_global_symbol_from_objfile() thanks to their's ALL_OBJFILE_COMPUNITS.
In fact after reverting that ba715d7fe49c8a59660fbd571b935b29eb7cfbdb above
the lines of code were exactly the same.
So instead of accelerating both lookup_symbol_in_objfile_symtabs() and
lookup_global_symbol_from_objfile() I just accelerated
lookup_symbol_in_objfile_symtabs() and I am proposing to reuse
lookup_symbol_in_objfile_symtabs() in lookup_global_symbol_from_objfile()
instead. In fact such unification would already save some lines of code even
before the checked-in acceleration patch above.
Thanks,
Jan