From patchwork Sun Dec 31 20:25:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 83062 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 5252C3858419 for ; Sun, 31 Dec 2023 20:26:48 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 46BE93858403 for ; Sun, 31 Dec 2023 20:25:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46BE93858403 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 46BE93858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054343; cv=none; b=G848c6AGPd0XgpdT13FxtIQ/TJzjCA1cwaSCg0SXqASFtUm0RZq6r5BvGmqomrWKE/iJGm/kVsJjJ333K7DWI2pjT+fNec8WIV2sXL0LdG8yWtzt7dWDK75RncXvmQPs6+aczu3E1orTsAgX4CBB8DiruuyS2J95zmZox1DFZGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054343; c=relaxed/simple; bh=7fcsQKKW4xy+Qrg15Y5c39zXG/cWxuw7/+cDgrEZccU=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=TlOy8AlM3EzdgwRlb8eSRU3B5GcANiNZCWOmDwornNfPaTlVF+DDNDBMpIZqoYNaWbQnVsfUIlNJW+92s74K202pDXuomTzC8Erw50cRjkFmJ4CCKjc940yFx2aFeYqMVwbAfMt8rJrMtFGoUWctMw4EnZ0k9BZlZzyjCfRbdPw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6009a.ext.cloudfilter.net ([10.0.30.184]) by cmsmtp with ESMTPS id JtY5ry5ja6nOZK2NQrYGBQ; Sun, 31 Dec 2023 20:25:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id K2NQrO1klBOccK2NQrLfYe; Sun, 31 Dec 2023 20:25:40 +0000 X-Authority-Analysis: v=2.4 cv=J+25USrS 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=5jCr4CifHAZcJYYkbtUA:9 a=QEXdDO2ut3YA:10 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=MehwcbNRDv1oR02s95c/LREWZ+7gTSeI5eJ2m62IiCc=; b=qZh7rABW7MN6YvuZhR1hxxZmii bn17Mja+nSuBAxOVRBD/Td1YOBnmIKlP6/MkOERIO1IbCG6kVV781iP9r4Fz0IP/PCW8NhGjt1PxS SQabSHOqQDM0vSTSawn22zKT1; 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-03 for gdb-patches@sourceware.org; Sun, 31 Dec 2023 13:25:40 -0700 From: Tom Tromey Date: Sun, 31 Dec 2023 13:25:42 -0700 Subject: [PATCH 5/6] Move remote_fileio_data to header file MIME-Version: 1.0 Message-Id: <20231231-remote-fileio-v1-5-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-03 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: 8 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGl/Mm0BR3yV97ujmCWmxhpoKe/t8KoIkZtvhSpvTR/zXsxsY8LjUwqd9b7hAW13/T4oNYm29BonStMozQVCT5lAXjFwYlhPd8bs8inmwk06lXxIBoy7 /iP/QRBHaBpXwT+1hU6g/dooimIGZo7ZloDY3ub308TxhP7KCutGeuYM8RzFQxT9X5hVjY6INyoU3MxoA+NKEfRRbpGNHl2eEsM= 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 moves remote_fileio_data to remote-fileio.h, in preparation for removing the global. --- gdb/remote-fileio.c | 36 +----------------------------------- gdb/remote-fileio.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index e001c220522..a954ab1bb55 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -37,41 +37,7 @@ #endif #include -static struct remote_fileio_data -{ -public: - - void request (remote_target *remote, - char *buf, int ctrlc_pending_p); - - void reset (); - -private: - - int fd_to_targetfd (int fd); - int map_fd (int target_fd); - void close_target_fd (int target_fd); - - void func_open (remote_target *remote, char *buf); - void func_close (remote_target *remote, char *buf); - void func_read (remote_target *remote, char *buf); - void func_write (remote_target *remote, char *buf); - void func_lseek (remote_target *remote, char *buf); - void func_rename (remote_target *remote, char *buf); - void func_unlink (remote_target *remote, char *buf); - void func_stat (remote_target *remote, char *buf); - void func_fstat (remote_target *remote, char *buf); - void func_gettimeofday (remote_target *remote, char *buf); - void func_isatty (remote_target *remote, char *buf); - void func_system (remote_target *remote, char *buf); - void do_request (remote_target *remote, char *buf); - - int init_fd_map (); - int resize_fd_map (); - int next_free_fd (); - - std::vector m_fd_map; -} remote_fio_data; +static remote_fileio_data remote_fio_data; #define FIO_FD_INVALID -1 #define FIO_FD_CONSOLE_IN -2 diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h index 71d85c618a9..c632c9e40f8 100644 --- a/gdb/remote-fileio.h +++ b/gdb/remote-fileio.h @@ -27,6 +27,44 @@ struct cmd_list_element; struct remote_target; +/* This holds the state needed by the remote fileio code. */ + +struct remote_fileio_data +{ +public: + + void request (remote_target *remote, + char *buf, int ctrlc_pending_p); + + void reset (); + +private: + + int fd_to_targetfd (int fd); + int map_fd (int target_fd); + void close_target_fd (int target_fd); + + void func_open (remote_target *remote, char *buf); + void func_close (remote_target *remote, char *buf); + void func_read (remote_target *remote, char *buf); + void func_write (remote_target *remote, char *buf); + void func_lseek (remote_target *remote, char *buf); + void func_rename (remote_target *remote, char *buf); + void func_unlink (remote_target *remote, char *buf); + void func_stat (remote_target *remote, char *buf); + void func_fstat (remote_target *remote, char *buf); + void func_gettimeofday (remote_target *remote, char *buf); + void func_isatty (remote_target *remote, char *buf); + void func_system (remote_target *remote, char *buf); + void do_request (remote_target *remote, char *buf); + + int init_fd_map (); + int resize_fd_map (); + int next_free_fd (); + + 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,