From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6gF+Dmx3oGkyVgsAWB0awg (envelope-from ) for ; Thu, 26 Feb 2026 11:40:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1772124012; bh=c0KdBbaWiUa2DmHSSWaxsueNYRPzqUOE4yoZQp2o6SA=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=s8ft6hW1AM1bjbscckP+//kndF898n8oap5i4cbuCJhhDHWagyN3aSZo2ZSe5MYjm x7UMOrK5ZJ6iS7Bv5EWJiaBReqb1cGEzZhivLCAuC3EVU5X321K2NeiVTPeb62t+gv 9nfoor1rL2vu4mgiBxRRXnQpkD06itEYcspvNgGw= Received: by simark.ca (Postfix, from userid 112) id 1E1441E0DD; Thu, 26 Feb 2026 11:40:12 -0500 (EST) 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=kw9sLQXa; 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 D62FA1E089 for ; Thu, 26 Feb 2026 11:40:07 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 5C9454B9DB6D for ; Thu, 26 Feb 2026 16:40:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C9454B9DB6D 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=kw9sLQXa Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 638BF4B9DB65 for ; Thu, 26 Feb 2026 16:39:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 638BF4B9DB65 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 638BF4B9DB65 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772123942; cv=none; b=YYn0hje9CVjg2nnm355mMQjifCJyCx2PQyiJMJoEB4WCMtwBpAmpi8hedizfp5j41CFI4XYCP1Kfn1kdgRpa10DROMF5lmkHAVBTC5dJxARznE2x8mQ8aA/19RuAcivQIYQY87jubSv8WMeXoQ8eTxEJ2s4HZwDW4qTXyKS+lWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772123942; c=relaxed/simple; bh=c0KdBbaWiUa2DmHSSWaxsueNYRPzqUOE4yoZQp2o6SA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=PM6CZgyyGeGxNdJyFHs4wcNs5vTQ6jRfpuReS0Heyna3mhCq2YUGagjHim4lvFEEctYge8CuKJ5Y3i8jLRs3tOQvUa/DGTA9gYK3P98EXBIkMLLroxQNlqHrs65vC1mreVnDwTRzrJ++BBan8tEukLEzGHJdy3T+EYV3epjW7qA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 638BF4B9DB65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1772123941; bh=c0KdBbaWiUa2DmHSSWaxsueNYRPzqUOE4yoZQp2o6SA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=kw9sLQXaora6aiigP7l0oyttoJ2Am6sHUf4lOFqi1VyZTBrteVLDBont6qUtoISXp fCJkuJ9bX9/WhgEgcgZi0Jf9MuJ4GAdz8X2jI8O60eEDyTvZSHu/tGF5YLCT70CBlG JXNVYd9Io0OFpNYOS/SCbkpcQO6Nn3gGFi5jmRvw= Received: by simark.ca (Postfix) id 642D81E089; Thu, 26 Feb 2026 11:39:00 -0500 (EST) Message-ID: <3b326c61-0b46-491a-8217-a88a5741bd5b@simark.ca> Date: Thu, 26 Feb 2026 11:38:59 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] Use a newtype for remote file descriptor To: Tom Tromey , gdb-patches@sourceware.org References: <20260225-target-fd-newtype-v1-0-e04af6692ccb@adacore.com> <20260225-target-fd-newtype-v1-1-e04af6692ccb@adacore.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20260225-target-fd-newtype-v1-1-e04af6692ccb@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 2/25/26 4:25 PM, Tom Tromey wrote: > I was digging through the remote fd code and got a little confused at > some point about what kind of fd was used where. > > It seemed better to me to avoid any confusion by making the remote > file descriptor a newtype, i.e., incompatible with 'int'. > > I limited the change to the "public" API. That is, I let the file > descriptor as used by the actual target implementation methods remain > "int". > > This found one bug, namely that sparc64-tdep.c assumed that 0 was an > invalid value for a target fd. > > The solib-rocm.c changes are best-effort, as I can't compile this > file. solib-rocm.c just needs one more change to build: diff --git i/gdb/solib-rocm.c w/gdb/solib-rocm.c index 651a958f1620..6ebe0c2b8cd2 100644 --- i/gdb/solib-rocm.c +++ w/gdb/solib-rocm.c @@ -94,7 +94,7 @@ rocm_solib_fd_cache::open (const std::string &filename, /* The file is already opened. Increment the refcnt and return the already opened FD. */ it->second.refcnt++; - gdb_assert (it->second.fd != -1); + gdb_assert (it->second.fd != remote_fd::INVALID); return it->second.fd; } } Otherwise, LGTM. Just a naming nit below. Approved-By: Simon Marchi Btw, if you want to build the ROCm stuff as part of your all-targets build, it's not that difficult, as long as your distro has some ROCm packages. Looks there are some for Fedora (which I believe you use): https://src.fedoraproject.org/rpms/rocdbgapi You should only need the dbgapi package. You configure with --with-amd-dbgapi, which will make configure fail if it can't find the dbgapi library. configure will hopefully find the dbgapi library in its default installed location, otherwise you have to point PKG_CONFIG_PATH to it. That's pretty much it. > diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c > index 29169417682..6e05913696a 100644 > --- a/gdb/solib-rocm.c > +++ b/gdb/solib-rocm.c > @@ -45,26 +45,26 @@ struct rocm_solib_fd_cache > Open the file FILENAME if it is not already opened, reuse the existing file > descriptor otherwise. > > - On error -1 is returned, and TARGET_ERRNO is set. */ > - int open (const std::string &filename, fileio_error *target_errno); > + On error remote_fd::INVALID is returned, and TARGET_ERRNO is set. */ > + remote_fd open (const std::string &filename, fileio_error *target_errno); > > /* Decrement the reference count to FD and close FD if the reference count > reaches 0. > > On success, return 0. On error, return -1 and set TARGET_ERRNO. */ > - int close (int fd, fileio_error *target_errno); > + int close (remote_fd fd, fileio_error *target_errno); > > private: > struct refcnt_fd > { > - refcnt_fd (int fd, int refcnt) : fd (fd), refcnt (refcnt) {} > + refcnt_fd (remote_fd fd, int refcnt) : fd (fd), refcnt (refcnt) {} > > DISABLE_COPY_AND_ASSIGN (refcnt_fd); > > refcnt_fd (refcnt_fd &&) = default; > refcnt_fd &operator=(refcnt_fd &&other) = default; > > - int fd = -1; > + remote_fd fd = remote_fd::INVALID; Calling it remote_fd in the context of ROCm is weird, since it's not remote. Perhaps call it target_fd? It would make sense to me, since it's the target file I/O interface. Simon