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 81C5B383D829 for ; Mon, 30 May 2022 06:33:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 81C5B383D829 X-IronPort-AV: E=McAfee;i="6400,9594,10362"; a="262527764" X-IronPort-AV: E=Sophos;i="5.91,262,1647327600"; d="scan'208";a="262527764" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2022 23:33:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,262,1647327600"; d="scan'208";a="632487863" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga008.fm.intel.com with ESMTP; 29 May 2022 23:33:36 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) 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; Sun, 29 May 2022 23:33:36 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx607.amr.corp.intel.com (10.18.126.87) 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, 29 May 2022 23:33:36 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.102) 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; Sun, 29 May 2022 23:33:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ekrEOIXSqdoYKg16YqxrfJORfmK3HVLcRmVcWlGxv5YDKYBY+14O/3ehBfzzZHiw5q6ZG3QHdfiAfbE/t0+jqx48mR7hRiaXqvFNQcXdqZECBAaG72aBpn6I4PfVDtiJQeRzTyxcL0WHSoAR1VT7U8ClEtN7ZeeXZ+Z2PzqK77s05AxGGpjGsRj/0a4M7mH1gGtXibhNB0NlxnijIU23GfqEgvPOiGndmL5tHbUqIl93doFRHe+371xvRZmb6ueUt2QKFaoNNOrUVastY95q7EO2k/bT2hJ0NOvB4J+RySEjNCNqMcCkBsuqHxiSPmzmf5gS5C4uPJyG4QmCDAGoIw== 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=L4ihEPRObPJhyH5OKqiS03fCqRsuiUf4LwXoSb4FElOU8XngZscG8vLdZEl63M2WT7fW2EliMcXgvBxbw4kjBHRP7DXdmjNsjVG70IhxQupQAGvp+m2Guy8LD3QoFfpmHp7RMCPoXrU/xFd10f2BDtpG7nio+pEodIQrkNlZ4hZvazw9upHTYAs/4/HgVpdSQwr+JWyZW0KmJ/vKv/aG5ZHZl4HO+wsvAKepVCyNgAMRWB+y/f9GsCI/HmOitcsdmk52gRILJv6oUQJp3cFTU9Ry8816a0JywHIm/XwWgYxJ12oAbrCR29VRuI0EVqql+81kUcxswDqG28hjNziCig== 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 BY5PR11MB4372.namprd11.prod.outlook.com (2603:10b6:a03:1bb::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Mon, 30 May 2022 06:33:34 +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.5293.019; Mon, 30 May 2022 06:33:34 +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: Adhz7ycyHkJ7X5F+RFadlPajTfmn9Q== Date: Mon, 30 May 2022 06:33:34 +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: bf09e975-6ae7-46ab-0e73-08da42065262 x-ms-traffictypediagnostic: BY5PR11MB4372: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: PxeVMTnOYB9i8k6fP/7QTNNSBPxbvfRDEQ1ap4bKPbV79nsUItEzXnJER6/0eoZYtG5l1V5BudL0CgzoRC3+pFwB5KVfWw6Yn1q3zdvZWUfc8cNkGkbvmattpZ/Jw54E0zOVUL3KnXqDHIWz/1aTUiniUR8PPXQgPF4IvOS1XBwlJBjz+DvRGRJuhIN28qQi6bXduTW5qIfv5mYMrQ0Hfw+S4uzaGDNkEGzDPkjoxEXfYz8oaFun7xIJrYDq9FK29pBYgtuH8xANcHXhvUgH1dZlqwXlg2Daxkfw0RICU/WUVRRMPq30l6TcA814ClCiAbHdZQhejhOxnrg4Ft0zrCyVMUOD9qWiIUR3WmXibmnkXTgN5tz7zlECP/ok6yvNL4c0a55JAKx5lcvpX36bs4kSaiIGCNOXLYJR/dv9+y6O94lw6EuwgS7BrD2wKCgNnjB3+MPWOoDwlgee4okaip06jJNSzXyWXflUuOJfi/OkzSHkuWhF5gZEc9Tpsy/4Cku3/p9rhIhzugUVJY/HPKleOesvj4vh67kS/vmi1yWNSYv1Fsc1tOdTQIiUcIG46uwS/f2Zls7Kt817Y68zUez9qwr8EccMeqh1uPDcSiYno11WtA4e1CBxr5f11RAIV8yi/dUYX/46lbgsWnNzT9HdJ4BjLgcH5BgzryU3SPcepvjR9MO3d44zMnxusHFodhKHuIEcetC65xTXlvYbkg== 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)(38100700002)(186003)(71200400001)(55016003)(8676002)(316002)(4326008)(6916009)(66476007)(66446008)(76116006)(83380400001)(38070700005)(66946007)(64756008)(8936002)(52536014)(53546011)(7696005)(6506007)(86362001)(508600001)(33656002)(5660300002)(82960400001)(122000001)(9686003)(26005)(2906002)(66556008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?uk9Ta5VnMVyzJWdk07KKRWmSpLvrF++gcHm7uq/Q0AQB3uVXRfLKBYDgqBHA?= =?us-ascii?Q?dcn5gsaM1CyOIJe7ln0PHblhbHGWTdNEgD1X3VYAgwuwS5vlgUyHaOWpYmkd?= =?us-ascii?Q?cPKk4k+WoB+c766ZkfJL+c8x//XQkCEos3JPk60HnyvS64Y7jseQgv5+KPRv?= =?us-ascii?Q?+8hrTZmJBlA+AI7VbJIuojPaOhoHKNcVBpj37mbx5TqjI+aWAvYr/lSCLyre?= =?us-ascii?Q?uzcUYwnmx+cY9JA363zvjE641wNhX5hNNT/juUQEKcT0W1h4eCh2sygxliCi?= =?us-ascii?Q?1wQHfsDUhHREGu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1Zh?= =?us-ascii?Q?9cn3Fa//9fKFfCWDE0CyQ1OarLZW+H/esczNJm5AZ2svCOdwf1woDHmaTGVk?= =?us-ascii?Q?ZVEC3J4DsfywzGXxl2EGGk9w48nJL0Up+PVuXrxquTVYFwXSrJjxoyVm4Bd3?= =?us-ascii?Q?mjRxm/UySrUzVqv4RjwhQZr5NRuN09zeskU7mC4FV1Ox2LM5Coa2v5UWCedE?= =?us-ascii?Q?1oT3SmsDAYAU1Jn2S2IrXwiUpIUvrrhE0WTYss3Q7IXTBca8r4hjwyJDcjMJ?= =?us-ascii?Q?RC6ZrUKuOwD4WRUH9k1KbvOhAZVkL7BOvzlIB6xGEqpje5fRln30Hh14RQp5?= =?us-ascii?Q?ti39IjyXo5TtmE5IkytCafwdpdI7JRgJ/y5RvGrVaUF6r27S73hzNBHszJDW?= =?us-ascii?Q?NYNp2IOJ35DdzTC6ipzo5cstEdiDXUXm1G6J0Yxj+XeGXG07kJJ6+Vhi84V5?= =?us-ascii?Q?lzPSdc0VmVy1+FwCOqCzM8bnMRJSwL2hOXXv/ckeyHKUUr8QMtmu20wkzNME?= =?us-ascii?Q?tM3sd1K9Kaw3XUuUc+jF3rQFm6R6blM0RseCElvx/48yIInmD0ZS+YefyDiJ?= =?us-ascii?Q?QMiG1HsDhg=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: bf09e975-6ae7-46ab-0e73-08da42065262 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2022 06:33:34.5272 (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: ZyxjpA0C6rp1tLdo8xrffY/WRxVy4YRX3hQrxAVQ7+0Kn22Ci45cmsp/A6aT903JWUnHkaSqNicJ1uUPtmHT5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4372 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-12.4 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: Mon, 30 May 2022 06:33:41 -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