From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18725 invoked by alias); 28 Jun 2010 20:37:55 -0000 Received: (qmail 18686 invoked by uid 22791); 28 Jun 2010 20:37:54 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,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; Mon, 28 Jun 2010 20:37:50 +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 o5SKbmEw003433 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 28 Jun 2010 16:37:48 -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 o5SKbmxp031091; Mon, 28 Jun 2010 16:37:48 -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 o5SKblmc007796; Mon, 28 Jun 2010 16:37:47 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 43C46378967; Mon, 28 Jun 2010 14:37:47 -0600 (MDT) From: Tom Tromey To: Jan Kratochvil Cc: gdb@sourceware.org Subject: Re: gdbtypes.h #defined field accessors References: <20100624195656.GA19643@host0.dyn.jankratochvil.net> Reply-To: tromey@redhat.com Date: Mon, 28 Jun 2010 20:37:00 -0000 In-Reply-To: <20100624195656.GA19643@host0.dyn.jankratochvil.net> (Jan Kratochvil's message of "Thu, 24 Jun 2010 21:56:56 +0200") 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-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00140.txt.bz2 >>>>> "Jan" == Jan Kratochvil writes: Jan> #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses Jan> Why the code does not use directly the right hand side? I'm not sure I know the real answer. I think this was a kind of GNU style thing for a while. GCC is still heavily macroized this way, nearly all fields go through accessors. In GCC I think this has enabled some refactorings. And, I think I've run across internal evidence in GDB that this was done as well -- specifically that type and main_type used to be the same but were split apart. I'm not sure the argument for this macroization is very strong in GDB, though. They are somewhat nice in that they can let you easily find all the users of a field -- but they aren't always uniformly used (ISTR some of the symbol accessors are not used universally), and there may be other ok ways to get that info. Jan> Coccinelle makes such later transformation automatic even without Jan> any macros. Yeah. Or now that GCC has decent column information, you can even do fun stuff just parsing its error messages. Though FWIW, little of the GDB work I've done seems amenable to automation, even the grungy add-an-argument-to-val_print stuff :-( Jan> Should new fields still follow this paradigm? I tend to stick with the style of a given module. In new code I don't generally write accessors. Tom