From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id D19DE3857BAB for ; Thu, 11 Aug 2022 07:09:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D19DE3857BAB X-IronPort-AV: E=McAfee;i="6400,9594,10435"; a="271663216" X-IronPort-AV: E=Sophos;i="5.93,228,1654585200"; d="scan'208";a="271663216" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2022 00:09:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,228,1654585200"; d="scan'208";a="581553861" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga006.jf.intel.com with ESMTP; 11 Aug 2022 00:09:15 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) 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.2375.28; Thu, 11 Aug 2022 00:09:15 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 11 Aug 2022 00:09:14 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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; Thu, 11 Aug 2022 00:09:14 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Thu, 11 Aug 2022 00:09:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d8cq1u28or+xQRkaaHEbQBfXapZb8n0r2cYVmQ9YjH6xXUiP0S5Ow+KYP3gCLVi3ToMnrtWU7wAQe93aaNS7pXf/zNUnlmy6COx3lsqF32nmERe1DDTnlRUt2SMjCtRbucSFDUEz13OpUa884QNq/2Qvai11LTcCa4wShRQLDthuzPNjxnehaKhoONwOId7gcZy0oeV9Xul6chOQ0sfAtJInQFod07J6Q8LRagvLuWAqMhQSj7vDnMDUIFgpFTC8E5hbxoMdSs7GqWhdX1KaV9U7fI1Dg96D4hci1Vr6JGZcXZBhWjcwp+mhYpSyrnLF0E/7pW6hlnSiTLYPmfNAzA== 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=TbgTveKF5rGcCr2rifrl75SvcIwynEw58LNMNuD2BCeigwqOtn3L6FGWu1f+6LuL9QFfJ5mzVhWVDujJn2N+Su1Yqf4q+mw8qKcfTL65hcrLA8ygx2Qul/50Xcv0TNsVKWngl4c4u0X9+01qEHJnkQDdUWaOiI74lT9bU2vUmcQrbuqhMdBnFjVBg/FZEFmzIt4y7rQ8hquqFCRdr9S6795nPy43OdyF/c5hU/L5H1S2muLyGKKvwWuzPG2GxiZ5hf8I2OkbanJpknyPRBQ52CDhRyjU4yH+lR0gBIRmESunrfTfV5x4uAS/uaSgbTNJ/bdvZaVG46t2/gn4W/qElA== 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 BN6PR11MB1571.namprd11.prod.outlook.com (2603:10b6:405:d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Thu, 11 Aug 2022 07:09:11 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::fc78:13e:f55:8da6]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::fc78:13e:f55:8da6%6]) with mapi id 15.20.5525.010; Thu, 11 Aug 2022 07:09:11 +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/d1fm2wYrDkmpYy79VGQNmq2p9ZiQ Date: Thu, 11 Aug 2022 07:09:11 +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: efd142a1-4934-4330-0e21-08da7b68640e x-ms-traffictypediagnostic: BN6PR11MB1571:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BVVOLaWtzHnMPOX8eQ1mAFd3EQwKtDIQPerVdXrXdbgd/tvrixLUR9OZNGksTopSpItP1ls/VNPn3VTNTTiCmiJkudeP63M7Dha8YVTyjzzcwE5D589yACeuii9Ym4SkDZ8euBxsDuHqM/k1B2VGe6vUrIM7EoyrW2FQhN+IU71vLdYqaiK7MmogXblrOd6qxgQwFN0Kf3g1M4IMkWsVrgE6xpdnvkLydTRwKZrXShomQgZSWiibRtJoD+D0aq7Q9vbjhPAPMHh7JavNi4lSMMTo8gr7pcdnMuSIAJXGFxGdbwD7yhaIL9repHMgp0LJE3KtTN8sYr76EuKRay8dqV112aMywbl6DdiJIUSOqFo+NEAmO8X+I1xZBpmaR63ocaLTpZ7b/SqmzkINPyh7eg5mXjSV/34gtvftmub+gfatWuEkNpnoA7kGYV2AScEu494jyS1D1VkDcDDY06c7oN6ZyTNWO3MgUR+xOvVzOGTu/N5LjFeZ5chnO7KHhYiknUaSu64ZWoKlXikGfUgA8pR8s3zW4WhxYtOtimV/tWidFjpCLBNWBkaxbtZPhCTswjnTsc3x+l+74ft0tGgDxNFGQZriqFGh48T2z7ZGEPgUJAA1htfyRN/MVporNY3nvk3ZNYudkMPkI0vSKPufAzMYuwiNa8CanBKwRj0O7T3TNRR4aWaNSrAIYiz0/qaHYNo9EpJCHY2VjGaG0NNViJMWOpBEVtHThBpimUiTgeilNbU/H77xcpMFbVFZgxYT6zpHuchJ+M0MizdkEFLy2EZfqLL7bju+0N91AbaYv9E= 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)(376002)(39860400002)(396003)(366004)(346002)(136003)(5660300002)(8936002)(6506007)(53546011)(7696005)(41300700001)(52536014)(82960400001)(9686003)(26005)(86362001)(316002)(55016003)(6916009)(478600001)(64756008)(71200400001)(66446008)(66556008)(66476007)(66946007)(8676002)(4326008)(38070700005)(91956017)(76116006)(2906002)(186003)(122000001)(33656002)(38100700002)(83380400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?iTTiAGp6iqwk+wTP9PWAT83xx/2WMbIwkDW571O0vvaa+PfbRQBQ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bUMJbEOwWAxYct+vC+f+JJTS+U57?= =?iso-8859-1?Q?E9iKAFSjYP9NEm9KhX8B/cdmCEk8hqrQOvVnea/4rfL32ISyr6CHDj89Nu?= =?iso-8859-1?Q?1pQD5naRhpsoPLxPL4d3o7yW1j7iIwr9Vi409gdbyUukV0pFe16DFhckdU?= =?iso-8859-1?Q?a0WKj7jBoHc9s3AvyKgt5wuonxBq2lFk/3Bqq6L7F/1OnD+azrmC9/flVk?= =?iso-8859-1?Q?oTk35EZ5RfHdskDgsSvw9pDBpilXTh5UMcth3hmUt77o/oN4rpn2wZbyzw?= =?iso-8859-1?Q?YFdPmwpQDDBT+ra3zqq4gOISHdwcue2Ho14+JJgX/0WJ7Nmc0sV5jjMXos?= =?iso-8859-1?Q?V8/HsDqxVm+wYnDtZn4Gt5fxaJy/2wqdQ7KsXvln4Xg41/uua6nRwM3lN5?= =?iso-8859-1?Q?AhjIRb6FIpDRkNCxTqV8TMTT9QxUYdyKxMWoTrvkhQyCadOmAm03ixVzy/?= =?iso-8859-1?Q?r07FsdWuvx+I6wcrCfuapo/t4kT2xpX25r8IlxtCv7f5x/DtRDh7AC7yNa?= =?iso-8859-1?Q?uo3J25fdn4jOOiwBNUKpw3EGOVjeLiksGSKmZQy8FJeS2HRfcK9/iWItU6?= =?iso-8859-1?Q?1HFw5y3M1n47XonR5rN7UEebsXwhscOVw05w/AOX1h5V3MRZHJBRags9z/?= =?iso-8859-1?Q?Y5cI1ImN1qgBjMtqd229kqfASaVqgx70Asst/IOPBqeZbZvoA9U2MzPUtB?= =?iso-8859-1?Q?SDSVBcUuokILwJOMndLtaoEqp3loZ9VzZX?= 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: efd142a1-4934-4330-0e21-08da7b68640e X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Aug 2022 07:09:11.1646 (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: Cp/SHKnLlZqLjFDnF4OkdekFIG+0M2akAazQ49kPlF1ZoIu5EEK+R1OTTGrylZZcj1JQnFloi8OGH6WlswxmIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1571 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.3 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, 11 Aug 2022 07:09:27 -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