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 20A883858406 for ; Mon, 13 Jun 2022 06:18:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 20A883858406 X-IronPort-AV: E=McAfee;i="6400,9594,10376"; a="258620284" X-IronPort-AV: E=Sophos;i="5.91,296,1647327600"; d="scan'208";a="258620284" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2022 23:18:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,296,1647327600"; d="scan'208";a="711885256" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga004.jf.intel.com with ESMTP; 12 Jun 2022 23:18:44 -0700 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Sun, 12 Jun 2022 23:18:44 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Sun, 12 Jun 2022 23:18:44 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.176) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Sun, 12 Jun 2022 23:18:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H2yWagW8d4mrnpWs02v3mYXVSHvU26/9N44allToLTfdMtO8yCxRFH9i6HAQe+2i9X/bkUsZ5EtpTb5TIPLh9QrUFCrjmgKMi9RJeJgkBD2ARNJefAs6aX4wCHMSVEibC3SWZchz4YYCuvaYNbnWonmHLtBUmH9wxe8JC+Aueo75ymvYzVvSYF2OZdGIsq0ddJKztTpxjuXZz/ugwbQ+S7VxLWUO+iZ04srgQOFxgdQHL/3b71ARqb+Jwlfp1mKeSsw4vs4qfkJO2gLKOR9Vkgn6Pheg7m7TK6nJIB6TpEau4GcvYVmM5nq4zgZPYti7LfV4wRJLOFFmGo/KsfjaYQ== 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=NBC96Su7ZVnxVh0T14AVnOReE8sVZWcPRhXQLlS7Em4=; b=Cm6W5G1ibzYmVuUH7HHkI6idbCIZO+k0zudPvCMSW2lIuc62BbSTtIeGXVYNG6OcXS9e4PMpgg3av0dckQlF1z0PV+X0Vypyi4pj+nYQmbf+g3/ltmWPb5KAzFVUTEkKTWvGfmaVFvAsjBcCZSHLyntHzt8jBPjhxsb/kN1aXyZqMHkrqz9s0JSAl9DLHoPPL5k9dPiMXi9YrDsgz6JFJYptgYXZwkGRGoSEq+lESRPrjypW/vajyJRjA+Kw92gNGJAKcmU4wBlmOQa1a6DXJUVfYpg9Y2zRTNOdOEC11AMaqQhdn/1CkytX8x1xO+A9NvMG2y6fXiD3FQWPO3VWcQ== 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 BY5PR11MB4420.namprd11.prod.outlook.com (2603:10b6:a03:1c9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12; Mon, 13 Jun 2022 06:18:41 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::b54b:c4dc:320c:8e52]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::b54b:c4dc:320c:8e52%5]) with mapi id 15.20.5332.020; Mon, 13 Jun 2022 06:18:41 +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: Adh+7V5WP+7SqF8SSR+JvNb0kTVeCg== Date: Mon, 13 Jun 2022 06:18:41 +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.500.17 dlp-reaction: no-action x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cdce9bca-257e-4be1-b34c-08da4d048fce x-ms-traffictypediagnostic: BY5PR11MB4420: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: tzLa2HBTEbfElurivsqzgbLRfBeFobRvHez1wtbCDNbPeBiip84Lohkb/GIDey3RmZ/jcVMkgp7d3Jv3MFqpUGDi2Q4Zorf3MVAnQhVyq7MB1Ig0aVwhrLR9UADd40WQJTJNrSNI7mMlfmVRXUyHzoYvkzZFtj7iNlU52BGYbIl486wfL0K/hW2MwFtFOhLGDin4NhV5f8PxdYPhS+Pu12wI0MXaYG3aFUD37+5GspMNjDt6hK9gwUy1VxCIoFtCQDZwwktk8pfYmn/I2yTgglvO/XtIdbgC2vodwQZPQGkqQPLfWBEEyn1cR5zVq4A/EItkANkOKTM5R2dUVceXT0pGCgl8pqmpW1bG6SHeSwehu3J4i2vT+KO6DAssFyyX1sR/Urc5V/TF+BeR9etz/IF8ptRdN6td/07p+J32OTInXOZTYMAg42PBXg8hnk3W1gsjXuD51LpxSmW18SNGayBqVC1PBrBfn7vGA4mS2HKuAI/RY67IwxJaMP8gdJuoXBi/wLtn+UsB14R15EymLxD99yaaZfEFNLtG/N7J/T1GTzxEyuhgPEPjXkeszgyKlR6d5BvIn61SUOUPKA+iO62JRgT04WKCIqQs1+TC7iXSCZdjhK0/g+4WR5/HA37WODr9k6otWMlc4o7RSRQjVyW5FgkZZTVKaxHH22Ur2bLqDeAsT2BOTIzdl0s/Ga/h0K0kC0YnjVpGLJbJdL39zA== 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)(83380400001)(55016003)(53546011)(122000001)(9686003)(26005)(6506007)(82960400001)(64756008)(66476007)(186003)(66556008)(66446008)(66946007)(8676002)(4326008)(76116006)(52536014)(5660300002)(8936002)(6916009)(316002)(2906002)(508600001)(38070700005)(38100700002)(33656002)(7696005)(86362001)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Z83kYlggikCIi4iHq7HR97FMaaJTxJZ6jxZPHGy0OACRMf0c5MNkWBPHWRog?= =?us-ascii?Q?xm1p+oGXgOpD64WtuuClp3NL+ixwGiDPrb6f4AVnuRQQl3yo0gFUKZ+qLqTO?= =?us-ascii?Q?GMMkA336SNJRrZoMopy2U8zJIhcUVKrmBnr7oTog0htKyo7DycgK7+O4i5Bs?= =?us-ascii?Q?C9LfuoIjkcK/EjWSCNRY7BMiFZU4+BsokcLtHLodkNDyPQHtYXRZoeWwfjZr?= =?us-ascii?Q?XF61bOtSVqAOBLEfIkURTkNhPzczwCnOV/veAiLSA6kZS2/is/Ds1dc/IL8X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C4glUh+BhztImhcheMwaHuiC8WeT37zg8SxO?= =?us-ascii?Q?KRrulNP0goTI+THCeMYIxe1T0EI6PWLkPswqj8lbfUk90Fj0bZaYXSMfM+Nq?= =?us-ascii?Q?8aBd4TET/CAALHfBmGc5DYDR7zk5wzT63Npvd7ZA+lhyyRwDv/boQf5sLUDy?= =?us-ascii?Q?4fUwDw3+o18cgoFJyjYDTsLazOZZaY5UAw6MtYoBjPW/L2m511kBcumt2NSe?= =?us-ascii?Q?dEBdAaW/zWWJtF4JJJ8DnHEb0FY88fNxM3BMsCU9wQOXfifDqzhvlmuYs92R?= =?us-ascii?Q?GojvVtngpnh4sfpZa9lvgvWXK5eQmhHPMTdhZQdFXAM8/lcMQdaMz/1XmeKa?= =?us-ascii?Q?RpgOLR4E7ocW6gGg98JGyOEWu7mq0Tlfr8G+j5nqznOh+1g+sXlJsjGUXXxb?= =?us-ascii?Q?1DfRmaVRjtb9hPUEtePxYZFk3szYoIcQ+MSzOI0IJ12OUyU2QlmPV0xp73YB?= =?us-ascii?Q?EfpRv7bRNRFILX8vFe09oDfkiT/Hs8D8z6FVncryDjuT1Ob28XpO4zFKxDAO?= =?us-ascii?Q?P8JrdGDzTwPQq3pvr0/Xpz8X5PMVk2RumkIm4BgSUaHCJeBcG+TMH54Nm04F?= =?us-ascii?Q?jtKP6WeGuA=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: cdce9bca-257e-4be1-b34c-08da4d048fce X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2022 06:18:41.3930 (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: rMDkfNG13QL/y9rhvRcBJVoD/1mWYMyqNz/NKAdaqYLaK+oXprG5mlnMfwKbgH1bKUDwQ1oCvscExcy9cu+1rw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4420 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-12.9 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, 13 Jun 2022 06:18:49 -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