From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id azvjDXw+/WkiWyAAWB0awg (envelope-from ) for ; Thu, 07 May 2026 21:38:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1778204284; bh=a/9zECcD7y+qX0TTc4aFNUxgwvG5c8iQoTh1UTBxIRE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=j9O8eN9+Mmf1MW/+2H7scR/xZjt5iMKCU9IOfQQ8IAWuDm2xGb0exZsfuLQ7Bpm+c 6oVDkRRp4fvj9CH+GsLVn4ZeezFcEflmmHOS7tDiKuaF7FgKdCwVbsIdl072Eo992U Oe7C57zZQhWmTS1UQ1ZNWcT61RRHqQ15E6xEM0x8= Received: by simark.ca (Postfix, from userid 112) id 252A11E0BA; Thu, 07 May 2026 21:38:04 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=RbcNKXAM; dkim-atps=neutral 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 494FF1E093 for ; Thu, 07 May 2026 21:38:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C10164BA2E2A for ; Fri, 8 May 2026 01:38:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C10164BA2E2A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=RbcNKXAM Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A10F44BA2E15 for ; Fri, 8 May 2026 01:37:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A10F44BA2E15 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A10F44BA2E15 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778204255; cv=none; b=dZSWfuVXTOWs+GQ5BnWM8cYOa8iou6OCKLRHQsnLVdvzImssTP+RF6D6Ccpo98IIEJoPQRjhM/54SApuFBaNqLCq9e84rpfYZWI3E0m8lK5cy6Wgb54Xkr3To6vJeCzz0lIKVtpDOFP8yPE4tVGdfaWtAwgpX2Q6ZkbsIQ9UmoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778204255; c=relaxed/simple; bh=a/9zECcD7y+qX0TTc4aFNUxgwvG5c8iQoTh1UTBxIRE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=egzZLnQwVAaldVTbjKWF/f1DIP+n2az/kwgTz9P8Muk+hs/Ny1h12a7+Oe6+gUHKZ5ViyJvH6Tf9Gc/ZMbaOAQ+Q6YsCYVTLleZ371RJwiCUV4gAK0K3WwXQZcFSx9c7JlNYrJC+zO6AUUTpPACsY6QAUYjDaHZiH7bEnghYOKM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=RbcNKXAM DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A10F44BA2E15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1778204253; bh=a/9zECcD7y+qX0TTc4aFNUxgwvG5c8iQoTh1UTBxIRE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=RbcNKXAM28AvVaicgoIRuItf577R6EUBvrhzlYwx9Vh2+4wtW7OWXrYPC/pcClE2M vM+AZGWrBMk8Xy4mDOOehfqBSt9Jk3J7ym+eANaBMxAlf7mAAGMn6WIAE+iTS84TfI B/vh+hFmhwJIzlKW8zegOSdPJwXo+9S8SCUQra5E= Received: by simark.ca (Postfix) id 6A8231E093; Thu, 07 May 2026 21:37:33 -0400 (EDT) Message-ID: <223ae525-3642-46e3-8490-f8d17de90968@simark.ca> Date: Thu, 7 May 2026 21:37:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/11] gdb/solib-rocm: assert that host ops isn't rocm_solib_ops To: Lancelot SIX , Simon Marchi Cc: gdb-patches@sourceware.org References: <20251209193610.296085-2-simon.marchi@efficios.com> Content-Language: fr From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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. So I'm still team 1) for the moment. I guess in general I'm team "use asserts generously". > 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? Simon