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 4EB9E3858C83 for ; Tue, 16 May 2023 16:00:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4EB9E3858C83 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=1684252856; x=1715788856; h=from:to:subject:date:message-id:references:in-reply-to: mime-version:content-transfer-encoding; bh=GeA7cPbxCiv2wlZnxEt8y+FMTf3y9M9CmZn2y/re9ew=; b=hoON+nbbf9ZZna1zzI6wxpUebMcW+efntywIAzEau8yIH1txNiZBAqFm JeTwg7uduMyLKzV+h3aF0sKlaEN3KnBoxmKTv+iWKfNKRbD4lkjxBIHxT /OJGiDKAMFSbdRESP93p2kkRS5/Y7aVgfuyki/f4cx8+KJ2FVz5gpsXen bjnwiUOz8fRRpsOYfMZnY0duRa653QB2Px3lGAjD76GyLfpCPDVx7sqOy OfEoJ2q18qL2t9x1W+yfnRbypmJzI7/yHjRrbJzsbabSz6SnhLXxNaIEH kqtseRr2f8NQfxv0cIemOcnM1HkIcwcuntCQyT8QbpLVK09abs/kWwUeY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="340888503" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="340888503" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 09:00:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="766422786" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="766422786" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga008.fm.intel.com with ESMTP; 16 May 2023 09:00:54 -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; Tue, 16 May 2023 09:00:54 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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; Tue, 16 May 2023 09:00:53 -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; Tue, 16 May 2023 09:00:53 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.43) 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; Tue, 16 May 2023 09:00:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKqcp9WPHS/w9t8IUyfQ0wMfg0/HzbwBfMZb6DFePSEQyuMDAPP5jUztzaZW9Ocvxfo3Q+t2uTAkhXmIQGUgr8k3g0ZsGIN72ZuCB/raC7Rb/5MIQetYrm6y71C2U+VLC1rsb6rciu3XAwDPbnc5WQwWgKqXOaKB31sM0FK7yocpJlgZk818gTIraO5IOhEV3MCtrPUL8XyR3os2RzdXxPbuQEqdHST4H7jtnLLPtewuMD4AZRtedB3zhIKRfMTY281q7mSoidlmjfWLyV5RdLrGatVrFzyKa0hMayWONBkj9lepnkNLqzVXbfN+0kbViTAsCIBA+R750uCWZYehAw== 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=SsoHH4NgABW6iZJEwKBYxK5wNH1tuUzm2F6Go2JU+0U=; b=anXxwUWA2qlJ7v+KyNZA/qZv7WO0eRw91NzYSr4ftgQTKAuAZ9BS45Qkiyj4Fr7NhxVN4tro5OlDOgyan9gEBJ66u55oiObP57TJ3AR+xwXCZHYmBbFGwkqgBqEoat0hntfR5aKhYwTwZ/0rQNv82DAM42BYq0NTOIV9AyMotOoKMRZelJwumFBN4Hle7Eaw2u8rEcvbQqaa00XpMP/hxDoUWWqot0oi3jAo1o4QqVD/bY78unozPVhgMQk1+x7DbPLXNQ/BYKjAch/qLi52iX8WSqtlhJcJpUv2M/n2Btc9NAxuOaH4apCjNxXHKK3SWag/5VyN841U0CSIdg0bcA== 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 DM4PR11MB7303.namprd11.prod.outlook.com (2603:10b6:8:108::21) by IA1PR11MB7822.namprd11.prod.outlook.com (2603:10b6:208:3f2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.32; Tue, 16 May 2023 16:00:46 +0000 Received: from DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::830b:dc92:e628:ab8c]) by DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::830b:dc92:e628:ab8c%2]) with mapi id 15.20.6387.030; Tue, 16 May 2023 16:00:46 +0000 From: "Aktemur, Tankut Baris" To: Andrew Burgess , "gdb-patches@sourceware.org" Subject: RE: [PATCHv7 4/6] gdb/remote: avoid SIGINT after calling remote_target::stop Thread-Topic: [PATCHv7 4/6] gdb/remote: avoid SIGINT after calling remote_target::stop Thread-Index: AQHZh2LAHbTzLwW1CUKZLn0vp5ETGa9dDKEw Date: Tue, 16 May 2023 16:00:46 +0000 Message-ID: References: <9a5d537b06f63d95419bd2c290304b6e881dab6a.1684178293.git.aburgess@redhat.com> In-Reply-To: <9a5d537b06f63d95419bd2c290304b6e881dab6a.1684178293.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: DM4PR11MB7303:EE_|IA1PR11MB7822:EE_ x-ms-office365-filtering-correlation-id: 2ee875a6-c348-4db9-d8b9-08db5626b5ee x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: btLd5A+sQMisvXAwuAKBlvrIXNumChYiSzrA+GPeSbzG1HImkajBAKmvIUyfyGElYkGCFNq3ZXl+feLJOMoONYht5wrKcAFdYBBuocai1Ihw/vtkpyfAcs56MPDSlj0m6sGxkoc6liZh+QGm+fdVj52VTG4wy4oWZOTNkdiLOGeF5x/qFipTh+OtEdlRH3WsvIpVza3X9rHXnDd07+ceVo4q11KC0qfwgkoA0cLDRxcE7NAPmKr/nK8Yy+Q/g/TwM19v5y/k+JssVrEwD71EePsTxK8SPSVTmLeVlYWKM1Y6XZXlMisRIMqNBLVOVSnx9mlDrDfx7l3LvfgslO8AdL6pCNA3iWl8M7oPCU/+dNaZxv4WQx1Mj7rOzaR2anlp9l4/OOqAG+KMicWIh7MPYvlZkB7j0azLLL7o+I02QE0h8qXOW54TLX17Bo3i0QWrZNcFgZ5kO4DAc6GNvvfqKiBrpNwVHebK+xtc4/4AR8mrOKj56T033CjJqNZDsGvMzoFvX4aB5lrEXgAap6PwbrXJFNEhctN45FKLW2HTW3/2R684Cg/08kb8qQhU0atTTXab2O8+lBd5Mi10miA8AMI5ZYsfu1sr36l2sII24qnPChad7NleS6Z+jn5hPvke x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB7303.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(376002)(346002)(366004)(396003)(39860400002)(451199021)(38070700005)(66446008)(478600001)(76116006)(66946007)(66556008)(64756008)(7696005)(66476007)(316002)(110136005)(33656002)(86362001)(83380400001)(6506007)(53546011)(186003)(9686003)(26005)(52536014)(8676002)(8936002)(5660300002)(2906002)(41300700001)(55016003)(122000001)(82960400001)(38100700002)(71200400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?YbtPefE5LjTXBwu4stEmqFuXKiRwh0ZL8SvxLlJMrHrkkpghJr0F5b9aF371?= =?us-ascii?Q?RmW7UCjkWjR1j7KrbKi1mZN2XPultxidVhVRwicNYty22JCaDppaedIalGBF?= =?us-ascii?Q?0zvWF+LaGfuc33uHUaqrcETGPnM7w4QXHrxGp70CfvOhek+5zJcZqrQ1kP0+?= =?us-ascii?Q?/z4UpWYgAQEiIQkSbObMHa2F93E/qwfXNtxwHT9eIt88gt599TxV3EA64HMN?= =?us-ascii?Q?t6u9dUB8HbuSFa7jGuAXDfX7Od+Chj7XMKgQ03v5NS8ARHo0JAFB+QpgUF7m?= =?us-ascii?Q?406S+c+LDUSBk6Qi+xJB9ITvUY7re6XJ9U7CHPZ6atvr+UAvrZhoyP9O16O8?= =?us-ascii?Q?EwA0kRnJBh4oFv/Kw5huU4VA2oFnKXdcLjhZNOh2TPuBeSGphBHzYH6hny8T?= =?us-ascii?Q?Egr8TiR9hIKN9vPq685yITLybIkylDSl2bbNbajd61j1KpP9K8ALDp9dFVAl?= =?us-ascii?Q?6dgYQqgUG/OGwyK09ojnrpgIk6A6uTpqI3WklbM/bxiYDv2qGtbaXonUuKQT?=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TRHPII+T/fpaS0C8kbRZDe91D?= =?us-ascii?Q?ue//SgxObBAR1cZzVi0+fP3MAy7IlImgc7wAYmCUHtdN73gfS+vfOyIb7aqw?= =?us-ascii?Q?KXtCntNHUh5SiF4A6uicWWymhJVRZKMjpH2u/XHapetttAkOwr/+4SH+SuMY?= =?us-ascii?Q?6cjTlDL8hVTOOSFMv2tjKHUTsRf3Md72hezb2FbFkI7ri0W2nds6FGzlj4R3?= =?us-ascii?Q?yg=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB7303.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ee875a6-c348-4db9-d8b9-08db5626b5ee X-MS-Exchange-CrossTenant-originalarrivaltime: 16 May 2023 16:00:46.3889 (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: rtFWKMn7miC8mNaiUQA0EHudqpaCQn9FyCpztuV5jyziBWXf69nsYWLQumY/6zvkOuDCBsb6YxeuZIST702xv/x119kxJap/LcGC0YGdXwY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB7822 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.9 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 List-Id: On Monday, May 15, 2023 9:22 PM, Andrew Burgess wrote: > Currently, if the remote target is not running in non-stop mode, then, > when GDB calls remote_target::stop, we end up sending an interrupt > packet \x03 to the remote target. > = > If the user interrupts the inferior from the GDB prompt (e.g. by > typing Ctrl-c), then GDB calls remote_target::interrupt, which also > ends up sending the interrupt packet. > = > The problem here is that both of these mechanisms end up sending the > interrupt packet, which means, when the target stops with a SIGINT, > and this is reported back to GDB, we have no choice but to report this > to the user as a SIGINT stop event. > = > Now maybe this is the correct thing to do, after all the target has > been stopped with SIGINT. However, this leads to an unfortunate > change in behaviour when comparing non-stop vs all-stop mode. > = > When running in non-stop mode, and remote_target::stop is called, the > target will be stopped with a vCont packet, and this stop is then > reported back to GDB as GDB_SIGNAL_0, this will cause GDB to print a > message like: > = > Program stopped. > = > Or: > = > Thread NN "binary name" stopped. > = > In contrast, when non-stop mode is off, we get messages like: > = > Program received SIGINT, Segmentation fault. > = > Or: > = > Thread NN "binary name" received SIGINT, Segmentation fault. > = > In this commit I propose making use of thread_info::stop_requested > within remote.c to know if the stop was triggered by GDB (and the > SIGINT should be hidden) or if the stop was a user interrupt, and the > SIGINT should be printed. > = > In remote_target::process_stop_reply if the inferior stopped with > SIGINT and the thread_info::stop_requested flag is set, then we change > the stop signal to GDB_SIGNAL_0. > = > Two of the tests added in the previous commit exposed this issue. In > the previous commit the tests looked for either of the above > patterns. In this commit I've updated these tests to only look for > the "stopped" based messages. > = > This commit is the reason why the previous commit took care to set the > thread_info::stop_requested flag in infcall.c. > --- > gdb/remote.c | 10 ++++++++++ > gdb/testsuite/gdb.base/infcall-timeout.exp | 9 +-------- > .../gdb.threads/infcall-from-bp-cond-timeout.exp | 9 +-------- > 3 files changed, 12 insertions(+), 16 deletions(-) > = > diff --git a/gdb/remote.c b/gdb/remote.c > index 8eaa1b2c4d1..c61eeeadc52 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -8275,6 +8275,16 @@ remote_target::process_stop_reply (struct stop_rep= ly *stop_reply, > } > else > { > + /* If this stop was actually requested by GDB then we can hide > + the SIGINT from the user. */ > + if (status->kind () =3D=3D TARGET_WAITKIND_STOPPED > + && status->sig () =3D=3D GDB_SIGNAL_INT) > + { > + thread_info *thr =3D this->find_thread (ptid); A few lines above, there is remote_notice_new_inferior (ptid, false); remote_thread_info *remote_thr =3D get_remote_thread_info (this, ptid= ); which first does 'target->find_thread (ptid)' to find the thread_info*. It is unfortunate that we cannot access the thread_info* directly from remote_thread_info*. It's not in this patch's scope to add such a backlink. How about changing = remote_thread_info *remote_thr =3D get_remote_thread_info (this, ptid= ); to thread_info *thr =3D this->find_thread (ptid); remote_thread_info *remote_thr =3D get_remote_thread_info (thr); so that we can reuse 'thr' without having to call 'find_thread' a second time? Besides this suggestion, the patch looks fine to me. FWIW Reviewed-By: Tankut Baris Aktemur Thanks -Baris 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