From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by sourceware.org (Postfix) with ESMTPS id F096F385840C for ; Mon, 23 May 2022 15:13:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F096F385840C X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="273243842" X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="273243842" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 08:13:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="675900400" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga002.fm.intel.com with ESMTP; 23 May 2022 08:13:55 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) 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.2308.27; Mon, 23 May 2022 08:13:55 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 23 May 2022 08:13:55 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.49) 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.2308.27; Mon, 23 May 2022 08:13:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KsIN60XfLcNpIwLz5R1KN+RXm0kl1kel8d/x09G2Clrtmn0htv/FQReuADRe0RPETcoXBJPgHWli+cjG7R5jSgD7paIAuKbHUEaSLGT7F5N6RZixoRAIOJhg00GuTgECmUX2WHsdPUO2B4AUg2A2GNI4k+ogxHRdEpknye2HZ33zHTGlUwzWB31otliqLbKjEL8zxz/qUA17917ikVFvtl8esfIuqnMUkfbAmgMSz+QhnjX0YT+H9u3Uh3RO4Ec/ua3HqnmDkRFC+T4oN2ncjIndhNhtEdxXTZE44XRP8t6KZb/xUY8/g1rkSx30K3WHzAomu/lKotWWzy7zEE7BlQ== 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=E95xtlV1fxJxTu6jJnigkbC4IJpULRpaBvl4jho1/cU=; b=fZAqL98ire85ArWgShr4TfE707NddEyU9PvmmSxabma1npmrP4kAJ3Z0Xzc3wQ1afj+U0lGz+9vXZzgy7Ka9B8Ns3yPztGXcaWQ9XA8Mk0IdX4IXJL2pb9BqrsqyzJJofb6i3utsES7PDNRgrtKtBCiYZnzGOFM8z9rB9mlrm4LPdfBPKQO0dRtPfXJ9H+DQsySOQNmYw3CvOQZ3eLLdGXfMtnugrRpeSEM17AWKFsOpIiMiHOC4M6/G/uWF7sdbLUgkRBlbkhQTN7PnHNLJQMBzqvUmxp+5iK1Xy0YZ4opXF4r+zDm71wc1CQ9Z/EA/iCagUJ5b0xyIJwcFCF2PeA== 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 BL0PR11MB2996.namprd11.prod.outlook.com (2603:10b6:208:76::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.13; Mon, 23 May 2022 15:13:49 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::c0e:51ab:3f72:b981]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::c0e:51ab:3f72:b981%8]) with mapi id 15.20.5273.023; Mon, 23 May 2022 15:13:49 +0000 From: "Rohr, Stephan" To: "gdb-patches@sourceware.org" CC: "tom@tromey.com" Subject: [PING] [PATCH 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type. Thread-Topic: [PING] [PATCH 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type. Thread-Index: Adhut6ihI2oUaIGXSvucgsqONssFeQ== Date: Mon, 23 May 2022 15:13:48 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.401.20 dlp-reaction: no-action x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3b4c7bfa-8234-4ff5-1c73-08da3cced6b5 x-ms-traffictypediagnostic: BL0PR11MB2996:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: TMixqrea1N3ZKsTO1QALgRX5Jx2BUMfg26vGhD/6K/DStUNDfhLXOjka8BdfJIs7AVRwEaNFvFoNJBrJ03h4hrejUpbGqDpDZuYvsL9c/8zuWtE7OlY3lpotR1HxPnTEMA0VufIlq/Nv3BAWArhN3mgiGaHdeYVsXjdKEyApItyR1HwQkvQlrc0GRoMM8/IotQ0OGg6wWIrvOZu0Q1qAkD5jqXl1BxjAfXOq9f3hGuA2uTefsZicC36TfUZf7paQwjAnHxyBGM7vNFH+47g+3jT5F/Ao2s7Kk4PmzW/ljgGJRNSTbKigz5vHk0X1tQrfKOSsTwRAgu5hRcvGu6i3renOeQeJ3cHIBdLTfxL2WW03BHT+9KdRhog5HmFEKOkvv3TnYouYFzKROj0jA+h227Dj8bZaznL6KX6oNpMdN1Lo1EFydF0sMahxx+CXoCuhN1XWYAz1Kj3nqdRSL4VRRvPsJAuHUe15dI/P8DXY2CPPZeTp4JnAUGln98O0xtI0RnzLc51sU4paXdQqujlG/3UWH1TL/Cc3wL2qBh9T+fvlJhvcb5LkAvKsRUZJpVzwYRUwVlq6pPrcHn31Azr0pIGh+ZozN4+rwIxLeuwqVcN0t8lKuj9f54SBXgMnirMx9esZJ4UHhKO4CgOs1ZdQcsqafESou3s2AWnK3JpaMc4VQVYTA2c2LiIPP78XnTwvnYgUiJzQvRmEJb1g4HD+dw== 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:(13230001)(366004)(8936002)(6916009)(7696005)(6506007)(122000001)(5660300002)(52536014)(4326008)(53546011)(83380400001)(55016003)(86362001)(38100700002)(66556008)(64756008)(66476007)(66446008)(316002)(71200400001)(38070700005)(82960400001)(508600001)(9686003)(26005)(2906002)(33656002)(186003)(66946007)(76116006)(8676002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?24fWDwAlruDfpmnPd6XeaUgXK6+Wn2ht/yrZLyjccCBFYyeqQ18Uebdga7jn?= =?us-ascii?Q?WElmGYdXsw2dljsKpadMAGNBz1IBNE6ApEkbMZqEoc5BQgOQS5NLw9YbvS2y?= =?us-ascii?Q?AmaDNRBFDpjyhBgrONpl00H3Vzvk4Tn2SpGwqDV+e+q9/qwVZvAcPpOSGd0Z?= =?us-ascii?Q?FsZTx4KHgvUqaXWD+5S+tFA5gBxGqB9dzrFtB1b4TwlcvrWfC91sTLsgD4uM?= =?us-ascii?Q?q794FkpQVZvn68KocQVjJnE0gl50wx0ykSd/g4PyIHNIjhTnMbGjdUgD86NP?= =?us-ascii?Q?v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bk?= =?us-ascii?Q?4jrAS2CK++W9nfm2XP+erjIFa0Eoo/qEbXFBJFc6kCm5u50tfqF2Sm6gvoYd?= =?us-ascii?Q?hUNvj9EFS/CK/olgupehI6opkOnwAL0E5BhNIzPaKDbkhLiZZrWzwVlgVqS6?= =?us-ascii?Q?ermGGS82hSASZ9GLqQI09mcuhJvMSA0UkcQsYDwR0Y062uwDBBz6Ltoo5waF?= =?us-ascii?Q?I50XjEfRby89jjLSNNs4SRB/KUrrEAaIh0UI7WIkL/A4lrTtMhPU9exNDMMv?= =?us-ascii?Q?en8zSENyvFvzba38xZDIZRgl1FARTGYTkP3I4vCHTm6KUmb1ssREzO1oeUcS?= =?us-ascii?Q?V9GJo684V/5ebO73QGQmLRZCJc9wnC9G3ibMvnI5Bac2jlQSJ3ml1wCBTrTI?= =?us-ascii?Q?VpJ3Z4h9uGpUMMe9XjByGhNZ2tijT59y+TAFXNMRPL6/oBEERSLC278Mk7Na?= =?us-ascii?Q?fWuzOTAtc7I1Gh6Mbc0bdCaZugWEa1Ox1eb81VILPsvjAQTlt5xoXt7LlkFT?= =?us-ascii?Q?1eEtNIrrg9hM287j5wflyAee+n5f0ROT8rOdFe+8FhnTlusZJIaZ8bnRAzLb?= =?us-ascii?Q?EOXLKluaIw=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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: 3b4c7bfa-8234-4ff5-1c73-08da3cced6b5 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 May 2022 15:13:48.9157 (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: 0gGEzuRMuPou9Bv3rLTrMxqL7jNSpWY/wXhl4tb7WVI1EtP9XY+v2w8iUahx30EC9ayqZtN68GBCl5jtV2TlLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR11MB2996 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-12.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: Mon, 23 May 2022 15:14:06 -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. >=20 > From: "Rohr, Stephan" >=20 > The 'rw_pieced_value' function is executed when fetching a (lazy) variabl= e > described by 'DW_OP_piece' or 'DW_OP_bit_piece'. The function checks the > 'type' and 'enclosing_type' fields of the value for identity. >=20 > * 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. >=20 > 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. >=20 > 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(-) >=20 > 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