From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sbxsDS8W/2qcayAAWB0awg (envelope-from ) for ; Thu, 19 Nov 2026 10:30:55 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=JIPeyO9O; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 324DB1E0BC; Thu, 19 Nov 2026 10:30:55 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2 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 20C231E023 for ; Thu, 19 Nov 2026 10:30:53 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A1C84BA5434 for ; Thu, 19 Nov 2026 15:30:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A1C84BA5434 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=JIPeyO9O Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012001.outbound.protection.outlook.com [52.101.48.1]) by sourceware.org (Postfix) with ESMTPS id 88D924BA2E0C for ; Thu, 19 Nov 2026 15:30:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 88D924BA2E0C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 88D924BA2E0C Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=52.101.48.1 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1795102220; cv=pass; b=sk9PNidcCmSA6JQV2k8FEFDSk5ke1ypZaNfJHULNtXrNjXN0cKsQQrBvchx387MkTc54JBrLy0Kv+LR0d1+59jjEWWMUIl/ipcmouHE0EfdlvPdV0/NCbhENqyy/J0zZYyvQuKdHnAWBYmWPTs8EN6WOqA3po16WDqIynyaIVj0= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1795102220; c=relaxed/simple; bh=t21ryBOWKIU6n5Q/nMARp/U/bq+GxDWlCFTkvjIsl0k=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Yv6bO5r7ZpikDnWlxi6fdIzrm3yT8SMRHXYiTuAAZzXmDIpAr4shrR4nHnRTBKYg2AmLrY+QVL+OQX0nZgsDIfU3Y/tKYAjn07GOUHMukafNvdR2p0/GpS5Gh/wNsXHphhijPvH8FVVLRn7Q5Taot0DNnndjiObIDTcNlKjctYg= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=JIPeyO9O DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88D924BA2E0C ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EMN0sE3IleKECDwoHJuloWf66ET/vhrxU7twKCdx+G1qyE1nqks1rERa6OErBsKkJQspsBLa6IgUk3/VY60YMaG0j65kCDQNPZRGsQlnndMPXXD7jwGz0khjFhEOXCQHoJcYS1AqeyNVCtvcWXNZdszAAxphpFI0bZTd5Vo17ayYWPZ8kLCufSacevZMfghLIrJNkWkWwhmesUd18i2rAohzGaLkD/e5lgKyKottQmWTYr+S3JNLqXUbJk/vW5qx+qTDJfLAlAhV8UYjWE0KofPcZYNcFdDMRPQlCU8YUWcBLusa6zIYI4Ik7yN0KtVgJoFy86mabtMYpX5Ddp05Mg== 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=TGnH7qRc+7fvm08ciV+2HvZMNFO8kbvTFdyYOjvz4og=; b=xpL7lY+Gll6pmZJllDeXNtk/dz68X+QQDs8NRJZj11D8aPR+9VppbOcmVxFLnTc1OIKFicuW3c6bHaXfT1201pISXnmqaPhj3X8jLyF1orMVH545g9bxhW6hxfFi+raTOgzDi7UUkJt5ur8faBYaX0HDz4OmsakAzr6UXe2eKD8hNQEaoMhIR1JvuqqqAp+R14RJoup3WtCiIz9tcYsthwkpDCU7QCjYnFmFVJIH+N4s7UiBlQtHJYUMY0r1apSF+H5tQj6MNEYZO6lrJYDr4MtafDPOpg+neGdRxhpTNBUq33//Y/pGuX+/cIBmoGjh0wsRRleIBUOBZeHoleTTMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TGnH7qRc+7fvm08ciV+2HvZMNFO8kbvTFdyYOjvz4og=; b=JIPeyO9OQNBwI+5iSZ9VB6r8FEg7V4Y7c7Cef/7UBlJBAfjpobWhpSkwYZA+ZN32HIdOnAJtAJlMUyjqXELlOWOtxqpR3s14kzajtg7MHt1ZK/ffmMRdbyMEgveWZbRar/khncKB0CIiHNH8qXMzuFW1KC/xO3b/68R9BBLz+A4= Received: from SJ0PR13CA0178.namprd13.prod.outlook.com (2603:10b6:a03:2c7::33) by CH3PR12MB7713.namprd12.prod.outlook.com (2603:10b6:610:14d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.615.14; Thu, 19 Nov 2026 15:30:05 +0000 Received: from SJ5PEPF000001F5.namprd05.prod.outlook.com (2603:10b6:a03:2c7:cafe::31) by SJ0PR13CA0178.outlook.office365.com (2603:10b6:a03:2c7::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.2 via Frontend Transport; Thu, 19 Nov 2026 15:30:00 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ5PEPF000001F5.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.639.5 via Frontend Transport; Thu, 19 Nov 2026 15:30:00 +0000 Received: from khazad-dum (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 19 Nov 2026 09:29:58 -0600 Date: Thu, 19 Nov 2026 15:29:50 +0000 From: Lancelot SIX To: Bratislav Filipovic , Subject: Re: [PATCH v5] gdb: Implement stop-on-solib-events for GPU code objects Message-ID: References: <20261119142057.58123-1-bfilipov@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20261119142057.58123-1-bfilipov@amd.com> X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001F5:EE_|CH3PR12MB7713:EE_ X-MS-Office365-Filtering-Correlation-Id: 507ec825-cc48-47d2-2ed0-08df4651f97e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700016|82310400026|23010399003|376014|18002099003|22082099003|6133799003|261009223027099003|3023799007|13003099007|5023799004|11063799006|56012099006|261102123227099003|261022105027099003|261026140227099003|261028144727099003|261026121527099003|261021123027099003|261021121427099003|261022075727099003|10067099003; X-Microsoft-Antispam-Message-Info: fHOadCT+igclnTxCR1MlBqu2ZhNRBhFYm+VLHlNRZH+Ogp/eu1ytkPs+TA9OX8DezkHyOUvST1qRM57bOMaoRK8M0R2TsAk5fxKpMRqu3mcxeeKAQDu7ZYBVi+waQPKcN7Tl8N76Cr7oLMAuqjtN9vKYkaPSCgJQakrHYEkyCWLiMBh36OEqJ+58n//DKCXjT7umnl0LgmExZ/XG1QPsJhZoU1ul5PAw9uoOQq0eAFZpH3S8KP4rOXHHKLPHPz8T4pW8KCuR5Z5Vm5EH4qlvLWgoLCU2yfD8/UDBLDt1+2/SHM5/tg9/V8a6MuD3UrS5TTXNCVtvr9JikcZYthFcsqRXEXJ6mKvyc9whzsLQw3kPhaJm9v58VZjsEuh61Fi3JPBvyyzmh1/Hc4uPNt+B1mV5V3IIkKbXNGcjTQiL7Pd1QzlovJYh1+izEX68DbBQzt5fDlBmvPqSlCim5KNpuoq7cE61yBzuMI+ZxU0vkx2jDEoYayeHmwd2nykXt4tCFJkUBq5pqsa7vY++9xF6YbpAYhdQr4loH93ewqmk5F6FZD7eDqFzsCf5OSwmETn+HBWrPHSk2bfT/hrDzzAHyrcAdMvoTWg0EjrQiPwGxqy5qtaBoYD/oaJW30UWjsCt1Gp421tp2L9Ul6tdMS5rvAH2V0UUUUc6nXVDLQmaPuU= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700016)(82310400026)(23010399003)(376014)(18002099003)(22082099003)(6133799003)(261009223027099003)(3023799007)(13003099007)(5023799004)(11063799006)(56012099006)(261102123227099003)(261022105027099003)(261026140227099003)(261028144727099003)(261026121527099003)(261021123027099003)(261021121427099003)(261022075727099003)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BQa64SefWbTWtCVNhv3I774KqR1FyCgBSoTerxnJkUX9nuq1IpPgpC0R9n8ePvNvkRcVOyvdQQ2r0BRICdKVfLpHMcNY99znXr62uQ8lKyuCzmVDK/Myc5O/h9dqNkY6Aq2lRTLqF2jxrAAtlZQ0eavXORVOVWJ/QJgYT1VIfWRr2HRGqZrwz+lqO7AICH7N71FdZym9Kb9OIGYcskhB4hbAqwBYUNBK/yQaxm3seyd7Hy6AlCaQUuT+q9XPJLo8142pWEl/dwiFjPVNJQE7hNrHKAGtYSN0pP2yfe6Mo2DrrpcmmsF9CGiwp0qpGp0FWXKWTZTMEoh9NezOJsXB7tZCqARDFS8mZcgVk0H+i9Xaz97JQ5hAD8p5gnDYsMtFk35cEWkExDLGZY9jBSgp5SRLRxhCyFasmfDo40HhnaYQ8uZFxAayCyMCFTL1GgJ0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2026 15:30:00.0662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 507ec825-cc48-47d2-2ed0-08df4651f97e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7713 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 On Thu, Nov 19, 2026 at 03:09:57PM +0100, Bratislav Filipovic wrote: > GDB's "set stop-on-solib-events" setting allows users to stop execution > when shared libraries are loaded or unloaded, enabling inspection and > breakpoint placement before library code executes. This works for CPU > shared libraries, but has no effect on GPU code objects loaded by the > AMD ROCm runtime, even though those are reported as shared libraries > (e.g. in "info sharedlibrary"). > > The reason is that amd_dbgapi_target_breakpoint::check_status > unconditionally sets bs->stop to 0. This is in contrast to > internal_breakpoint::check_status for CPU shared libraries, which > honors stop_on_solib_events. > > Fix this by having process_event_queue report whether a > CODE_OBJECT_LIST_UPDATED event was processed while draining the event > queue. check_status then sets bs->stop and bs->print the same way > internal_breakpoint::check_status does for bp_shlib_event breakpoints. > It no longer sets bs->print_it to print_it_noop: bpstat_stop_status > already does that when the breakpoint does not stop. A print_it > override reports the stop through print_solib_event, so the stop is > presented like a CPU shared library event, both in the CLI ("Stopped > due to shared library event") and in MI (*stopped,reason="solib-event"). > > "catch load" and "catch unload" catchpoints are not affected by this > change and still do not trigger for GPU code objects. > > Add gdb.rocm/solib-event.exp, which tests both file:// code objects > (hipModuleLoad) and memory:// code objects (hipModuleLoadData), their > unload events, that nothing stops when the setting is off, and the MI > stop record. > > --- > Changes in v5 (addressing Lancelot's review of v4): > - Drop the CPU/GPU-specific messages: breakpoint.{c,h} and > break-catch-load.c are no longer touched. GPU code object events > now print "Stopped due to shared library event", like CPU ones. > - Remove the leftover object-kind paragraph from the MI documentation. > - Fix the print_it comment; process_one_event is unchanged and > process_event_queue sets code_object_list_updated itself. > - check_status now mirrors internal_breakpoint::check_status. > - Test: empty kernel body (no inline asm), unambiguous end-of-test > marker, remove the test_file_load/test_memory_load breakpoints, > use the default MI version, simplify the MI solib-event check. > - Rebased on current master; the int -> bool change for > stop_on_solib_events is now upstream and is no longer part of this > patch. > > Tested on gfx90a: gdb.rocm/solib-event.exp, gdb.base/catch-load.exp, > gdb.mi/mi-catch-load.exp. > Hi, The AMDGPU part looks ok. Thanks for working on this! Approved-by: Lancelot Six (amdgpu) Note that the infrun.c change would require a global maintainer approval. I am not sure this change is really needed or wanted, as I expect most users of GDB will not have a GPU backend, and this message might end-up missleading. But this is for global maintainers to decide. Best, Lancelot. > gdb/NEWS | 5 + > gdb/amd-dbgapi-target.c | 47 +++++- > gdb/doc/gdb.texinfo | 9 +- > gdb/infrun.c | 5 +- > gdb/testsuite/gdb.rocm/solib-event-kernel.cpp | 26 +++ > gdb/testsuite/gdb.rocm/solib-event.cpp | 105 ++++++++++++ > gdb/testsuite/gdb.rocm/solib-event.exp | 155 ++++++++++++++++++ > 7 files changed, 340 insertions(+), 12 deletions(-) > create mode 100644 gdb/testsuite/gdb.rocm/solib-event-kernel.cpp > create mode 100644 gdb/testsuite/gdb.rocm/solib-event.cpp > create mode 100644 gdb/testsuite/gdb.rocm/solib-event.exp > > diff --git a/gdb/NEWS b/gdb/NEWS > index db3fa820df1..e9335955b1a 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -7,6 +7,11 @@ > Support displaying and modifying Intel APX registers (Extended GPRs > $r16 - $r31) including byte, word and dword pseudo registers. > > +* The 'set stop-on-solib-events' setting now applies to GPU code objects > + loaded by the AMD ROCm runtime, in addition to CPU shared libraries. > + When enabled, GDB will stop execution whenever GPU code objects are > + loaded or unloaded, allowing inspection and breakpoint placement. > + > * GDB now distinguishes between the GNU (MinGW) and MSVC Windows ABIs. > > The "set osabi" command accepts two new values, "Windows-GNU" and > diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c > index a38a8bafb90..bbb6b633a44 100644 > --- a/gdb/amd-dbgapi-target.c > +++ b/gdb/amd-dbgapi-target.c > @@ -30,6 +30,7 @@ > #include "gdbsupport/unordered_map.h" > #include "inf-loop.h" > #include "inferior.h" > +#include "infrun.h" > #include "objfiles.h" > #include "observable.h" > #include "registry.h" > @@ -275,7 +276,17 @@ struct amd_dbgapi_inferior_info > wave_info_map; > }; > > -static amd_dbgapi_event_id_t process_event_queue > +/* Return value for process_event_queue. */ > +struct process_event_queue_result > +{ > + /* The event ID, or AMD_DBGAPI_EVENT_NONE if no event was found. */ > + amd_dbgapi_event_id_t event_id; > + > + /* True if a CODE_OBJECT_LIST_UPDATED event was seen during processing. */ > + bool code_object_list_updated; > +}; > + > +static process_event_queue_result process_event_queue > (amd_dbgapi_inferior_info &info, > amd_dbgapi_event_kind_t until_event_kind = AMD_DBGAPI_EVENT_KIND_NONE); > > @@ -587,6 +598,7 @@ struct amd_dbgapi_target_breakpoint : public code_breakpoint > > void re_set (program_space *) override; > void check_status (struct bpstat *bs) override; > + enum print_stop_action print_it (const bpstat *bs) const override; > }; > > void > @@ -603,7 +615,6 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs) > amd_dbgapi_status_t status; > > bs->stop = 0; > - bs->print_it = print_it_noop; > > /* Find the address the breakpoint is set at. */ > auto match_breakpoint > @@ -639,7 +650,7 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs) > > /* If the action is AMD_DBGAPI_BREAKPOINT_ACTION_HALT, we need to wait until > a breakpoint resume event for this breakpoint_id is seen. */ > - amd_dbgapi_event_id_t resume_event_id > + auto [resume_event_id, code_object_list_updated] > = process_event_queue (info, AMD_DBGAPI_EVENT_KIND_BREAKPOINT_RESUME); > > /* We should always get a breakpoint_resume event after processing all > @@ -665,6 +676,23 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs) > pulongest (resume_breakpoint_id.handle)); > > amd_dbgapi_event_processed (resume_event_id); > + > + /* If the code object list was updated, stop if the user requested to > + stop on shared library events, as internal_breakpoint::check_status > + does for bp_shlib_event breakpoints. */ > + bs->stop = code_object_list_updated && stop_on_solib_events; > + bs->print = bs->stop; > +} > + > +enum print_stop_action > +amd_dbgapi_target_breakpoint::print_it (const bpstat *bs) const > +{ > + /* This is only called if check_status decided to stop, which happens > + when the code object list was updated while stop_on_solib_events is > + enabled. Report it the same way as a shared library event. */ > + print_solib_event (false); > + > + return PRINT_NOTHING; > } > > bool > @@ -1645,9 +1673,11 @@ event_kind_str (amd_dbgapi_event_kind_t kind) > /* Drain the dbgapi event queue of a given inferior. Stop processing the > events if an event of a given kind is requested (not AMD_DBGAPI_EVENT_NONE). > Wave stop events that are not returned are queued into their inferior's > - amd_dbgapi_inferior_info pending wave events. */ > + amd_dbgapi_inferior_info pending wave events. The code_object_list_updated > + field of the result is true if a CODE_OBJECT_LIST_UPDATED event was > + processed. */ > > -static amd_dbgapi_event_id_t > +static process_event_queue_result > process_event_queue (amd_dbgapi_inferior_info &info, > amd_dbgapi_event_kind_t until_event_kind) > { > @@ -1655,6 +1685,8 @@ process_event_queue (amd_dbgapi_inferior_info &info, > performance, make sure it is not required. */ > gdb_assert (!info.forward_progress_required); > > + bool code_object_list_updated = false; > + > while (true) > { > amd_dbgapi_event_id_t event_id; > @@ -1675,7 +1707,10 @@ process_event_queue (amd_dbgapi_inferior_info &info, > event_kind_str (event_kind)); > > if (event_id == AMD_DBGAPI_EVENT_NONE || event_kind == until_event_kind) > - return event_id; > + return {event_id, code_object_list_updated}; > + > + if (event_kind == AMD_DBGAPI_EVENT_KIND_CODE_OBJECT_LIST_UPDATED) > + code_object_list_updated = true; > > process_one_event (info, event_id, event_kind); > } > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 7998dfb58c8..64a91e6a5c1 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -22536,14 +22536,15 @@ The surrounding square brackets are optional. > @item set stop-on-solib-events @r{[}on@r{|}off@r{]} > @kindex set stop-on-solib-events > This command controls whether @value{GDBN} should give you control > -when the dynamic linker notifies it about some shared library event. > -The most common event of interest is loading or unloading of a new > -shared library. > +when the dynamic linker notifies it about some shared library event, > +or when GPU code objects are loaded or unloaded. > +The most common events of interest are loading or unloading of a new > +shared library or GPU code object. > > @item show stop-on-solib-events > @kindex show stop-on-solib-events > Show whether @value{GDBN} stops and gives you control when shared > -library events happen. > +library events or GPU code object events happen. > @end table > > Shared libraries are also supported in many cross or remote debugging > diff --git a/gdb/infrun.c b/gdb/infrun.c > index 08fac30e9e8..432c2eb27ae 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -10851,8 +10851,9 @@ leave it stopped or free to run as needed."), > Set stopping for shared library events."), _("\ > Show stopping for shared library events."), _("\ > If on, gdb will give control to the user when the dynamic linker\n\ > -notifies gdb of shared library events. The most common event of interest\n\ > -to the user would be loading/unloading of a new library."), > +notifies gdb of shared library events, or when GPU code objects are loaded\n\ > +or unloaded. The most common events of interest to the user would be\n\ > +loading/unloading of a new library or GPU code object."), > set_stop_on_solib_events, > show_stop_on_solib_events, > &setlist, &showlist); > diff --git a/gdb/testsuite/gdb.rocm/solib-event-kernel.cpp b/gdb/testsuite/gdb.rocm/solib-event-kernel.cpp > new file mode 100644 > index 00000000000..3e1c895f95e > --- /dev/null > +++ b/gdb/testsuite/gdb.rocm/solib-event-kernel.cpp > @@ -0,0 +1,26 @@ > +/* This testcase 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 . */ > + > +/* Device kernel for solib-event test. > + Compiled with --cuda-device-only to produce .co file. */ > + > +#include > + > +extern "C" __global__ void > +test_kernel () > +{ > +} > diff --git a/gdb/testsuite/gdb.rocm/solib-event.cpp b/gdb/testsuite/gdb.rocm/solib-event.cpp > new file mode 100644 > index 00000000000..161c7c15b17 > --- /dev/null > +++ b/gdb/testsuite/gdb.rocm/solib-event.cpp > @@ -0,0 +1,105 @@ > +/* This testcase 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 . */ > + > +#include "rocm-test-utils.h" > +#include > +#include > +#include > + > +/* Test file:// events (hipModuleLoad). */ > +static void > +test_file_load (const char *module_path) > +{ > + hipModule_t module; > + CHECK (hipModuleLoad (&module, module_path)); > + > + hipFunction_t function; > + CHECK (hipModuleGetFunction (&function, module, "test_kernel")); > + > + CHECK (hipModuleLaunchKernel (function, 1, 1, 1, 1, 1, 1, > + 0, nullptr, nullptr, nullptr)); > + > + CHECK (hipDeviceSynchronize ()); > + CHECK (hipModuleUnload (module)); > +} > + > +/* Test memory:// events (hipModuleLoadData). */ > +static void > +test_memory_load (const char *module_path) > +{ > + /* Read module file into memory buffer. */ > + std::ifstream mod (module_path, std::ios::binary | std::ios::ate); > + if (!mod.is_open ()) > + { > + fprintf (stderr, "Failed to open module file\n"); > + exit (EXIT_FAILURE); > + } > + > + size_t module_size = mod.tellg (); > + mod.seekg (0, std::ios::beg); > + std::vector module_buffer (module_size); > + > + if (!mod.read (reinterpret_cast (module_buffer.data ()), > + module_size)) > + { > + fprintf (stderr, "Failed to read module into memory\n"); > + exit (EXIT_FAILURE); > + } > + mod.close (); > + > + /* Load from memory buffer. */ > + hipModule_t module; > + CHECK (hipModuleLoadData (&module, module_buffer.data ())); > + > + hipFunction_t function; > + CHECK (hipModuleGetFunction (&function, module, "test_kernel")); > + > + CHECK (hipModuleLaunchKernel (function, 1, 1, 1, 1, 1, 1, > + 0, nullptr, nullptr, nullptr)); > + > + CHECK (hipDeviceSynchronize ()); > + CHECK (hipModuleUnload (module)); > +} > + > +__global__ void > +warm_up () > +{ > +} > + > +int > +main (int argc, char **argv) > +{ > + if (argc != 2) > + { > + fprintf (stderr, "Usage: %s \n", argv[0]); > + return EXIT_FAILURE; > + } > + > + const char *module_path = argv[1]; > + > + /* Submit an empty kernel to force the runtime to do any necessary > + setup which might include loading internal code objects. */ > + warm_up<<<1, 1>>>(); > + CHECK (hipDeviceSynchronize ()); > + > + /* Enable SOLIB events here. */ > + > + test_file_load (module_path); > + test_memory_load (module_path); > + > + return 0; /* Break here at end of test. */ > +} > diff --git a/gdb/testsuite/gdb.rocm/solib-event.exp b/gdb/testsuite/gdb.rocm/solib-event.exp > new file mode 100644 > index 00000000000..0fde181c5cb > --- /dev/null > +++ b/gdb/testsuite/gdb.rocm/solib-event.exp > @@ -0,0 +1,155 @@ > +# 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 . > + > +# Test that "set stop-on-solib-events on" works for GPU code objects. > +# Tests both file:// events (hipModuleLoad) and memory:// events > +# (hipModuleLoadData), as well as unload events (hipModuleUnload). > +# Also tests that the default setting (off) does not stop execution, > +# and that the MI stop record reports a solib-event. > + > +load_lib rocm.exp > +load_lib mi-support.exp > + > +require allow_hip_tests > + > +standard_testfile .cpp > + > +# Build GPU code object. > +set kernel_srcfile ${testfile}-kernel.cpp > +set hipmodule_path [standard_output_file ${testfile}.co] > + > +if {[gdb_compile $srcdir/$subdir/$kernel_srcfile \ > + $hipmodule_path object \ > + {debug hip additional_flags=--cuda-device-only}] != ""} { > + return > +} > + > +# Build host executable. > +if {[build_executable "failed to prepare" $testfile $srcfile \ > + {debug hip}] == -1} { > + return > +} > + > +proc test_disabled {} { > + with_rocm_gpu_lock { > + clean_restart $::testfile > + > + if {![runto_main -inferior-args $::hipmodule_path]} { > + return > + } > + > + # Set breakpoint at program exit and verify execution continues > + # through all code object load/unload events without stopping. > + gdb_breakpoint [gdb_get_line_number "Break here at end of test"] > + gdb_test "continue" \ > + "Breakpoint .* main .*Break here at end of test.*" \ > + "no stops for code object events when disabled" > + } > +} > + > +proc test_enabled {} { > + with_rocm_gpu_lock { > + clean_restart $::testfile > + > + if {![runto_main -inferior-args $::hipmodule_path]} { > + return > + } > + > + gdb_breakpoint [gdb_get_line_number "Enable SOLIB events here"] \ > + -temporary > + gdb_continue_to_breakpoint "at enable solib-event" > + > + gdb_test_no_output "set stop-on-solib-events on" > + > + with_test_prefix "file://" { > + # Test 1: file:// load event (hipModuleLoad). > + gdb_test "continue" \ > + "Stopped due to shared library event.*Inferior loaded file://\[^\r\n\]+" \ > + "load" > + > + # Test 2: file:// unload event (hipModuleUnload). > + gdb_test "continue" \ > + "Stopped due to shared library event.*Inferior unloaded file://\[^\r\n\]+" \ > + "unload" > + } > + > + with_test_prefix "memory://" { > + # Test 3: memory:// load event (hipModuleLoadData). > + gdb_test "continue" \ > + "Stopped due to shared library event.*Inferior loaded memory://\[^\r\n\]+" \ > + "load" > + > + # Test 4: memory:// unload event (hipModuleUnload). > + gdb_test "continue" \ > + "Stopped due to shared library event.*Inferior unloaded memory://\[^\r\n\]+" \ > + "unload" > + } > + } > +} > + > +proc test_mi_output {} { > + with_rocm_gpu_lock { > + if {[mi_clean_restart $::testfile]} { > + return > + } > + > + # Set inferior arguments before running to main. > + mi_gdb_test "-gdb-set args $::hipmodule_path" "\\^done" \ > + "set inferior arguments" > + > + if {![mi_runto_main]} { > + return > + } > + > + mi_create_breakpoint [gdb_get_line_number "Enable SOLIB events here"] \ > + "insert breakpoint at enable marker" > + > + mi_execute_to "exec-continue" "breakpoint-hit" "main" ".*" \ > + ".*$::srcfile" [gdb_get_line_number "test_file_load (module_path);"] \ > + {"" "disp=\"keep\""} "stop at enable marker" > + > + mi_gdb_test "111-gdb-set stop-on-solib-events on" "111\\^done" \ > + "set stop-on-solib-events via MI" > + > + # The file:// code object load must be reported as a solib-event > + # stop. The stop record is preceded by =library-loaded and console > + # output, which the unanchored pattern skips. > + mi_send_resuming_command "exec-continue" "continue to GPU load event" > + > + gdb_expect { > + -re "\\*stopped,reason=\"solib-event\",added=\\\[library=\"file://\[^\r\n\]*\r\n$::mi_gdb_prompt$" { > + pass "solib-event stop" > + } > + -re "$::mi_gdb_prompt$" { > + fail "solib-event stop" > + } > + timeout { > + fail "solib-event stop (timeout)" > + } > + } > + } > +} > + > +with_test_prefix "stop-on-solib-events=off" { > + test_disabled > +} > + > +with_test_prefix "stop-on-solib-events=on" { > + test_enabled > +} > + > +with_test_prefix "MI output" { > + test_mi_output > +} > > base-commit: 20a3bfdbee7e4615e96d779744e25e272beb1f4c > -- > 2.43.0