From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 106C13858D35 for ; Tue, 21 Nov 2023 20:01:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 106C13858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 106C13858D35 Authentication-Results: server2.sourceware.org; arc=fail smtp.remote-ip=192.55.52.43 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700596905; cv=fail; b=mwmiTM8s86DYTNYUjDVPlG4ujv94Vd1K2gxIzRvYTd9d4FLFZeazvgR2bzUlxdlwoGTYvo7ZKlByD6NoInYFSCrhSiKiKVAUbqyjPO71yYdJOGSQmJDUEvp+Kvh9CS0bg4LemENyQGQHsX2mnZvgS86GB5yp9mhGcjC41wCteEQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700596905; c=relaxed/simple; bh=ybHxsR8xMEQjWgluohSkMo6/I+cDcyFEBGM+bzybLQ0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FHDp2riXm7iWQRSz/fJYQa133CnTo90aCsTtsSmFinhSkxPp8GNmb5dS7v6N/pLGADKw1WMtG0DfBQBOi3aGwl/M9wcQGCzgptLGymbYyDfrNT/sleS2tfHF2He2065fVH+mdM92dy1UCapwchfIvEbcqb6eDKdPxxDUi8Kk5es= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700596902; x=1732132902; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=ybHxsR8xMEQjWgluohSkMo6/I+cDcyFEBGM+bzybLQ0=; b=ESG8QBjEKAKJhPjL2Cx6yjdL4ROwtKfsc5IfaYOkdP8pq9MngMX+rpMs qwUtFOV1LQ9VfvNGvfGGTRs1F8ZsMkiHU2Qyfm0uUigWIkaZdWxO9vs9I dV48qpIL5oy2pZRwwOkY7GqS6GaYYquUHxSXyxAAnvMhMwr3IbmXRbwMO U4gayHI3dzDHDxBoD1da3ufCa/3p6IdNT8Fi/DT21dCX/M1QsB6f0Rvzg LzdykxO9DFkGwGGzHSCemRQ/MeUWA7vHgNT4CAWzEixhRAd375cNx2gqR zWY+6vylQRmlTwqmt7iS2UpEAFqVxgt4CWu7TvwP5fesbtf5A5Ar9Wi47 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10901"; a="478126445" X-IronPort-AV: E=Sophos;i="6.04,216,1695711600"; d="scan'208";a="478126445" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2023 12:01:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,216,1695711600"; d="scan'208";a="8189645" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmviesa002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 21 Nov 2023 12:01:37 -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.2507.34; Tue, 21 Nov 2023 12:01:35 -0800 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.34; Tue, 21 Nov 2023 12:01:06 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) 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.34 via Frontend Transport; Tue, 21 Nov 2023 12:01:06 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.40) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Tue, 21 Nov 2023 12:00:42 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+NG7IHjjcgvByqK0CNQAqkrAe57QsxB25NPDpgC9z5ZCCIGZYg97DAJMJYOjl9cbW6cVh7OEJk8buD+Sgsnx/p3I4GTyeQqsPbSHLKf/RYLPC7JbzeJO4TcIbRIXpqiED5Dr0bUd0KMGZBzTvPivq9pdk8xqAHQQgD0M6Sj4dWxWlRd+e4cXuQNNhf9WlEUDWDbMqlM39WQSjzpEPgrw/6XObzmF0MMcU0ljWfllc4lph5xCqhs3P3B9TTrYuL4rkUAI5aG8qtWvLPDcD0OX/nLKUOpp5bJ6LrNTi+12T5wz3WtUh8owa/v90XcDuyrH8zx/8LDb77QKy/4Tb5Wvg== 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=oqACGWkMx6JsZnl7OWugkklnxWDmerhyAumlMLZCmeM=; b=a6mbH6KUEBV6seIvgJtuqgXEjvLVwDY40AfCwc+hMjrSqjRDQTmO5HUsUXuIeAKtfjXPJc/w6z7q8+z9AelTafAahrbxdln25wbOjQor3erjUOOlxboJEpnt2m/tW8r5wpG4L/GkJjhxIR/EZZtVyl0DWcVidXDxWnTJIhSJ7LpdAwF2yJPzMJEZ6Ugh/k78nhYRnVBZyeUOtCgG655upPZIi59S1sFNn1XUhWbHgzkkXbdiXXSXUUfMzNTCcltew4oiJ4hSEpmThlrRfMz2VoQXr4/6NP0+IQWJm606ySaog5XuvlV6qavFvJt2xGQzeDrVWN2andZSEAmRqsCdmQ== 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 SJ0PR11MB5197.namprd11.prod.outlook.com (2603:10b6:a03:2d1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Tue, 21 Nov 2023 20:00:40 +0000 Received: from DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::9597:5d8e:99f8:b993]) by DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::9597:5d8e:99f8:b993%5]) with mapi id 15.20.7002.029; Tue, 21 Nov 2023 20:00:39 +0000 From: "Aktemur, Tankut Baris" To: "gdb-patches@sourceware.org" CC: "simark@simark.ca" Subject: RE: [PATCH v2] gdb/infrun: do not restart a stepped thread if not running (was: gdb/infrun: reset thread control's step info in end_stepping_range) Thread-Topic: [PATCH v2] gdb/infrun: do not restart a stepped thread if not running (was: gdb/infrun: reset thread control's step info in end_stepping_range) Thread-Index: AQHZo4tqkRa9cB7xykSW426EN3rHNLCGIsKw Date: Tue, 21 Nov 2023 20:00:39 +0000 Message-ID: References: <20230620152455.471716-1-tankut.baris.aktemur@intel.com> In-Reply-To: <20230620152455.471716-1-tankut.baris.aktemur@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: DM4PR11MB7303:EE_|SJ0PR11MB5197:EE_ x-ms-office365-filtering-correlation-id: 90520938-5099-4c8e-c4fa-08dbeacc8907 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6qD+mAteaL01IHNKmQiaWhdnM4bsWAM8hWMFkp94h0RbvpeMbfhzmVq+uL9zHw0hTmu+VcaoR6FRqbGLeSFQqOz3A+GRrbz3/OjyKCeCmcXSTQYzr7WYXF76XJtiUIMMWowAFGvRWxAx1aECBbiegLqxGt1ClZXzCSb+WDqk4I/Y6oN52GNUD1CZcp2cUlUtPuekaKbrI0YimyDJ59oiSJKRn/ZfH3b/m74q/GF5V/vgK7fFzpkumXhMl6j76lfdSsdarOM98BoCfYFin7uqKvOgtUAaKDYzD7yaEcTSplIqKMlxVo7qnO3LHrlZB52cvm9iFczv3+cR83KsbD3CPnYIcBpc+rhHxqVNb8U92h+lCNCuOjJ3W78BOyk6QgmEkFmuGMhtVc7zBnkeW5TUv7Lpdwro/BLWxsK0WSM9dNSXkh3o7M1P9myZe2ULcpd3jknYvs+pwz6VP5giFxY/Y76hiSxpkGd7YJXhpZqHRyN/5m7NoeYPpM+mcTVoUS1iyKL8TZfR8nSY/nwoU6X009ZTAiuLKjZzDmqaUCC9f3Me//sv7J8rEaqCm0mtdqkvvalMg8w4emTelvtTc4YKCjuO85/vq0H0OIlMie2tPGFUqa30CDcObYAhh2MdCiUdwxuyTgPUeTVZaM+R+hsipbmphXXzm8FztuOZhoPNO3w= 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:(13230031)(396003)(376002)(346002)(366004)(39860400002)(136003)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(55016003)(83380400001)(53546011)(82960400001)(71200400001)(7696005)(6506007)(26005)(9686003)(478600001)(966005)(38100700002)(122000001)(76116006)(66946007)(8676002)(8936002)(4326008)(64756008)(66476007)(66446008)(66556008)(6916009)(316002)(33656002)(86362001)(5660300002)(30864003)(2906002)(38070700009)(41300700001)(52536014)(2004002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?SvXkqV6AYcrK0w4jVxewa4JTONxzTcRdy4Udaa2+Lde4+HcdlMtEF59tC++n?= =?us-ascii?Q?MQ5VvU13sCOamwbueb6P26VX4NqTkr1TGvmGOtKaJ7DVih3SXUWIXeVWRJFU?= =?us-ascii?Q?x1TF3wtI6a4HTOzHRutYlPqe5x3wlVPfbQJTXSs2kOWHKj6AdTD1Sak8Bd12?= =?us-ascii?Q?RIDzrDoX9l5gdKevwr6tkaTlXbN/5XYB0aAdYUJsOCJLqaObsUAr24kFzTtp?= =?us-ascii?Q?jmDXUJ2mxgyoxcfspNa2eeta4P/ajlbl98kYRseX5voWQZGNj1XBU2yLV7wS?= =?us-ascii?Q?zsRYpQQZYqhfY99Qzs8NuY9jOKHXkxB99GcRedMXUhX7orf4KbiVXrGwOw9X?= =?us-ascii?Q?5O7bAvlbMsfk8aHACRSPCi3tS6ylAxfXKZPgg2O62CJs8AdVTB9EEXH1R1lr?= =?us-ascii?Q?EVVe6HtSUYvxF8l0TEmAgAw9+c2W7kkGzS3mZeXQitpKRa/LMmunIwTzwYEv?= =?us-ascii?Q?AyYsshI1k2xtGJ3EOuCUg0axAx24odJPzk90Wwmg00Kh0LG05sHHcbN0myRV?= =?us-ascii?Q?4KxQAhNGFIIX6dC6pOFn1tz7R77zf485XAdZq39XBmat7Iiq8h9UL/UMxhCs?= =?us-ascii?Q?UQK9Qbm72p6zc8V835dEfPBzGf4rqzbGHbtkJj68QlXau/CFfFHCl2BZU9Nn?= =?us-ascii?Q?AqxXmaU95aqTp9xbUUvm4qIzX1P0ZCBetbvRXJOmV422Xx06aD9/YgDEJPkt?= =?us-ascii?Q?zgWeSv9xj0Lv5TOxiCFgaMaYoJdU8rFNeUVNoHEmO71WZOXVyg2mrySI4Ao/?= =?us-ascii?Q?YjfgO5L4YOkaf3QzVcIzsOMCgLQToKGckfD6RgCtHH07vczFqP+uOFE5ePHZ?= =?us-ascii?Q?4AQqePek/CO+IV9xRy5LtseoU+3ChkFZibWqJBtqcGZ2ud/vpUouMSdArcYT?= =?us-ascii?Q?rvD9W8F98/0/kjVovdIwRP6YtX06CvZXyjYn87ZIWo0IUNjyAQDqOSpwLMk/?= =?us-ascii?Q?acq0mg5SiC7QCJSDjdWBjz2R+xQV3OVF6VAlOE3/Kt96dVn0nkll81uouTyV?= =?us-ascii?Q?3M4uXFUQI+DQNfSCI7K4yEX7lAdarc65EYvdd7QLQqmOSGt+MaTQh853ACxq?= =?us-ascii?Q?6NLxEBL1B++Y1/Zbhe4ILwv65bh9M7u1h14JflHPX5w+qT+IWcazaAd2hLaB?= =?us-ascii?Q?AJEiCshdFU9VUKvc1zlXD301aeErtsurCXq2u2LqlFli3WTL5b4MnSumQ6+q?= =?us-ascii?Q?W3pG0lDg6CCt9rPeD7sVpbSfi0hvTJgdr4OcyMamiGSqdqt0TQP30F1CsP3d?= =?us-ascii?Q?vV0YKCMMTarivZIo++jP6qLx08yPgf4N0afavTi/KiGBKIFpmogWWTVSy4ao?= =?us-ascii?Q?n92RsrlQ6yqC7D9hTjRF0vJtEyy9wpH9tjrplbk7w1BiPBwN/xVU7eyRgzF/?= =?us-ascii?Q?k9KBzlZx2l8xvVMzFR6Tqla+Lne9tUChNH7YVcqFp9lsg1av071JIDIFKQcs?= =?us-ascii?Q?vASDKFCHCADQn2y4BtRV7tG8ZsEfWFAB+RllqR9bBtsCPX71q/VHC6vzvXbe?= =?us-ascii?Q?AxraJNyaqBqoTijP1G8bmlfsVkpgwaJ37ku3Z5T6wV9wCQLJfdbmmb6o960v?= =?us-ascii?Q?SxFWbTClMj5/PRVjKqBnZUGZiBMwIWFVlDyo0Do+IWGrXhMuWLvGonMS6s+d?= =?us-ascii?Q?hw=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: 90520938-5099-4c8e-c4fa-08dbeacc8907 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 20:00:39.5953 (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: z1IASX8pHXftNO0j3VRZCx7t8ApU/Rbb0rfNkNckqv0e8J+yTPpIFQx2r07Gzpp8vNfmMnWgRVVO65IgDsi3XkVRVS/OrF4GCjEobEgflZw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5197 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.7 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: Kindly pinging. (The patch was Tested-By: Guinevere Larsen ) Regards -Baris On Tuesday, June 20, 2023 5:25 PM, Aktemur, Tankut Baris wrote: > =3D=3D=3D=3D=3D=3D > Changes in V2: > = > * Changed the thread state check to `(tp->state !=3D THREAD_RUNNING)`. > * Rebased on the current master. > = > The latest discussion was > https://sourceware.org/pipermail/gdb-patches/2023-May/199613.html > = > =3D=3D=3D=3D=3D=3D > = > Suppose we have two inferiors on an all-stop target with schedule-multi > set on: > = > $ gdb -q > (gdb) target extended-remote | gdbserver --multi - > Remote debugging using | gdbserver --multi - > Remote debugging using stdio > (gdb) file /temp/test > Reading symbols from /temp/test... > (gdb) set remote exec-file /temp/test > (gdb) start > Temporary breakpoint 1 at 0x115c: file test.c, line 8. > Starting program: /temp/test > stdin/stdout redirected > Process /temp/test created; pid =3D 864027 > ... > = > Temporary breakpoint 1, main (argc=3D1, argv=3D0x7fffffffd218) at test.= c:8 > 8 foo(); > (gdb) add-inferior > [New inferior 2] > Added inferior 2 on connection 1 (extended-remote | gdbserver --multi -) > (gdb) inferior 2 > [Switching to inferior 2 [] ()] > (gdb) file /temp/test > Reading symbols from /temp/test... > (gdb) set remote exec-file /temp/test > (gdb) tbreak 2 > Temporary breakpoint 2 at 0x555555555131: /temp/test.c:2. (2 locations) > (gdb) run > Starting program: /temp/test > stdin/stdout redirected > Process /temp/test created; pid =3D 864430 > ... > = > Thread 2.1 "test" hit Temporary breakpoint 2, foo () at test.c:2 > 2 int a =3D 42; > (gdb) set schedule-multi on > (gdb) > = > At this point, detaching the first inferior works fine: > = > (gdb) detach inferiors 1 > Detaching from program: /temp/test, process 858904 > Detaching from process 858904 > [Inferior 1 (process 858904) detached] > (gdb) info inferiors > Num Description Connection Exec= utable > 1 1 (extended-remote | gdbserver --multi -) /tem= p/test > * 2 process 858925 1 (extended-remote | gdbserver --multi -) /tem= p/test > (gdb) > = > Let us now repeat exactly the same scenario, but before detaching, we > make the current thread single-step an instruction: > = > ... > Thread 2.1 "test" hit Temporary breakpoint 2, foo () at test.c:2 > 2 int a =3D 42; > (gdb) stepi > 3 int b =3D 43; > (gdb) detach inferiors 1 > Detaching from program: /temp/test, process 876580 > Detaching from process 876580 > gdbserver: Couldn't reap LWP 876580 while detaching: No child processes > [Inferior 1 (process 876580) detached] > (gdb) 3 int b =3D 43; > = > There is a mysterious line info output. Running the scenario with > infrun debug logs reveals more information. > = > ... > Thread 2.1 "test" hit Temporary breakpoint 2, foo () at test.c:2 > 2 int a =3D 42; > (gdb) stepi > 3 int b =3D 43; > (gdb) set debug infrun on > (gdb) detach inferiors 1 > [infrun] scoped_disable_commit_resumed: reason=3Ddetaching > Detaching from program: /temp/test, process 872445 > Detaching from process 872445 > gdbserver: Couldn't reap LWP 872445 while detaching: No child processes > [Inferior 1 (process 872445) detached] > [infrun] start_step_over: enter > [infrun] start_step_over: stealing global queue of threads to step, l= ength =3D 0 > [infrun] operator(): step-over queue now empty > [infrun] start_step_over: exit > [infrun] restart_stepped_thread: switching back to stepped thread (step= ping) > [infrun] keep_going_stepped_thread: resuming previously stepped thread > [infrun] keep_going_stepped_thread: expected thread advanced also (0x55= 5555555131 - > > 0x555555555138) > [infrun] clear_step_over_info: clearing step over info > [infrun] do_target_resume: resume_ptid=3D-1.0.0, step=3D0, sig=3DGDB_SI= GNAL_0 > [infrun] infrun_async: enable=3D1 > [infrun] reset: reason=3Ddetaching > [infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed = for target > extended-remote > [infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed = for target > extended-remote > (gdb) [infrun] fetch_inferior_event: enter > [infrun] scoped_disable_commit_resumed: reason=3Dhandling event > [infrun] do_target_wait: Found 2 inferiors, starting at #0 > [infrun] random_pending_event_thread: None found. > [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1],= status) =3D > [infrun] print_target_wait_results: 872464.872464.0 [Thread 872464.= 872464], > [infrun] print_target_wait_results: status->kind =3D STOPPED, sig = =3D > GDB_SIGNAL_TRAP > [infrun] handle_inferior_event: status->kind =3D STOPPED, sig =3D GDB= _SIGNAL_TRAP > [infrun] context_switch: Switching context from 0.0.0 to 872464.87246= 4.0 > [infrun] handle_signal_stop: stop_pc=3D0x555555555138 > [infrun] handle_signal_stop: [872464.872464.0] hit its single-step br= eakpoint > [infrun] handle_signal_stop: delayed software breakpoint trap, ignori= ng > [infrun] process_event_stop_test: stepi/nexti > [infrun] stop_waiting: stop_waiting > 3 int b =3D 43; > [infrun] infrun_async: enable=3D0 > [infrun] reset: reason=3Dhandling event > [infrun] maybe_set_commit_resumed_all_targets: not requesting commit-= resumed for > target extended-remote, no resumed threads > [infrun] fetch_inferior_event: exit > = > GDB attempted to do a step-over for the current thread. This takes us > to the commit that introduced restarting step-overs: > = > commit 408f66864a1a823591b26420410c982174c239a2 > Author: Pedro Alves > Date: Mon Jan 11 20:01:58 2021 +0000 > = > detach in all-stop with threads running > = > A following patch will add a testcase that has a number of threads > constantly stepping over a breakpoint, and then has GDB detach the > process, while threads are running. If we have more than one inferior > running, and we detach from just one of the inferiors, we expect that > the remaining inferior continues running. However, in all-stop, if > GDB needs to pause the target for the detach, nothing is re-resuming > the other inferiors after the detach. "info threads" shows the > threads as running, but they really aren't. This fixes it. > = > However, the thread that was resumed for step-over in our scenario did > not have an interrupted step-over; it had completed its stepi already. > More debugging reveals that the thread is resumed because of the > following two conditions in `restart_stepped_thread`: > = > if (tp->control.trap_expected) > { > infrun_debug_printf ("switching back to stepped thread (step-ov= er)"); > = > if (keep_going_stepped_thread (tp)) > return true; > } > = > and > = > if (tp->control.step_range_end) > { > infrun_debug_printf ("switching back to stepped thread (steppin= g)"); > = > if (keep_going_stepped_thread (tp)) > return true; > } > = > The root cause of the problem is, `restart_stepped_thread` checks for > the thread state as > = > if (tp->state =3D=3D THREAD_EXITED) > continue; > = > but the thread's state is THREAD_STOPPED. To fix, we change the state > check to > = > if (tp->state !=3D THREAD_RUNNING) > = > Additionally, the 'trap_expected' and the 'step_range_end' fields of > the thread's control remain set even after the "stepi" command > completes, creating a half-baked internal state that can be misleading > when debugging. We address this problem by clearing the control > fields when stepping completes. We also add a regression test. > = > Regression-tested on X86_64 Linux using the default, native-gdbserver, > and native-extended-gdbserver board files. > --- > gdb/infrun.c | 7 ++- > gdb/testsuite/gdb.multi/detach-stepi.c | 30 +++++++++++ > gdb/testsuite/gdb.multi/detach-stepi.exp | 66 ++++++++++++++++++++++++ > 3 files changed, 101 insertions(+), 2 deletions(-) > create mode 100644 gdb/testsuite/gdb.multi/detach-stepi.c > create mode 100644 gdb/testsuite/gdb.multi/detach-stepi.exp > = > diff --git a/gdb/infrun.c b/gdb/infrun.c > index 58da1cef29e..f40d924dc7a 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -7776,7 +7776,7 @@ restart_stepped_thread (process_stratum_target *res= ume_target, > = > for (thread_info *tp : all_threads_safe ()) > { > - if (tp->state =3D=3D THREAD_EXITED) > + if (tp->state !=3D THREAD_RUNNING) > continue; > = > if (tp->has_pending_waitstatus ()) > @@ -7800,7 +7800,7 @@ restart_stepped_thread (process_stratum_target *res= ume_target, > = > for (thread_info *tp : all_threads_safe ()) > { > - if (tp->state =3D=3D THREAD_EXITED) > + if (tp->state !=3D THREAD_RUNNING) > continue; > = > if (tp->has_pending_waitstatus ()) > @@ -8523,6 +8523,9 @@ static void > end_stepping_range (struct execution_control_state *ecs) > { > ecs->event_thread->control.stop_step =3D 1; > + ecs->event_thread->control.trap_expected =3D 0; > + ecs->event_thread->control.step_range_start =3D 0; > + ecs->event_thread->control.step_range_end =3D 0; > stop_waiting (ecs); > } > = > diff --git a/gdb/testsuite/gdb.multi/detach-stepi.c b/gdb/testsuite/gdb.m= ulti/detach- > stepi.c > new file mode 100644 > index 00000000000..d365645fb3f > --- /dev/null > +++ b/gdb/testsuite/gdb.multi/detach-stepi.c > @@ -0,0 +1,30 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + 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 .= */ > + > +void > +a_function () > +{ > + int a =3D 42; > +} > + > +int > +main () > +{ > + int b =3D 43; > + a_function (); > + return 0; > +} > diff --git a/gdb/testsuite/gdb.multi/detach-stepi.exp > b/gdb/testsuite/gdb.multi/detach-stepi.exp > new file mode 100644 > index 00000000000..28ef8c4f9f7 > --- /dev/null > +++ b/gdb/testsuite/gdb.multi/detach-stepi.exp > @@ -0,0 +1,66 @@ > +# This testcase is part of GDB, the GNU debugger. > + > +# 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 detaching from an inferior after a thread in another inferior > +# completes a stepi. This is a regression test for a bug that was > +# causing an inadvertent resume of the just-stepped thread. > + > +standard_testfile > + > +if {[use_gdb_stub]} { > + untested "using gdb stub" > + return 0 > +} > + > +if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { > + return -1 > +} > + > +if {![runto_main]} { > + return -1 > +} > + > +delete_breakpoints > + > +# Setup inferior 2. > +gdb_test "add-inferior" "Added inferior .*" \ > + "add empty inferior" > +gdb_test "inferior 2" "Switching to inferior .*" \ > + "switch to inferior" > + > +gdb_load $binfile > +runto "a_function" > +gdb_test "info inferiors" > + > +# The bug for which this regression test is written appears in > +# schedule-multi mode. > +gdb_test_no_output "set schedule-multiple on" > + > +# Single-step the thread in Inferior 2, then detach Inferior 1. > +gdb_test "info threads" ".*" "threads before stepi" > +gdb_test "stepi" > +gdb_test "info threads" ".*" "threads after stepi" > + > +gdb_test "set debug infrun on" > +gdb_test_multiple "detach inferior 1" "" { > + -re "resuming previously stepped thread.*$gdb_prompt" { > + fail $gdb_test_name > + } > + -re "$gdb_prompt $" { > + pass $gdb_test_name > + } > +} > -- > 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