From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by sourceware.org (Postfix) with ESMTPS id 1908F3858D1E for ; Thu, 10 Nov 2022 07:58:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1908F3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668067139; x=1699603139; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=ySHEi13EGhpQtijlWt3fccHao4TLd/zW5z+LMXk7fns=; b=HBZFQDyvq80itvF7/zedIBfJ16JCE6mjTVgfVl8NARndcJK/WIJBuW2U ZP1Kyl8dEakDgGkyX3MzmvlDLKBcrsVXp1oAzpVXNRUNU08DVMe43X6Pq XtbsS6BSLY9r3Bp9vMv/SeMveURFllDT6/gnR5xMriU/CzggQSr46CWgr uv+0oWsuV6Em1Em6yz54wrsmB6WbgNBhJzwBzeznRsamDBW/6pBn4FN63 6B272ILAEHuBEYybxm4ehKIXvMi1h1lmhKBE12KLnpwvMSUVdLgVfB/5a bBu6ON6MZrxvv05qsZbN5uwuEkh4V8ISOudHxe4gOh0W/ys6yym8Ox25D A==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="312376823" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="312376823" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 23:58:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="811946916" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="811946916" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga005.jf.intel.com with ESMTP; 09 Nov 2022 23:58:41 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 9 Nov 2022 23:58:41 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Wed, 9 Nov 2022 23:58:41 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.175) 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.2375.31; Wed, 9 Nov 2022 23:58:40 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PHIPDnGV1YecXDcglKlvUczunGVpKAYWBJl5u5Qtg5iBvYGN3GFUbhg4nr/ILXHkcADJrA3SS9zUYjPN2lOrjvSGELcYqG+bZ113IxIWWs1J0oLJzpZ16fyaEn9pq4g4LllcW10poMjIc8e61kLrMHkdPxVHvqpe6VoX5+z2BBTbb0ok7oefC7O7Wx05f+Oex0tFFgFHKsryCtc6VIAnaWRxxawV1uOoUpn8rD3NtWd5468ZOs/pVyq9kxDfJPOeUUomHv7cuUp7yQ1gePLNlPnlk5Q4NpFYPqbrNkecF1cHfNq2NLZzApDVUs33ZRa6zV04M00d3VGlxHnOZ4uxDQ== 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=SE5NBqnQkYXynJS7/HYndTOGS/EaREDaSpLp19PdH6E=; b=KlN/vH8vOKe6MIciVI0y4ltV7CAUsePE5PFGDNL4BL99NSAZtHRcdBdtnxJf9FQn+Gs8ANqVuzV0GUrrpEK7UrOWm3EMgWk2FWR5d5DO3IMXXvPztfn7nUWsympkyPxvfNoMdzk3qdXXQJOBNvCC+vErgOK0OvE8+QbEKrS5rBmWzDc+XYR6+zYzoW1RU6RyZX14r5QJAv480D4t9Nnb+950XDj5g6L9LJKzfUlIJ3Yz8QnIhb4FNc2FUDKa6CiGSPrPG51rz4kVnXH4hfthgF0Hj6TmmTCm55aIBOPdIV9EAqvla/Gpf/vFHmlVsRMhOWI9T9TkMX3HfpGDf8ltEg== 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 BL1PR11MB6026.namprd11.prod.outlook.com (2603:10b6:208:391::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Thu, 10 Nov 2022 07:58:34 +0000 Received: from DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::a6c8:f291:5058:36b]) by DM6PR11MB4564.namprd11.prod.outlook.com ([fe80::a6c8:f291:5058:36b%6]) with mapi id 15.20.5813.013; Thu, 10 Nov 2022 07:58:34 +0000 From: "Rohr, Stephan" To: "gdb-patches@sourceware.org" CC: "tom@tromey.com" , "simark@simark.ca" Subject: RE: [PATCH v2 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type. Thread-Topic: [PATCH v2 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type. Thread-Index: AQHY6Hed/B4QD0z6LkCK5zePxjvcFq434yAw Date: Thu, 10 Nov 2022 07:58:33 +0000 Message-ID: References: <20221025134207.1548919-1-stephan.rohr@intel.com> <20221025134207.1548919-2-stephan.rohr@intel.com> In-Reply-To: <20221025134207.1548919-2-stephan.rohr@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR11MB4564:EE_|BL1PR11MB6026:EE_ x-ms-office365-filtering-correlation-id: c698e238-4227-4d3c-7375-08dac2f15d9d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Z1z47RltGw2Xi0U5c53rdqB2HgB7eGl60RnqgpjhI4q6wzujLPSpAo6WZfPsxsAZ7WuZxy43MJjwzlSfVJlKCQGGkA9TKklw7qp5ThxyhDBzEyhkI4lo3Y/ZhjPUMBKZeQcEykG7temeaRFCaWzknNLO3/bT2Km878wYLhXmdzh+wnuV6rmeSjlI9bMPMtiekvBic6/VJCpPjpBOEB6mrsprX5An1hNHYlVAhjP0BoZ5e2OaVimpUtihEjbzBYe9l+/nsSCM6DCMHDhfXtD2evyIvgrIN/pxLrObWrrmRYqGzTPRq3icSK0Ml9wd6FXkp9TEZSOTrGBFP7WE3/dYZg6X0GbvWCfOe2w3bAxXuirAUpqI4mOiTLyxhOOSc8QLFLMJtG0setV1FCjGWFC7p9RpMhWq4+kKg0iCvlDYm7kyg3Agyk3Vr9QieCOVWF/TZE0dpbtejbXLnuV25GpMLedNDY+WdVySJmMSDyncYl9mdOIiaiEKrDNgFzu8lW1Q5aP4VGAnCIp2jVUwlhRZggDr1TtMaShJ7iZLkjnwhdpSuDXpdpuOUCsoWccp+tUK7GR3F3B8k3T1SqOpYgG8CFJvQwY30q/g/37svA8BtKfQLBrKumIy/pzSkQwrAkqpjzD1DlrZCoCgPAMe0X1Ojt7Bbo73Xrcjt8C+9o+AuO99psVFqb9QRViV0pFC8ppZp1XdeslTf5aUbwTM4nFPWtrAXGEGAJdJrYLJEix25l+9SmRspGSv//9ZoPXMkpZD4xlCBUugROLiM/Xf82IExZEewfvWx1nqlgartcyjfnQ= 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:(13230022)(366004)(136003)(39860400002)(376002)(346002)(396003)(451199015)(7696005)(26005)(9686003)(53546011)(6506007)(71200400001)(478600001)(38070700005)(966005)(2906002)(38100700002)(4326008)(66476007)(64756008)(82960400001)(66446008)(66556008)(8676002)(91956017)(33656002)(122000001)(86362001)(83380400001)(5660300002)(52536014)(8936002)(66946007)(41300700001)(54906003)(186003)(6916009)(76116006)(316002)(55016003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?TT6U1Y0jVrQp31FPGOkIVV4fhV04ZefytH5yFIQnzBNuC249xHv3o2vbrJ?= =?iso-8859-1?Q?qeF9Wj73EhDwtuIOcROBVjiw0zU8cwVyvIZjxHgf8lA9C4BP0a9H5ZOndt?= =?iso-8859-1?Q?HL0+IqqRUT2OROR4dHLbJt9ByXg/3dm9oHCzDPAu74/pNB5bRs1gYF+Xsi?= =?iso-8859-1?Q?yDlzz+BOaskeGdpYRLPIiNi+xPLGU397P4ntaue1NdJUKKlJaeDFUEezV8?= =?iso-8859-1?Q?jBT4q5iKPrqLEKFZEcdkDWBtF7ukK3Jnto4b6ISt4iEuwAsiuXY8lnE/hS?= =?iso-8859-1?Q?zdDfYFJlTaUJF5LQjuvqrUxtILemQl9kJXmIgHV36YuEMxqDNmPTWAgg2Z?= =?iso-8859-1?Q?ZflgUMdz+3XbAs1bS9H8SMFoM54EUiM4GgHaDAV/Yu1kkJfOt0Ygp57KNS?= =?iso-8859-1?Q?NnUrf7qItirbKRJLdVtOYDLotB24Kyz8WUF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?Q?o2OHQQgbnpoajsUPs5OobPUF1X+Zmq36gZl2JgjH5lcCa+p65KiKNeclNj?= =?iso-8859-1?Q?6k+aMv8g0dBk5a6MKD6cDYnqpU1lpIyCNRevVoUEd8raRk+tjOVRJ27REM?= =?iso-8859-1?Q?d/6S25znfyrnnwidLfLSaU+Lql28TeRTT5ntMjESM1IaN7aIJSUd+PAKZD?= =?iso-8859-1?Q?O+6FzkBT47Nbhs9z5x7ywzVZDix3wH/qfbev/56PypwD/ijClBtW9ZTQNG?= =?iso-8859-1?Q?4rnbeh6Ue6KaPga3LhLAqV/ORuJxSLCJjBpVej1LiiOsX3YuFDDwDqC6ER?= =?iso-8859-1?Q?eHpRvqFvNLKUsY5PKzBrZKTWAPkIyGjj9P?= 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: c698e238-4227-4d3c-7375-08dac2f15d9d X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2022 07:58:33.9540 (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: JwsHEq8FutOMNjsX4mw+VsfavnaMdETtvNPpvbYpxLrQeJRP1dXtSFmYHVIoqT6fBucMydXyEnn6+S4OwJntxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB6026 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.1 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi all, I would like to ask for feedback regarding my patch. Thank you stephan > -----Original Message----- > From: Rohr, Stephan > Sent: Tuesday, October 25, 2022 3:42 PM > To: gdb-patches@sourceware.org > Cc: tom@tromey.com; simark@simark.ca; Rohr, Stephan > > Subject: [PATCH v2 1/1] gdb/dwarf2: Fix 'rw_pieced_value' for values cast= ed > 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 fo= r 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, this patch fixes > the previously mentioned cases by removing the check for identity. > = > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28605 > = > gdb/ChangeLog: > 2022-04-13 Stephan Rohr > = > * dwarf2/loc.c (rw_pieced_value): Fix check on 'type' and > 'enlcosing_type' when reading pieced value 'v'. > = > gdb/testsuite/ChangeLog: > 2022-04-13 Stephan Rohr > = > * gdb.dwarf2/shortpiece.exp: Added test cases. > --- > gdb/dwarf2/expr.c | 3 -- > gdb/testsuite/gdb.dwarf2/shortpiece.exp | 50 > ++++++++++++++++++++++++- > 2 files changed, 49 insertions(+), 4 deletions(-) > = > diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index > 73dfd4b4ffb..fa08ad89024 100644 > --- a/gdb/dwarf2/expr.c > +++ b/gdb/dwarf2/expr.c > @@ -161,9 +161,6 @@ rw_pieced_value (value *v, value *from, bool > check_optimized) > } > else > { > - if (value_type (v) !=3D value_enclosing_type (v)) > - internal_error (_("Should not be able to create a lazy value with " > - "an enclosing type")); > 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..f1808bff5be 100644 > --- a/gdb/testsuite/gdb.dwarf2/shortpiece.exp > +++ b/gdb/testsuite/gdb.dwarf2/shortpiece.exp > @@ -29,7 +29,7 @@ Dwarf::assemble $asm_file { > = > cu { addr_size 4 } { > compile_unit {} { > - declare_labels int_label ushort_label struct_label > + declare_labels int_label ushort_label struct_label struct_label_2 > = > int_label: DW_TAG_base_type { > {DW_AT_byte_size 4 DW_FORM_udata} > @@ -59,6 +59,23 @@ Dwarf::assemble $asm_file { > } > } > = > + struct_label_2: DW_TAG_structure_type { > + {DW_AT_name "S_2"} > + {DW_AT_byte_size 6 DW_FORM_udata} > + } { > + DW_TAG_member { > + {DW_AT_name "a"} > + {DW_AT_type :${int_label}} > + {DW_AT_data_member_location 0 DW_FORM_udata} > + } > + > + DW_TAG_member { > + {DW_AT_name "b"} > + {DW_AT_type :${ushort_label}} > + {DW_AT_data_member_location 4 DW_FORM_udata} > + } > + } > + > DW_TAG_variable { > {DW_AT_name "s1"} > {DW_AT_type :${struct_label}} > @@ -86,6 +103,20 @@ Dwarf::assemble $asm_file { > DW_OP_piece 8 > } SPECIAL_expr} > } > + > + DW_TAG_variable { > + {DW_AT_name "s3"} > + {DW_AT_type :${struct_label_2}} > + {DW_AT_external 1 DW_FORM_flag} > + {DW_AT_location { > + DW_OP_constu 0 > + DW_OP_stack_value > + DW_OP_piece 4 > + DW_OP_constu 1 > + DW_OP_stack_value > + DW_OP_piece 2 > + } SPECIAL_expr} > + } > } > } > } > @@ -98,3 +129,20 @@ if { [prepare_for_testing "failed to prepare" ${testf= ile} > \ 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\\, = \\}" > + > +# Test for correct output if the size of the original object is not a # > +multiple of the array's element size. > +gdb_test "p s3" " =3D {a =3D 0, b =3D 1}" > +gdb_test "p (int \[\]) s3" " =3D \\{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