From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44951 invoked by alias); 2 Nov 2015 17:09:21 -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 44937 invoked by uid 89); 2 Nov 2015 17:09:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham 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; Mon, 02 Nov 2015 17:09:20 +0000 Received: from EUSAAHC006.ericsson.se (Unknown_Domain [147.117.188.90]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 81.C3.26730.66B27365; Mon, 2 Nov 2015 10:22:46 +0100 (CET) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.92) with Microsoft SMTP Server id 14.3.248.2; Mon, 2 Nov 2015 12:09:17 -0500 Subject: Re: [PATCH] Fix length calculation in aarch64_linux_set_debug_regs To: Pedro Alves , References: <1446475684-31936-1-git-send-email-simon.marchi@ericsson.com> <56378884.70001@redhat.com> CC: From: Simon Marchi Message-ID: <563798BC.3000407@ericsson.com> Date: Mon, 02 Nov 2015 17:09: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: <56378884.70001@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00014.txt.bz2 I looked a bit more into the issue and did some testing, and it appears the current code is correct (as Yao mentioned). It's probably not as clear as it could be though. I think it would be nicer if expressed as (size of fixed part) + (size of variable part) On 15-11-02 11:00 AM, Pedro Alves wrote: > IIUYC, you're pointing out two issues: > #1 - the offsetof that doesn't work in C++. This actually appears to be a bug in g++. See this, especially towards the end: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14932 The expression is accepted by gcc and clang++, but not g++ (test with 4.8 and 5.2). > #2 - an off-by-one. Never mind, I thought wrongly at first that sizeof (regs.dbg_regs [count - 1]) would give the size for "count - 1" elements, but it's actually the size of a single element. So scratch that, the current code works fine. So the only reason to change the code would be to circumvent a bug in g++, which is probably a valid one (otherwise we can't build). > I don't know enough about Aarch64 to judge #1, but it does sound right to me. > > On #2, I saw the same on x86. See my fix here: > > https://sourceware.org/ml/gdb-patches/2015-02/msg00213.html > > I think it's a little nicer to hide away the offsetof+sizeof. You mean hide in in a function? This expression is only used at one place and I think it's reasonably straightforward if expressed correctly, but if you think it will make the code clearer I don't mind.