[RFA] Change to pre-expand symtabs
Jan Kratochvil
jan.kratochvil@redhat.com
Sat Sep 4 20:48:00 GMT 2010
On Thu, 02 Sep 2010 21:35:04 +0200, Keith Seitz wrote:
> --- symtab.c 1 Sep 2010 21:50:26 -0000 1.252
> +++ symtab.c 2 Sep 2010 19:25:25 -0000
> +psymtab_search_name (const char *name)
> + {
> + static char *ret = NULL;
> +
> + if (ret != NULL)
> + {
> + xfree (ret);
> + ret = NULL;
> + }
> +
> + if (strchr (name, '('))
> + ret = cp_remove_params (name);
> +
> + return (ret == NULL) ? name : ret;
> + }
[...]
> + const char *psym_search_name = psymtab_search_name (name);
> sym = objfile->sf->qf->expand_one_symtab_matching (objfile,
> block_index,
> - name, domain,
> + psym_search_name,
> + domain,
> match_symbol_aux,
> objfile);
I find such static buffer as needlessly dangerous, in general, without
thinking too much more.
I do not see obviously why some the callee expand_one_symtab_matching could
not recursively call this function (incl. psymtab_search_name again) while
still accessing also its passed parameter, which gets freed this way.
I would just say the caller should xfree the string. (Yes, it is a pain to do
make_cleanup if appropriate but that part is a different problem.)
Thanks,
Jan
More information about the Gdb-patches
mailing list