From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 291E3384B0CB for ; Fri, 24 Jun 2022 11:44:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 291E3384B0CB X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="269713976" X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="269713976" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2022 04:43:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="645238322" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga008.fm.intel.com with ESMTP; 24 Jun 2022 04:43:59 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) 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.2308.27; Fri, 24 Jun 2022 04:43:58 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Fri, 24 Jun 2022 04:43:58 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Fri, 24 Jun 2022 04:43:58 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.106) 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; Fri, 24 Jun 2022 04:43:57 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DX0FAes6xBAw947eetuQ4pE8j5S4FKeZBsDTngWByncoG9v1IjB/8oghyNZYK6M2TwI4z2h+dx0BZ4S9UcG7A5lGoGtdYZ32ty1BYuF85ZpQhAz/5XPMKbxnYWysrDvpQ7djGg3ljh7CWQlWHHolqjaZafa47SkqfoWW2u61tzTiLqgfh7nmcptRfsUJtNhG0tA1Ry5pjrbYIaldJQLcLDihplxdSuRH4OlJBd+t+2XicBFt0ckxoGTmWeaMG+xPZjzXirOAIfGrSGE0tuMek40K20MgrYjqNDzytcMATQc0eL1AwQqJ+1QEtyKXlDmqYr+bsagp7TztZT0GDTgejQ== 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=GoNY2RB+q3bmNjI8hWXAJSxWBX+whLgRWf/3uLh7WzbxISUH4Lhb3C9Skivg1cOPXhwB9oRIwydtqwB/B97fAcg3k3cdjZeRv+Kiy/1InjdhLvV8QUfMsBnTx6RJG8hGD3OD13pj93Z937E6csHGAR8IjP4HpYuBjvRqLg7yvGCuCNZC1+u0Wp8Mx4SoaVOQ3o/AShe6jVUIbe9Ma8M8xkVqsw8owRulBbkw67as9gI7612m/of6WkPbqHUMj9QkRBmx7BHTeHaRp6l3v4o2QDIZiOqkruWF6HOFeT9Ppf0/Hqb4epAN3M8ZIxCG6/nM3mO6QZ2Z+//lvqkX5JiwHA== 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 BN8PR11MB3684.namprd11.prod.outlook.com (2603:10b6:408:86::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17; Fri, 24 Jun 2022 11:43:52 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::b54b:c4dc:320c:8e52]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::b54b:c4dc:320c:8e52%6]) with mapi id 15.20.5373.016; Fri, 24 Jun 2022 11:43:52 +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: AdiHv6EcLnLFniPSSpGktoaud4M5Aw== Date: Fri, 24 Jun 2022 11:43:52 +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: 0329a09c-7c5c-4334-685f-08da55d6cfd6 x-ms-traffictypediagnostic: BN8PR11MB3684:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9qLndbDY8effYWQ6Rwca5GnRYZiYQpXHe8Vy/oNZ2YB7d4T4yB/lQU5Ma90XoXg7Yop1FIJBbE7mk5R0tB+KN+rGeCgC0466Kt3c8ZYqjhWc1NL3G5gCeYGH9875J+N6b9Y2uoUZAkYlr5Zl2XeMy9K6Kh+HvRrwceJiSCAq77t3O02XJblwergQTfQJZBOTl7OINS93HYvZTc26qjlkFWwuLCk2DmB2FN64Hzjk6NeTf2CPP3f8CKzcvzb/wlg93GUjqbyJ+2QJqU38jtAAo0GLcIfoBNiLwdw+vtxTpBiHrp0M+gA9FEOWKtZcQpIBsjRkHoq+V/5szaryR2GaggLbdu0T+9hEuqMNesRueTRHiTJurHKcugRTyQGRSLiYUd6jYi8iND22buRhBD8+baKS/vCe9B1Mobyc1lIXcDlr41p+Vl9WVdyp1xgSOZXRFuveNR6wJANIV8oGXDlujcwVFhtsHyPI4/L+XR2CSvU+UZSuf3UsYW3wuciF6c656FsL/u7ex+pgEB0Vga9MiIXfTkP0BrdvPfPMwWXIleWjtUa5jnEn/iIMsVjMlSEte7a4wDcdci/rmGLk8WQwmvtC5duGN3+7gWa4on2SVri8BuSzJ5P4PtccJD/UuHJKBnHDWsKrG/TYzQMHpiBBeUcsBGvGNJG1EUH4KSSIF7GfYzvv0T9dh9QVexhuHd1TS6LgQKjfKtgsuJQlUXPb78JWJUPunE619FFnBLGzbmIemnDUoWArLR0+c0uEYou4kCgpp+/m9KLyR3ozT2ylu6IAj4YMyW167Vf3OespMnk= 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)(39860400002)(136003)(366004)(376002)(346002)(396003)(76116006)(4326008)(52536014)(8936002)(33656002)(66446008)(82960400001)(8676002)(64756008)(66556008)(66946007)(71200400001)(66476007)(316002)(6916009)(122000001)(38070700005)(38100700002)(86362001)(83380400001)(186003)(9686003)(53546011)(7696005)(26005)(478600001)(6506007)(41300700001)(55016003)(2906002)(5660300002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?1S6tCJ+Lyi66QrL7O3Q+EAucmYw3WCTelzCL4AK8UOV9sGI/080DEDfdS+H0?= =?us-ascii?Q?iO4patimxtZpKqA3i3baT5/BHA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?Q?do3WIBS3vHAvBazW0A6wp0hRROC7HQsKulDe6h+LUK54fcycegan4Fmasalb?= =?us-ascii?Q?LfmkNmZk4YS+ByQ6Uz1le7yMiaKehD3qoJGhn+G4r+XGumFvksdJmZVxUy7T?= =?us-ascii?Q?lbINnitQRDag4anI7t9if499CaNg8fTxIVY522cQdNU/6I1R/S+4ppUMDTfs?= =?us-ascii?Q?KCoKRBqTZ/S/Qys9NS2Nou2pR0uTlyccg7xSokQMA9l6PONX1X0aUpg9zMfd?= =?us-ascii?Q?/l09AzYDdEoMlOB0x6HhzuMug9RLZKNjXS7QbdQgQ31IzD2H9nKy6gbgTPCU?= =?us-ascii?Q?J0St5dNv+LUTP5LLgxEELy+XCiPmeMdn9FO7+ZQSBCDCvN5uRBOzq6D3mdQX?= =?us-ascii?Q?3rPUZFYA33EojI5yhX4i76Y/q85LCYK6caGEODQRpzEWxxO3q19ukQcCAlHk?= =?us-ascii?Q?/psNM6J/K8TyT1JrpF/zLyFvuHCdUH1C6CQ4MOCZNj6Xm9H0n17ECmmWivpW?= =?us-ascii?Q?Eez2ibnp6YbBQyP/7lVjxa7X75AqLeWr6Eq3lAxVAdr26+kbGKGNjZTUW2vM?= =?us-ascii?Q?o2pd7xs7WWkxblCyMx+LWXGdtdjuGBnLgIri/sLbvuwoqKZOzj5SZBK6zm2d?= =?us-ascii?Q?GliMOKWMNxsDzEykTRJ2WX3nRcbVVGMKDtKfX8iV?= 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: 0329a09c-7c5c-4334-685f-08da55d6cfd6 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2022 11:43:52.4331 (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: 5PKnubpgxtCKlq5sHP1sUGRbne6lsnNGEI+YXuCM4UpRA0ks7XyCT/N7M05JGbI9QeGFKMTAA69ce3RUfTKHEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR11MB3684 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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, 24 Jun 2022 11:44:04 -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