This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Do not add partial_symbol again and again to the list
- From: Daniel Jacobowitz <drow at false dot org>
- To: Aleksandar Ristovski <aristovski at qnx dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 11 Feb 2008 15:38:09 -0500
- Subject: Re: [patch] Do not add partial_symbol again and again to the list
- References: <47B0AEC7.3070400@qnx.com>
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