From: pinskia@gmail.com
To: Marcus Shawcroft <marcus.shawcroft@gmail.com>
Cc: Yufeng Zhang <Yufeng.Zhang@arm.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Marcus Shawcroft <Marcus.Shawcroft@arm.com>
Subject: Re: [PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling
Date: Thu, 19 Dec 2013 10:23:00 -0000 [thread overview]
Message-ID: <1687CC80-34C1-4D76-836B-418050049B16@gmail.com> (raw)
In-Reply-To: <CAFqB+PyUfWodaTX=jam=dE6ZzE4goj8n4xfc52AsvvMNaj4y+w@mail.gmail.com>
> On Dec 19, 2013, at 2:16 AM, Marcus Shawcroft <marcus.shawcroft@gmail.com> wrote:
>
>> On 19 December 2013 07:00, <pinskia@gmail.com> wrote:
>> I think this patch is wrong as the size that is passed is always just one element as sizeof (regs.dbg_regs [count - 1]) is the same as sizeof (regs.dbg_regs [0]). This should have been sizeof (regs.dbg_regs [0])*count instead.
>
>
> + iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1])
> + + sizeof (regs.dbg_regs [count - 1]));
>
> The offsetof() gives the number of bytes from the start of
> user_hwdebug_state upto and including all of the reg array bar the
> last in use entry. Adding on the sizeof() therefore gives the number
> of bytes from the start of the structure upto and including the last
> in use reg entry.
>
> I agree that the sizeof() could be written either with dbg_regs[0] or
> dbg_regs[count-1] with no change in behavior. But I think Yufengs
> code is functionally correct.
>
> It would have been simpler to write:
> iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count])
>
> .. but I think that is illegal when count equals the number of
> elements defined in the array.
Oh, I see I think this should have been written using offsetof [0] and then count*sizeof to make easier to understand and fits in with most other code which uses a variable size last element.
Thanks,
Andrew
>
> Cheers
> /Marcus
next prev parent reply other threads:[~2013-12-19 10:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 16:07 Yufeng Zhang
2013-12-18 16:24 ` Pedro Alves
2013-12-19 7:00 ` pinskia
2013-12-19 10:16 ` Marcus Shawcroft
2013-12-19 10:23 ` pinskia [this message]
2013-12-19 10:26 ` Marcus Shawcroft
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=1687CC80-34C1-4D76-836B-418050049B16@gmail.com \
--to=pinskia@gmail.com \
--cc=Marcus.Shawcroft@arm.com \
--cc=Yufeng.Zhang@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=marcus.shawcroft@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