From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 46D373856DD1 for ; Tue, 2 Aug 2022 06:30:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46D373856DD1 X-IronPort-AV: E=McAfee;i="6400,9594,10426"; a="269101443" X-IronPort-AV: E=Sophos;i="5.93,210,1654585200"; d="scan'208";a="269101443" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2022 23:30:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,210,1654585200"; d="scan'208";a="929849085" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by fmsmga005.fm.intel.com with ESMTP; 01 Aug 2022 23:30:40 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 23:30:40 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 23:30:40 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Mon, 1 Aug 2022 23:30:40 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.171) 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.2375.28; Mon, 1 Aug 2022 23:30:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lTPX1my278/kZSR1QjmftZ0syQ3ysSWFhmLEtHNV8cZuoNSHNrzctQt1BUSvPitFCqBQcF2nH/DKAtPr6abrhnpj3oZL+LLFVBqh79I3rocLabDZ6e1CvYba46B/BdYJktyVMru9LdIqkrR3DbrspgLjbIOtfhRbDXwcocVgK8SPWb9zIsFO/VSEEY3jo9z/nCTumNwdnnYKgQOCrslZqt38lg8lUaAJ40kagTprNUQnSBUflzC8WHXzZSRl/SPjLmNSq3tPJ03B5TlONdNi2cg/EdkP8uuxG3F5vMInxXoAC8WmjgkS5a+ptRMdmTg4DJUt+iembV6qjIx6pL7F/A== 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=BFp4UqU4qAG+SQZYvKeey7aHBkX7PCCZIzKECXRH9XA=; b=CVs4gwNU04D7tznR9U1l5OXlziWtwkeuGN/OoXiBlFlf5VI/ldcA5Co14slndlAW60E1fjM7YAJIhVafMC9UvS49bYlOJX8rvh4S2FwMnxM7tVrBjwnGn1Lv147YRZX7HhgbSWoCOcOO76k35laZxkiMKD9YCFJwbMy6i16zb9nLhQlRbYlIevyUDIdJmGdVUGmCfp34z+GcrlUYzmDAIalWzRi/75oWv80cOP7CywRqfEYDRcobU/DaM+OA7Nd2kkK58LtDO+pjWrNZfCblt47XTXRMg5dOpE0I7f1paDaZhU758KkA7GljI4Fbit8NgmspCqYytK7ckegRPbkqJQ== 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 MW3PR11MB4569.namprd11.prod.outlook.com (2603:10b6:303:54::7) by DM6PR11MB4564.namprd11.prod.outlook.com (2603:10b6:5:2a0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 2 Aug 2022 06:30:37 +0000 Received: from MW3PR11MB4569.namprd11.prod.outlook.com ([fe80::2d0f:61c3:a579:5ab6]) by MW3PR11MB4569.namprd11.prod.outlook.com ([fe80::2d0f:61c3:a579:5ab6%4]) with mapi id 15.20.5482.016; Tue, 2 Aug 2022 06:30:37 +0000 From: "Rohr, Stephan" To: "gdb-patches@sourceware.org" CC: "tom@tromey.com" Subject: RE: [PATCH 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type. Thread-Topic: [PATCH 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type. Thread-Index: AQHYVld/d1fm2wYrDkmpYy79VGQNmq2bxebw Date: Tue, 2 Aug 2022 06:30:36 +0000 Message-ID: References: <20220422144420.3545190-1-stephan.rohr@intel.com> <20220422144420.3545190-2-stephan.rohr@intel.com> In-Reply-To: <20220422144420.3545190-2-stephan.rohr@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d39d41d0-dc16-40f1-6bb7-08da745082fd x-ms-traffictypediagnostic: DM6PR11MB4564:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 76YTybxNKR3Uu6tSYiXpXOp+fTd+2a2fEKtKc1FLXhKUcpbay0uHGE25PDDPRHG1FffFbwUeRZagZeNKNTN9XlYprrs0+JOm4QhzQk98DMft/v4cpWMiWTavgalb1P4V1hZpVuW+qdsXt4dmQ2F6q9aNK0TvYY5W/N/0ZO1chHzaV9oFYV9VfmRlMxnlicd6XeFxF/hdtvlrtvBNlQFIEsDqovtLRumvQTTkLGS/dasC94qK9+uFAg4qVB3iZaWCVhhN7aZJQ7AfBAtP1Siq2Smabb8j7VFMeg67EufUQ7blkWhk2lT5z4Tgru1Ale6jSHZAgJdPuYsBNFYHiv2pkdqeJqDcIQmONvBvYmGRbJuTP8T0v1ERorJ+z4lrYRWQV555R2oQaXEULyIBCivBb6Nc8Uq/J8FCj7LsQeJxhfdMB2zK/Vt+TNkPABpxu/2NH7j0ngwuKCY7QrQ+LmCbP7Rd5sYx+eWDO5hZsTDgL6lCjtqM/JHMfhp8E38fO9BK6qzH676Q0pHSf6HeDLTYcgn51CgyR7RNIV6XXZr4jqYp4oU3k7wGmezP4Wy6Crj/V74L14xtoVldRrFUggHmARS5vxl2iWisdaAJfvwaYwID50+81gnQJ+p9oec2fvqij1qwY5bNWpTeqWPE6IIcegCO8vzpdgVe5rmlao4uWRtAnXwU/rh9i+iXb7liVQ4pTqH/W3GOPHma3yFaF/j/8Z50luwzjKsrVBE+2R7yo6RQMHSf8FP1X60B7F+mfBXgJeCVx+u3NxPAe5yvFB9dnTQv2qSmFy5BSj3BfMj/EGo= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW3PR11MB4569.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(136003)(366004)(376002)(346002)(39860400002)(76116006)(64756008)(66446008)(66476007)(316002)(38100700002)(66946007)(66556008)(8676002)(4326008)(5660300002)(33656002)(41300700001)(82960400001)(2906002)(91956017)(38070700005)(8936002)(52536014)(83380400001)(186003)(86362001)(478600001)(55016003)(9686003)(26005)(53546011)(6916009)(71200400001)(7696005)(6506007)(122000001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?FlvpSzt4uWIfGzyrM9dUtEKLzgMsoqQBzLisZUj6ZUxH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XtpBTVCpOMaPMtDnYdVUASwQKxxUY23XKHl?= =?iso-8859-1?Q?0g9Bds9GCJo4lmKPOCeV+wzeYZDG40Kf2xUxFwRaW/m14RD38aChrbgBp9?= =?iso-8859-1?Q?nhspF1tqIQMNcvq8WpItM22WwFI8cirmU5h4HIDeR5nq1rY2RtDzJd2+W0?= =?iso-8859-1?Q?+bZquhJo40AYCUn3A1PIapFwdz1bD+JC546OZsI6+JlyXXYMkQT1kPXJf8?= =?iso-8859-1?Q?+AkxvWIKQrFU57wRsmM/hrrYEO+yhXTT4GG6d0HyOfN4rUv6dP7Fh3giqK?= =?iso-8859-1?Q?v9mmucuydlDKGKyyp/DoYNHSIscVHpTfRYXTgM0OrUXi6o9VI6cLPfeKTe?= =?iso-8859-1?Q?gqST2ixiUEJwrJwORF2ZdcRBmtnLXyfcXojYa4cFeBdzPIwC7+a/ssBgN2?= =?iso-8859-1?Q?p1pOoMegoGAqxsTAlEy0yGE64o/3aO8wPKf6YFnTjtJzY6m6o82c++2Nfq?= =?iso-8859-1?Q?GxFfl8zwBg4bahaudaUYScf+QPCQSCa0dOB/arXDdYFCbG25oQwF8sWfAc?= =?iso-8859-1?Q?fVoEyV8tXLfpCcPN2DE5NiszqnbdXY7TbpJs+NROz0ER/EQNQhU5BhKs/X?= =?iso-8859-1?Q?T2zaXe+zQkUrCSr/W+QubJClOrQ4suMdO3RTe31I0U3Wb6DvlLsHCnWAUI?= =?iso-8859-1?Q?7sU4d7PdAkK+jKaa1mWu+X5zI24iX1qY9EKKsvTH2/t4c65cwZRvLdbxb/?= =?iso-8859-1?Q?NuOF/OYIEcFtlK+uq0GZ4yX0Dm5LbJlEnE?= Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4569.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d39d41d0-dc16-40f1-6bb7-08da745082fd X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2022 06:30:36.9573 (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: 9p3+kZfhuv0j6wQDIjoWnKrD+v/Klgq/zNtb6ZfrGTxGPnxl0xIBRtyKOSUPPxwsF9ewuriFTutCcXGwXigGHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4564 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2022 06:30:46 -0000 Hi all, I would like to ask for review of my patch. Best stephan > -----Original Message----- > From: Rohr, Stephan > Sent: Friday, April 22, 2022 4:44 PM > To: gdb-patches@sourceware.org > Cc: Rohr, Stephan ; tom@tromey.com > Subject: [PATCH 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values casted = to > different type. > = > From: "Rohr, Stephan" > = > The 'rw_pieced_value' function is executed when fetching a (lazy) variable > described by 'DW_OP_piece' or 'DW_OP_bit_piece'. The function checks the > 'type' and 'enclosing_type' fields of the value for identity. > = > * The 'type' field describes the type of a value. > * In most cases, the 'enclosing_type' field is identical to the > 'type' field. > * Scenarios where the 'type' and 'enclosing_type' of an object > differ are described in 'gdb/value.c'. Possible cases are: > * If a value represents a C++ object, then the 'type' field > gives the object's compile-time type. If the object actually > belongs to some class derived from `type', perhaps with other > base classes and additional members, then `type' is just a > subobject of the real thing, and the full object is probably > larger than `type' would suggest. > * If 'type' is a dynamic class (i.e. one with a vtable), then GDB > can actually determine the object's run-time type by looking at > the run-time type information in the vtable. GDB may then elect > to read the entire object. > * If the user casts a variable to a different type > (e.g. 'print ( []) '), the value's type is > updated before reading the value. > = > If a lazy value is fetched, GDB allocates space based on the enclosing ty= pe's > length and typically reads the 'full' object. > This is not implemented for pieced values and causes an internal error if > 'type' and 'enclosing_type' of a value are not identical. > = > However, GDB can read the value based on its type. Thus, it should be > sufficient to check if the type's length (potentially shifted by > 'embedded_offset') does not exceed the enclosing type's length which was > used for memory allocation. > --- > gdb/dwarf2/expr.c | 6 ++---- > gdb/testsuite/gdb.dwarf2/shortpiece.exp | 12 ++++++++++++ > 2 files changed, 14 insertions(+), 4 deletions(-) > = > diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index > 99862583336..6330a5787fc 100644 > --- a/gdb/dwarf2/expr.c > +++ b/gdb/dwarf2/expr.c > @@ -174,10 +174,8 @@ rw_pieced_value (value *v, value *from, bool > check_optimized) > } > else > { > - if (value_type (v) !=3D value_enclosing_type (v)) > - internal_error (__FILE__, __LINE__, > - _("Should not be able to create a lazy value with " > - "an enclosing type")); > + gdb_assert ((TYPE_LENGTH (value_type (v)) + value_embedded_offset > (v)) > + <=3D TYPE_LENGTH (value_enclosing_type (v))); > if (check_optimized) > v_contents =3D nullptr; > else > diff --git a/gdb/testsuite/gdb.dwarf2/shortpiece.exp > b/gdb/testsuite/gdb.dwarf2/shortpiece.exp > index f5a933e521b..19cdec83193 100644 > --- a/gdb/testsuite/gdb.dwarf2/shortpiece.exp > +++ b/gdb/testsuite/gdb.dwarf2/shortpiece.exp > @@ -98,3 +98,15 @@ if { [prepare_for_testing "failed to prepare" ${testfi= le} > \ gdb_test "p s1" " =3D {a =3D 1, b =3D 0}" > gdb_test "p s2" \ > "access outside bounds of object referenced via synthetic pointer" > + > +# When fetching a lazy value, GDB typically tries to fetch the 'full' > +# object based on the enclosing type. GDB does not support the reading > +# of a pieced value with a (possibly larger) enclosing type. However, > +# the user may want to print a value casted to a different type, # e.g. > +print ( []) . This cast causes an update of the # > +value's type. In case of a pieced value, GDB failed to fetch the # > +value's content. > +# This test verifies that GDB can print a pieced value casted to a # > +different type. > +gdb_test "p (int \[\]) s1" " =3D \\{1\\, 0\\}" > +gdb_test "p (short \[\]) s1" " =3D \\{1\\, 0\\, 0\\, = \\}" > -- > 2.25.1 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