Re: [PATCH 1/3 v2] Add expansion_notify callback to expand_symtabs_matching

Doug Evans
2014-12-05T07:56:11Z

Gary Benson <gbenson@redhat.com> writes:
> This commit adds a new callback parameter, "expansion_notify", to the
> top-level expand_symtabs_matching function and to all the vectorized
> functions it defers to. If expansion_notify is non-NULL, it will be
> called every time a symbol table is expanded.
>
> gdb/ChangeLog:
>
> * symfile.h (expand_symtabs_exp_notify_ftype): New typedef.
> (struct quick_symbol_functions) <expand_symtabs_matching>:
> New argument expansion_notify. All uses updated.
> (expand_symtabs_matching): New argument expansion_notify.
> All uses updated.
> * symfile-debug.c (debug_qf_expand_symtabs_matching):
> Also print expansion notify.
> * symtab.c (expand_symtabs_matching_via_partial): Call
> expansion_notify whenever a partial symbol table is expanded.
> * dwarf2read.c (dw2_expand_symtabs_matching): Call
> expansion_notify whenever a symbol table is instantiated.

Hi. Just a few comments.

> [...]
> diff --git a/gdb/psymtab.c b/gdb/psymtab.c
> index 2fc882f..17f5b11 100644
> --- a/gdb/psymtab.c
> +++ b/gdb/psymtab.c
> @@ -1373,6 +1373,7 @@ expand_symtabs_matching_via_partial
> (struct objfile *objfile,
> expand_symtabs_file_matcher_ftype *file_matcher,
> expand_symtabs_symbol_matcher_ftype *symbol_matcher,
> + expand_symtabs_exp_notify_ftype *expansion_notify,
> enum search_domain kind,
> void *data)
> {
> @@ -1415,7 +1416,13 @@ expand_symtabs_matching_via_partial
> }
>
> if (recursively_search_psymtabs (ps, objfile, kind, symbol_matcher, data))
> - psymtab_to_symtab (objfile, ps);
> + {
> + struct compunit_symtab *symtab =
> + psymtab_to_symtab (objfile, ps);
> +
> + if (expansion_notify != NULL)
> + expansion_notify (symtab, data);

Check for symtab == NULL.
Also, dwarf2read.c does a symtab_was_null dance.
Seems like we should do that here too (or, if unnecessary,
add a comment explaining why it is unnecessary).

> + }
> }
> }
>

Still reading through the other patches.