From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id 6C3D9385740C for ; Thu, 14 Jul 2022 07:50:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C3D9385740C X-IronPort-AV: E=McAfee;i="6400,9594,10407"; a="347126929" X-IronPort-AV: E=Sophos;i="5.92,269,1650956400"; d="scan'208";a="347126929" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2022 00:50:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,269,1650956400"; d="scan'208";a="600036202" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga007.fm.intel.com with ESMTP; 14 Jul 2022 00:50:40 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 14 Jul 2022 00:50:40 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 14 Jul 2022 00:50:39 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Thu, 14 Jul 2022 00:50:39 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 14 Jul 2022 00:50:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bCW43lMLTYPc/feQZiFKl1dCRWV0cU+IGR/MUM62NBaXVTAqvFHb7JzTbJJ56ZR/uoUU2SKpvblkCQ4/LeO7X0h1KNP6tS84Bf1Sw+D22w0PK8/Emaan0O811CbdcbiPU1qVSQxxUL3QW4joPweNFBcqAbHl6mFwhUuTG6+WBbhxub5kysdgxrlhb28loJumjtc80rX8e3qwkDSjPvt7XKbJ0ROGt7cu2Ft3j4naZY7Yn8d0KYXApJowGG6KdB0b8jZYTFDDPfHkGVTc1ORMBYWOdDozCZZkcodjVabo5QEO+K1g+5XVid/X+KyPk9en8XZP07+sFtE7bzQjpWkP6w== 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=oMqXsVf+6RRhZ83SiGZcKPPxCI2vCSNnwkruo5Ua7FYiYPhNQJqPVbIB0ZRlTU5uX6uGRKzSKd0cwjOWVBqA6pjSszrnJoyLxnfNTgAZlMCODIeyJNogk1d4p23l2rb0FPpShuCBOIQEO+Yx/SmD7B0s1mlj7F4MyZPtaVFz0zhfYkEs1J0LB9ipskBi95Tl7RGpe8AEOmWIPzaBCiwGUI23W59pC92fJHICf61aN/WJDTu1zmSXDsBNyzn+0rkvFtZP8G8jDGyNv4D+fhFZ0Azpfn8FcWootLDqqHGkt9TjuXgwRRTphIgKBuiZiAZFCcwf/WlAWBiqgYkGUpSWDA== 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 DM6PR11MB4564.namprd11.prod.outlook.com (2603:10b6:5:2a0::7) by BN8PR11MB3731.namprd11.prod.outlook.com (2603:10b6:408:8b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25; Thu, 14 Jul 2022 07:50:32 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::412b:9705:f826:1568]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::412b:9705:f826:1568%5]) with mapi id 15.20.5417.028; Thu, 14 Jul 2022 07:50:32 +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/d1fm2wYrDkmpYy79VGQNmq15RJfQ Date: Thu, 14 Jul 2022 07:50:32 +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: suggested_attachment_session_id: 1394967b-d01b-6ae0-ab76-ed499ed167a3 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5ac0a343-e154-4890-de19-08da656d8787 x-ms-traffictypediagnostic: BN8PR11MB3731:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7FQqNKKnsr85RIwUEc9FkFmQ3vkrgefPsRg90oVeWiGaczmTwg+fN/K971r2y7YuFwizVaeb0PXpRu3EL+M0sDJvCDJxVpVQCMjhUGBXhzGc3JgF5azSjQyqCOYNFj1G5pDjYVVJmBBzWmMqr9CW9FP45390Ki5BZOYKVSMivoPqEPIWmgUuLqWRa22zjCbPaP6aHVu3NqDgdnukeBTwAEqI7T2VS5h5zt+x5HLkwmmB5h7xpvGW39tQr90zRDwCsj8bloKRpFJNHbTQ2I3oX2xS1KmL9v0DdErxZ1ik/14qEz3WtdaURRx2h2k/UMDuHnuRPcf40a/yoCl85hGq5dSVN6Ti28AwEOtm3mf4kVcbOu0sPy+dAbXjJe3WGrSHfInKI2z4K7i+Si/iIh3NsFiMBc0tebRjL4YqPMR5tmMam7W0fYZUAlwBGXJsG1LxiiITk8i7ZfhG/HXryJk8nMXRQGulvp3XGTIDy02PkqKAAj/24sbuK64URsydviCfsLtl7Sr4GUb8X0WxfsZ1hH0B80O04nUxiszleFwlHm9QoIbE9Q5QUOzL/pmP3tBkV8xRTM1GUizddq9WN+dApJmM9VcveWWmbZAOBh3VZZTaz0vNdWfzKlEHKqjWaPQwcAIGcfMDySdIEKxikP5G0miDDhKuc0q8GE3aqZhaksupgyCdE+dTUNMNWlRvGA3lrWLWUvfD4jnNQfSMnci3NAch4ISBRUbLBBsBoV6Huu0CX6LEEBWDRA559j/w0yp8ye1iqtn8yAoMMu2KXrc1IzoFzTkEcYj43D9yEumvvwpzb3MmtdeCZ+V44mKiLBl4 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4564.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(366004)(396003)(39860400002)(346002)(136003)(376002)(66476007)(478600001)(66946007)(4326008)(122000001)(38100700002)(66556008)(91956017)(83380400001)(86362001)(76116006)(8676002)(66446008)(186003)(38070700005)(64756008)(82960400001)(8936002)(55016003)(2906002)(316002)(33656002)(52536014)(6506007)(7696005)(53546011)(6916009)(5660300002)(41300700001)(71200400001)(26005)(9686003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso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twUhWw+5p9ue3wRcRkYRHxULfq8E16woJG11FctAhI?= =?iso-8859-1?Q?IcerBvQJVVxvHoa6A2cFTJK2SweTtqlhNHtjk47VJN0aCeHqYA0VQO/Hav?= =?iso-8859-1?Q?UVi2QtiKxjCW0QbF0cK3/UYQ6DmowbJavWkBCPEb3Wu6fixX0QQaHalssO?= =?iso-8859-1?Q?INgtEjn9i98/QhPcCpWLcTIH4Jw0z2y0bw0HjqYX2icdR8dLT/6LtH7ge5?= =?iso-8859-1?Q?2VNAc0IHlFO/BmypVIrZ2KI35ug6tPsD+S8mWL9ZqbU8ugabDANU0tzs2W?= =?iso-8859-1?Q?/+lBabI269Pa6zr7wIxb1go8k5NVg2W9CIfXaPKfrKEYVSYbctnICphGVh?= =?iso-8859-1?Q?iSaLEZUTw5PW6J+21ZH9HxCUCRAEQqrtJCFx/i444Lj/JvOehW2Py/FaxW?= =?iso-8859-1?Q?jQwFErDmAid4bREo1hL26fgXH1tvW7DLDax/o0PEqBYNo3Hm8BBcTc1xWq?= =?iso-8859-1?Q?nNKBq88kdojp+gE532ffEHnEZVfQxfiD4IARnFeu6Y+6/ElDur2Y2fNPXx?= =?iso-8859-1?Q?LuLwGZ0GmAhZ5q93VmKEym7R4HbhecebRG+aQD8gIMIChPmewjeCSCi8DC?= =?iso-8859-1?Q?9ri0mmYXLNFydt3EUaq4PjlesKgVmcb4qudv3ucX8dPZNugTcjyv/g1ppM?= =?iso-8859-1?Q?LK8CtAxHat0BYQUzBvBA+YSr8/9HH/j/41cO/IGfp2BzsD/VZ/f2wzf5dN?= =?iso-8859-1?Q?hyAd3WF1Uzy9KDeOFpJ63v8NcpQAA0KRtsE8XMT2m3oGeG/2FC2bcT51Gj?= =?iso-8859-1?Q?qkh+FpQ64JZaw=3D?= Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4564.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ac0a343-e154-4890-de19-08da656d8787 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jul 2022 07:50:32.5546 (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: tQ93ibqJSFzFLJPbpRGY5ooOCgjf3R9DxIYL3DPbfTpqv0I3HSoGnCAyalGsLPJe4hSg0P7fEMGKIDq12npbLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR11MB3731 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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: Thu, 14 Jul 2022 07:50: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