From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 6A9363858D28 for ; Thu, 21 Jul 2022 12:21:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A9363858D28 X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="373330560" X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="373330560" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 05:21:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="725021567" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga004.jf.intel.com with ESMTP; 21 Jul 2022 05:21:28 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) 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.2375.28; Thu, 21 Jul 2022 05:21:27 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 21 Jul 2022 05:21:27 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 21 Jul 2022 05:21:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cwT7dDNnd9dDkKa6vI8FH2HOmOrzh8qpZaw2UXZ79YGl95+hKhGU7Mcx3lGPKFeUw3vcUIJCQzcYBLJJYcRpcZZHlLnZUiNOvtnl70DaAoAS1+3tRJLPf5/Ta8PEDBM4qWQpLyiEe3XwUP6kV54LZQ5c2NRZOzwYL4zlgCtLgI+5EzVsvutmbu+QUpIEPVDvBne2eONrJAdtMcM4+Fx4hmTvE5zX7hK5vhI587KTlN4z4FSIdx72ErBZ/sd9R29ybgkt9ebBwsvBmjCnwW3JxhKV0TFG0NEweqvFsRFifrPOU/XNcLxOm3PaGOrKgsR2Ni0P1OyRjhLjmdVHfAZO0A== 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=cQCcSIwiLvw0hoIRYlwHFhvWTEkZjSktJDy/q3W+IVA=; b=N9ng+8ZLzq8/sVl2CA1jzBki6cfrpyjQ0No+5xWo6+VnIkStCKaFazk9ogWtQukzDu5zHSnciZJJwSo6MQtaokydkqfYVWk6mwPvOAfIQ30hZGy8btKnbl88YxOhHy6oc9RClLB/UbZEVhtk7ytTMUxqi3A0k5jogkNAfwadqo7FsQ7Y5ZVP2j8urrUvCP//5ACZ5DcZ9y1V3e5gPaDSfKmJYxq7eCuOSq+PiBWd45XifgAjcs8wGPBRPpcnlSGdxRZO57Pd5ItB61j2ierAnSS777eJJehjOA6kJM5wKpIa9L/p19qpjluYzuzM8PgMsKWkDhMjHSvazYS5AfAQsA== 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 SA2PR11MB5162.namprd11.prod.outlook.com (2603:10b6:806:114::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Thu, 21 Jul 2022 12:21:25 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::e889:a8fb:a657:d62a]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::e889:a8fb:a657:d62a%8]) with mapi id 15.20.5458.019; Thu, 21 Jul 2022 12:21:25 +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/d1fm2wYrDkmpYy79VGQNmq2JS+dw Date: Thu, 21 Jul 2022 12:21:24 +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: suggested_attachment_session_id: 0f57f624-cb0f-8378-b547-c657e7524e8a x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1156a50f-df72-4590-0726-08da6b138799 x-ms-traffictypediagnostic: SA2PR11MB5162:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MlsjYIoR0jgFtytj5r+PqcMKDaHX6/Usqd8boYFGOB3CF5KczoQj8i7X1y4NmdBokq5DPtfdRdVYoLx5q2C28SV9AhEo7fDu3NPgg2/bHJfLc3qxYnWKO7woVVNtqgmjEydodAX22B0iwnWsFtzOLTEdNZX1yBd6met48WECxbma+VyuN+8iMQm58gEmVAOaU7wSS961iJd0buhIqlPx+0uwhgDye8GQTJ+VuLvqM2gpNStZ+9UQQhxxLtMR8Jpzw54plMpgjC0NnCTWICsRnP/8UocAuPG4vKzLeyAzdleQKsfQr3wtT5/vatOiw9/qOye4mZV3vQAi1y+oRxn6AY4dcF4amw8CCnaqw8+8TlCc4yXwcOhSPpHE9LbZDOxSoZYrGJFYmoVxczjlJJgqZLk1LYu5pWKN9AFaPoKBjSV+3PSbrhfptChbG53tWR7oPHzd8x35XPer4kZGJBg5qeXVUW+MuXylsS3Q4JsK3lwj59dV78uhJN76id098131CrOyVoOtt78CBaGeTMX0Ad7eAno4aqYrZ6/5Gv1w8pDf1y8UclW0pJu25Yc+p9Ny2Pm2cIXW8Uo/ehGlBGr2cayFFxn/wTXhqpxDbJ0zIKm5+udyUdVaBMzpsKuf2vvfQI4ZpaNjLtT2h/c7jz5Pvbw10h4/AGfQ1cMOXhNQdUTBLcFBww/7t6/q26VVD/hmKO5fPuZHUWYR6HSeCNxCaM04WCWoqMQ/L1ScFIcF6ySNdX5cu1ykQBw63ShvGwidgNFtRbnKIxGb23ZlzuwTF8KHbLyYnAv6WkyLKCzmf6RPkvPSwdiClqQ3V7PJNdub 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)(55016003)(6916009)(66556008)(66476007)(66446008)(9686003)(76116006)(66946007)(91956017)(71200400001)(4326008)(8676002)(64756008)(86362001)(5660300002)(52536014)(478600001)(8936002)(316002)(122000001)(83380400001)(2906002)(53546011)(6506007)(7696005)(186003)(82960400001)(33656002)(38100700002)(38070700005)(41300700001)(26005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?0Bcq6u73Y0CXmkjVejlAGtc8M2ikF1kUps7ddjWnbRB7EzBoBQCIGZdnao?= =?iso-8859-1?Q?/AC/Zn2kC6f3c7PlPD6JNR6BseSC5wSTibuVR3zUvV+bMcXbm+PDyDAkm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LLPLF2m3MqtUhwztPJw14dH6NJiyR10Rt+fiUT7hHDqKqYAzIH464?= =?iso-8859-1?Q?Ok1o74DkDbjzOGFTfGRJIr/0FGJNm34D8LylKDTL9o2W2V70LKUbnQ++dR?= =?iso-8859-1?Q?LE4Cq8hN8pjku8Uc2eFfmciSRk/9S0Ta577goYYbwtNVlh1q+JRb+Bf0Rg?= =?iso-8859-1?Q?fTIc+V5N0x77TJ0yLPdIufnKQD2zTzW8S9Lm/xs5SEZ7Z41P7NG0rALyoP?= =?iso-8859-1?Q?6e+HUmhT/KgccEDoBKXVa7Kr5xqw/6FRUzb9uloID+tCsbMBIi500trOPG?= =?iso-8859-1?Q?PjxA3xnTvPORhKcxxjzwZpEIBhY2A+CuLM5QoNTErD0LH3rHty627ZFJVq?= =?iso-8859-1?Q?YgkNp6AVasy+2dqebFP+VgPaS8maTi2Zj9HgNC8Qslcpo9LJyYQhdIOA9a?= =?iso-8859-1?Q?cT7/Ac01eN0kgfe5WCZorN9lAKjzM9R30243tYAW10XNBu/wdbrNHxWoUQ?= =?iso-8859-1?Q?vK4mlTnEYYAo9iOydKBJpAs7u1IS+VukfNI5QYGjI+NEHSbUqz0ZfN59za?= =?iso-8859-1?Q?0O11P2t0W27hBTj5REWlbBLV6Sp/6FIHBI82Ewkp2wOSKTFWQublaiC+oQ?= =?iso-8859-1?Q?bZBZRKVdfI3txCOPJfMhzkhsLLMYEvvgaWoInca+u58dDbM9z9wU5G8h6o?= =?iso-8859-1?Q?Ca0CVwxTNviNMov1fJwEVbHIGiTQGYY5Rl?= 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: 1156a50f-df72-4590-0726-08da6b138799 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2022 12:21:24.9381 (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: w0trqVbkqmPw5ZbUmLAwYLGksRIFdjXoDpgpqjTYpgAcbBsoQFqN+feMd6QAw6nndzY1s6RN4L3pJDcgvlncGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5162 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.3 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 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: Thu, 21 Jul 2022 12:21:32 -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. > = > 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