From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by sourceware.org (Postfix) with ESMTPS id 8EB093858C41 for ; Tue, 8 Aug 2023 02:39:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8EB093858C41 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=windriver.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=windriver.com Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3782RmtV009425; Tue, 8 Aug 2023 02:39:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from:to:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s= PPS06212021; bh=xmduSGIwbP6fvRMWKnZSOL0PXdM/298LCgxwaTPgLaI=; b= Gf91jyxlmr+lW7WJRRheDV6k9b8b6kqGGycMLaNHwDIViGPfmB9DQorET9f/QM1h nAvlIOcApevhxtCWLJET9BWKKYH0x1CEqCsCNpv6NCvc5uCjR8IKsAVAxXvH1PP2 uMGvVwPTtvhAArunqqn/qCfa7OQqp5qJ+is9Ixd13EOlnw1BNcMjEj+8J/hTk/PP qnvtIECEzFZ4XHW/ZCOb52slWQ98PKrlnTqG4V9/yejvKSOadXvMei3RaMmfitCf 98zjleTfkxNkf8Ak2G2pfrLh+oZhbDB1+LnFTUGZGaF47gUC9JUkB6EuY7bZzRmh l9a+2aOrEQmPIUZIg24tXA== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3s9dd625t0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Aug 2023 02:39:10 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cVTudF2zP63yGHxV+Te0qpK8ly4IgdLx9mDhED5hj6rbPK7hS1XFF5OmBI/1x/xDb1z+eCXjx4R7No8G371jU+Ng1aDSwYPJU2cWm6C22nZvxSY4ZaD4tPMp+xb6oNcFs/K7IpQrlWRMaJtngrZ6kZuSdyevPrm34NyUxkITas3zabKjNKfhBHsRC3vFxZkwMqstnACbSMeA/lyVvZg1JytmYf47J0V0K0nX9MjMfKw/1k7QB+9YTZ9dCbEgx6DuiFieR8VUBnWQdwCSWKTRk9Mqu3bwGXXBg9bSwlkOt9G+aZEc53qz9yR1h8RnfpXdpQRh2vJlWC7fAam3oKcZPQ== 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=xmduSGIwbP6fvRMWKnZSOL0PXdM/298LCgxwaTPgLaI=; b=bBya7pf56R8He7ehivJAq6/v0ipiJrP89s3xj8WnWWKXw7R2yUVz6UudCK/ezX4icLaWHCmwRrjU41sVTpTU5on29ttdHlt1vmenFKR9Rfdc2uURm74tSdBaP+SxU/Pv3q6BoFeM7o6oB0VBBdldXATcAb8a/eFmNQdOMxBszstdxCKzdHxAwIH8KxCA+5N7Uasut4UxnLrjk3u5XQk8kME4a5K7WcsuvrxjXZpHff/kn3HEvIqIXkJuEgCx/U/pAuX6T2NQTZGyjtKExRhH8/XGcU5Kl82TlBDhmom6LZDHzqiZ1raQ768IDABjaEI+YXQ49AihayROYAXYkP9pEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DS0PR11MB6447.namprd11.prod.outlook.com (2603:10b6:8:c4::16) by MW4PR11MB6886.namprd11.prod.outlook.com (2603:10b6:303:224::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Tue, 8 Aug 2023 02:39:06 +0000 Received: from DS0PR11MB6447.namprd11.prod.outlook.com ([fe80::f7e4:b822:8ebc:36fc]) by DS0PR11MB6447.namprd11.prod.outlook.com ([fe80::f7e4:b822:8ebc:36fc%4]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 02:39:06 +0000 From: "Yan, Zhiyong" To: Kevin Buettner CC: "gdb-patches@sourceware.org" , "simon.marchi@polymtl.ca" Subject: RE: [PATCH 1/1] gdbserver: Reinstall software single-step breakpoints in resume_stopped_resumed_lwps Thread-Topic: [PATCH 1/1] gdbserver: Reinstall software single-step breakpoints in resume_stopped_resumed_lwps Thread-Index: AQHZxaeVtMfkD3ZaCkyWUvFIx3Ic5q/erkMQgAEHSQCAAAEQgA== Date: Tue, 8 Aug 2023 02:39:06 +0000 Message-ID: References: <20230803011146.2093194-1-kevinb@redhat.com> <20230803011146.2093194-2-kevinb@redhat.com> <20230807193126.76c1be58@f37-zws-nv> In-Reply-To: <20230807193126.76c1be58@f37-zws-nv> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS0PR11MB6447:EE_|MW4PR11MB6886:EE_ x-ms-office365-filtering-correlation-id: a239e41c-1f15-4ae7-42a5-08db97b8a2e8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rzcePg1RfsRHmYljdDy9iyptfOokrsH77h6GOqI87BcXF3x4vx4Ou0dGeK3W4rHT8KyppCrJAKwsz1v2AR9QCqdBzOk0lHRwivduKZ6hIKK+lMmSzDbFOA8jMr09PWpODFChK2GzK600vmHG3GjX/H7XAOPPGIs2ScrRtfEJCv4G28MXmHazXvNna5UbAe0UnYuaYtnphcHX/kKhg2p/LKPn5ycQUb1tMIDcJ42+z6oi3XjViiRby0wmDZB0UVQQSQJUaqPsm6CRoBjqqIPukAS7P7XS7MEAEHtHY65OgRp6TFdRwuNGA08DlVFvl3bRXLL6qUhMn82QzqbQ44cVY0mGmaXAVkLE78ZjyLbTSS981emG6seRx/fJ7MyC172LsoDYdSlAyAlRQ8PHovU9rPAZwbD6RnNUAakyU1cLI3Ro+enBu7qLgTsfrlc9RdXJO34YvrKqLEHEtROKDQEqbYnEiYgVYGp0J1LvIJn2mX2TaTjXnJJ2bdjxLMA2ek7Jf1YwG7mrIylFj6xROI6G+BgOc7FdLMmA0c0HcEMt65heFVneCbzFyW614rVbUTI0VnDNx30BxC7ORGSGBvCFO1HKAiITQY7F5kPVS13RI8iSlt/s3wh0NClbO4UwX43lrx3fYMQZT+/c0crehgYHNyWs23I1xuINChcLrPXdjZOJ8Ku3iROSl67JeqXAOqGvy/fbJVjahPC/PM0eiJV4n/qD8tJXvunPZRxCJOuWpHU= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR11MB6447.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(396003)(136003)(39850400004)(376002)(186006)(90011799007)(1800799003)(90021799007)(451199021)(122000001)(478600001)(84970400001)(83380400001)(66899021)(9686003)(966005)(53546011)(6506007)(26005)(55016003)(66556008)(33656002)(66946007)(66446008)(76116006)(64756008)(66476007)(8936002)(8676002)(316002)(30864003)(2906002)(4326008)(6916009)(7696005)(41300700001)(71200400001)(54906003)(38100700002)(86362001)(38070700005)(52536014)(5660300002)(2004002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?yzhKgLhUXjES5JUUjt8u4kQ5Qux9yFuBhjVhvlbcO5X46ONz4iEkpX+nahdj?= =?us-ascii?Q?VBEzRzBr1Vw8DqpOegT3v+/8LNkUIOdZ7hUdmzfFXRZ5LwqWwkZC2H+tSmXf?= =?us-ascii?Q?vA3IHJuXZhbwdd4VMd5ZaIWr9Gdo+6QPZOx+qWxLwA4o3xj4t+WRHYxzDh7I?= =?us-ascii?Q?a0MnTxKt9TD07taqFa7+yMpL8FSBl3s3WmQdES79DxpOVq2zj+hMLAi3ZlWk?= =?us-ascii?Q?8GZk767YT4ShpPTock6gOJTAb1MllD8HSYYVsKp3A33r1xAPV8v7ARsGRj1P?= =?us-ascii?Q?9C9vM8ziEveoT6SXxpOkapzWEFHU/1oGoe68xdFHHgknmA20qb6Dxrrm4Vb1?= =?us-ascii?Q?72v1K3rzr0UpqObNrgfAL2GjYT8HrrczZQk67GQjbFLr08tmXIW2BNVtZV2X?= =?us-ascii?Q?iZYYNAwu4PqzHAwer2+yrK9R+EaSk+Blme/FDnBs3eada1caEn4+8i6OkreS?= =?us-ascii?Q?Hn2/V+kcOVMgFIoNIldj7x08pwUdm8JMWR8+LDxOCq0XtlnAio+B6xpANJn0?= =?us-ascii?Q?ecdrPsLlCGJGU5ateuNV+O7cOCbo9add19XQrultkQAboBlE+Gqnn8k93yTN?= =?us-ascii?Q?NMrVwN/PKy0Xk/e1RTh1K5Ja59lrBFwF3JvKQpvMrlScv6uxzWu/QzGeHZEp?= =?us-ascii?Q?tgWSkv4jSli/rUhoO3HNHJ8rh9hpi188MqFrf0L2kjq/i3xi6nm2ZdadbNGm?= =?us-ascii?Q?mrqLcUsvDF1iXJ0WdLthKTarU5tFJSCPlWlioAqgE+0aFB3bTtF32oR5whtW?= =?us-ascii?Q?vUtsEfxVZmeZIEsCRgqDbLjppiZ0N1ZJzsFDIjuKo/QByDL06l1Ktq025ZqY?= =?us-ascii?Q?+QJwzkHogHPT75m4NspbSH1IHKLBQICziqJ0PgxAGX65Ct6DW7MBOFDAh7r/?= =?us-ascii?Q?w4sK+9bFbNJSnLNc5LA2kx1QwK5AZ0RJeysMCtskgN6LnXLDXLBgXvXbSTg1?= =?us-ascii?Q?nm8zrlN2i3FiDYMFW7sb9VTwCx/p3knfQJjz4RNsMXqb9/DGHSIGmUjTR6O3?= =?us-ascii?Q?Cc6rLQXp9D0AOuPDf6RbVxjIEuIHu3WpAksnWpTYonZatrR66pjTlxwa6vjJ?= =?us-ascii?Q?94zciAIOXOHq6yEDfFR3D2X/CDHvVNzDoIEjTGJlWOaLsGTjsXHes7Ysx+/8?= =?us-ascii?Q?jT4S96UvuRfQNZh/R5iMkEm6EQKyAJGqZrDRUGHtUiQmGyhxqM1OBVYoyeOH?= =?us-ascii?Q?3YKrrH6X3FrAWWT3RJzH0H6tPtGUu8kHVgiM5ZivesSwGh5sQ1O5JFt0IjFF?= =?us-ascii?Q?LCu029ryF8dAxdRbvLFwN5XVtV8noVoks7LDx2xd0NCvuZ+PDOwBD0eGKhi9?= =?us-ascii?Q?3v9+VdP93HfOZ+QZh6HpEJn8JxfHyCb2yBT0cFHyv1AcbhsuqovlXl4I/EnG?= =?us-ascii?Q?HCpb8IQ84Ieg9yqaA7dtEucYpBq7jiUfpvPKvZ+71TOaYngmJWNU/1rZJSvo?= =?us-ascii?Q?5iGGP9U2e3aoEQDVajveG3L48NTTWvIhgncSs5NZGxhXGRUNrZlOMaEPTFBj?= =?us-ascii?Q?G4AwFVzQp7x+MHqhnBWYa+MtRU4huBStRNvWbdwJERE6rHh8yjqYr6aQ7AHu?= =?us-ascii?Q?Cd6TS6JVPNULwaWEg5/uyu3cypKElLdMFz7j8/Ae?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB6447.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a239e41c-1f15-4ae7-42a5-08db97b8a2e8 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2023 02:39:06.5870 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OfkZJhHz7SqokmfaR/iK/itnkUxMeDqkRb21Y8HcfSVgFZ9Dj3TCFkl9vSXES4jUf1Oqox4wQP0OP7gQg3EmgW18so3oKMqtcoyiC4X1O1I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6886 X-Proofpoint-GUID: d3S-hMGlecCVk3T39Vg5RYh7FSKqDaJm X-Proofpoint-ORIG-GUID: d3S-hMGlecCVk3T39Vg5RYh7FSKqDaJm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-07_28,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2306200000 definitions=main-2308080021 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,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_PASS,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: Hi Kevin, It is pleasure for me to cooperate with you. When the release version for this issue is determined, please let me k= now. I will forward this information to my customer. Thanks! Best Regards. Zhiyong -----Original Message----- From: Kevin Buettner =20 Sent: Tuesday, August 8, 2023 10:31 AM To: Yan, Zhiyong Cc: gdb-patches@sourceware.org; simon.marchi@polymtl.ca Subject: Re: [PATCH 1/1] gdbserver: Reinstall software single-step breakpoi= nts in resume_stopped_resumed_lwps CAUTION: This email comes from a non Wind River email account! Do not click links or open attachments unless you recognize the sender and = know the content is safe. Hi Zhiyong, Thanks for testing. In addition to the Co-Authored-By tag, I've added a Te= sted-By tag for you. I'll wait a few more days for comments, after which, assuming there are no = objections, I'll push it. Thank you for all of your contributions (bug report, test case, initial pat= ches, and testing) in resolving this problem! Kevin On Mon, 7 Aug 2023 10:54:16 +0000 "Yan, Zhiyong" wrote: > Hi Kevin, > Today I backport below patch to gdb 13.0.5 which is used by our cust= omer board. > I verify this patch by customer's app where the assert error was fir= stly reported, and verify it by test app "osm". > This patch can fix the assert error in my tests. > > Best Regards. > Zhiyong > > > -----Original Message----- > From: Kevin Buettner > Sent: Thursday, August 3, 2023 8:56 AM > To: gdb-patches@sourceware.org > Cc: Yan, Zhiyong ; simon.marchi@polymtl.ca;=20 > Kevin Buettner > Subject: [PATCH 1/1] gdbserver: Reinstall software single-step=20 > breakpoints in resume_stopped_resumed_lwps > > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender an= d know the content is safe. > > At the moment, while performing a software single-step, gdbserver fails t= o reinsert software single-step breakpoints for a LWP when interrupted by a= signal in another thread. This commit fixes this problem by reinstalling = software single-step breakpoints in linux_process_target::resume_stopped_re= sumed_lwps in gdbserver/linux-low.cc. > > This bug was discovered due to a failing assert in maybe_hw_step() in gdb= server/linux-low.cc. Looking at the backtrace revealed that the caller was= linux_process_target::resume_stopped_resumed_lwps. > I was uncertain whether the assert should still be valid when called from= that method, so I tried hoisting the assert from maybe_hw_step to all call= ers except resume_stopped_resumed_lwps. But running the new test case, des= cribed below, showed that merely eliminating the assert for this case was N= OT a good fix - a study of the log file for the test showed that the single= -step operation failed to occur. > Instead GDB (via gdbserver) stopped at the next breakpoint that was hit. > > Zhiyong Yan had proposed a fix which resinserted software single-step=20 > breakpoints, albeit at a different location in linux-low.cc. Testing=20 > revealed that, while running gdb.threads/pending-fork-event-detach, > the executable associated with that test would die due to a SIGTRAP after= the test program was detached. Examination of the core file(s) showed tha= t a breakpoint instruction had been left in program memory. > Test results were otherwise very good, so Zhiyong was definitely on the r= ight track! > > This commit causes software single-step breakpoint(s) to be inserted befo= re the call to maybe_hw_step in resume_stopped_resumed_lwps. This will cau= se 'has_single_step_breakpoints (thread)' to be true, so that the assert in= maybe_hw_step... > > /* GDBserver must insert single-step breakpoint for software > single step. */ > gdb_assert (has_single_step_breakpoints (thread)); > > ...will no longer fail. And better still, the single-step breakpoints ar= e reinstalled, so that stepping will actually work, even when interrupted. > > The C code for the test case was loosely adapted from the reproducer prov= ided in Zhiyong's bug report for this problem. The .exp file was copied fr= om next-fork-other-thread.exp and then tweaked slightly. As noted in a com= ment in next-fork-exec-other-thread.exp, I had to remove "on" from the loop= for non-stop as it was failing on all architectures (including x86-64) tha= t I tested. I have a feeling that it ought to work, but this can be invest= igated separately and (re)enabled once it works. I also increased the numb= er of iterations for the loop running the "next" commands. I've had some t= est runs which don't show the bug until the loop counter exceeded 100 itera= tions. The C file for the new test uses shorter delays than next-fork-othe= r-thread.c though, so it doesn't take overly long (IMO) to run this new tes= t. > > Running the new test on a Raspberry Pi w/ a 32-bit (Arm) kernel and userl= and using a gdbserver build without the fix in this commit shows the follow= ing results: > > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dfork:=20 > target-non-stop=3Dauto: non-stop=3Doff: displaced-stepping=3Dauto: i=3D12= :=20 > next to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dfork:=20 > target-non-stop=3Dauto: non-stop=3Doff: displaced-stepping=3Don: i=3D9: n= ext=20 > to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dfork:=20 > target-non-stop=3Dauto: non-stop=3Doff: displaced-stepping=3Doff: i=3D18:= next=20 > to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dfork:=20 > target-non-stop=3Doff: non-stop=3Doff: displaced-stepping=3Dauto: i=3D3: = next=20 > to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dfork:=20 > target-non-stop=3Doff: non-stop=3Doff: displaced-stepping=3Don: i=3D11: n= ext=20 > to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dfork:=20 > target-non-stop=3Doff: non-stop=3Doff: displaced-stepping=3Doff: i=3D1: n= ext=20 > to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Dauto: non-stop=3Doff: displaced-stepping=3Dauto: i=3D1:= next=20 > to break here > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Dauto: non-stop=3Doff: displaced-stepping=3Don: i=3D3: n= ext=20 > to break here > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Dauto: non-stop=3Doff: displaced-stepping=3Doff: i=3D1: = next=20 > to break here > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Don: non-stop=3Doff: displaced-stepping=3Dauto: i=3D47: = next=20 > to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Don: non-stop=3Doff: displaced-stepping=3Don: i=3D57: ne= xt to=20 > other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Doff: non-stop=3Doff: displaced-stepping=3Dauto: i=3D1: = next=20 > to break here > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Doff: non-stop=3Doff: displaced-stepping=3Don: i=3D10: n= ext=20 > to break here > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Doff: non-stop=3Doff: displaced-stepping=3Doff: i=3D1: n= ext=20 > to break here > > =3D=3D=3D gdb Summary =3D=3D=3D > > # of unexpected core files 12 > # of expected passes 3011 > # of unexpected failures 14 > > Each of the 12 core files were caused by the failed assertion in maybe_hw= _step in linux-low.c. These correspond to 12 of the unexpected failures. > > When the tests are run using a gdbserver build which includes the fix in = this commit, the results are significantly better, but not perfect: > > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Don: non-stop=3Doff: displaced-stepping=3Dauto: i=3D143:= next=20 > to other line > FAIL: gdb.threads/next-fork-exec-other-thread.exp: fork_func=3Dvfork:=20 > target-non-stop=3Don: non-stop=3Doff: displaced-stepping=3Don: i=3D25: ne= xt to=20 > other line > > =3D=3D=3D gdb Summary =3D=3D=3D > > # of expected passes 10178 > # of unexpected failures 2 > > (I think that the two remaining failures are due to some different=20 > problem. And, FWIW, I don't see these failures on the Pi when using > --target_board=3Dnative-extended-gdbserver.) > > Running the new test on x86-64 and aarch64, both native and native-gdbser= ver shows no failures. > > Also, I see no regressions when running the entire test suite for=20 > armv7l-unknown-linux-gnueabihf (i.e. the Raspberry Pi w/ 32-bit > kernel+userland) with --target_board=3Dnative-gdbserver. Additionally, > using --target_board=3Dnative-gdbserver, I also see no regressions for th= e entire test suite for x86-64 and aarch64 running Fedora 38. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30387 > Co-Authored-By: Zhiyong Yan > --- > .../gdb.threads/next-fork-exec-other-thread.c | 82 +++++++++++ > .../next-fork-exec-other-thread.exp | 131 ++++++++++++++++++ > gdbserver/linux-low.cc | 7 +- > 3 files changed, 219 insertions(+), 1 deletion(-) create mode 100644=20 > gdb/testsuite/gdb.threads/next-fork-exec-other-thread.c > create mode 100644=20 > gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp > > diff --git a/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.c=20 > b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.c > new file mode 100644 > index 00000000000..884706c6c3c > --- /dev/null > +++ b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.c > @@ -0,0 +1,82 @@ > +/* 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=20 > + . */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MAX_LOOP_ITER 10000 > + > +static char *argv0; > + > +static void* > +worker_a (void *pArg) > +{ > + int iter =3D 0; > + char *args[] =3D {argv0, "self-call", NULL }; > + > + while (iter++ < MAX_LOOP_ITER) > + { > + pid_t pid =3D FORK_FUNC (); > + if (pid =3D=3D 0) > + { > + /* child */ > + if (execvp (args[0], args) =3D=3D -1) > + { > + fprintf (stderr, "execvp error: %d\n", errno); > + exit (1); > + } > + } > + > + waitpid (pid, NULL, 0); > + usleep (5); > + } > +} > + > +static void* > +worker_b (void *pArg) > +{ > + int iter =3D 0; > + while (iter++ < MAX_LOOP_ITER) /* for loop */ > + { > + usleep (5); /* break here */ > + usleep (5); /* other line */ > + } > +} > + > +int > +main (int argc, char **argv) > +{ > + pthread_t wa_pid; > + pthread_t wb_pid; > + > + argv0 =3D argv[0]; > + > + if (argc > 1 && strcmp (argv[1], "self-call") =3D=3D 0) > + exit (0); > + > + pthread_create (&wa_pid, NULL, worker_a, NULL); pthread_create=20 > + (&wb_pid, NULL, worker_b, NULL); pthread_join (wa_pid, NULL); > + > + exit (0); > +} > diff --git a/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp=20 > b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp > new file mode 100644 > index 00000000000..e4d6ff53ded > --- /dev/null > +++ b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp > @@ -0,0 +1,131 @@ > +# Copyright 2022-2023 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or=20 > +modify # it under the terms of the GNU General Public License as=20 > +published by # the Free Software Foundation; either version 3 of the=20 > +License, or # (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, #=20 > +but WITHOUT ANY WARRANTY; without even the implied warranty of #=20 > +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU=20 > +General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License #=20 > +along with this program. If not, see . > + > +# This test was adapted from next-fork-other-thread.exp. The .c file=20 > +# was adapted from the reproducer for this bug: > +# > +# https://sourceware.org/bugzilla/show_bug.cgi?id=3D30387# > +# > +# That bug demonstrates a problem with software-singlestep in gdbserver. > +# Prior to being fixed, this test also demonstrated that bug for a #=20 > +32-bit ARM target. (Use > +RUNTESTFLAGS=3D"--target_board=3Dnative-gdbserver".) > +# It has been reproduced on a Raspberry Pi running Ubunutu server # > +20.04.5 LTS with 32-bit kernel + 32-bit userland. It was NOT=20 > +reproducible # using a circa 2023 Raspberry Pi OS w/ 64-bit kernel and 3= 2-bit userland. > + > +standard_testfile > + > +# Line where to stop the main thread. > +set break_here_line [gdb_get_line_number "break here"] > + > +# Build executables, one for each fork flavor. > +foreach_with_prefix fork_func {fork vfork} { > + set opts [list debug pthreads additional_flags=3D-DFORK_FUNC=3D${for= k_func}] > + if { [build_executable "failed to prepare" \ > + ${testfile}-${fork_func} ${srcfile} $opts] } { > + return > + } > +} > + > +# If testing against GDBserver, consume all it its output. > + > +proc drain_gdbserver_output { } { > + if { [info exists ::server_spawn_id] } { > + gdb_test_multiple "" "" { > + -i "$::server_spawn_id" > + -timeout 0 > + -re ".+" { > + exp_continue > + } > + } > + } > +} > + > +# Run the test with the given parameters: > +# > +# - FORK_FUNC: fork flavor, "fork" or "vfork". > +# - TARGET-NON-STOP: "maintenance set target-non-stop" value, "auto", = "on" or > +# "off". > +# - NON-STOP: "set non-stop" value, "on" or "off". > +# - DISPLACED-STEPPING: "set displaced-stepping" value, "auto", "on" o= r "off". > + > +proc do_test { fork_func target-non-stop non-stop displaced-stepping } { > + save_vars { ::GDBFLAGS } { > + append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${targe= t-non-stop}\"" > + append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" > + clean_restart ${::binfile}-${fork_func} > + } > + > + gdb_test_no_output "set displaced-stepping ${displaced-stepping}" > + > + if { ![runto_main] } { > + return > + } > + > + # The "Detached after (v)fork" messages get in the way in non-stop, = disable > + # them. > + gdb_test_no_output "set print inferior-events off" > + > + # Advance the next-ing thread to the point where we'll execute the n= exts. > + # Leave the breakpoint in: it will force GDB to step over it while n= ext-ing, > + # which exercises some additional code paths. > + gdb_test "break $::break_here_line" "Breakpoint $::decimal at $::hex= .*" > + gdb_test "continue" "hit Breakpoint $::decimal, worker_b.*" > + > + # Next an arbitrary number of times over the lines of the loop. > + for { set i 0 } { $i < 200 } { incr i } { > + # If testing against GDBserver, the forking threads cause a lot o= f > + # "Detaching from process XYZ" messages to appear. If we don't c= onsume > + # that output, GDBserver eventually blocks on a full stderr. Dra= in it > + # once every loop. It may not be needed for 20 iterations, but i= t's > + # needed if you increase to 200 iterations. > + drain_gdbserver_output > + > + with_test_prefix "i=3D$i" { > + if { [gdb_test "next" "other line.*" "next to other line"] != =3D 0 } { > + return > + } > + > + if { [gdb_test "next" "for loop.*" "next to for loop"] !=3D 0= } { > + return > + } > + > + if { [gdb_test "next" "break here.*" "next to break here"] != =3D 0} { > + return > + } > + } > + } > +} > + > +foreach_with_prefix fork_func {fork vfork} { > + foreach_with_prefix target-non-stop {auto on off} { > + # This file was copied from next-fork-other-thread.exp and > + # then adapted for the a case which also involves an exec in > + # addition to the fork. Ideally, we should test non-stop "on" > + # in addition to "off", but, for this test, that results in a > + # number of failures occur preceded by the message: > + # > + # Cannot execute this command while the selected thread is runnin= g. > + # > + # That seems like correct behavior to me, but perhaps the > + # non-stop case can be made to work; if so, simply add "on" > + # after "off" on the line below... > + foreach_with_prefix non-stop {off} { > + foreach_with_prefix displaced-stepping {auto on off} { > + do_test ${fork_func} ${target-non-stop} ${non-stop} ${dis= placed-stepping} > + } > + } > + } > +} > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index=20 > 651f219b738..e1806ade82f 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -2463,7 +2463,12 @@ linux_process_target::resume_stopped_resumed_lwps = (thread_info *thread) > int step =3D 0; > > if (thread->last_resume_kind =3D=3D resume_step) > - step =3D maybe_hw_step (thread); > + { > + if (supports_software_single_step ()) > + install_software_single_step_breakpoints (lp); > + > + step =3D maybe_hw_step (thread); > + } > > threads_debug_printf ("resuming stopped-resumed LWP %s at %s: step= =3D%d", > target_pid_to_str (ptid_of (thread)).c_str=20 > (), > -- > 2.41.0 >