From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QSqhEsW8/WmP+yIAWB0awg (envelope-from ) for ; Fri, 08 May 2026 06:36:53 -0400 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=EmqmTf/d; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4729C1E0BA; Fri, 08 May 2026 06:36:53 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED 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 B77681E093 for ; Fri, 08 May 2026 06:36:52 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A75F4BA2E0E for ; Fri, 8 May 2026 10:36:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A75F4BA2E0E 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=EmqmTf/d Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azlp170100009.outbound.protection.outlook.com [IPv6:2a01:111:f403:c107::9]) by sourceware.org (Postfix) with ESMTPS id CCCE34BA2E04 for ; Fri, 8 May 2026 10:36:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CCCE34BA2E04 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 CCCE34BA2E04 Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c107::9 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1778236585; cv=pass; b=rP6fAzBkdpWEm8JE+J6PRe2zx2uJIgGTLolZOvok+ugv+MWimqaYgCtF6c6bRkN/p3j7LreIBI/JXAz/ut9zSJzwAAlZKjhzb4dd/nU3dOXbCRKUokqAyWosgbrHDmKqYXyDRzVGSKojR9E8i2HRTEry3znGKYK1VuuS7DG88DQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1778236585; c=relaxed/simple; bh=5OpG1r1NeiUcp+mIyqXTXoW67m74Vs6vxEB5zlVzM/4=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=rBOLLMzcNZ62Gw8ZqyonPu/uwNZKJKv8T213sGryEMabM6G453UhpOFpkODNju3GVo6+I6HHaMw0+48DeGuqxQia2nDvBZAHhGVeIigeGX/gJ6fr+Yp4rGzpNdOjdpnMHeeG3S32wtOWniGcvihXX/8R8sG0n4LAE8AKo0pH/5M= 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=EmqmTf/d DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CCCE34BA2E04 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bMjYeeMrasDaTJ7AAmh2ccprpgy7duVu2wh7/Zny+vWMq2BH/xq3XJBo9cxmGBitDqfi3ex1VNFOSwLKcNc1VUssCsveoQtF7z6zDdKqYSt41knR+Jll6jFux3XB3brnhF2lQjrMU8Vg8T6zEqJiCqJnC6nS0FLwSLL9O0TqFFMT+jvPjx4xiLt7Yt24jk+37Z0NG7VmA1rLfhTcErpSFp0WYRY3DCmKNosO9U29DElxz8HTh/3WHcILqG7cNcfITnww96fX8WG/vSZLxTF4bVVTn3DcUcciTa7nLEiGNP4LdUZnczkS8WDHR9yqPShEe2P3mcyWNOFTYvtUGB0kag== 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=8m9Xu4NsbZjgYbU0NNTB9zvOGUfNE2HiRZvWUMsPuRA=; b=IgdQKCd6B3AM9RSL4m6PYzy9hfid/iTGcIfJjWkf+dXEKkfEjoCqWbDEObyAYXRSG782b/rR5FtmAuDRfmnacudVydm7JgNCvthhYP5S5uxdwks0TuEkUzgmPXzJaBW/CXv1Pm46JWNAzW+Sb0FeCPoQdUE8Y0E9z2ajAOmTZR5poQzWdGisz3eyLbjpggE1TaGM54kNF+HQY6c0J1zh/x51tqNA9a+gLwwnRPZ5qUKRlixEdmbf1rTJ/ha29U61TLIyy35G30PI8WzTl2G0S18HPCIPezsg/XmDNmeURE0yttb8p1aczAoz7QejNwW3sGPkylAcqNCO3m9nafIjGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=8m9Xu4NsbZjgYbU0NNTB9zvOGUfNE2HiRZvWUMsPuRA=; b=EmqmTf/dd2vLCYZAdVFillJ94gVpkF9ET+0yxbiTeySMLkWPaJdIBXYWkHAHlfM6eLgFmR/GHbcC5YXJj2Ds8nSq6KpQ4F/nX6GseiUD0aHE6W0RYlLd3dhFNrjHWrJlOc49ipe8p/QkShYQn232erv7zRTm5DQrcADMTmH6T7E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH3PR12MB9079.namprd12.prod.outlook.com (2603:10b6:610:1a1::9) by PH7PR12MB7914.namprd12.prod.outlook.com (2603:10b6:510:27d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9891.19; Fri, 8 May 2026 10:36:18 +0000 Received: from CH3PR12MB9079.namprd12.prod.outlook.com ([fe80::5a7a:2adf:1862:35c3]) by CH3PR12MB9079.namprd12.prod.outlook.com ([fe80::5a7a:2adf:1862:35c3%5]) with mapi id 15.20.9891.008; Fri, 8 May 2026 10:36:18 +0000 Message-ID: Date: Fri, 8 May 2026 11:36:12 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/11] gdb/solib-rocm: assert that host ops isn't rocm_solib_ops To: Simon Marchi , Simon Marchi Cc: gdb-patches@sourceware.org References: <20251209193610.296085-2-simon.marchi@efficios.com> <223ae525-3642-46e3-8490-f8d17de90968@simark.ca> Content-Language: en-US From: Lancelot SIX In-Reply-To: <223ae525-3642-46e3-8490-f8d17de90968@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR5P281CA0020.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::19) To CH3PR12MB9079.namprd12.prod.outlook.com (2603:10b6:610:1a1::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB9079:EE_|PH7PR12MB7914:EE_ X-MS-Office365-Filtering-Correlation-Id: 74c2dbda-4efa-429b-4712-08deaceda32f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|1800799024|22082099003|56012099003|18092099006|18002099003|10086099003; X-Microsoft-Antispam-Message-Info: e3U5ysfnH8lI8vnug0hQ/e2wPIBIZt1drRr2xtkdaJSgFPHNR9dmKnC8QNoBnUCEAKTCiY4AcOt+uVZUySOWwYUKI+lF/PKbTfYJipaPXJD2lAgj+xD/VUKK/qe0Ojgx9dCISdVfO4wauDjBGMpIWe2Xvaov1QKLB2VfFVAJGlVWNFVKwP41csFL94OfA//+witzjY5gBNgcycNpN6ktXqTJtmxCHHUDYwVFHxfDGtslprbuorpXe0Z94f5siRKhYL5rTXwD0Edwr6fh/HeVJXm1J91V4zEcT1mfD+GV2OrjYe7hfuz9IMADt7rhMxcX8ByTnX4oYMo83qwfhjyM5MpoCGqg2vQRIXHrY2zMHywoBnUMVggzt7xAr15yMDW13Wuc0ZQgS76peTzjyxGjinRw9eUuJVcV30XcCYYRw9INWcAVMTgAac4Kn8zLaGv+rMu6zzZx7A46JgbuVnM0v2n2KTmsuP5fMmhLmjg88ufNaw1rnVTRJntSZPHIOVzWZWU+5kpdwVTtzMjoy/b7UbAGiwpUu4FEokeny5HUZwTSIME2DVrDgd66aIC+liWU5hXD6jUOwAijT0AqgXQXEZzwcPfE+79ZQSrGqRIQiLlAlriR6MM7yD8KrtDIAuLUaY8C/ETiFKQp+OM6IcZB8vUdNigK1bL1SptLu+zJfsrdvUDvvv6B1A3bhhScKcMK X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR12MB9079.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024)(22082099003)(56012099003)(18092099006)(18002099003)(10086099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cGZ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M2MvVkdYTjM4RW9zd0ZL?= =?utf-8?B?UW1Yd2lULzhyaVhmTXIyZ05ScGp0TThab2ZrR0hEQWliUTRXRFk1ZjRTYm5k?= =?utf-8?B?bVRoSzhmdDQvSktoTDZNYWRJR1ZvcGx0R2ZIenZlS1Z1dllRSDVOVmtYM0lD?= =?utf-8?B?S3Vmd3dLaXdyZVhWWVJIRVBaMWdJQTBydjA1ZnF2MDF6N005Z2FLdmIreVhV?= =?utf-8?B?M3Z1aEMvanYzWTJwaVcwQzhZZWtMb3pYRU0ySU01TkMzMHc4YjN1ZWluUUE0?= =?utf-8?B?TlRSS2FJUDk0S2oyb0NKcm1GS0tXWjIyU2hheElGcHB1SWdvN01XRldYaVVD?= =?utf-8?B?NEV5ekd2Sy9WTWhSRWQxOU1zVCtreS9qd2Zib2twTERuTDhYZ0RuN0REanJk?= =?utf-8?B?dWZXdVA1QXJCSHNpMUZtYkNLNExuK1gvdXFqTmkzUG5MamszT2ZYV2xmK2JB?= =?utf-8?B?RW11WWR1MzBsQTBsNFNlc090ekcydU1SSktGVDJnVGQ3YWptYWZsdWs4YmdB?= =?utf-8?Q?OYqRlqTY5sV+2t0TOr?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74c2dbda-4efa-429b-4712-08deaceda32f X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB9079.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2026 10:36:18.0163 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ew0DdUZWceLib1o4ePwoxuVp71JycvYG3B+lBj+Pqv0e/wQSNpEXfNwqoS2hS6qtDa+XKOwokh6tVOv1I6qAlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7914 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 08/05/2026 02:37, Simon Marchi wrote: > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > > On 5/7/26 1:56 PM, Lancelot SIX wrote: >>> diff --git a/gdb/observable.h b/gdb/observable.h >>> index 5f064cf1fc8c..c8cbdbad97d1 100644 >>> --- a/gdb/observable.h >>> +++ b/gdb/observable.h >>> @@ -92,9 +92,13 @@ extern observable >>> the child (because we follow only the child or we follow both), CHILD_INF >>> is the child inferior. Otherwise, CHILD_INF is nullptr. >>> >>> - FORK_KIND is TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED. */ >>> + FORK_KIND is TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED. >>> + >>> + detach_on_fork and follow_child represent the "detach-on-fork" and >>> + "follow-fork-mode" settings. */ >> >> Just a nitpick here. >> >> Should DETACH_ON_FORK and FOLLOW_CHILD be upper case? > > Yes (it's not a nitpick, you're objectively right). > >>> @@ -839,6 +849,24 @@ rocm_solib_target_inferior_execd (inferior *exec_inf, inferior *follow_inf) >>> get_solib_info (exec_inf)->solib_list.clear (); >>> } >>> >>> +static void >>> +rocm_solib_target_inferior_forked (inferior *parent_inf, inferior *child_inf, >>> + target_waitkind fork_kind, >>> + bool detach_on_fork, bool follow_child) >>> +{ >>> + if (detach_on_fork && follow_child && fork_kind == TARGET_WAITKIND_FORKED) >>> + { >>> + /* In this particular configuration, infrun's follow_fork_inferior >>> + function moves the parent pspace to the child directly. Remove the >>> + existing rocm_solib_ops from the child and restore the host solib_ops, >>> + to make it look like a brand new pspace. */ >>> + auto rocm_ops_holder = child_inf->pspace->release_solib_ops (); >>> + auto rocm_ops >>> + = gdb::checked_static_cast (rocm_ops_holder.get ()); >>> + child_inf->pspace->set_solib_ops (rocm_ops->release_host_ops ()); >> >> I think I am overall OK with the approach, even if I would prefer not >> have the target explicitly rely on assumption about what the core does. >> >> If the core in infrun was to change at some point, I expect this would >> fail: the pspace's solib would not be a rocm_solib_ops, so >> checked_static_cast would fail. Should this use dynimac_cast and test >> for nullptr instead? >> >> Would it work to do it unconditionnaly (not check for detach_on_fork and >> follow_inf), check if the pspace's solib is the rocm one, and if so use >> the host one instead? > > I also hesitated between the two options: > > 1) do a very targeted check + checked_static_cast > 2) just do a dynamic cast and see > > We can afford to do 1), because we control both sides (core and target). > It's not like it's an external lib that could change out of our contorl. > If the core ever changes in this regard, yes the checked_static_cast > will fail (in debug mode), then we simply update the target accordingly. > I like doing it this way, so that our expectations are written in code > and verified. It also has the potential to catch some unwanted changes > in the core, which the dynamic_cast would hide. > My main concern would be that most people contributing to GDB do not build the amdgpu target (requires the rocm-dbgapi library to be available), so it would be easy for many to build with --enable-targets-all and not enable this code path. That being said, we (at AMD) would pull such change from master and hit a CI failure quite promptly, so I do not expect this would be un-noticed for very long. > So I'm still team 1) for the moment. I guess in general I'm team "use > asserts generously". > I am happy to follow you there and keep this approach. >> And last question, shouldn't this be in solib-rocm.c rather than >> amd-dbgapi-target.c? > > I'm confused, it is in solib-rocm.c currently, isn't it? You are absolutely right, somehow I thought I was in amd-dbgapi-target.c… Best, Lancelot. > > Simon