From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id 4693B3858289 for ; Fri, 23 Dec 2022 10:06:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4693B3858289 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=1671790013; x=1703326013; h=from:to:subject:date:message-id:references:in-reply-to: mime-version:content-transfer-encoding; bh=VqFcKMgojWPH3B3OeA3YdY86X19/FxNZfKz2lCOzxeQ=; b=Ed/94g0/kIpBL2HvDJORikcOl35DxoBG8JgqvBW38PZYX2ADlTK5nNe5 1ttU4Fd0vDAyFK/C6QirvIpFdPyw9GT1rs2tSMwdypXgL4RWVyY74RwIV 7lz04X40V3BnCxCl/SYDKuFV73dqAXmvZI/S+OeF6PkrR77J3ci1cuH67 4I7qZGD8S5asLXcOo2S+SsPWjym1ONI6M/rurhzbz3NDxt8yshAVbpiwZ uj+YOclyhZ5EeLQTe2ikIVx+G9UaWNwN0hXYX1MBGXu9Nm5arijN7ID+F jiK4C+l7H8gPi9IHzQwc2V0F1X8CxQdw0iPyHrcDO47vDUz6eDLHn6BLU g==; X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="384699449" X-IronPort-AV: E=Sophos;i="5.96,268,1665471600"; d="scan'208";a="384699449" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Dec 2022 02:05:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="652076400" X-IronPort-AV: E=Sophos;i="5.96,268,1665471600"; d="scan'208";a="652076400" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga002.jf.intel.com with ESMTP; 23 Dec 2022 02:05:44 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.16; Fri, 23 Dec 2022 02:05:44 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 23 Dec 2022 02:05:43 -0800 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.16 via Frontend Transport; Fri, 23 Dec 2022 02:05:43 -0800 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.40) 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.16; Fri, 23 Dec 2022 02:05:43 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jtfE7d6HjDnaHtdCSyKqx8H5Cq//GPV8sBZGXIU0mSeb6AfB8WqS/6NvyOiAYDBmls0Tn8a0HilNyGK4Jca6YJDKTzZ5O+Nq6hPD7ALrZBAxYnZrW5XJ9AyFLEgk5iH7Nx54gPeta5HjzvkNSkRN7fG3RiuGNTPPZThGBsglzPNM2xh3COi0r4GgXCb7sYQzzh38tqISyuZyRqyczRP37nyqR4TWFgFcqKphgZQDdiLxuypZmW7cLw86BwCgycmfFQiU2b8fWhAYl7VstUjCKGEEXvZWXg59Mzxfg9IWQFSax+C8IL+iWM5YlcXn0oa9P2LC7G68j8PzZdrMGzuIIA== 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=6bLfik0rYr+PuaSg4yWfkecvJVaF3uilYcMQBcjIxIA=; b=blXGdTB591BXxpUcC8ogSyW/O2gDy42Gbch73I9n30AQI4gkbDBJz+7MI9hujkhuBikk3fcpsItFG2Ikkkx9ytuBWf4HUaHRWlGE66/Nq9dCLUxCGwf0Q5K9P6AhXo6q645OZmr1SQCk6ghLVIQJ9F3KOETHHiMJz8EHx0x4tFYS9+8W9T8jN655EOWl6LBPPQ40VgOi7DmWtKteN0qiQQiaomJctHZ2QAL2+PNJq8PR+ttgGgtyRCb1cjPb3RYNsgoEuMjxjU29s0anwRyRX8FDc46Kcp82TGXK0phJtFmO0ECVRnBWzUfXkzNvGDQoIZeY8mM19JZErWW8oUEn/A== 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 MWHPR1101MB2271.namprd11.prod.outlook.com (2603:10b6:301:52::23) by DM4PR11MB5389.namprd11.prod.outlook.com (2603:10b6:5:394::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Fri, 23 Dec 2022 10:05:41 +0000 Received: from MWHPR1101MB2271.namprd11.prod.outlook.com ([fe80::c801:5fec:f9a6:c87a]) by MWHPR1101MB2271.namprd11.prod.outlook.com ([fe80::c801:5fec:f9a6:c87a%2]) with mapi id 15.20.5944.013; Fri, 23 Dec 2022 10:05:41 +0000 From: "Aktemur, Tankut Baris" To: Andrew Burgess , "gdb-patches@sourceware.org" Subject: RE: [PATCH 5/6] gdb: add inferior-specific breakpoints and watchpoints Thread-Topic: [PATCH 5/6] gdb: add inferior-specific breakpoints and watchpoints Thread-Index: AQHZAxx9jvujEPaZaUCUDBSLG5fZeq57VB6g Date: Fri, 23 Dec 2022 10:05:41 +0000 Message-ID: References: <0d3144a162d93c2b7d409234bd199e3c9fbbfce8.1669634536.git.aburgess@redhat.com> In-Reply-To: <0d3144a162d93c2b7d409234bd199e3c9fbbfce8.1669634536.git.aburgess@redhat.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: MWHPR1101MB2271:EE_|DM4PR11MB5389:EE_ x-ms-office365-filtering-correlation-id: 6386bbf4-c873-44ad-7634-08dae4cd3fc8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8E/ERUckeLKIhO0NbpyYIyq6SRlJYzGu0K9ArDVw0GmJPiYRLgW4w/AEiy36lQxVPRqvQidzEivk7Ix6eCWs2kyEp+jkCa69kp71f2qQt9YbzbQy318j0czG7NgUgc2WE5RCxz4XPb0MJj1Q0R0x+ml3x1C8MtkQfB0y2xjMaZH44xX90TvDVz/iqmTH3yoD327eSD01Rihec4MldfQoEgIlX2rOkVY3IPfRqlIw2hnskxNXkTz6nZPvRhgMIft6qTX8vwbiPOk9OowxYzNeZHz02W6d+Ss2GWbfzmiAMSRWoEksm8C1j/WzAcpxkQAY4VGhJZiveDgLQEUbSjx6NteRp2kQdVvjLwIfR1xgEuCdkAqiOv3xSnwLOeGOE7PAPbAD94N4dA4L7P10VWTfon3JznENeDvLm71PRfERcc8EQQ/33A8ztub/FiwMhACbHubQ76D/Vs3iUkDKgUaF+KvzLpl00nyfc4UKO/ZlZAbZSdUlxGObC4sd7NJAPk7s5mmgU79CrpMeXzEzbGpBqAW9ExyDW9H9g7Hl3LtocfhrpMrH0EYg8+yyBK5Ia8p1nruu9a2xpiSrW0+m5INHB/j1f9uI3PhjZuOiXHG8Ibsow5ELahCgxngYR7V1fksdPueF8phqvWjxte8/zDVOnznDOTuTJ59aDoIWmcgcIxH1tgsZbGLY5Ei11n5YE5bRmZpUye967aAIK4g7e7hXfY/2EVKpkbJ/6cfAd7MTzo4bd8CcPuaHios7eTvB/MJIoM9iZn9mOU+jCF4FoZDJsb140Dh7UdAViInu34ZcXMM= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1101MB2271.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(82960400001)(33656002)(2906002)(8936002)(38070700005)(52536014)(478600001)(83380400001)(41300700001)(5660300002)(55016003)(122000001)(38100700002)(86362001)(30864003)(71200400001)(110136005)(6506007)(966005)(26005)(7696005)(186003)(76116006)(53546011)(66946007)(66446008)(64756008)(66556008)(316002)(9686003)(66476007)(8676002)(2004002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?2/oEir2C8GNewadcTf2YhoWQtVR7DmmUr7yzij5CoWKdU/7Yh5hC6FXqTmMx?= =?us-ascii?Q?t8QABEdHB/7eiwnxMU3ZY5LVJ6pLxdR1fMU0C1zYCYujvXIf3ZSK2tU+OMTb?= =?us-ascii?Q?CyZ4ZHuKVLM7w+vHKiueFNZ3lHDt9gRtwGcpZ5K4CbNeE1FzbGuoD0lFEwA0?= =?us-ascii?Q?QC914oamV3mF7LvPDWbCxdcUkF8DzKiDAUi9AQHp+BaFcKAIA/hyi+kO+9Yr?= =?us-ascii?Q?r/817qo2V09pRBCt7A79jltlHQ2nVBn5qQ6l6lb6eXNBXdAiIqSKzrGcs8B+?= =?us-ascii?Q?Y0YHFJKXA2Gvn8rYYSPYAHzHOCLgYmz9hMIICKgJWdIGjkyPHWBLeqWsoUct?= =?us-ascii?Q?RCzJE4o3DikuXbnnA14DCc4CWSfUoJZYxGVv1B+T6Tcpjbk0ppWsLQ38WZVr?= =?us-ascii?Q?ycfMz7ZV5mJuvvf8Qe4uOndhmwAang+jZHQsX3MoJN+45PTtuNaNULAbp00a?= =?us-ascii?Q?/oFVBM5SeyvN6GcPkQlv3UJmyBh/jTiZPtErw+6PPQssMn/lOfHHycIVJUoj?= =?us-ascii?Q?A4QdIZ3+e57M2NWyuHU/iSgYkwjyHB6jQ6slZY6jLw0lK+w4N8ze3HmtdDg4?= =?us-ascii?Q?LwSp+LB63FtLcoj32Wpgt4tTnQlqfSQ/egtzZj1sp34jJ2spSsMgoRWS36kF?= =?us-ascii?Q?6wF3RBy/EFXX+qnTiBtgX1TI2slMRAine8uWinWBlnQzwhDTeXy8Mxjm4jcv?= =?us-ascii?Q?JJGFeS2YT5oJjsrdiNgDHbatb2Br7mWFVXCP+7kRWEhTYN1v3ET1Z2CqvQ16?= =?us-ascii?Q?LX3qLiYOT+yINM5gVCK3U3f+fDlNDClVSIPybPrjx3wZG3KcSfVoKLnYTMx2?= =?us-ascii?Q?YbHxaND1iQivNX9ESXAekbOtDu/k59f9tmr8EzxeQQH9pTbgRPPhC3zQyGnb?= =?us-ascii?Q?SXx1S8WFCtcjlc4gT2VEJPKSlqOR9r0m1vnQmtmRoOdPX2L7vJAtfRBDQgD5?= =?us-ascii?Q?dxteRMENjPAGnxbGATgPpNVBjJTpUjT/CnlwwQC0cv7pWIEn9hKF7bb4dKOp?= =?us-ascii?Q?IJPP0l7Xu/Vf2Tbjpt3xSCMNJUpuWZgfmL4/eGHl4dH9aodab183hJUtLtwl?= =?us-ascii?Q?0GGjz539vyZvWE6FsMphxMYAKD+DOKdQ1BlTUVn/mCW4KT5o+Zaisn4H5kNy?= =?us-ascii?Q?ai6ioc5fY2sHCD1f8e7qa40JyJr0PTOgrMVWpOjtyD4JjW9XIAKNWJnl/Mn0?= =?us-ascii?Q?4pPcoR9MuvmgE8DXyQ1/97BGZfzjqwGk09UfWhe+buEhijturAEBjH1QeX+O?= =?us-ascii?Q?EgEvHn3gRI9Jf6OX6ZMEWRRRCX3uCfUGBvpUGqYpHqoeiaLG4b8H/z0Bshej?= =?us-ascii?Q?UGsVjMapEPbX9V4feHb+P2iKYG8ZdLrht158AjK4KxU7soiIpRwF6WAg4L92?= =?us-ascii?Q?7G3jOH8J3bJIFDAHI93NeFu/ziWzVucopep0gV9VC2FT9tjkVTul+n1KlkN8?= =?us-ascii?Q?sF9q/fVumviOJEfqnig3gupp8vwAu2ZMWNftu3Ba3mGo8HU9P36aqE9eNEkz?= =?us-ascii?Q?h7UTvkJho4lPniciHQSaW6mLDRbCRCi6yXNPD3tLwPk661yKAfUUHAMzvAeq?= =?us-ascii?Q?mNowtTHaOYAvLDMZ20CU6VqdUZJw4Uj5/rPhPGXaRsSVORMOyOnUqQ9Oiwky?= =?us-ascii?Q?MQ=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR1101MB2271.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6386bbf4-c873-44ad-7634-08dae4cd3fc8 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Dec 2022 10:05:41.5252 (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: vceyryNcrX1YdMw5lThCY0jlemTTsEipDFqbqrfDScoOQWXdFNducGKt00wK6aM3Bc+lbl8Nsm6Myb9lBGSJEtooOSuw/h4prM/pwzCMO8Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5389 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.4 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 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: On Monday, November 28, 2022 12:26 PM, Andrew Burgess wrote: > This commit extends the breakpoint mechanism to allow for inferior > specific breakpoints (and watchpoints). > = > As GDB gains better support for multiple connections, and so for > running multiple (possibly unrelated) inferiors, then it is not hard Nit: IMHO, removing "then" makes the sentence sound better. > to imagine that a user might wish to create breakpoints that apply to > any thread in a single inferior. To achieve this currently, the user > would need to create a condition possibly making use of the $_inferior > convenience variable, which, though functional, isn't the most user > friendly. An important difference of an inferior-specific breakpoint wrt using conditions that contain the 'thread' keyword or the '$_inferior' variable could be that the breakpoints would not be inserted at all on other inferio= rs. For inferiors that have a large number of threads, this could save a substantial amount of overhead of stopping, evaluating the condition, and resuming. IMHO, it is worth considering this for inferior-specific breakpo= ints. In a downstream debugger, we had included this feature: https://github.com/intel/gdb/commit/7d87ac91308cd7a8984ba7b0e333a6689790972d (Please see the modifications in 'create_breakpoint'). With this perspective, I also think that allowing the use of both 'thread' and 'inferior' clauses makes sense, because they would have different advan= tages. More comments are inlined below. Thanks -Baris = > @@ -3255,6 +3278,32 @@ Thread-specific breakpoint %d deleted - thread %s = no longer in the > thread list.\ > } > } > = > +/* Called when inferior INF has exited. Remove per-inferior breakpoints= . */ > + > +static void > +remove_inferior_breakpoints (struct inferior *inf) > +{ > + for (breakpoint *b : all_breakpoints_safe ()) > + { > + if (b->inferior =3D=3D inf->num && user_breakpoint_p (b)) > + { > + /* Tell the user the breakpoint has been deleted. But only for > + breakpoints that would not normally have been deleted at the > + next stop anyway. */ > + if (b->disposition !=3D disp_del > + && b->disposition !=3D disp_del_at_next_stop) > + gdb_printf (_("\ > +Inferior-specific breakpoint %d deleted - inferior %d has exited.\n"), > + b->number, inf->num); > + > + It seems one of the blank lines is redundant. > @@ -8430,6 +8500,11 @@ code_breakpoint::code_breakpoint (struct gdbarch *= gdbarch_, > = > thread =3D thread_; > task =3D task_; > + inferior =3D inferior_; > + > + /* A breakpoint can be thread specific, or inferior specific, but not > + both. This should be checked when the breakpoint condition is pars= ed. */ > + gdb_assert (!(thread !=3D -1 && inferior !=3D -1)); The previous assertion expressions are easier to read, I think: gdb_assert (thread =3D=3D -1 || inferior =3D=3D -1); > @@ -8821,11 +8914,15 @@ find_condition_and_thread (const char *tok, CORE_= ADDR pc, > else if (rest) > { > rest->reset (savestring (tok, strlen (tok))); > - return; > + break; > } > else > error (_("Junk at end of arguments.")); > } > + > + if (*thread !=3D -1 && *inferior !=3D -1) > + error (_("Invalid use of both 'thread' and 'inferior' in " > + "breakpoint condition")); Nit: This error message sounds to me like "the conditions you used both in the 'thread' and the 'inferior' clauses are incorrect." But = in fact the problem is, using both clauses at the same time is not allowed. Maybe this would be clearer: "Using the 'thread' and 'inferior' conditions together is not allowed." > @@ -10068,6 +10170,10 @@ watch_command_1 (const char *arg, int accessflag= , int from_tty, > tok++; > toklen =3D end_tok - tok + 1; > = > + if (thread !=3D -1 && inferior !=3D -1) > + error (_("Invalid use of both 'thread' and 'inferior' in " > + "watchpoint condition")); Same comment here. > diff --git a/gdb/inferior.h b/gdb/inferior.h > index 69525a2e053..3b25403d83c 100644 > --- a/gdb/inferior.h > +++ b/gdb/inferior.h > @@ -746,4 +746,14 @@ extern void print_selected_inferior (struct ui_out *= uiout); > extern void switch_to_inferior_and_push_target > (inferior *new_inf, bool no_connection, inferior *org_inf); > = > +/* Return true if ID is a valid global inferior number. */ > + > +inline bool valid_global_inferior_id (int id) Function name should be at column 0. > @@ -280,11 +280,69 @@ bppy_set_thread (PyObject *self, PyObject *newvalue= , void *closure) > return -1; > } > = > + if (self_bp->bp->inferior !=3D -1 && id !=3D -1) > + { > + PyErr_SetString (PyExc_RuntimeError, > + _("Cannot have both thread and inferior conditions " > + "on a breakpoint")); This error message is clearer than the one I commented above and I think it would make sense to align the two. > diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp > b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp > new file mode 100644 > index 00000000000..5d65f19b88c > --- /dev/null > +++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp > @@ -0,0 +1,183 @@ > +# Copyright 2022 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 inferior-specific breakpoints. > + > +standard_testfile -1.c -2.c > + > +if { [use_gdb_stub] } { > + return > +} > + > +set srcfile1 ${srcfile} > +set binfile1 ${binfile}-1 > +set binfile2 ${binfile}-2 > + > +if { [build_executable ${testfile}.exp ${binfile1} "${srcfile1}"] !=3D 0= } { > + return -1 > +} > + > +if { [build_executable ${testfile}.exp ${binfile2} "${srcfile2}"] !=3D 0= } { > + return -1 > +} > + > +# Start the first inferior. > +clean_restart ${binfile1} > +if {![runto_main]} { In the if-statements above, there are spaces around the condition. > + return > +} > + > +# Add a second inferior, and start this one too. > +gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2" > +gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2" > +gdb_load $binfile2 > +if {![runto_main]} { > + return > +} > + > +# Try to create a breakpoint using both the 'inferior' and 'thread' keyw= ords, > +# this should fail. Try with the keywords in both orders just in case t= he > +# parser has a bug. > +gdb_test "break foo thread 1.1 inferior 1" \ > + "Invalid use of both 'thread' and 'inferior' in breakpoint condition" > +gdb_test "break foo inferior 1 thread 1.1" \ > + "Invalid use of both 'thread' and 'inferior' in breakpoint condition" > + > +# While w're here, check that we can't create a watchpoint with both thr= ead Typo: w're > +# and inferior keywords. As above, test with keywords in both orders. > +foreach type {watch rwatch awatch} { > + gdb_test "$type global_var thread 1.1 inferior 1" \ > + "Invalid use of both 'thread' and 'inferior' in watchpoint condition" > + gdb_test "$type global_var inferior 1 thread 1.1" \ > + "Invalid use of both 'thread' and 'inferior' in watchpoint condition" > +} > + > +# Clear out any other breakpoints. > +gdb_test "with confirm off -- delete breakpoints" Why not use "delete_breakpoints"? > +# Create an inferior specific breakpoint. Nit: This should be spelled "inferior-specific", as far as I know. > +gdb_test "break foo inferior 1" \ > + "Breakpoint $decimal at $hex: foo\\. \\(3 locations\\)" Why not use 'gdb_breakpoint'? > +set saw_header false > +set location_count 0 > +set saw_inf_cond false > +gdb_test_multiple "info breakpoints" "" { > + -re "^info breakpoints\r\n" { > + exp_continue > + } > + > + -re "^Num\\s+\[^\r\n\]+\r\n" { Removing "^" at the beginning could help eliminate the first regexp above to obtain shorter code. > + exp_continue > + } > + > + -re "^$decimal\\s+breakpoint\\s+keep\\s+y\\s+\\s*\r\n" { > + set saw_header true > + exp_continue > + } > + > + -re "^\\s+stop only in inferior 1\r\n" { > + set saw_inf_cond true > + exp_continue > + } > + > + -re "^$decimal\\.\[123\]\\s+y\\s+ $hex in foo at \[^\r\n\]+ inf \[12= \] inferior 1\r\n" > { > + incr location_count > + exp_continue > + } > + > + -re "^$gdb_prompt $" { > + with_test_prefix $gdb_test_name { > + gdb_assert { $saw_header } > + gdb_assert { $location_count =3D=3D 3 } > + gdb_assert { $saw_inf_cond } > + } > + } > +} > + > +# Create a multi-inferior breakpoint to stop at. > +gdb_test "break stop_breakpt" > + > +# Now resume inferior 2, this should reach 'stop_breakpt'. > +gdb_test "continue" "hit Breakpoint $decimal\.$decimal, stop_breakpt \\(= \\) .*" \ > + "continue in inferior 2" > + > +# Switch to inferior 1, and try there. > +gdb_test "inferior 1" ".*" \ > + "select inferior 1 to check the inferior-specific b/p works" > +gdb_test "continue " "hit Breakpoint $decimal\.$decimal, foo \\(\\) .*" \ > + "first continue in inferior 1" Maybe we can check here explicitly, for extra confidence, that the hit came actually from Thread 1.*. > + > +# Now back to inferior 2, let the inferior exit, the inferior-specific > +# breakpoint should not be deleted. > +gdb_test "inferior 2" ".*" \ > + "switch back to allow inferior 2 to exit" > +gdb_test "continue" "Inferior 2 \[^\r\n\]+ exited normally.*" \ > + "allow inferior 2 to exit" > + > +gdb_test "inferior 1" ".*" \ > + "select inferior 1 to check inferior-specific b/p still works" > +gdb_test "continue " "hit Breakpoint $decimal\.$decimal, foo \\(\\) .*" \ > + "second continue in inferior 1" > +gdb_test "continue " "hit Breakpoint $decimal\.$decimal, stop_breakpt \\= (\\) .*" \ > + "third continue in inferior 1" > + > +# Now allow inferior 1 to exit, the inferior specific breakpoint should = be > +# deleted. > +gdb_test "continue" \ > + [multi_line \ > + "\\\[Inferior 1 \[^\r\n\]+ exited normally\\\]" \ > + "Inferior-specific breakpoint $decimal deleted - inferior 1 has exited= \\."] > + > +set saw_header false > +set location_count 0 > +set saw_inf_cond false > +gdb_test_multiple "info breakpoints" "info breakpoint after inferior 1 e= xited" { > + -re "^info breakpoints\r\n" { > + exp_continue > + } > + > + -re "^Num\\s+\[^\r\n\]+\r\n" { > + exp_continue > + } > + > + -re "^$decimal\\s+breakpoint\\s+keep\\s+y\\s+\\s*\r\n" { > + set saw_header true > + exp_continue > + } > + > + -re "^\\s+stop only in inferior 1\r\n" { > + # This should not happen, this breakpoint should have been deleted. > + set saw_inf_cond true > + exp_continue > + } > + > + -re "^\\s+breakpoint already hit 2 times\r\n" { > + exp_continue > + } > + > + -re "^$decimal\\.\[12\]\\s+y\\s+ $hex in stop_breakpt at \[^\r\n\]+ = inf \[12\]\r\n" { > + incr location_count > + exp_continue > + } > + > + -re "^$gdb_prompt $" { > + with_test_prefix $gdb_test_name { > + gdb_assert { $saw_header } > + gdb_assert { $location_count =3D=3D 2 } > + gdb_assert { !$saw_inf_cond } > + } > + } > +} > diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/g= db.python/py- > breakpoint.exp > index c3215b13d5c..8906dea6655 100644 > --- a/gdb/testsuite/gdb.python/py-breakpoint.exp > +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp > @@ -112,6 +112,8 @@ proc_with_prefix test_bkpt_basic { } { > "Get Breakpoint List" 0 > gdb_test "python print (blist\[1\].thread)" \ > "None" "Check breakpoint thread" > + gdb_test "python print (blist\[1\].inferior)" \ > + "None" "Check breakpoint inferior" > gdb_test "python print (blist\[1\].type =3D=3D gdb.BP_BREAKPOINT)" \ > "True" "Check breakpoint type" > gdb_test "python print (blist\[0\].number)" \ > @@ -214,6 +216,46 @@ proc_with_prefix test_bkpt_cond_and_cmds { } { > "check number of lines in commands" > } > = > +# Test breakpoint thread and inferior attributes. > +proc_with_prefix test_bkpt_thread_and_inferior { } { > + global srcfile testfile hex decimal > + > + # Start with a fresh gdb. > + clean_restart ${testfile} > + > + if ![runto_main] then { I thought you had removed the uses of 'then'. :) > + return 0 As I wrote previously, the testsuite does not look consistent about what to return here. But "-1" makes more sense to me, because not being able to run to main sounds like a major problem. > + } > + > + with_test_prefix "thread" { > + delete_breakpoints > + gdb_test "break multiply thread 1" > + gdb_test "python bp =3D gdb.breakpoints ()\[0\]" > + gdb_test "python print(bp.thread)" "1" > + gdb_test "python print(bp.inferior)" "None" > + gdb_test "python bp.inferior =3D 1" \ > + "RuntimeError: Cannot have both thread and inferior conditions on a= breakpoint.*" > + gdb_test_no_output "python bp.thread =3D None" > + gdb_test_no_output "python bp.inferior =3D 1" \ > + "set the inferior now the thread has been cleared" > + gdb_test "info breakpoints" "stop only in inferior 1\r\n.*" > + } > + > + with_test_prefix "inferior" { > + delete_breakpoints > + gdb_test "break multiply inferior 1" > + gdb_test "python bp =3D gdb.breakpoints ()\[0\]" > + gdb_test "python print(bp.thread)" "None" > + gdb_test "python print(bp.inferior)" "1" > + gdb_test "python bp.thread =3D 1" \ > + "RuntimeError: Cannot have both thread and inferior conditions on a= breakpoint.*" > + gdb_test_no_output "python bp.inferior =3D None" > + gdb_test_no_output "python bp.thread =3D 1" \ > + "set the thread now the inferior has been cleared" > + gdb_test "info breakpoints" "stop only in thread 1\r\n.*" > + } > +} > + > proc_with_prefix test_bkpt_invisible { } { > global srcfile testfile hex decimal > = > @@ -849,6 +891,7 @@ proc_with_prefix test_bkpt_auto_disable { } { > test_bkpt_basic > test_bkpt_deletion > test_bkpt_cond_and_cmds > +test_bkpt_thread_and_inferior > test_bkpt_invisible > test_hardware_breakpoints > test_catchpoints > diff --git a/gdb/testsuite/lib/completion-support.exp b/gdb/testsuite/lib= /completion- > support.exp > index 0c03d0f035e..135649ed4d9 100644 > --- a/gdb/testsuite/lib/completion-support.exp > +++ b/gdb/testsuite/lib/completion-support.exp > @@ -27,7 +27,7 @@ namespace eval completion { > # List of all quote chars, including no-quote at all. > variable maybe_quoted_list {"" "'" "\""} > = > - variable keyword_list {"-force-condition" "if" "task" "thread"} > + variable keyword_list {"-force-condition" "if" "inferior" "task" "th= read"} > = > variable explicit_opts_list \ > {"-function" "-label" "-line" "-qualified" "-source"} > -- > 2.25.4 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