From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10492 invoked by alias); 11 Feb 2008 20:38:31 -0000 Received: (qmail 10484 invoked by uid 22791); 11 Feb 2008 20:38:31 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 11 Feb 2008 20:38:11 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 5605A98036; Mon, 11 Feb 2008 20:38:10 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 340029801D; Mon, 11 Feb 2008 20:38:10 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.68) (envelope-from ) id 1JOfPl-0007mW-9F; Mon, 11 Feb 2008 15:38:09 -0500 Date: Mon, 11 Feb 2008 20:38:00 -0000 From: Daniel Jacobowitz To: Aleksandar Ristovski Cc: gdb-patches@sourceware.org Subject: Re: [patch] Do not add partial_symbol again and again to the list Message-ID: <20080211203809.GA29560@caradoc.them.org> Mail-Followup-To: Aleksandar Ristovski , gdb-patches@sourceware.org References: <47B0AEC7.3070400@qnx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47B0AEC7.3070400@qnx.com> User-Agent: Mutt/1.5.17 (2007-12-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00182.txt.bz2 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