From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by sourceware.org (Postfix) with ESMTPS id 2F8F63858C83 for ; Fri, 19 Aug 2022 07:42:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F8F63858C83 X-IronPort-AV: E=McAfee;i="6500,9779,10443"; a="292955622" X-IronPort-AV: E=Sophos;i="5.93,247,1654585200"; d="scan'208";a="292955622" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2022 00:41:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,247,1654585200"; d="scan'208";a="604526357" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga007.jf.intel.com with ESMTP; 19 Aug 2022 00:41:54 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) 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.2375.31; Fri, 19 Aug 2022 00:41:54 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Fri, 19 Aug 2022 00:41:54 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.173) 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; Fri, 19 Aug 2022 00:41:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b/E4D542e41UpYm596FkOeA8/mXWT3nLUFDXdfzHnLw0R3ayKpPipCRW3r4EAO82nngfO8DapWpM9VlCCn9KmLEPmn/1QFgOF3Tmqkm6LT4jpRD0IZKCj0t2OeyENCe4j+rICJmkYeaoOya01bhjo7mR451ENcYIiW/MHsSahVihfvwq+/BDDa0RECt7J9T4odrIJgkDgrq1yV1Sgg+e3tIT03TPL4qUf9GTr1QiaxfJBl7eqriKu/uo3RZd1uc/OmWk/ElX2EYdP1HzzpP+PcLaZ4FjvYQUYgjch21r71DWmRoe6K/v8qTwMrZnwD8ZrDjZKrGY/yvIn2Bq/gz5zw== 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=XzU7JvOWkhTBB5YWziJgKSUVxj9eyu0HT0ZxLnHTEMw=; b=MVWcVo9SBVZUo4HOtG7Eac8OgaYod7Xh82e0RNzdnePktVJ92MHzj4cYCKx+3s4su5SNrSM09GG3TsLOXZhQdo7otawGR8TxUwhvsJrCDSYnhwOIUXXQydJj8qLsnhDsyCw8H0VYTz2Re2DxDLblCCBTxMnfuA96z7Htkd3e0nXH4Huh6vzZuRJXW0jxra9kpAktt4cDyeJqyhEi/b7eTh49nfjU1A86LSBU04UzOR85232d5ao29FxSM8h4NpAAuMwHhPauvZ+kPAr/QAITI/eywBA8848eKjUONEdjUyw4nv5CxQf4yiUq/4jv8pQwtmpZfluVJ9QQdfjPXa/ElQ== 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 BYAPR11MB2776.namprd11.prod.outlook.com (2603:10b6:a02:c8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.17; Fri, 19 Aug 2022 07:41:51 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::fc78:13e:f55:8da6]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::fc78:13e:f55:8da6%5]) with mapi id 15.20.5546.018; Fri, 19 Aug 2022 07:41:51 +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/d1fm2wYrDkmpYy79VGQNmq22kVKA Date: Fri, 19 Aug 2022 07:41:51 +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: 8e358198-14a9-4bf4-72e8-08da81b647d3 x-ms-traffictypediagnostic: BYAPR11MB2776:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1rnM91RqnNKtokIf5RbFMEXu43X/6RWzHNOVWTQTHcUZD5xxWhTQKNsAHgK/DoZ8kC2Yjl+64A8wqDFwtiDZOscFy6ZoSPP8NICoZcJ8GgFjkLQ7daLUxqtacaDpE3GaRfyrdkeSgWApUNtqOQ/nC803xDW68IT9v80snG+yLoYHCCSK1OlnyOD530NNPf/0rUKgPEQRQPAHbTB4DRfP/lFH3k6amVKBm5HjenI+WigXYFSyqUqo6lnrlRcXi5O1zGhV5j7ecGIs6btV/GG/jkmh5adwC9OQiLtUybKMm85MaOwbBoexHc2JsrDU/ZDLz0mAjzceMn5Q3sJSQiup0KcLcFIgtVWTIhkBtqPd/mUydhsjhHzJnDzkm35j1OzrNA96GtduUGqvmN3WCRX2+q3tPJQyq955hR2DWa4B7mIBk6Ghz0BlQ71fuY7jO42ySESYnhkXgG3d+HxCNBua9/5vhbkEbkfc1Nz+RoFUNNknCKb0X9tT+7CnJOrnqBL/gqfqRB1NFF08/qQMdiz5kwdzmBuSsfYUEdQ9UJx7bAFq43qi1MUKsOGccBqebV5MaojLQ9ZHJUAaPKlZzy9acJPO5JTlSZdfq11Lk1BH8RH/i/tEPPDKqsymIcIem6lYisBtzeOoUwuDpMzWHBI8HkghLo6ykvbx1XolE3d1nY5uxdmiiI34v4/7Ujruzh0T8IN3meDLbnbqH0JCJxfSyj9aZ5d50RbTaFMbywAMdVqN6l/JTUoT4IBEmIHDqsRKlVye4OCH9PpDp4SX6Kv1uQ== 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)(346002)(39860400002)(136003)(396003)(366004)(91956017)(66946007)(6506007)(76116006)(4326008)(66446008)(53546011)(66556008)(66476007)(64756008)(55016003)(7696005)(6916009)(9686003)(38100700002)(122000001)(86362001)(8676002)(52536014)(316002)(26005)(2906002)(82960400001)(8936002)(38070700005)(41300700001)(83380400001)(33656002)(478600001)(71200400001)(5660300002)(186003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?eAhuqNmApZtgqq4WKJMXsl7PHCE3C25cna53OCzY9x/dxcykHg2qfrBOEO?= =?iso-8859-1?Q?aKKOwwsRS7f79cwEd86j34kywYTNpyaDQTvH4JabL7nrHKvSMgJHlQ9FYU?= =?iso-8859-1?Q?o6ggqaEoLev39W+BX7onzB+0B2JbqX1HJkoZ18gzD+XF1nFXQbhUStVre+?= =?iso-8859-1?Q?shs3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ryCeqq?= =?iso-8859-1?Q?MIOWM559UMJ1XGpyNPUqgZI4RWgfBW2/bwJLr9zYePhyM4Ax1vFB29bnsK?= =?iso-8859-1?Q?xSa+v9DDxczSN4qaUUMyY3yQ2G+dXeRnFAzPV6OB6limqEtoL4MnU5BKTB?= =?iso-8859-1?Q?vs0KD0lcWEQI8CiAaNO6XuE+A+vZvIYC/rKs/DaFQJNjAgdALFWK4i+Qxl?= =?iso-8859-1?Q?48edWd4N5Hde8p8MEI0N/vGlEg75UHb3p9UjVwwp/Qkr+mOUzZvZUaufWr?= =?iso-8859-1?Q?3oSE5aJ/HxstuAzSWdLBW++DYEwFrlQ2XdCZJfH8m9nsRuFMhPj/++VWJY?= =?iso-8859-1?Q?jnCB5Adr2pH/iZXJAQTQPcGzq/wKJkBPxPJqSkLvv2anelnLGyQs5NQhFV?= =?iso-8859-1?Q?Qrw3HvGVHJ4uUKld80vP7ee02I9SG6eMTDjE9q5boWkGfwPeyiDPvXt99i?= =?iso-8859-1?Q?lvLEi7MwV5kcl2ZVxTqqNwb57ujjTIuyQ1WJpzrk/PJ7vQtHPaypb9gIEX?= =?iso-8859-1?Q?5kvvV3Gnzc95m+066EUGcrkLZwEPfzl8aUDKMkCo4EVVPP0MVcPp4lU5xV?= =?iso-8859-1?Q?zUJOAn08aESDOd9qd7Y4tiaNcMjsC8+OA4?= 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: 8e358198-14a9-4bf4-72e8-08da81b647d3 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2022 07:41:51.4791 (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: Pje5xRrp3ssH6pxdBs/C3bI/lwR66Wdly2iRoVvBv/cSbqG26UqzE7c9ycPiUbLhfu7f3OJ7Y/UpEaGIozXdKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2776 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: Fri, 19 Aug 2022 07:42:09 -0000 Hi All, I would like to ask for review of my patch. BR 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