From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56064 invoked by alias); 21 Jun 2018 14:16:14 -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 54193 invoked by uid 89); 21 Jun 2018 14:15:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.2 spammy= X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Jun 2018 14:15:55 +0000 Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 06.E1.31169.213BB2B5; Thu, 21 Jun 2018 16:15:46 +0200 (CEST) Received: from ESESSMB502.ericsson.se (153.88.183.163) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 21 Jun 2018 16:15:11 +0200 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB502.ericsson.se (153.88.183.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Thu, 21 Jun 2018 16:15:10 +0200 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [142.133.60.192] (192.75.88.130) by BYAPR15MB2390.namprd15.prod.outlook.com (2603:10b6:a02:8c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.19; Thu, 21 Jun 2018 14:15:08 +0000 Subject: Re: [PATCH v2 3/3] Use partial register read/writes in transfer_regset To: Alan Hayward , CC: References: <20180621093802.79342-1-alan.hayward@arm.com> <20180621093802.79342-4-alan.hayward@arm.com> From: Simon Marchi Message-ID: <85583a14-9c9f-605c-8216-57b6cda22d41@ericsson.com> Date: Thu, 21 Jun 2018 14:16:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180621093802.79342-4-alan.hayward@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN4PR0801CA0017.namprd08.prod.outlook.com (2603:10b6:803:29::27) To BYAPR15MB2390.namprd15.prod.outlook.com (2603:10b6:a02:8c::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cda52bf9-57c1-40f6-9213-08d5d78164e0 X-MS-TrafficTypeDiagnostic: BYAPR15MB2390: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Forefront-PRVS: 07106EF9B9 Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2018 14:15:08.0203 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cda52bf9-57c1-40f6-9213-08d5d78164e0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR15MB2390 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00518.txt.bz2 Hi Alan, On 2018-06-21 05:38 AM, Alan Hayward wrote: > @@ -1013,12 +1077,18 @@ regcache::transfer_regset (const struct regset *regset, > if (offs + slot_size > size) > break; > > + /* Use part versions to prevent possible overflow. */ > if (out_buf) Can you update the pointer comparisons in the code you touch to use != NULL or != nullptr? > diff --git a/gdb/regcache.h b/gdb/regcache.h > index c17ce09dee..a69b67d513 100644 > --- a/gdb/regcache.h > +++ b/gdb/regcache.h > @@ -162,6 +162,11 @@ public: > void raw_collect_integer (int regnum, gdb_byte *addr, int addr_len, > bool is_signed) const; > > + /* Collect register REGNUM from REGCACHE, starting at offset in REGCACHE, > + reading only LEN. If this runs off the end of the register, then fill the > + additional space with zeros. */ To have a consistent interface, I would be tempted to use the same behavior as read_part and write_part for reads and writes that run off the end of the register (not allow it). It would be the responsibility of the caller to ensure that they don't overflow. I think it would just be a matter of std::min (reg_size, slot_size) ? Simon