From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9076 invoked by alias); 5 Nov 2009 22:16:47 -0000 Received: (qmail 9067 invoked by uid 22791); 5 Nov 2009 22:16:47 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 05 Nov 2009 22:16:37 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA5MGat5027595 for ; Thu, 5 Nov 2009 17:16:36 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA5MGZX3015530; Thu, 5 Nov 2009 17:16:36 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nA5MGYGR025060; Thu, 5 Nov 2009 17:16:35 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 776793782CF; Thu, 5 Nov 2009 15:16:34 -0700 (MST) From: Tom Tromey To: gdb-patches@sourceware.org Subject: Re: FYI: minor simplification in add_psymbol_to_bcache References: <20091103202058.GA23081@caradoc.them.org> <20091105200252.GA18502@caradoc.them.org> Reply-To: Tom Tromey Date: Thu, 05 Nov 2009 22:16:00 -0000 In-Reply-To: <20091105200252.GA18502@caradoc.them.org> (Daniel Jacobowitz's message of "Thu, 5 Nov 2009 15:02:52 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2009-11/txt/msg00104.txt.bz2 >>>>> "Daniel" == Daniel Jacobowitz writes: >> On Wed, Nov 04, 2009 at 12:16:27PM -0700, Tom Tromey wrote: >> TBH I was not thinking too soundly, I suppose, when I nuked this. I >> think your point is a good one. If you'd prefer, I will leave this >> static and just zero out that field. Daniel> Unless you have a good reason not to, I suggest making that change. Here is the patch I am checking in. Tom 2009-11-05 Tom Tromey * symfile.c (add_psymbol_to_bcache): Make 'psymbol' static again. Zero the 'value' field. Index: symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.253 diff -u -r1.253 symfile.c --- symfile.c 5 Nov 2009 19:53:04 -0000 1.253 +++ symfile.c 5 Nov 2009 22:15:30 -0000 @@ -3105,9 +3105,15 @@ enum language language, struct objfile *objfile, int *added) { - struct partial_symbol psymbol; - - memset (&psymbol, 0, sizeof (struct partial_symbol)); + /* 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; + + /* However, we must ensure that the entire 'value' field has been + zeroed before assigning to it, because an assignment may not + write the entire field. */ + memset (&psymbol.ginfo.value, 0, sizeof (psymbol.ginfo.value)); /* val and coreaddr are mutually exclusive, one of them *will* be zero */ if (val != 0) {