From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 833 invoked by alias); 19 Dec 2013 10:16:12 -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 822 invoked by uid 89); 19 Dec 2013 10:16:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ve0-f170.google.com Received: from mail-ve0-f170.google.com (HELO mail-ve0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 19 Dec 2013 10:16:10 +0000 Received: by mail-ve0-f170.google.com with SMTP id oy12so555217veb.1 for ; Thu, 19 Dec 2013 02:16:08 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.52.157.1 with SMTP id wi1mr236092vdb.12.1387448168438; Thu, 19 Dec 2013 02:16:08 -0800 (PST) Received: by 10.52.171.202 with HTTP; Thu, 19 Dec 2013 02:16:08 -0800 (PST) In-Reply-To: <430CEAB7-7F7B-430D-9C37-75F87D1F65AC@gmail.com> References: <52B1C84F.4000102@arm.com> <430CEAB7-7F7B-430D-9C37-75F87D1F65AC@gmail.com> Date: Thu, 19 Dec 2013 10:16:00 -0000 Message-ID: Subject: Re: [PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling From: Marcus Shawcroft To: pinskia@gmail.com Cc: Yufeng Zhang , "gdb-patches@sourceware.org" , Marcus Shawcroft Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00740.txt.bz2 On 19 December 2013 07:00, 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