* [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs
@ 2014-12-03 17:07 Jan Kratochvil
2014-12-05 12:37 ` Yao Qi
2014-12-05 18:03 ` Doug Evans
0 siblings, 2 replies; 4+ messages in thread
From: Jan Kratochvil @ 2014-12-03 17:07 UTC (permalink / raw)
To: gdb-patches
2014-12-03 Jan Kratochvil <jan.kratochvil@redhat.com>
* symtab.c (lookup_symbol_in_objfile_symtabs): New declaration.
(lookup_global_symbol_from_objfile): Call it.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 79035f6..1951c97 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -79,6 +79,11 @@ struct symbol *lookup_local_symbol (const char *name,
const domain_enum domain,
enum language language);
+static struct symbol *
+ lookup_symbol_in_objfile_symtabs (const struct objfile *objfile,
+ int block_index, const char *name,
+ const domain_enum domain);
+
static
struct symbol *lookup_symbol_via_quick_fns (struct objfile *objfile,
int block_index,
@@ -1546,24 +1551,12 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
objfile;
objfile = objfile_separate_debug_iterate (main_objfile, objfile))
{
- struct compunit_symtab *cust;
struct symbol *sym;
-
- /* Go through symtabs. */
- ALL_OBJFILE_COMPUNITS (objfile, cust)
- {
- const struct blockvector *bv;
- const struct block *block;
-
- bv = COMPUNIT_BLOCKVECTOR (cust);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = block_lookup_symbol (block, name, domain);
- if (sym)
- {
- block_found = block;
- return fixup_symbol_section (sym, objfile);
- }
- }
+
+ sym = lookup_symbol_in_objfile_symtabs (objfile, GLOBAL_BLOCK, name,
+ domain);
+ if (sym != NULL)
+ return sym;
sym = lookup_symbol_via_quick_fns ((struct objfile *) objfile,
GLOBAL_BLOCK, name, domain);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs
2014-12-03 17:07 [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs Jan Kratochvil
@ 2014-12-05 12:37 ` Yao Qi
2014-12-05 15:15 ` Jan Kratochvil
2014-12-05 18:03 ` Doug Evans
1 sibling, 1 reply; 4+ messages in thread
From: Yao Qi @ 2014-12-05 12:37 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
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'. Is it because we are iterating COMPUNITS
(primary symtab?) so block_lookup_symbol is equivalent to
block_lookup_symbol_primary under this context?
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs
2014-12-05 12:37 ` Yao Qi
@ 2014-12-05 15:15 ` Jan Kratochvil
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2014-12-05 15:15 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs
2014-12-03 17:07 [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs Jan Kratochvil
2014-12-05 12:37 ` Yao Qi
@ 2014-12-05 18:03 ` Doug Evans
1 sibling, 0 replies; 4+ messages in thread
From: Doug Evans @ 2014-12-05 18:03 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 2014-12-03 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * symtab.c (lookup_symbol_in_objfile_symtabs): New declaration.
> (lookup_global_symbol_from_objfile): Call it.
>
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 79035f6..1951c97 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -79,6 +79,11 @@ struct symbol *lookup_local_symbol (const char *name,
> const domain_enum domain,
> enum language language);
>
> +static struct symbol *
> + lookup_symbol_in_objfile_symtabs (const struct objfile *objfile,
> + int block_index, const char *name,
> + const domain_enum domain);
> +
> static
> struct symbol *lookup_symbol_via_quick_fns (struct objfile *objfile,
> int block_index,
> @@ -1546,24 +1551,12 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
> objfile;
> objfile = objfile_separate_debug_iterate (main_objfile, objfile))
> {
> - struct compunit_symtab *cust;
> struct symbol *sym;
> -
> - /* Go through symtabs. */
> - ALL_OBJFILE_COMPUNITS (objfile, cust)
> - {
> - const struct blockvector *bv;
> - const struct block *block;
> -
> - bv = COMPUNIT_BLOCKVECTOR (cust);
> - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
> - sym = block_lookup_symbol (block, name, domain);
> - if (sym)
> - {
> - block_found = block;
> - return fixup_symbol_section (sym, objfile);
> - }
> - }
> +
> + sym = lookup_symbol_in_objfile_symtabs (objfile, GLOBAL_BLOCK, name,
> + domain);
> + if (sym != NULL)
> + return sym;
>
> sym = lookup_symbol_via_quick_fns ((struct objfile *) objfile,
> GLOBAL_BLOCK, name, domain);
LGTM.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-05 18:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-03 17:07 [patch +const 2/2] Unify lookup_symbol_in_objfile_symtabs Jan Kratochvil
2014-12-05 12:37 ` Yao Qi
2014-12-05 15:15 ` Jan Kratochvil
2014-12-05 18:03 ` Doug Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox