Re: [patch] Do not add partial_symbol again and again to the list

Daniel Jacobowitz
2008-02-11T20:38:31Z

On Mon, Feb 11, 2008 at 03:23:35PM -0500, Aleksandar Ristovski wrote:
> The attached patch checks if partial_symbol has already been added to the
> list instead of adding duplicate records.

How does this ever happen? It seems very wrong. Also, I am worried
that the linear search will be a bottleneck (this is quadratic as each
psymtab grows).

> @@ -3102,15 +3103,20 @@ add_psymbol_to_list (char *name, int nam
> enum language language, struct objfile *objfile)
> {
> struct partial_symbol *psym;
> - char *buf = alloca (namelength + 1);
> + struct partial_symbol **ps;
> + char *buf = name;
> /* psymbol is static so that there will be no uninitialized gaps in the
> structure which might contain random data, causing cache misses in
> bcache. */
> static struct partial_symbol psymbol;
> -
> - /* Create local copy of the partial symbol */
> - memcpy (buf, name, namelength);
> - buf[namelength] = '\0';
> +
> + if (name[namelength] != '\0')
> + {
> + buf = alloca (namelength + 1);
> + /* Create local copy of the partial symbol */
> + memcpy (buf, name, namelength);
> + buf[namelength] = '\0';
> + }
> /* val and coreaddr are mutually exclusive, one of them *will* be zero */
> if (val != 0)
> {

Even easier: eliminate the copy entirely. SYMBOL_SET_NAMES -> symbol_set_names
already does this and it never modifies its argument.

--
Daniel Jacobowitz
CodeSourcery