From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xffRE96EKWrU4T8AWB0awg (envelope-from ) for ; Wed, 10 Jun 2026 11:38:06 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=selector1 header.b=PO5lm6FW; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3D07A1E070; Wed, 10 Jun 2026 11:38:06 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C1B061E070 for ; Wed, 10 Jun 2026 11:38:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB0174BA23C8 for ; Wed, 10 Jun 2026 15:38:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB0174BA23C8 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=selector1 header.b=PO5lm6FW Received: from YT5PR01CU002.outbound.protection.outlook.com (mail-canadacentralazon11021101.outbound.protection.outlook.com [40.107.192.101]) by sourceware.org (Postfix) with ESMTPS id 7A8824BA5439 for ; Wed, 10 Jun 2026 15:37:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A8824BA5439 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A8824BA5439 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.192.101 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1781105855; cv=pass; b=d8NAewk1cKFBR0Ka8x9PuhYaaAmwYkRzj9UIZgH6Rek88gNUCWB1I5X7QUsbf2eGlI6qhgzPtppQV1Xn7kKDdr9ymuRdX+bm/+MhF1JLMziopAfGOgfVPOMfrNE1i/mPh2WY6qNYIIMOM96Zv+cOX1Ry48XLQKwxaiW+timFPoI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1781105855; c=relaxed/simple; bh=ICIM0JGPIGk9N8OJW/ZAaeXzY9y/A8FnDo2O8Jiebqw=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=DwqUU7NnIQDSQ7dfe+6apkjqLG4CMThvrz7nFeAGFFfoJzAVkGrkPebP/3OEG7CkqIm77zGuyqSMQ8t80FgLDS9KByEVCH0nCOAynJ3wdqjurNFB1MYNGBQ+MK6vTX9iDIhJc4m2CkviKN0Z/hmJLjFAm0cWdnKzeVO7PQC+yqU= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=selector1 header.b=PO5lm6FW DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A8824BA5439 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sz4CI6DmhsUmCSaqFZJi0OJaWKi3nwJJ8ykXNO5HbyVjXPLTvGG3AICJJQ7qfWIB1RyRVWu/8RCNfQm00Utuxwxaji4hUyrAE14pjgAWgtHczDR2AkiXQ9AvqBFL8RGyGZSBkBuptkaWUgRCAsq/dLuU3p9GJeHdBSCluiJZLCFPmw4y67nyEQ1pO/XnPMeAWUNuhjnUGcHuBktRjwVFzgAZOmyRkPt293dpsdbKs4JzVGi3K6FUK5azzrjDgL3p945Ku+V9LDNtFpLghIuhNryYv9Uhnya9cM7HZZcC+WvG+rQ7hB5kw9VU6JcJL+AzWRWwc3z8+X1ndunIL72pqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=/EHQAO2NwLSReF4GNf82gh2oi/qZwzOrjW0UzsQBJsY=; b=KiJ7aInMfVQAwkQm+GN7c2FR0+/6OrD6uVBtX4IbSotoio12FMjyuAIUkHofjYhgZ3KbNRhIkg4FCFYzzH7R5BU6I7024a/ohcU2YeABQUZPRPZ5Hs/eliSWxg/LtRl9KbASPpxrmtORNSomt3wwDHRvfs30ti6POhWy2kcqYmzbjf2b8KeXGw9dCf6cNcihsopnXtY1SYLkW+2+FOMSL0L1q6CfpT7BkUAXxhCjivlmQLLgKp2QqATh8Bo/9k2Z/gJvX9zxKs3443HDFcnyvmR/uEO87zuBCfV2NnIiy/FV6xIupZxw94Zw/556p/y5b6La9LCdDqmSdBR1w/bvRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=efficios.com; dmarc=pass action=none header.from=efficios.com; dkim=pass header.d=efficios.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/EHQAO2NwLSReF4GNf82gh2oi/qZwzOrjW0UzsQBJsY=; b=PO5lm6FWyL+ERBJiCSiCvhHnXF5azlc2ugLGNJ8JrCS6eS2dgUH4V8MpEqk6+9i5ygKWSL4gjHubAjpyXJ/lEt0xBGdOGGRtIXnd5UpKDWr+HcB3TO1y+nu7bWsKdNwmZ+0Sl9KKjFQc9RwYqeH3seMG20RCrBlQnXcQ8mbEKScKcfxP4vgO/eh0skOKzCb3eoPpVWmtIbllznMDUykW1XjjByLIt0Wks5L0FdXXYOCSi4Nnlz76kx6C9UhONgt6EItyA+myUJdPiWLQDNdW4FQVz7QuiO08w5v4nDFoFZ8uGFQtyvpCF6jc0FvH2tj67hEOoCX/lcPfQiD2w8t1qw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=efficios.com; Received: from YQBPR0101MB9104.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:5f::18) by YT1PR01MB8489.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:c4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.113.11; Wed, 10 Jun 2026 15:37:29 +0000 Received: from YQBPR0101MB9104.CANPRD01.PROD.OUTLOOK.COM ([fe80::8c3:42b8:f43:3b9f]) by YQBPR0101MB9104.CANPRD01.PROD.OUTLOOK.COM ([fe80::8c3:42b8:f43:3b9f%7]) with mapi id 15.21.0113.011; Wed, 10 Jun 2026 15:37:28 +0000 Message-ID: <96548ea3-f59a-4371-936a-26a8aae69bf5@efficios.com> Date: Wed, 10 Jun 2026 11:37:27 -0400 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] gdb/breakpoint: remove assertion when printing internal breakpoints without locspecs To: Andrew Burgess , gdb-patches@sourceware.org References: <20260610141509.12950-1-sdarche@efficios.com> <877bo6qvbr.fsf@redhat.com> Content-Language: en-US From: =?UTF-8?Q?S=C3=A9bastien_Darche?= In-Reply-To: <877bo6qvbr.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: YT4PR01CA0427.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::18) To YQBPR0101MB9104.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:5f::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: YQBPR0101MB9104:EE_|YT1PR01MB8489:EE_ X-MS-Office365-Filtering-Correlation-Id: 51eb89cd-3640-4d3c-282f-08dec7062dba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|23010399003|1800799024|376014|13003099007|22082099003|18002099003|5023799004|4143699003|3023799007|56012099006; X-Microsoft-Antispam-Message-Info: FSfPeNZXz1yDGCFcFYvCTJZ/8E/AuXGkYIot+PXxJJZsVwAZhXZkJASNLbnD5K6DsJXT5BobgP1dgn4PQiYBAFObRlV2tcGmkELu4Loch0YhxISDdGhiB5MDEmvt2UPJUApiyINEqWYgbN7cZffL5QgqF91NZHKlFHssGjg3qmNViXdCR8mI6WHr3ay3HSDuq4fsW3OJff/B9jWef1hMoRxdrkhD/p6VdLCIh9fzszYDWK3J096zFjxwX8jV7B7kfkRdy+m4pe5AW21hMNu2R/Z5yw6Z9x1bMQ0S5Et/TsjjN/MhZZIg+vE8/TYKIXLmsebe3W4KbrH+hColhJseL5+MGIADvknEwrLH9w8Dc5/mNUambJX7uTddB+n/K3sLp71FPoHZzrz302B9GZiCjFukIqopQj3mx5OQQ/wwqWH9tfr2sLVPse2sMmzyIrpifj80S+fJS656w8Xxk5zDlp5xcGpG8XH2AYD35niZ7KhEMGL3ZAJKAZE3nHlQLasleaISzJ1+lctS34fIukqthudVRXR5vFqStCJJ5JJcrT1Yg2RFGlFAgr84LHujnUOPudYPUt4KH+Wo3Wy6iFG8+qsKk8LS52PsWL0MxUQdsZ9uznA11aWsieyV8F8ONLn4qNsdpSuF6oiniQzuNHw3zjcB4vJEafmnQrKK1QOvBrDJ/g8vTKFuDq7/bDGsHkzj7fS4EI6+r7OU7iMmnhrf/w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YQBPR0101MB9104.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230040)(366016)(23010399003)(1800799024)(376014)(13003099007)(22082099003)(18002099003)(5023799004)(4143699003)(3023799007)(56012099006); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZW16aHE2azdGS09ZSkQ0RWdvaDBHbUREckZqK2ljMUcwMXV3YlluYy9hck1v?= =?utf-8?B?SFpVV3J6SFQ0M28yVzJNSHNDUm5XOU5YWVE5bnFYcTlpd3IwSTkyYVlxdDVS?= =?utf-8?B?WDdHeHRzS0NnWFRvOXBLdzJkMTNGclFkRi8rQW1ZZEQ0emM4NTl3eHBLbFlv?= =?utf-8?B?aTJBbUpKSVpBaEd4WDdzMWY4bis1T0plNG1xQmtOOWtGMmZUeC91cnpFa1gx?= =?utf-8?B?em1DOUx4QkZldGtHYUppWkpwTkI1ZWhDVjBOWFNTWDRSaWJrMUlDeGs2UkNI?= =?utf-8?B?L1ZydDJLRXo1SllqL01ZY0Q0U3E5M0pXc2RPUCtESXFLeURwdFhLRHJnQ2Iy?= =?utf-8?B?U3dZbHdsTjBRVzlyVkdKVUIrRjFEVU1TN3JwUDVVbFNqMTRtU2VpNFhic0dT?= =?utf-8?B?dDZYZzR2MlZzcVF4Y3cvdER0enFiQTZZb3FNK1NIRzBFczNhWTFqKy9nUzZO?= =?utf-8?B?ZUdudzRLajZwc2pyTFA2elUvSWl0cDc2WkJlOStiSlBjV2pyM0VnUzJJbW5E?= =?utf-8?B?KzU2OGRUOTEyeGtDSDBycUhHRVFmZk83akVYY0kwRHVqdXcxczlmaWZkZU1X?= =?utf-8?B?MWQzTmlUTEZzRkI2UGw3aXdIblRzc1pqc0haZERrUTFTN3VTQW1IRkN3dS9N?= =?utf-8?B?a0JCcjBrU1R5VzlNRnFHKy9kOW1QZkdYOSswSndxcFFnWFN2a0xBZWpSQklP?= =?utf-8?B?bDhCQTBJaWJNWlV3cjBMZWEvMHFsY2NDSkswOGNYZVdzWjVYZnNTMUNqQ0ZY?= =?utf-8?B?K1d6eUVpbGdya0t4VVVNNHo2cEptZFJLL2hYWVBaYVZMVlV3TERFSTExSWpz?= =?utf-8?B?SXMzUS9ZMTNCWlZLdm01L2lZcW5UakU0NklESE1XSGlwMlNuYTB0WkRtcHVF?= =?utf-8?B?cGlMT1N5NlpxTjAwSVdlR1RPY1RkWnhOTXJnQnlxQnhvZEN2QWR5VmF2Y0RS?= =?utf-8?B?Z1VrV2pPcUdlcmwwT1JmTXEvdjZLVEtTcG1JR2xHclVaQW5EMjV1ekZhTVpK?= =?utf-8?B?V09tczBrR1R4TVRTcUYxRkxYVlpiOUVhOGhFWXN4dkphY0lyZit2R2UvZDg1?= =?utf-8?B?S2hTZ2kxMXprcEcyeHh6TDBRd200Mzc3a213Q3VSWnE0ZXJHZEF3YVFYanBB?= =?utf-8?B?VkpTbktPU0l3WU1DL3djbTY3ZmRPWTQxa2lQUVZHRkxMMjB6ejFnL3ppb1VB?= =?utf-8?B?NE1SR1BhWXJhZUpuUVRHTCtuVk1abE9CTStvL1pHNzhsdEo0ZWV4KzJBRHpG?= =?utf-8?B?bU52RzVZTVJDdlMwRDJnVGpNQThsSzY4YWFjODY5engzbGRtU3JIWnU3M0cr?= =?utf-8?B?b3JrZEFVblVCTVNESGVpMEVqRDlOb1JCRE82UGk3eU1UcE5iVXVKS3FJTVJI?= =?utf-8?B?M2FuekVpbkJMRjhPUkFnbExzeGZSUTlmQ2Y4RVF3RjlVS2dhY0pGNWdrQUxl?= =?utf-8?B?SWRqR09jai9WTDBxVWFlTFJWaEV5UzdaK3Uxd3VlUDNNK3V0Qlo5T3JGeGVK?= =?utf-8?B?YTkyT3IvM3NybSt0S1F5OFZQQzVXOHk5WEUwTGxoY2E3a1U4cmJPYzhYdUR3?= =?utf-8?B?TDVVcnFWbkNXcFp4eXlLNHB6YnNRTzYxblowcy9QWHNTUEZnbjF3MGZ4b1M4?= =?utf-8?B?RWlSb044YWdlejFPL01NdTNGbGtleFhRa054L2xJaGNrMVM1MUR6MGdLaWNn?= =?utf-8?B?RHJjVm9qdzByaGZJWkc5TVovNFN6c3RWWDBhWllhL0NiazNBM3Z1Mlg2Z1Ey?= =?utf-8?B?VFNoOVNCbUx5VHB6Y1pWY2ZvL3BmaGc5cjNudzlDd21IWk5vOXRrelNodU0y?= =?utf-8?B?akZVQ2pZUGMzbVpkZHZSQUtENmdCeFBjSVNlbVRCSGlUVjZvMnJpTEdaVWh1?= =?utf-8?B?NmswR3h4MGdYWmNqZWk3K2ZaYUIzaVFFdXgzZy9XNmVRaFBxWTRLRXNzS29E?= =?utf-8?B?MnprRXgxY1VSMER3OU5odzhpL25qblNXY0R4dHNCa0NGaEpnR2pTNkVZekVY?= =?utf-8?B?Ym5wOEl1cEliYnJCR09pVlZxV3QvWG9QUGJjOHVMRElMV0pmOE1naXpheVFv?= =?utf-8?B?TnF3MFNnUnp5bHBwdXR6U084bkQ2WHc1bHd3QUpTNDNMZVpNMXlyWDF3ZXlH?= =?utf-8?B?cDM0aVRiR3J1emJ2UHkwaWRIWUM3ZmJrNElPbkpLQ0dlMGZ0Y2l3dEFBaDdz?= =?utf-8?B?UzhtZWxtbE1KeUtSYUJOOFFoblFGUDBvRU1nOEtNU1dWQTNLK3RheGNnUEJh?= =?utf-8?B?TllZb1QzWVhWUmwxOGxwR0lLUTNzM2J2SWxITXVBakNUd1BacVZ3aTAwWjJH?= =?utf-8?B?d0IyVWFXV0Q2MEt1bjczb2x3YnZoRkJmRkpoUW9ORmtIcit0OGVCQT09?= X-OriginatorOrg: efficios.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51eb89cd-3640-4d3c-282f-08dec7062dba X-MS-Exchange-CrossTenant-AuthSource: YQBPR0101MB9104.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2026 15:37:28.5306 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f278736-4ab6-415c-957e-1f55336bd31e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: x39wksoK9l89quxXhzg2bXvt5foEx1OQti0q42Tr4diMmIKHpNSy3DUF3NrMPxOcNF+QTdhK9khLjl3gbHm/NA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT1PR01MB8489 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Thanks again, Andrew. Just pushed. Best, Sébastien On 2026-06-10 11:16, Andrew Burgess wrote: > > Thanks, this looks great. I have one minor nit, no need to repost though... > > Sébastien Darche writes: > >> When debugging gdb with `set debug breakpoint on`, gdb would crash if >> the inferior happened to unload (through dlclose ()) a shared library >> that contains jit debugging symbols: >> >> ../../gdb/breakpoint.c:6473: internal-error: print_breakpoint_location: >> Assertion `b->locspec != nullptr || (!user_breakpoint_p (b) && (b->type >> == bp_shlib_event || b->type == bp_thread_event))' failed. >> A problem internal to GDB has been detected [...] >> >> This assertion was added in commit 5770f68 ("gdb: handle empty locspec >> when printing breakpoints"). The assumption for this assert is that the >> user may not call any (gdb-)debugging command between the time a shared >> library is marked (bp_location->shlib_disabled is set) and the >> breakpoint is actually removed. This would be true if the user called >> `maint info breakpoints` as explained in the original commit message. >> >> However, if `set debug breakpoint on` is called, gdb prints debugging >> info as the shared library is being unloaded. The ~jiter_objfile_data >> dtor deletes the breakpoint, which calls remove_breakpoint_1 on the >> bp_location in the recently unloaded shared object. Since `debug >> breakpoint` is enabled, we go through print_breakpoint_location with the >> bp_location's shlib_disabled flag set, which results in the assert >> above. >> >> This commit removes the assertion as it is not true in all cases. I've >> also included a minimal test case that loads a shared library with a >> __jit_debug_register_code symbol. The test fails with the assert. >> >> Change-Id: Ia19c84f194a6f0c10315548c7f423bfd86ef0266 >> --- >> gdb/breakpoint.c | 17 ------- >> gdb/testsuite/gdb.base/jit-unload-solib.c | 21 ++++++++ >> gdb/testsuite/gdb.base/jit-unload.c | 45 ++++++++++++++++ >> gdb/testsuite/gdb.base/jit-unload.exp | 62 +++++++++++++++++++++++ >> 4 files changed, 128 insertions(+), 17 deletions(-) >> create mode 100644 gdb/testsuite/gdb.base/jit-unload-solib.c >> create mode 100644 gdb/testsuite/gdb.base/jit-unload.c >> create mode 100644 gdb/testsuite/gdb.base/jit-unload.exp >> >> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c >> index 101dc57ee6b..85c4ffc3171 100644 >> --- a/gdb/breakpoint.c >> +++ b/gdb/breakpoint.c >> @@ -6457,23 +6457,6 @@ print_breakpoint_location (const breakpoint *b, const bp_location *loc) >> } >> else >> { >> - /* Internal breakpoints don't have a locspec string, but can become >> - pending if the shared library the breakpoint is in is unloaded. >> - For most internal breakpoint types though, after unloading the >> - shared library, the breakpoint will be deleted and never recreated >> - (see internal_breakpoint::re_set). But for two internal >> - breakpoint types bp_shlib_event and bp_thread_event this is not >> - true. Usually we don't expect the libraries that contain these >> - breakpoints to ever be unloaded, but a buggy inferior might do >> - such a thing, in which case GDB should be prepared to handle this >> - case. >> - >> - If these two breakpoint types become pending then there will be no >> - locspec string. */ >> - gdb_assert (b->locspec != nullptr >> - || (!user_breakpoint_p (b) >> - && (b->type == bp_shlib_event >> - || b->type == bp_thread_event))); >> const char *locspec_str >> = (b->locspec != nullptr ? b->locspec->to_string () : ""); >> uiout->field_string ("pending", locspec_str); >> diff --git a/gdb/testsuite/gdb.base/jit-unload-solib.c b/gdb/testsuite/gdb.base/jit-unload-solib.c >> new file mode 100644 >> index 00000000000..3cf2c580320 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/jit-unload-solib.c >> @@ -0,0 +1,21 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> + Copyright 2026 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 . */ >> + >> +/* This simulates a JIT library. */ >> + >> + >> +#include "jit-protocol.h" >> diff --git a/gdb/testsuite/gdb.base/jit-unload.c b/gdb/testsuite/gdb.base/jit-unload.c >> new file mode 100644 >> index 00000000000..92dfa16c055 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/jit-unload.c >> @@ -0,0 +1,45 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> + Copyright 2026 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 . */ >> + >> +/* Simulate loading of a library JIT code. */ >> + >> +#include >> +#include >> + >> +#ifdef __WIN32__ >> +#include >> +#define dlopen(name, mode) LoadLibrary (TEXT (name)) >> +#define dlclose(handle) FreeLibrary (handle) > > There's no definition of dlerror() here. Similar tests do: > > #define dlerror() "an error occurred" > > If you're happy to add that here then: > > Approved-By: Andrew Burgess > > Thanks, > Andrew > > >> +#else >> +#include >> +#endif >> + >> + >> +int >> +main (void) >> +{ >> + void *handle = dlopen (SHLIB_NAME, RTLD_NOW); >> + >> + if (handle == NULL) >> + { >> + fprintf (stderr, "%s\n", dlerror ()); >> + exit (1); >> + } >> + >> + dlclose (handle); >> + return 0; >> +} >> diff --git a/gdb/testsuite/gdb.base/jit-unload.exp b/gdb/testsuite/gdb.base/jit-unload.exp >> new file mode 100644 >> index 00000000000..a5f9adbd76c >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/jit-unload.exp >> @@ -0,0 +1,62 @@ >> +# Copyright 2026 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 . >> + >> +# This test checks that gdb does not assert when unloading a shared library >> +# that defines a __jit_debug_register_code if `set debug breakpoint on` is set. >> + >> +require allow_shlib_tests >> + >> +standard_testfile .c -solib.c >> +set lib_testfile ${testfile}-lib >> +set lib_binfile [standard_output_file $lib_testfile] >> + >> +if { [build_executable "build shlib" $lib_testfile $srcfile2 \ >> + {debug shlib}] == -1 } { >> + return >> +} >> + >> +set lib_testfile_on_target [gdb_download_shlib $lib_binfile] >> + >> +set options [list \ >> + debug \ >> + shlib_load \ >> + additional_flags=-DSHLIB_NAME=\"${lib_testfile_on_target}\"] >> + >> +if { [prepare_for_testing "build main file" $testfile $srcfile \ >> + $options] == -1 } { >> + return >> +} >> + >> +if { ![runto_main] } { >> + return >> +} >> + >> +gdb_test_no_output "set debug breakpoint on" >> + >> +set saw_exit false >> +gdb_test_multiple "continue" unload { >> + -re "^\\\[Inferior $decimal \[^\r\n\]+ exited normally\\\]\r\n" { >> + set saw_exit true >> + exp_continue >> + } >> + >> + -re "^$gdb_prompt $" { >> + gdb_assert ${saw_exit} $gdb_test_name >> + } >> + >> + -re "^\[^\r\n\]*\r\n" { >> + exp_continue >> + } >> +} >> -- >> 2.54.0 >