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 902423858C2C for ; Mon, 16 May 2022 09:33:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 902423858C2C X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="251292707" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="251292707" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2022 02:33:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="699455032" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP; 16 May 2022 02:33:00 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) 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, 16 May 2022 02:32:59 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 16 May 2022 02:32:59 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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 via Frontend Transport; Mon, 16 May 2022 02:32:59 -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, 16 May 2022 02:32:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eH2dG+CQcFSbBQfdz9CoK7GqPmBosTOm4t+Cphubbyp+s0r7s/ESob2g7gZbWCI7xESZ6YtC4vo/0cxoYBVlbn2wligTUQiyMMBP5R4b/o47/a/mx2TYQzN/A7HxoIDry8fZPIZBGdnNgwMmv0RPsHZi8KPKqsAJoQDnlVmuxJBC975FMLW7G2ZGNwcVKKwjRuyP6QuPNXvt7RZtDQZlUKAC9xP0Tz4h/PAiLzMdM0AR/4MEwnnMk62JVk2R2g91XcBFv6r9kJVsdY4zq1hRq0gWcx0FfkYzjTWMxx5UqVdS3IaIrCRquG+2ycN1T29J0vAZEEmoQhHIOai3nk60WA== 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=RUt1ZLexSfPAG+1qjp12TBxwTPmuVEhZ8m2HeppOARs=; b=jiNe6SeCtdH0k+txRcMMPwNZzTKg12EtcTufSzvbViyBKDUiYE6xHPFiBYSr02l5OjuGstpkzhK5Y8dZkeAi0xmlsI0Ixqz6OnmtkC3+1YYCRVn0tgvD+wBKm+aMy4728w+wXS/EsUSPSlMV8my5xpVe6KS/7/RzDqeQ7Q2hjT+1nfpURiOSzCgiN9f8fHNlq/JuL+TxUgoBvYpZ0o8qStPhTumShp2oSMOZT4kR2IkZIGeGUQIop4jUEepnQbxctNTEv9ALmO8h+OcFWMa0J1ZFf+9zAadgp55GAmk16qnuke4MqxsUpRRIGkcSEmDQ9G2L94BEWvoC9wd0ycTeQw== 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 CY4PR1101MB2166.namprd11.prod.outlook.com (2603:10b6:910:1e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Mon, 16 May 2022 09:32:57 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::c0e:51ab:3f72:b981]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::c0e:51ab:3f72:b981%9]) with mapi id 15.20.5250.018; Mon, 16 May 2022 09:32:57 +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: AdhpB9e8z1bnA/aQTAmgFwWv8dOygg== Date: Mon, 16 May 2022 09:32:57 +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: b3939813-8d4f-473f-6316-08da371f0fac x-ms-traffictypediagnostic: CY4PR1101MB2166: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: fTFXUgYsBW2rSOHgK+Hm0ycqkYxfNBY7AKil/MssimCKNa8S6h+2qXPydrKjMfpB2PwS/+E/3iUSIUo7v6PehutFdObspacV4h01Jajl1EwfmrAIEy22pbP7KVUBgn+3VODjdxCL6Afadz62vgwJMc9YW9NHTQngCPO3LRRJVAugDvmRTshbQmgnox8yOWVNQPlLDvnoabomoP0oUBjNErARofVBR+tLPRuBslTIS/CdJGVFoFyykKwOfZn608tSk1/pYhzaS/GS8pmnzgiDqbNVdIn0DvFBei7UtbDGBJiwai9dlXkyGDjVIeHbPFyL3iNnQLJdhebs2KyIcEiXHg2gxZ6b6MY81pKUvrJhApaffGy5b7gI6K6wshcMFbT0TNoQXEkbds0sKJh7IwabsjYkgeoXy0MJJkuEbBREpYAmQDiMPSL5go9BT9l4sZaCms66TftQkNwmxsjx1poToHtiKu4t860/qiyfO6OZqpmzkBfyAGTw7So9bJkFtTuZj4AHmE62EGXJxg5JOPH2wnN7kI8rQGupQefo6GadGmEiGQQ9fFTWiZLGQgLprS/ChyfQMzBeXGhd2JqRlNPAhJTVrZBnfNoMS8hE11/iDLGP+8Omj7YsyLI3a6m1lVSrmBqLNbT7bJP/3tX5eCA14gPhZ0Q3RvroC9vUbRuF0fV46P+rqGImf4taRx+sMCQooAeTz4/85RgebNZ2iLLNEw== 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)(66946007)(66556008)(66446008)(66476007)(186003)(52536014)(7696005)(76116006)(8676002)(4326008)(26005)(71200400001)(122000001)(82960400001)(83380400001)(6506007)(86362001)(6916009)(33656002)(38070700005)(5660300002)(8936002)(38100700002)(508600001)(53546011)(316002)(2906002)(64756008)(55016003)(9686003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?+kcutZUESrglfqhNmi2WO13M185oe5c7T7O08WH/olyKIHkudRnS/mS51O92?= =?us-ascii?Q?Sj4N984fdJS39epUPGFgiIbDwOxqfo3wmrHPaVwKUtgnc7vU+ZN+UaPYLrYO?= =?us-ascii?Q?/R1qckWFF4e1kircHOQlgROdaSrfhW7wDzoOQL2ekIZI/kSj6rcOEuAFiCP1?= =?us-ascii?Q?ubFMecnGEI6Ih9ruOPteYXSEEL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vsVZE+tTSXv2oFFFd79jg2SBe7gJxEGq07KfgJ5lBqTAcakwVqr27xJQ1?= =?us-ascii?Q?JotpDVCtCJcw25luCapW2G5FaQFwF8CIvpg9TPyBmfYIz9xcV0NLVHm3AL+y?= =?us-ascii?Q?6UYSd0A+CeuO/dPH+fmjs9AkiRzvJW423qlPQLqC+maWx6oFU9vz5WQdtS+N?= =?us-ascii?Q?iqgS7VTeiX6ZMI749kkIoEXnnBJ+xaGU+QlbaV84pxXBsHQF23xtm8prlQG8?= =?us-ascii?Q?WMpvPtgrFIFu8Y348ao19Jq6ozESNL4YJTQA4Ckifd6Sti0EUnStRiYjNFPg?= =?us-ascii?Q?8PK/RwSnFoNyIsl6aGpKOlXpZ1qSR9A6jHaWdIOWiOSFsSo84STKhWq1heb/?= =?us-ascii?Q?g3RbNgl3dC5SU525A42PyyyC5/haavsKj4I1m4sYOcRQV/20ZgO1Kv49Qvyi?= =?us-ascii?Q?wLHId3gReLNn8sZaNEa2cSV1xE/ZSbH4eH3PqOuTSx5EMkjff+YAc0ejII5o?= =?us-ascii?Q?uhMsXrzaeWsoo1m8CDILKCKWlSTxV/AAmh5lojCDVbupM8N0dZg6egSiLGdx?= =?us-ascii?Q?391ASN6UfhUuyisJ8/YT20TykXsYslN4tapTL6O90AsULLOb/H+B6iTulMs9?= =?us-ascii?Q?+nOPyIhzKpBiq4oH02ly+O43OqwIS9PDYyE0Hz3hp1syd3s0plfWngc4ZeuZ?= =?us-ascii?Q?UGXGmM8New=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: b3939813-8d4f-473f-6316-08da371f0fac X-MS-Exchange-CrossTenant-originalarrivaltime: 16 May 2022 09:32:57.2347 (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: tw9tkwhfJIreENlWl5P844U6DJ7+lnyZgQDc9LEI6ytLIfMVaQrvoQLvyWxmkvKWpe4ZmnxFUfiqUT5Fih46Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2166 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-11.5 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, 16 May 2022 09:33:06 -0000 Hello all,=20 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