From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31631 invoked by alias); 8 Jun 2010 17:02:27 -0000 Received: (qmail 31541 invoked by uid 22791); 8 Jun 2010 17:02:25 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD 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; Tue, 08 Jun 2010 17:02:19 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o58H2HWa032736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Jun 2010 13:02:18 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o58H2Hqe008116; Tue, 8 Jun 2010 13:02:17 -0400 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 o58H2G7R021894; Tue, 8 Jun 2010 13:02:16 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 03DFA3784BE; Tue, 8 Jun 2010 11:02:15 -0600 (MDT) From: Tom Tromey To: sami wagiaalla Cc: gdb-patches@sourceware.org Subject: Re: [patch] Change cplus_specific to an alocated struct References: <4BFD4230.3030600@redhat.com> Reply-To: tromey@redhat.com Date: Tue, 08 Jun 2010 17:02:00 -0000 In-Reply-To: <4BFD4230.3030600@redhat.com> (sami wagiaalla's message of "Wed, 26 May 2010 11:45:52 -0400") 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: 2010-06/txt/msg00208.txt.bz2 >>>>> "Sami" == sami wagiaalla writes: Sami> I plan to expand the cplus_specific struct to store template Sami> information needed, of course, only for C++. Tom suggested that I move Sami> the substruct out of struct general_symbol_info and change its Sami> reference to a pointer to be assigned to the struct if allocated. Sami> Thoughts ? I think the idea is fine. Sami> char * Sami> ada_decode_symbol (const struct general_symbol_info *gsymbol) Sami> { Sami> - char **resultp = Sami> - (char **) &gsymbol->language_specific.cplus_specific.demangled_name; Sami> - if (*resultp == NULL) Sami> + char *result = symbol_get_cplus_demangled_name (gsymbol); I don't think this change is correct -- but FWIW I don't think the existing code is correct, either. The code is written this way because this function caches the demangled name in the cplus_specific struct. Your change removes this caching. However, this takes a general_symbol_info and so, presumably, can be used for partial symbols. But, modifying a partial symbol is a no-no, because they are stored in a bcache. All this reminds me -- you should look at bcache utilization and memory use before and after your changes to make sure we aren't hitting a memory use regression here. There is some command that will show you bcache statistics, though I forget what it is offhand. Sami> +char * Sami> +symbol_get_cplus_demangled_name (const struct general_symbol_info *gsymbol) Sami> +{ Sami> + if (gsymbol->language_specific.cplus_specific != NULL) Sami> + return gsymbol->language_specific.cplus_specific->demangled_name; Sami> + Sami> + return NULL; Sami> +} Perhaps we should have different types of structs in the language_specific union, and have functions like this examine the language field. It seems to me that soon we're going to want to add a bunch of C++-specific fields, and we don't want to unnecessarily penalize the other languages with our baggage. If you were planning that for a follow-on patch, that is fine -- but also the sort of thing that it is handy to note in your submissions. Sami> +/* Initialize the cplus_specific structure. 'cplus_specific' is intended to Sami> + be allocated lazily. So this should only be called if the structure is Sami> + needed. */ Sami> +static void Sami> +symbol_init_cplus_specific (struct general_symbol_info *gsymbol, Sami> + struct objfile *objfile) Initializing lazily is usually good, but it breaks the bcache. However perhaps this can be fixed by having the partial symbol code force the issue. Tom