This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling
- From: Marcus Shawcroft <marcus dot shawcroft at gmail dot com>
- To: pinskia at gmail dot com
- Cc: Yufeng Zhang <Yufeng dot Zhang at arm dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>
- Date: Thu, 19 Dec 2013 10:16:08 +0000
- Subject: Re: [PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling
- Authentication-results: sourceware.org; auth=none
- References: <52B1C84F dot 4000102 at arm dot com> <430CEAB7-7F7B-430D-9C37-75F87D1F65AC at gmail dot com>
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.
Cheers
/Marcus