From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 4F0633858D35 for ; Fri, 15 Sep 2023 07:54:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F0633858D35 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=1694764440; x=1726300440; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=qZxc0Vzr/g1svgwiMiMOK1V89SiW5vWV7CXrQXPKgvM=; b=BYLGzWPDkdpZYs205QabiplIUhe4KblQ2pVe53xLHYpsSXQuGy0LOHsL YlZORRh8CucASwuA4MfnkEx14JBaMJqeYmbyUquAOIO3IIXTF8fgER4CA +Mbl/ibhGbWbSzJSfG8ZzItZ2Qs9SWj1XTCyKoQn5j7x8Tkeda5FBjr3e jtFz56sxjiodGTlklqaT8/aGnBadNpLeKhvryzQZxAqn3AUIE4l+Fsacx eAr6PSFA4h6rTS3xrSow71F1n8JQdmp807X1h30Pb+ICDOBHbLneTjXdT T2mfPdazJ2kDCDcZ5vplBVQFa/rrSR92nw0cGN2oe246/dsu3Ypf0qMzs w==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="369508754" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="369508754" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 00:53:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="815096230" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="815096230" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 15 Sep 2023 00:53:55 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 15 Sep 2023 00:53:55 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 15 Sep 2023 00:53:55 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 15 Sep 2023 00:53:55 -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.2507.32; Fri, 15 Sep 2023 00:53:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IsGrG8frAIoSQri/yxSIGVelasayA8XEEHAx07gcLXURp92I1YHdUwaeihCGfQBkS5NSKWju3aFARbGEqhJsSsR1/NQE2s/REfp58LFLDWQP5t1Lw2LN/Nb63JdXfpBUL1z5QtHyX6FH8h3OYKGep6VQh55r/qa5nCnnThmOVdrgWItSfDK5NX3CUk44xtAKAc+4asmvFKuH6qNw69u6QwkAcdoHgeGv6VrwD8Bh14JDyjZOEzfkruuHLO+q9BaNJVxs/6HK6gqWRQKMiwijddSpMCwyjGinmvBx8b/e73N8zyMg9o/dgPmWy1oTk4JzdXfIu4rBen+jaVAUN1rXNw== 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=FvNYO9TQzOYxTMDPQ5n5fwSNYo6MIDjtKH8zJhPIaHA=; b=CKwqWWo/MxqthrlxifFV9m9+1prFrA0anNY7EW3eHM01n5JoO/2p8U1yZvutz1eCdgajZZaZcWrUdg4Xggq5lc5znTUNDVpIzm5YGP7BBLJsKj+5oFSv4zPal0C8ihfx6xL0H3LdxkNfmpPMKnHWrWsQhRrI63OGigHA0Kz3SGI2oS7IH6zvIRk/DHn3Uigau8XlzUz2ugnEX6Klgc+jtxcSMrjW8hMn/DQL2l/WGKxEpiWzGqTsW2Hqb+3jD3znN9slNXBWV76wqPK4gXC5Sg9+vhpOUsDMWHXp4Ja5OC/0QmX7zkx5ekESmoRCG2LedqSUpQOC+44c0RWVZcF27Q== 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 CYYPR11MB8388.namprd11.prod.outlook.com (2603:10b6:930:c2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19; Fri, 15 Sep 2023 07:53:47 +0000 Received: from DM6PR11MB4457.namprd11.prod.outlook.com ([fe80::3207:2893:cd81:30a7]) by DM6PR11MB4457.namprd11.prod.outlook.com ([fe80::3207:2893:cd81:30a7%3]) with mapi id 15.20.6792.020; Fri, 15 Sep 2023 07:53:47 +0000 From: "Bouhaouel, Mohamed" To: "gdb-patches@sourceware.org" CC: "blarsen@redhat.com" , "aburgess@redhat.com" , "tom@tromey.com" Subject: RE: [PING][PATCH v3 1/1] gdb, breakpoint: add a destructor to the watchpoint struct Thread-Topic: [PING][PATCH v3 1/1] gdb, breakpoint: add a destructor to the watchpoint struct Thread-Index: AdnnqaZSWxDKiDocQ+amjPHyrTKZAw== Date: Fri, 15 Sep 2023 07:53:46 +0000 Message-ID: References: <20230630081015.17380-1-mohamed.bouhaouel@intel.com> In-Reply-To: <20230630081015.17380-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_|CYYPR11MB8388:EE_ x-ms-office365-filtering-correlation-id: 4c7afbcf-e4de-458f-144f-08dbb5c0e40e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4DFqssxuY0rBToEmOmaVmyUu3I6y+ffGi93g6Olwx22JpDVvXySXPbWx7zKTaqXZm6eMSNoYVlTHE5NKAN3dkFwEBdb/1xqzLmQiKjy95M8oJVuC5I+CDImMjFf8dWcnAOK/YeMzSID/15KkNFGGOTdwViwZxVUSJbV9Ys5wTl0jZlKPXYSpebhOrELoREY/jj4k+eWHn0cETX1MUf68Lb5mwOOV/s+Le83+GBzKaMtYKelQB8vBERh2oe4ziOI4ZdGUg3XMH+YYU1TrvaIUbFsM5CfsMGWtmz06TyuS4efwHqQ14g0TZT86pAMTiEd9ubWBaJ00Mm+ZbVaDoq5yWOsWcQfDBQJm33y6cNZw/VxtUcz+qIHKXF4M98lW+hIGGmVhZ6lVpy/hW/UgPlDiWqVN+xheWaH0kD6QPkoxTMl71f4CcrKUZoGHE2oriLvegbXIFdG/2iN5rxb5sHFfUEHhW93aQz/60uIF/ffC1bAGrI0yIZLt54Y3hfEYemlU5ox7l0vuLjwWHD1XsHHGOcsz4QtjzN1dRa+rftjoz971Y7oP82g04419077V/lCDDNEqn3IoZucuF608c7cIRCHnpLMdRX1eVDuT1XM1Mhqa6qT28rtelZjSNCmAykGE 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:(13230031)(366004)(346002)(396003)(39860400002)(376002)(136003)(451199024)(1800799009)(186009)(478600001)(53546011)(71200400001)(7696005)(6506007)(9686003)(2906002)(83380400001)(6916009)(54906003)(66476007)(316002)(64756008)(66946007)(5660300002)(4326008)(52536014)(66556008)(66446008)(41300700001)(8936002)(76116006)(8676002)(38070700005)(33656002)(86362001)(82960400001)(38100700002)(55016003)(122000001)(26005)(2004002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?BwXAlKsFcvlybRcKOhcZi58LkuM88hETW5NXsZc5uKpeysICh0JNLOt1dLuk?= =?us-ascii?Q?THZ6dNgx0Eu3bqDb+/4rpipB6b28o4TN9F/YXw4jB+ldNYrxSumNfxSPxg04?= =?us-ascii?Q?82iWjL2bzbaIN5+RYkXcfAQlrhS6wojGIAbt/pyKiGuG+W1ntqVaRL0WK9fp?= =?us-ascii?Q?/biGlJvbz4T7mNravlUsjaLAEOUvMPdV3/kxWSVXrxY84Pq8qs8S5zTGOaa6?= =?us-ascii?Q?XKquYrdDG3V91uHP87vofVrzKDbsBkNdnjuK1tYkjb3SIc8ShQGg53pcQGaA?= =?us-ascii?Q?Wa0+v7tQNLCKXz4krKgaQKebfY3CyqqFqjqRnHYUWQF0Awuo2KuMUuBNuoUI?= =?us-ascii?Q?c6bdmWHV4PbHdGQKiDcAy73VsFoVkMwdZMA5Sv34IL9NuWIXV2dpjJv6TmZ5?= =?us-ascii?Q?tyjnHvd9AKZlrbpLvqF1oVzTfKBf3fc+voGZ+s4PJHrCa8gzs8rDXySZ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1dYJA2/tuOd6ek3urSL/fmotP8ZdjzzOzXln/nDVwd?= =?us-ascii?Q?pFPSfetaye0y/N7mLNVRht/lStF4tNELdd0Bdrryl1rp0KBdVbO8pNaqBBez?= =?us-ascii?Q?m7GYIC8urHLKxQQCPF0UREjQ6bzNmJ92XpwEBhuX5ldB8l4wraxZaoTfCn6Z?= =?us-ascii?Q?84Ml0zjR/IH1oAQJWDVg7WQ9ByOrdL+tY/AVkskAWsPCzTIX3yEhevLJ7DdR?= =?us-ascii?Q?b5kPIl7FmkS7AX94SwdXDEXVi5dGPcihYMZSZFBIyseNWWAXzc3z7tx03cBj?= =?us-ascii?Q?Ng=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: 4c7afbcf-e4de-458f-144f-08dbb5c0e40e X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Sep 2023 07:53:46.7124 (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: 24AIPI1WwepWmS4rVm/sWeOsmSLk1j2aF/J5MLfIprv3i6ruUg/gWxiuMNg70pp2FxdxXHvtzjkz7B+M5UJ9TlmQxAwcE6BNitg2ZN/5mh0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR11MB8388 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,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: Dear all, I kindly request that you review this patch. Thanks, -Mohamed > -----Original Message----- > From: Bouhaouel, Mohamed > Sent: Friday, June 30, 2023 10:10 AM > To: gdb-patches@sourceware.org > Cc: blarsen@redhat.com; aburgess@redhat.com; tom@tromey.com; Bouhaouel, > Mohamed > Subject: [PATCH v3 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 > Reviewed-by: Bruno Larsen > --- > gdb/breakpoint.c | 14 +++++++ > gdb/breakpoint.h | 3 ++ > .../gdb.base/scope-hw-watch-disable.c | 26 ++++++++++++ > .../gdb.base/scope-hw-watch-disable.exp | 40 +++++++++++++++++++ > 4 files changed, 83 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 da6c8de9d14..8e14b3ba939 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -9597,6 +9597,20 @@ 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; > + while (bpt->related_breakpoint !=3D this) > + bpt =3D bpt->related_breakpoint; > + > + bpt->related_breakpoint =3D this->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 da150585f73..2de3fcec823 100644 > --- a/gdb/breakpoint.h > +++ b/gdb/breakpoint.h > @@ -992,6 +992,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 watchpo= ints > +# 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 disa= bled." > \ > + "unsuccessful attempt to create an access watchpoint" > +gdb_test "rwatch b" \ > + "Can't set read/access watchpoint when hardware watchpoints are disa= bled." > \ > + "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