From: Tom Tromey <tromey@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb@sourceware.org
Subject: Re: gdbtypes.h #defined field accessors
Date: Mon, 28 Jun 2010 20:37:00 -0000 [thread overview]
Message-ID: <m3oceux59g.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20100624195656.GA19643@host0.dyn.jankratochvil.net> (Jan Kratochvil's message of "Thu, 24 Jun 2010 21:56:56 +0200")
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> 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
next prev parent reply other threads:[~2010-06-28 20:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-24 19:57 Jan Kratochvil
2010-06-28 20:37 ` Tom Tromey [this message]
2010-06-28 20:57 ` Joel Brobecker
2010-06-30 21:51 ` Tom Tromey
2010-06-29 23:15 ` Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3oceux59g.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox