From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2609 invoked by alias); 11 Feb 2008 20:23:55 -0000 Received: (qmail 2600 invoked by uid 22791); 11 Feb 2008 20:23:55 -0000 X-Spam-Check-By: sourceware.org Received: from qnxmail.qnx.com (HELO qnxmail.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 11 Feb 2008 20:23:37 +0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.42.96.5]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id PAA20261 for ; Mon, 11 Feb 2008 15:09:01 -0500 Received: from [10.42.100.129] (dhcp-100-129 [10.42.100.129]) by smtp.ott.qnx.com (8.8.8/8.6.12) with ESMTP id PAA23303 for ; Mon, 11 Feb 2008 15:23:35 -0500 Message-ID: <47B0AEC7.3070400@qnx.com> Date: Mon, 11 Feb 2008 20:23:00 -0000 From: Aleksandar Ristovski User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [patch] Do not add partial_symbol again and again to the list Content-Type: multipart/mixed; boundary="------------040600060305040807070103" 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/msg00180.txt.bz2 This is a multi-part message in MIME format. --------------040600060305040807070103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 497 Hello, The attached patch checks if partial_symbol has already been added to the list instead of adding duplicate records. Tested on linux x86, no regression. Thanks, --- Aleksandar Ristovski QNX Software Systems ChangeLog: 2008-02-11 Aleksandar Ristovski * symfile.c (add_psymbol_to_list): Do not alloca and copy name if it's already properly terminated. Check if the partial_symbol structure has already been added to the list. If it has, do not add it again. --------------040600060305040807070103 Content-Type: text/plain; name="symfile.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="symfile.c.diff" Content-length: 1665 Index: gdb/symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.198 diff -u -p -r1.198 symfile.c --- gdb/symfile.c 29 Jan 2008 22:47:20 -0000 1.198 +++ gdb/symfile.c 11 Feb 2008 20:12:48 -0000 @@ -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) { @@ -3131,6 +3137,14 @@ add_psymbol_to_list (char *name, int nam psym = deprecated_bcache (&psymbol, sizeof (struct partial_symbol), objfile->psymbol_cache); + /* Check if the partial_symbol is already in the list. Do not add + it again if it is. */ + for (ps = list->list; ps != list->next; ps++) + { + if (psym == *ps) + return psym; + } + /* Save pointer to partial symbol in psymtab, growing symtab if needed. */ if (list->next >= list->list + list->size) { --------------040600060305040807070103--