Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Remove CHECK_TYPEDEF, use check_typedef instead
Date: Tue, 07 Jul 2015 22:01:00 -0000	[thread overview]
Message-ID: <559C4C4E.9050109@redhat.com> (raw)
In-Reply-To: <559C3349.1050501@ericsson.com>

On 07/07/2015 09:15 PM, Simon Marchi wrote:

> That's a bit better, but I don't think there's an advantage here of
> having two ways to do the same thing.  If anything, it's confusing for
> new contributors.

OK.

> 
> I was going to suggest adding __attribute__((warn_unused_result)) to
> check_typedef, as it would also prevent forgetting assigning the result.
> Especially if we change it, people used to the old macro would be at
> risk of forgetting it.  However, I realized that at a few places the
> result of check_typedef is ignored.  It is used only to initialize the
> length field of the typedef, so that TYPE_LENGTH (the_typedef) will
> return the right thing [1].
> 
> Using a side-effect of check_typedef to get the length of the type right
> seems very hackish and error-prone (easy to forget something or to break
> something when moving code around).
> 
> I think there should be a get_type_length [2] function that returns what
> you would expect: the actual length of the type, after having peeled all
> layers of typedef. You wouldn't need to call check_typedef beforehand.

I'd be fine with it.

> It would be cleaner and safer, and would allow us to add warn_unused_result
> to check_typedef.  Because there should be no reason to call check_typedef
> than to obtain the resolved type.
> 
> Thoughts?
> 
> [1] For example: https://github.com/simark/binutils-gdb/blob/master/gdb/tracepoint.c#L1532
> [2] I can see a get_type_length function mentioned in the ChangeLog here:
> 
>       https://github.com/simark/binutils-gdb/blob/master/gdb/ChangeLog-2014#L9750
> 
>     but I can't find any trace of it in the source code (even when checkout out
>     that commit). Any idea? Joel perhaps?

Looks like it was present in earlier revisions of the patch, but later dropped:
Gooling for '"get_type_length" sanimir' found it:

  https://sourceware.org/ml/gdb-patches/2013-12/msg00127.html

Thanks,
Pedro Alves


  reply	other threads:[~2015-07-07 22:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 20:06 Simon Marchi
2015-07-07 13:20 ` Joel Brobecker
2015-07-07 16:15 ` Pedro Alves
2015-07-07 20:15   ` Simon Marchi
2015-07-07 22:01     ` Pedro Alves [this message]
2015-07-11 13:19   ` Doug Evans
2015-07-11 18:32     ` Pedro Alves
2015-07-11 22:52       ` Doug Evans
2015-07-14  9:34         ` Pedro Alves
2015-07-14 20:42           ` Simon Marchi
2015-07-13 17:18     ` Simon Marchi

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=559C4C4E.9050109@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.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