From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by sourceware.org (Postfix) with ESMTPS id 3AAA83858D28 for ; Mon, 19 Jun 2023 12:45:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AAA83858D28 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=1687178706; x=1718714706; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=Y7An1CnWIG0uLYsrBhc0s6tG/jVH3Gd+c8eMbW294Dg=; b=MgPyF62FrbjzRmcMUKrw4innphApA2y85dtDPqumLJaqGSBbJzVEfwi0 yuKTH9quLkt2pQahUWdX1qJzRFbiptkJU1fQs41+PY24ZlKGc5ay2S3zq PxEJEBsoEWO0km89KQH1LPYBkdP7mhppkdmOz2qodHF4MPlHW/HhS9vv6 AFC3qyVlJ/7EYsIRZwXGDRc+I33gy6CEhIE0X/mzQoAsqC4oKWaNpFQrF bXO8KaXProFD1hTrzAnDDigoLR58Iu1viNaTBm2s4VydOIeap82jhHlt5 sgJDVmcbWQzytZJOBSAKIQHgeF1ez8JPcG75v7l42y2UPLsf+oSsSgVSI A==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="359624881" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="359624881" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 05:45:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="1043890819" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="1043890819" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga005.fm.intel.com with ESMTP; 19 Jun 2023 05:45:04 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 19 Jun 2023 05:45:03 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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.2507.23 via Frontend Transport; Mon, 19 Jun 2023 05:45:03 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.105) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Mon, 19 Jun 2023 05:45:03 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jbjMHbWsFtK8YyrZlCxmhJitzrWnmyeAqvJETM56x0ku7Meg+UmNHqTPNlNETMM6VyJ+Nib0TSTuSONX+4y36zpwjDWrZ0m5EmHfNfUf+wWxhdjpzy9/dKXqP9qdAuo5YPr72U64Fw7j1L43JHeBfl3b2owJGuXIAHdey2aZtP93iqAVJVov9m/M/RlwZAOERowJiCObtuSzMMrrzFTUZN2W3yWEyCI1YGJho5E1o/Gg59GQmCZ1LUQkTS77h+y50U0tIbkoRD5y1oSAKGHvbo1gU5eW811qQ6fy5ixsaRZKAzbv6Mg6zDze2Tds9ZOF3L5uYZ74wmHvQiDGipbn0Q== 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=fok/BqAmN5P6m/i+O3/UG1xyAPEc1xV51NJ3rysKNdY=; b=ZRzflqHYKLZMLIdBDbApyqULkhtU3s4f6JijPaQG1uU6mkTG+QVIPsjuqFkG3KK4Y4HvUn9RXf6CIN8DSS3RwPwnreS2UoCELg5NZWKsHzudGxmn2yYnN6e1xA+H4rI1YFKLLghj/K3DHx+kPxW9acjoiK+pNjRbKCzbsa4fuCFU08nRYjHEHSrWGvovuiA3/B3RIVUdNxdeQx9uv9ZtcqB5uG082Jl3sgG5lsoTJJMgq3mhVvnAYIxa2jTWZQibk8crgPXDEl/U2S2Uhkfz5qNQvTMC+L0C10CNFx1O5q5LaTRLOgPB59dauhqY2s4XQ7J8Ph6Yoc7dIpUsQk9qUw== 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 DM6PR11MB4457.namprd11.prod.outlook.com (2603:10b6:5:203::22) by CO1PR11MB4849.namprd11.prod.outlook.com (2603:10b6:303:90::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 12:45:01 +0000 Received: from DM6PR11MB4457.namprd11.prod.outlook.com ([fe80::b06a:654b:7ef3:494f]) by DM6PR11MB4457.namprd11.prod.outlook.com ([fe80::b06a:654b:7ef3:494f%4]) with mapi id 15.20.6500.036; Mon, 19 Jun 2023 12:45:01 +0000 From: "Bouhaouel, Mohamed" To: "gdb-patches@sourceware.org" CC: "tom@tromey.com" , "aburgess@redhat.com" , "Bouhaouel, Mohamed" Subject: RE: [PING][PATCH v2 1/1] gdb, breakpoint: add a destructor to the watchpoint struct Thread-Topic: [PING][PATCH v2 1/1] gdb, breakpoint: add a destructor to the watchpoint struct Thread-Index: Admiqyb8FAvIrG5ZS/6pOb5XEx5wNA== Date: Mon, 19 Jun 2023 12:45:01 +0000 Message-ID: References: <20230405133456.16087-1-mohamed.bouhaouel@intel.com> In-Reply-To: <20230405133456.16087-1-mohamed.bouhaouel@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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: DM6PR11MB4457:EE_|CO1PR11MB4849:EE_ x-ms-office365-filtering-correlation-id: 7896a59f-e05f-4665-94ff-08db70c2ff32 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PqpPmFBWIkzkQKVmbwlj2enEhuH2bsGp3uCYg3R2NK8lVYH2CU9lETOQFRAbgrl/mTI6bdSJJdQQCrSivfeGk+c8XRjnBhsBRTSOEjQtGepyLM0ZK/HQwTkP1o835A0PIxqVWyztgpM0Az4nW5/u7/isDEwZog/Ld63uReriOPaxTJ5brcg6DMhvvUR/zWvkbyBuyUiil80QIAC1JnIOU7T9rj5h75TB7ZNh8NINfEZ0FWVvXuvvpW97CXz/ySut3wpsHZp+wo45wT76wyciZmqWGvyM9pejjhBayNVtBAwFsKGjpenUZ6A712mOLvqWOsSQUxH6/ZKbIBIDOp5pmKY4vty9gWmo9yQXaqQAX5M24l/JMug6YUnHI2pFnfd89a1Ep8toLKLMB6OXoV9Yco+I1NVKWKbaHbkKFQjaqmFRAcuMmZqBCDlSphxzkf6rebKMJmE1T7o5QJ099CyMQwHUUSFdUtb/hb+Umup8Cm8JFuwta9RkT4OcV5gtIJSzVweTFiwK8uBjB19NAqU2MmkvkkWYJbbRcTbHpviWZxr87HPedGrN2+Y7tdQpbuRq9uwgQplBKSYrmKaPQSJ5Iy0+jJVeFI3VOdN+IRhfDHhAHa6JRk/Bcr0FBm+g9xycqqb3XG0oo3BCCnDjs+nw/F8ShSPz8qL6QDTlhg0GAgM= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4457.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(376002)(346002)(396003)(39860400002)(366004)(451199021)(107886003)(122000001)(15974865002)(82960400001)(478600001)(2906002)(38070700005)(55016003)(71200400001)(7696005)(54906003)(38100700002)(316002)(83380400001)(52536014)(5660300002)(41300700001)(66946007)(66476007)(66556008)(76116006)(64756008)(66446008)(6916009)(53546011)(9686003)(26005)(86362001)(8676002)(8936002)(33656002)(186003)(6506007)(4326008)(2004002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?sTaZPjcUpz6Z5BhC+iEe+i4Nh0RnCCRf2QiECPFtHVy6YVAnBzZmiJVSX3js?= =?us-ascii?Q?IM5cXJDdUXetfYuLNAp+u1IhV8DJbjbu+1KV8zMjvYxCqL5mV0agwd0qyRhB?= =?us-ascii?Q?Vm6b14KWgTwTvALXl7y0rWP332SKmIku109e9Knd12lV1vk9VYRdUEMBa3kY?= =?us-ascii?Q?Isi3mHR5zVsSF+UjxoxXheHXRRh6pCrDeM6imH6IdJrxeOCY7mpP2PdE7SPg?= =?us-ascii?Q?xdIHYyJec1nskoP4OYhWUNGmksa0rIfcQxis29KJVCGaFDruDSOD8tKLCSFR?= =?us-ascii?Q?CpTrzd8vJk6bgXNlGnapOgV95t6GeXr/qQ9EE7vopIC0gVf5DMJIWFK+3TBe?= =?us-ascii?Q?ztOIzyo6cotdI7NSjh2xF3U4ykgjzjS8Sy1vkPUQ8DKr5qFDGKHJO5iW0z9O?= =?us-ascii?Q?+9XzblzN6JaT2onUrWW7cjNt1BztyQYrC4UsDSGWelcc3DmByImAe0kLKh6L?= =?us-ascii?Q?8MsGuL/3SuHEDXh4F4bFH0ClhOjIQwZrMtIIg2DqBHqi4o5TLW0LzGe4FzwD?= =?us-ascii?Q?flnNKp85M6uOKKBarHrZ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?= =?us-ascii?Q?DlsuXKknOpyLjnCqTInnW8+zQCYihEPT+QtWs4NFImBB/tdbmBIAKayTcCHx?= =?us-ascii?Q?Cf2ExVmeEblz5Lt66LM+5jBIwSy0n1luX53DErOzc738NaCE6txUXyr7CP1W?= =?us-ascii?Q?PJ77qgqL8Dauw8vBuGgqHmsnXcXuDIT47Zr7DEbs+qkUmx169Js5dsb1r/1Q?= =?us-ascii?Q?+A=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4457.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7896a59f-e05f-4665-94ff-08db70c2ff32 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2023 12:45:01.0443 (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: mh592MbVpArbMUDsSdpWoIPK54rtbB9EFT2MdcHJCVxBd3rnnYkje9qCuv//q7hC2+7nabiOWr+cGRipIrQVYR1uVJQiaoCv9awY2sTwJ6c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB4849 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,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 List-Id: Dear all, I kindly request that you review this patch. Thanks, -Mohamed > -----Original Message----- > From: Gdb-patches bounces+felix.willgerodt=3Dintel.com@sourceware.org> On Behalf Of Mohamed > Bouhaouel via Gdb-patches > Sent: Wednesday, April 5, 2023 3:35 PM > To: gdb-patches@sourceware.org > Cc: tom@tromey.com; aburgess@redhat.com > Subject: [PATCH v2 1/1] gdb, breakpoint: add a destructor to the watchpoi= nt > struct > = > Make sure to unlink the related breakpoint when the watchpoint instance > is deleted. This prevents having a wp-related breakpoint that is > linked to a NULL watchpoint (e.g. the watchpoint instance is being > deleted when the 'watch' command fails). With the below scenario, > having such a left out breakpoint will lead to a GDB hang, and this > is due to an infinite loop when deleting all inferior breakpoints. > = > Scenario: > (gdb) set can-use-hw-watchpoints 0 > (gdb) awatch > Can't set read/access watchpoint when hardware watchpoints are > disabled. > (gdb) rwatch > Can't set read/access watchpoint when hardware watchpoints are > disabled. > (gdb) > >> HANG << > = > Signed-off-by: Mohamed Bouhaouel > --- > gdb/breakpoint.c | 15 +++++++ > gdb/breakpoint.h | 3 ++ > .../gdb.base/scope-hw-watch-disable.c | 26 ++++++++++++ > .../gdb.base/scope-hw-watch-disable.exp | 40 +++++++++++++++++++ > 4 files changed, 84 insertions(+) > create mode 100644 gdb/testsuite/gdb.base/scope-hw-watch-disable.c > create mode 100644 gdb/testsuite/gdb.base/scope-hw-watch-disable.exp > = > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index ebe97940f54..862e9a372ab 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -9594,6 +9594,21 @@ break_range_command (const char *arg, int > from_tty) > install_breakpoint (false, std::move (br), true); > } > = > +/* See breakpoint.h. */ > + > +watchpoint::~watchpoint () > +{ > + /* Make sure to unlink the destroyed watchpoint from the related > + breakpoint ring. */ > + > + breakpoint *bpt =3D this; > + breakpoint *related =3D bpt; > + while (related->related_breakpoint !=3D bpt) > + related =3D related->related_breakpoint; > + > + related->related_breakpoint =3D bpt->related_breakpoint; > +} > + > /* Return non-zero if EXP is verified as constant. Returned zero > means EXP is variable. Also the constant detection may fail for > some constant expressions and in such case still falsely return > diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h > index 7c5cf3f2bef..cccd331e6e8 100644 > --- a/gdb/breakpoint.h > +++ b/gdb/breakpoint.h > @@ -933,6 +933,9 @@ struct watchpoint : public breakpoint > void print_recreate (struct ui_file *fp) const override; > bool explains_signal (enum gdb_signal) override; > = > + /* Destructor for WATCHPOINT. */ > + ~watchpoint (); > + > /* String form of exp to use for displaying to the user (malloc'd), > or NULL if none. */ > gdb::unique_xmalloc_ptr exp_string; > diff --git a/gdb/testsuite/gdb.base/scope-hw-watch-disable.c > b/gdb/testsuite/gdb.base/scope-hw-watch-disable.c > new file mode 100644 > index 00000000000..30956fe1b84 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/scope-hw-watch-disable.c > @@ -0,0 +1,26 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + Copyright 2023 Free Software Foundation, Inc. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see .= */ > + > +int > +main () > +{ > + int a =3D 0, b =3D 0; > + b =3D a; > + a =3D b + 10; > + > + return 0; > +} > diff --git a/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp > b/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp > new file mode 100644 > index 00000000000..54ebb4e4226 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp > @@ -0,0 +1,40 @@ > +# Copyright 2023 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# Test that GDB displays the correct error message when hardware > watchpoints > +# are not supported or explicitly disabled. Test also that GDB terminat= es > +# successfully after several attempts to insert a hardware watchpoint. > + > +standard_testfile > + > +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { > + return -1 > +} > + > +gdb_test_no_output "set can-use-hw-watchpoints 0" > + > +if {![runto_main]} { > + return -1 > +} > + > +gdb_test "awatch a" \ > + "Can't set read/access watchpoint when hardware watchpoints are > disabled." \ > + "unsuccessful attempt to create an access watchpoint" > +gdb_test "rwatch b" \ > + "Can't set read/access watchpoint when hardware watchpoints are > disabled." \ > + "unsuccessful attempt to create a read watchpoint" > + > +# The program continues until termination. > +gdb_continue_to_end > -- > 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 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