From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60679 invoked by alias); 19 Nov 2015 15:20:33 -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 60623 invoked by uid 89); 19 Nov 2015 15:20:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.2 required=5.0 tests=AWL,BAYES_00,BODY_8BITS,GARBLED_BODY,SPF_PASS autolearn=no version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 19 Nov 2015 15:20:31 +0000 Received: from EUSAAHC008.ericsson.se (Unknown_Domain [147.117.188.96]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id E1.6F.26730.68A7D465; Thu, 19 Nov 2015 08:30:14 +0100 (CET) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.98) with Microsoft SMTP Server id 14.3.248.2; Thu, 19 Nov 2015 10:20:28 -0500 Subject: Re: [PATCH] Fix length calculation in aarch64_linux_set_debug_regs To: Yao Qi References: <1446475684-31936-1-git-send-email-simon.marchi@ericsson.com> <8637w21a14.fsf@gmail.com> <564DCF6B.9030302@ericsson.com> <564DD3BE.2080305@gmail.com> CC: From: Simon Marchi Message-ID: <564DE8BB.1060200@ericsson.com> Date: Thu, 19 Nov 2015 15:20:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <564DD3BE.2080305@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00400.txt.bz2 On 15-11-19 08:50 AM, Yao Qi wrote: > You can push it in, with some commit log adjustments, because the old > code is correct. Ok I pushed it. Again, sorry for saying the code was not correct :). =46rom bb82e93484cdd56c67efd52b869a6123b2623f6c Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 19 Nov 2015 10:17:36 -0500 Subject: [PATCH] Fix iov_len calculation in aarch64_linux_set_debug_regs MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit There is this build failure when building in C++: /home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c: In function= =C3=A2=E2=82=AC=CB=9Cvoid aarch64_linux_set_debug_regs(const aarch64_debug= _reg_state*, int, int)=C3=A2=E2=82=AC=E2=84=A2: /home/simark/src/binutils-gdb/gdb/nat/aarch64-linux-hw-point.c:564:64: erro= r: =C3=A2=E2=82=AC=CB=9Ccount=C3=A2=E2=82=AC=E2=84=A2 cannot appear in a co= nstant-expression iov.iov_len =3D (offsetof (struct user_hwdebug_state, dbg_regs[count - 1= ]) ^ We can simplify the computation and make g++ happy at the same time by formulating as: size of fixed part + size of variable part thus... size of fixed part + count * size of one variable part element thus... offsetof (struct user_hwdebug_state, dbg_regs) + count * sizeof (regs.dbg= _reg[0]); gdb/ChangeLog: * nat/aarch64-linux-hw-point.c (aarch64_linux_set_debug_regs): Change form of iov_len computation. --- gdb/ChangeLog | 5 +++++ gdb/nat/aarch64-linux-hw-point.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0539d96..94721a0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2015-11-19 Simon Marchi + + * nat/aarch64-linux-hw-point.c (aarch64_linux_set_debug_regs): Change + form of iov_len computation. + 2015-11-19 Pedro Alves * configure.ac (ERROR_ON_WARNING): Don't check whether in C++ diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-po= int.c index 1a5fa6a..dcbfa98 100644 --- a/gdb/nat/aarch64-linux-hw-point.c +++ b/gdb/nat/aarch64-linux-hw-point.c @@ -561,8 +561,8 @@ aarch64_linux_set_debug_regs (const struct aarch64_debu= g_reg_state *state, ctrl =3D watchpoint ? state->dr_ctrl_wp : state->dr_ctrl_bp; if (count =3D=3D 0) return; - iov.iov_len =3D (offsetof (struct user_hwdebug_state, dbg_regs[count - 1= ]) - + sizeof (regs.dbg_regs [count - 1])); + iov.iov_len =3D (offsetof (struct user_hwdebug_state, dbg_regs) + + count * sizeof (regs.dbg_regs[0])); for (i =3D 0; i < count; i++) { --=20 2.5.1