From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6674 invoked by alias); 19 Dec 2013 10:23:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 6661 invoked by uid 89); 19 Dec 2013 10:23:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f179.google.com Received: from mail-pd0-f179.google.com (HELO mail-pd0-f179.google.com) (209.85.192.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 19 Dec 2013 10:23:16 +0000 Received: by mail-pd0-f179.google.com with SMTP id r10so950286pdi.10 for ; Thu, 19 Dec 2013 02:23:14 -0800 (PST) X-Received: by 10.66.139.166 with SMTP id qz6mr775187pab.88.1387448594259; Thu, 19 Dec 2013 02:23:14 -0800 (PST) Received: from [192.168.1.51] (76-253-2-104.lightspeed.sntcca.sbcglobal.net. [76.253.2.104]) by mx.google.com with ESMTPSA id ja5sm6160309pbc.14.2013.12.19.02.23.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 02:23:11 -0800 (PST) References: <52B1C84F.4000102@arm.com> <430CEAB7-7F7B-430D-9C37-75F87D1F65AC@gmail.com> Mime-Version: 1.0 (1.0) In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <1687CC80-34C1-4D76-836B-418050049B16@gmail.com> Cc: Yufeng Zhang , "gdb-patches@sourceware.org" , Marcus Shawcroft From: pinskia@gmail.com Subject: Re: [PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling Date: Thu, 19 Dec 2013 10:23:00 -0000 To: Marcus Shawcroft X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00741.txt.bz2 > On Dec 19, 2013, at 2:16 AM, Marcus Shawcroft wrote: >=20 >> On 19 December 2013 07:00, wrote: >> I think this patch is wrong as the size that is passed is always just on= e 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 inst= ead. >=20 >=20 > + iov.iov_len =3D (offsetof (struct user_hwdebug_state, dbg_regs[count -= 1]) > + + sizeof (regs.dbg_regs [count - 1])); >=20 > 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. >=20 > 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. >=20 > It would have been simpler to write: > iov.iov_len =3D (offsetof (struct user_hwdebug_state, dbg_regs[count]) >=20 > .. 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.=20 Thanks, Andrew=20 >=20 > Cheers > /Marcus