From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by sourceware.org (Postfix) with ESMTPS id 7F4DD3858D37 for ; Thu, 30 Nov 2023 17:59:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F4DD3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F4DD3858D37 Authentication-Results: server2.sourceware.org; arc=fail smtp.remote-ip=198.175.65.12 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1701367175; cv=fail; b=bGXq6nQsy8YNAxZ9PtBr6qbefUPiNhtHWPAqV/iQPLlwcikvFGFSBYQimknUB/jaJsNEvGvLvVGvrffoWM+PR3OMLZglDkX1WcVciOkKxjfuDWtx+VUW6fd7xcD7gPPiP4pzLJsu0tZMMIXszM288W+JclCSneCoFivysnLw0jY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1701367175; c=relaxed/simple; bh=cNXLT9DhvQHiBh9hNFBtd1SLMHftSAbCk0pRsuT9FcQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DS3yPPHceXRUFxjmjr/g35JUmoxX+4AEgKeEqbS8lQJw6vwNICaUvYbZOMNcA7AOfZuO/rLs2oGM/t2BE+rUCVAhqjLtIPs3Rd0G09Itmk8//zKHOBKyU5/Oj4oEu72eLawNpMkryWH457yUBXNYT7O3CggmsZWTpFAF126qMOQ= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701367174; x=1732903174; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=cNXLT9DhvQHiBh9hNFBtd1SLMHftSAbCk0pRsuT9FcQ=; b=frDrMmy8ubOlKuzlNl/+/PG1PaZKAWHaccqwz59cT+F+xXO/yy9PYC/x pSnQm5gKdF5qSBolFuDrR6xl8mrqm9cOThXq0jVxWIxEazEVqSR+WDjXs uSLoVoxyLWA4MjDGi/JKG69u1HMbM4oK3wCbd2FEjfXqoILar2ffdPEMf Ng8w6SzwdSyg1yBLnCu5NwZRwdCl+u2iK909B7cYYm40rbisM2PfUYrx1 BfEgFIZr6Mqa73hcEhajYdwJc6i+UXckTrpF9n/JQE3k7EM6q3NQHCFs9 QX0WihJAUPdvKFN9C3l5CNCS4O1rshXH8z4ZSp8SF/GNL/+u360gJ6BkY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="361547" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="361547" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2023 09:59:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="860280069" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="860280069" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by FMSMGA003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 30 Nov 2023 09:59:32 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 30 Nov 2023 09:59:31 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Thu, 30 Nov 2023 09:59:31 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Thu, 30 Nov 2023 09:59:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cyDQRhshoMzRBe2fZa14FEI0Dbj/rwQKzp7G0VKgjqexgHUKIbnOTdU2qLYM0U3eSubuammy1CsRadmukEENwLMaRt5d54CY4l1zr0n3XhNKjo/4q/feaUfFuua/r2MzY5TdiuH7JqFWNTw3Z5VTJKIS/R/mQsSzxEPuxdZ7WV6HCRr+VsdeSJxMMJsbon2OEdKrMNcMsYiB9CQi8BYAt37cvkH6SSIo7qcqnE7Nqb4NUe4LI3JZGaXaQyh2KdNv1pmg+7jPntZi1/QKoO5jgFAXbJUb2U03LMvCagA40Yp6bgezrujKxdIP2Q2gt9DfZ9n/0B0oa+r+JY4KC0JeDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NZHM214ThqTUgt0aKeMRv2PaWa/6s9LpJ7UN6/6Anis=; b=CZbqcwXr762BCggIJ0RtenN9YxrCyM5xNuVBD57OvW2n8hpc+rR8Z6ng5eQV32brzz3UhUDSEJfGU5P5+EUftAJ9SE6VRWlErfIXkCo2owQh4JHEWTL1PevbfEeZTocaiwQx0jPRxNrAj9OzKXSIs2bP/JO1+c2Bv6CG7A09l8nwWHInZok8k1fnm4FjPKRI/XYwQgEKb+2sYhA1ubSSZEPFpY2kFRmSE7jyqH0Tuh1oG3pQa/tN0IB+C8iDc+1fmHXMw6/UoEJsckTJfPpfHOW5Nm/pGfWvTr8uf4rwN1zxbnHYMBTn2Lfe/I3Mux6jGYmMTSkk+oPKapBmcezKAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM4PR11MB7303.namprd11.prod.outlook.com (2603:10b6:8:108::21) by PH8PR11MB7967.namprd11.prod.outlook.com (2603:10b6:510:25e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22; Thu, 30 Nov 2023 17:58:59 +0000 Received: from DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::b960:9754:455d:b195]) by DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::b960:9754:455d:b195%7]) with mapi id 15.20.7046.024; Thu, 30 Nov 2023 17:58:59 +0000 From: "Aktemur, Tankut Baris" To: Simon Marchi , "gdb-patches@sourceware.org" CC: Luis Machado , John Baldwin , Andrew Burgess , John Baldwin Subject: RE: [PATCH v2 05/24] gdb: change regcache interface to use array_view Thread-Topic: [PATCH v2 05/24] gdb: change regcache interface to use array_view Thread-Index: AQHaHx0oTRVaQ4EPT0G/L65bIU6XULCTFNhQ Date: Thu, 30 Nov 2023 17:58:59 +0000 Message-ID: References: <20231124212656.96801-1-simon.marchi@efficios.com> <20231124212656.96801-6-simon.marchi@efficios.com> In-Reply-To: <20231124212656.96801-6-simon.marchi@efficios.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR11MB7303:EE_|PH8PR11MB7967:EE_ x-ms-office365-filtering-correlation-id: b22d8925-0752-4842-02c4-08dbf1ce079c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ytCnaGADEDlRwbCgvTHAFEFG+EPZ7GjrdGH3wEaJfI5gkn7ItjWubRZpyid96IJtodR0TQEHOFj1zfPRMRK9UfcTUbwuHqa8/nSFdLRWCBGZpGo0lna+dMrD6GCKL/qs7vlMiTcsWuuVxhqDQzH0zlCL5dNiZX4DU+JpAioXa6IfCZQN+4h13zgkHbUdSSWtrLJAywsYjavccA0rdI+IXGUnXoTAPL7pNN5bh/aoHzA2gQyeaNYbVVPFITjIew7bY6WedDFqWX//Na1UlRBv9JixGxBLtBUAodtt9qO/bRkkiJToZ1cTsrVazd3fWUTGvVRPncf3xlauoY9oOhSfIU7jXtkRx3Dc40t8wvopNuoluTkjbrn7LhrNRn0+IHya0vM2XCSISgQyi4AEjmKupRAIzp+gKaMhehbP1TSC5JOqVkLkVVVRuif/M3fJ2CVk66pZAj8mIa7WQSoEz57CLQPVBIBjn+IO9/wDxVD0bxpDq0Ed0cAk7JKt6v37UvYQsqCb+Dnvj++Jj7DFPwBi71AdYLHkmy/iHXvefTjyoC64GuwhtHAHy8q+Oi0cAI+sfirdNtfjwrgWSD4RLNddy+Fsqv12rEs82c4tK1ws71fChLNMahCjxQqhKeuRQyO5 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB7303.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(366004)(376002)(346002)(136003)(230922051799003)(64100799003)(451199024)(186009)(1800799012)(38070700009)(55016003)(33656002)(122000001)(5660300002)(2906002)(86362001)(82960400001)(53546011)(83380400001)(9686003)(26005)(71200400001)(38100700002)(7696005)(6506007)(110136005)(41300700001)(66556008)(66476007)(52536014)(64756008)(8936002)(66946007)(316002)(66446008)(478600001)(76116006)(54906003)(4326008)(8676002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?GHIfG+WICIhaPvzYh4WUMHd4w5HkccjyHUbeICPjTXPr4m1ikqDBO0X0E3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bJQoeW+hTKNEaxw5TGzt?= =?us-ascii?Q?afg4mokyR+9OTccJ4o90npthsqGXTscWvLS0fbcNdO6eVcclrF4wj3THOj8F?= =?us-ascii?Q?FRWdUwy3veaN9QGjm7fYNTYPRQIMR30tnFa80RGKgmNfsiSkxeNheiDAtbJM?= =?us-ascii?Q?R/BjVyX0/HoG5p4irXxownIHQAsYK3gTBLUF7OeVNCh+WEPauBzQJbw0S3jx?= =?us-ascii?Q?tmP+qPE7qG+qNZcE0jbjeWXyyU0/PD9//y/JbeqP7fww9XiPDHGV/2FaR6h/?= =?us-ascii?Q?iDuUm1HKt/H9dK7kTd3pOZ8ymfPTzvJjg1LxWhJVdm4fkVT4wfcIzuHXBvB4?= =?us-ascii?Q?RwOBgvxWuW/7W1r19YxBJl++BTm4JkEgOzf2nrne2xUp56g2Pl2PY0kenYmJ?= =?us-ascii?Q?1tgz/3AT/Y8z6vu2f1m14MzAhPi8Hj2muOPCZk2kYwIMwiVrLa3e1r5VGD3N?= =?us-ascii?Q?oIgn4kUDV76zzeo7o0Qro0yXK9AfhujpfkGgjlUGo8BHk+lyK8q/FwwuKxYM?= =?us-ascii?Q?sjhvEAgFkQhpkcpxvEqCKP/WOyxi8wdJsy/YYkZQ0aqVB1WQ1N8ni1zUktxg?= =?us-ascii?Q?g+pwhIv4UvjzoEFNncAmNWdUo9S6RGwh77DNBHQ+eIOCk8eQDaSTVy303q+G?= =?us-ascii?Q?H0bcxfF9OKXwCHMt2n8fCvtgnsV7HiKq+vhenLtAS6qiQHlwBC5ZPzuSQGiR?= =?us-ascii?Q?LQ=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB7303.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b22d8925-0752-4842-02c4-08dbf1ce079c X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2023 17:58:59.6069 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zxlUHYLWIlwau54BXv7a41qxmwSFY6fn5l8rKREAJtxdqykInOklslmf1L6nxBLYe8ByokbjJZEr8k5HWn+3+YKZpYgDgTHnSYMrJoLOQe8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB7967 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Friday, November 24, 2023 10:26 PM, Simon Marchi wrote: > New in v2: > = > - remove dummy float parameters > = > Change most of regcache (and base classes) to use array_view when > possible, instead of raw pointers. By propagating the use of array_view > further, it enables having some runtime checks to make sure the what we > read from or write to regcaches has the expected length (such as the one > in the `copy(array_view, array_view)` function. It also integrates well > when connecting with other APIs already using gdb::array_view. > = > Add some overloads of the methods using raw pointers to avoid having to > change all call sites at once (which is both a lot of work and risky). > = > I tried to do this change in small increments, but since many of these > functions use each other, it ended up simpler to do it in one shot than > having a lot of intermediary / transient changes. > = > This change extends into gdbserver as well, because there is some part > of the regcache interface that is shared. > = > Changing the reg_buffer_common interface to use array_view caused some > build failures in nat/aarch64-scalable-linux-ptrace.c. That file > currently "takes advantage" of the fact that > reg_buffer_common::{raw_supply,raw_collect} operates on `void *`, which > IMO is dangerous. It uses raw_supply/raw_collect directly on > uint64_t's, which I guess is fine because it is expected that native > code will have the same endianness as the debugged process. To > accomodate that, add some overloads of raw_collect and raw_supply that > work on uint64_t. > = > This file also uses raw_collect and raw_supply on `char` pointers. > Change it to use `gdb_byte` pointers instead. Add overloads of > raw_collect and raw_supply that work on `gdb_byte *` and make an > array_view on the fly using the register's size. Those call sites could > be converted to use array_view with not much work, in which case these > overloads could be removed, but I didn't want to do it in this patch, to > avoid starting to dig in arch-specific code. > = > Change-Id: I9005f04114543ddff738949e12d85a31855304c2 > Reviewed-By: John Baldwin > --- ... > @@ -650,13 +677,13 @@ template > void > regcache::raw_write (int regnum, T val) > { > - gdb_byte *buf; > - > assert_regnum (regnum); > - buf =3D (gdb_byte *) alloca (m_descr->sizeof_register[regnum]); > - store_integer (buf, m_descr->sizeof_register[regnum], > - gdbarch_byte_order (m_descr->gdbarch), val); > - raw_write (regnum, buf); > + > + int len =3D m_descr->sizeof_register[regnum]; > + gdb_byte *buf =3D (gdb_byte *) alloca (m_descr->sizeof_register[regnum= ]); We could use `len` as the argument to `alloca`. Could you also consider na= ming the variable `size` instead of `len`? It seems to be used more often than = `len` in this patch, and also fits better to array_view's `size` method. Regards -Baris Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928