Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Pedro Alves <palves@redhat.com>, <gdb-patches@sourceware.org>
Cc: <qiyaoltc@gmail.com>
Subject: Re: [PATCH] Fix length calculation in aarch64_linux_set_debug_regs
Date: Mon, 02 Nov 2015 17:09:00 -0000	[thread overview]
Message-ID: <563798BC.3000407@ericsson.com> (raw)
In-Reply-To: <56378884.70001@redhat.com>

I looked a bit more into the issue and did some testing, and it appears the
current code is correct (as Yao mentioned).  It's probably not as clear as it
could be though.  I think it would be nicer if expressed as

  (size of fixed part) + (size of variable part)


On 15-11-02 11:00 AM, Pedro Alves wrote:
> IIUYC, you're pointing out two issues:
> #1 - the offsetof that doesn't work in C++.

This actually appears to be a bug in g++.

See this, especially towards the end: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14932

The expression is accepted by gcc and clang++, but not g++ (test with 4.8 and 5.2).

> #2 - an off-by-one.

Never mind, I thought wrongly at first that sizeof (regs.dbg_regs [count - 1])
would give the size for "count - 1" elements, but it's actually the size of a
single element.  So scratch that, the current code works fine.

So the only reason to change the code would be to circumvent a bug in g++, which
is probably a valid one (otherwise we can't build).

> I don't know enough about Aarch64 to judge #1, but it does sound right to me.
> 
> On #2, I saw the same on x86.  See my fix here:
> 
>   https://sourceware.org/ml/gdb-patches/2015-02/msg00213.html
> 
> I think it's a little nicer to hide away the offsetof+sizeof.

You mean hide in in a function?  This expression is only used at one place and I think it's
reasonably straightforward if expressed correctly, but if you think it will make the code
clearer I don't mind.


  reply	other threads:[~2015-11-02 17:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 14:48 Simon Marchi
2015-11-02 16:00 ` Pedro Alves
2015-11-02 17:09   ` Simon Marchi [this message]
2015-11-02 17:57     ` Pedro Alves
2015-11-02 18:17       ` Simon Marchi
2015-11-02 18:19         ` Pedro Alves
2015-11-02 18:25         ` Andreas Schwab
2015-11-02 16:51 ` Yao Qi
2015-11-19 11:52 ` Yao Qi
2015-11-19 13:32   ` Simon Marchi
2015-11-19 13:51     ` Yao Qi
2015-11-19 15:20       ` 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=563798BC.3000407@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=qiyaoltc@gmail.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