From patchwork Sun Dec 31 20:25:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 83063 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C9E26385841F for ; Sun, 31 Dec 2023 20:27:00 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id DC68D3858404 for ; Sun, 31 Dec 2023 20:25:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC68D3858404 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC68D3858404 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054347; cv=none; b=uj4UohxRqaU7V3koboAJApcwmCr3EMwq8V5cVwrl8b4/4r3oqR70h4m2IxMYmWXFuuIqTs8A5vNhr0WP+7pqUQq9CC/fdoMzinMJrU49BV/a6oZHpxxwv/k56xjivQizQiiqzjygjEiCbb8H/pTYnJlWMKUxrK5fucYxsWPRuIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054347; c=relaxed/simple; bh=V7wxauL0WrkW24QnvI3hXatzbWhrcB/WB6NgAw58JNw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=bUTFFv1mc/pxPJB/uqHY+NTE95ghsigwj0/2kbLLmKiYa/oS/HF/+6KsVuNoUz76W0iixmYI5kT9wHVKJ7RPbv733rnAEEWJnYVcucvev79/CEpFEKm75r/c/RNwBmFli48vGAVE+wCyEaFXTVelX98g+dRc0OABXwM2EhwMXAA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id JsWsraFKqjtZ3K2Ner5KJt; Sun, 31 Dec 2023 20:25:54 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id K2NQrvq9Y3WZAK2NQrDjeh; Sun, 31 Dec 2023 20:25:40 +0000 X-Authority-Analysis: v=2.4 cv=c9W4/Dxl c=1 sm=1 tr=0 ts=6591ce44 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=e2cXIFwxEfEA:10 a=Qbun_eYptAEA:10 a=CCpqsmhAAAAA:8 a=al0khGN-nZ_-NgqlnV4A:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LZzcFE8sFWY5ZQf5yLnNQXL0wbFqB5PP8RtlJ4snJCY=; b=oQ0YW5ubrYxw0+J7ETSC6GcMN/ RnVfocZMvD8z0XsWcFrJZW77XhKviBdzmogFKvdP7geucy+CA1RubfQ+i7aHxLVD/QvI/IqTKr/RC iJDD00AU6j5OAwS6ZGv7zM0Yt; Received: from 71-211-161-25.hlrn.qwest.net ([71.211.161.25]:45228 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rK2NQ-002PSB-0Y for gdb-patches@sourceware.org; Sun, 31 Dec 2023 13:25:40 -0700 From: Tom Tromey Date: Sun, 31 Dec 2023 13:25:43 -0700 Subject: [PATCH 6/6] Store remote fileio state in remote_state MIME-Version: 1.0 Message-Id: <20231231-remote-fileio-v1-6-249cc6c440d9@tromey.com> References: <20231231-remote-fileio-v1-0-249cc6c440d9@tromey.com> In-Reply-To: <20231231-remote-fileio-v1-0-249cc6c440d9@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.161.25 X-Source-L: No X-Exim-ID: 1rK2NQ-002PSB-0Y X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-161-25.hlrn.qwest.net ([192.168.0.21]) [71.211.161.25]:45228 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfAOVq9uA0pP0I8/00D68aBnok5xFJTikLF83QH8SmrGZeXCQjHacpdn/vTU+CAL0QqBRFcM3AT8NwatjotMSzYpl3kjBObOGGpxwgGqIidnCzt/ydVtP kuZpQ8v65Lo2IpKOxjRafmfVn+7mm3pVxCPNl0gXRDZPVs+BAttlS8UWSQCWSB4mW4j+6Ifg+3GghPfk+LCHY59GtyQfCZFJmtU= X-Spam-Status: No, score=-3022.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org This removes the global 'remote_fio_data', moving it to remote_state. This in turn lets each remote target manage its own file descriptors. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31189 --- gdb/remote-fileio.c | 16 ---------------- gdb/remote-fileio.h | 8 -------- gdb/remote.c | 8 +++++--- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index a954ab1bb55..14ca2ecca44 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -37,8 +37,6 @@ #endif #include -static remote_fileio_data remote_fio_data; - #define FIO_FD_INVALID -1 #define FIO_FD_CONSOLE_IN -2 #define FIO_FD_CONSOLE_OUT -3 @@ -1141,14 +1139,6 @@ remote_fileio_data::do_request (remote_target *remote, char *buf) remote_fileio_reply (remote, -1, FILEIO_ENOSYS); } -/* Close any open descriptors, and reinitialize the file mapping. */ - -void -remote_fileio_reset () -{ - remote_fio_data.reset (); -} - /* Handle a file I/O request. BUF points to the packet containing the request. CTRLC_PENDING_P should be nonzero if the target has not acknowledged the Ctrl-C sent asynchronously earlier. */ @@ -1193,12 +1183,6 @@ remote_fileio_data::request (remote_target *remote, quit_handler = remote_fileio_o_quit_handler; } - -void -remote_fileio_request (remote_target *remote, char *buf, int ctrlc_pending_p) -{ - remote_fio_data.request (remote, buf, ctrlc_pending_p); -} /* Unpack an fio_uint_t. */ diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h index c632c9e40f8..295a4719436 100644 --- a/gdb/remote-fileio.h +++ b/gdb/remote-fileio.h @@ -65,14 +65,6 @@ struct remote_fileio_data std::vector m_fd_map; }; -/* Unified interface to remote fileio, called in remote.c from - remote_wait () and remote_async_wait (). */ -extern void remote_fileio_request (remote_target *remote, - char *buf, int ctrlc_pending_p); - -/* Cleanup any remote fileio state. */ -extern void remote_fileio_reset (void); - /* Called from _initialize_remote (). */ extern void initialize_remote_fileio ( struct cmd_list_element **remote_set_cmdlist, diff --git a/gdb/remote.c b/gdb/remote.c index dcc1a0d0639..7409b014ea4 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -603,6 +603,9 @@ class remote_state qSupported. */ gdb_thread_options supported_thread_options = 0; + /* Data needed for remote fileio. */ + remote_fileio_data remote_fio; + private: /* Asynchronous signal handle registered as event loop source for when we have pending events ready to be passed to the core. */ @@ -4428,7 +4431,7 @@ remote_target::extended_remote_restart () xsnprintf (rs->buf.data (), get_remote_packet_size (), "R%x", 0); putpkt (rs->buf); - remote_fileio_reset (); + rs->remote_fio.reset (); } /* Clean up connection to a remote debugger. */ @@ -6068,7 +6071,6 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p) /* Here the possibly existing remote target gets unpushed. */ target_preopen (from_tty); - remote_fileio_reset (); reopen_exec_file (); reread_symbols (from_tty); @@ -8602,7 +8604,7 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status, for a stop reply. See the comments in putpkt_binary. Set waiting_for_stop_reply to 0 temporarily. */ rs->waiting_for_stop_reply = 0; - remote_fileio_request (this, buf, rs->ctrlc_pending_p); + rs->remote_fio.request (this, buf, rs->ctrlc_pending_p); rs->ctrlc_pending_p = 0; /* GDB handled the File-I/O request, and the target is running again. Keep waiting for events. */