From patchwork Sun Dec 31 20:25:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 83064 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 8A6DC3858425 for ; Sun, 31 Dec 2023 20:27:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 02807385840B for ; Sun, 31 Dec 2023 20:25:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02807385840B 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 02807385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054346; cv=none; b=oj4MvJUm8aqNSKn/EX+dYwYL3JiAbnFBaTpv5MU2y1bwYezfhFojMl7UV6p0xsNwwtukMQxRKNRxNbUNRunVaUKA0+xzxgC9caFNiprEtEtQbJAaRu0kbtCjjywTNwF/vQnEE7Vvu44RO5C73rWCzqln98o1+OHTIoK+w9JblVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054346; c=relaxed/simple; bh=HABlack/ncn9NiGCfJmHoO150IgkPdDWNRRHyLvPuxw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=NXrhfLvXiozwb2bJ0Ll+7HVEVneMGJD3V8I9/ZQ7DHcJzpDDlAZ8LGapWqBiiH6ig6CJr/ynjDATsDVwtcMF3bYIYpPsCBhLsQHCav3cJGClQz+ygeJobOERWRy+emUhWnK8jIUQLZzE/K4dhtww54GtCgO7rTZkAf2yqBC54Sg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTPS id Jsc0rWglK8HteK2NQrpxUc; Sun, 31 Dec 2023 20:25:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id K2NPr9mRL11XZK2NQrrr2o; Sun, 31 Dec 2023 20:25:40 +0000 X-Authority-Analysis: v=2.4 cv=Z+v/oVdA 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=O8dN1M2yUwnL69gJIxIA: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=jaAeF3jveUnMs+PJMK0tg6Agn2Fb7wyy6zg1r3FnKC8=; b=LM74xiTzTsA9K0wBqTaYtHPw9y 6/cO+N4KLI6TupUFYWvU7tmbG81EY4Tn5MvwotvQMniDKF2vxCSYr58scq5J2lTQ4pbHnnkiM/x3c I9SiOBiRxqFrCwnOmhAfVXdJm; 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 1rK2NP-002PSB-1U for gdb-patches@sourceware.org; Sun, 31 Dec 2023 13:25:39 -0700 From: Tom Tromey Date: Sun, 31 Dec 2023 13:25:38 -0700 Subject: [PATCH 1/6] Make remote_fio_func_map 'const' MIME-Version: 1.0 Message-Id: <20231231-remote-fileio-v1-1-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: 1rK2NP-002PSB-1U 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: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEwa3hmsZ8jYVTpF+KZCNo+bObiwXAWl1Y4gGs/30QR0YxgZxHrJPkRRYGrwM+mxkS6rExOk6hy1yHE8YZW3JXStjSFUIGUJp9ctHHWI9I/L4Yg9ePGL px7VJRub/Ne8GWRl+C5GY3KFM98RqKOSRXqVvr9pbV/4u95y+5UsekGBIZ+/tJDhFIjTkW4w+XXIUJvd1v6jmpDK6okopp2kDVk= 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_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 changes remote_fio_func_map to be const, letting it move into the readonly data section. --- gdb/remote-fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 10bc86c1ba5..367edb54f74 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -1101,7 +1101,7 @@ remote_fileio_func_system (remote_target *remote, char *buf) remote_fileio_return_success (remote, WEXITSTATUS (ret)); } -static struct { +static const struct { const char *name; void (*func)(remote_target *remote, char *); } remote_fio_func_map[] = { From patchwork Sun Dec 31 20:25:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 83061 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 682C63858286 for ; Sun, 31 Dec 2023 20:26:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id C8A2A3858C2D for ; Sun, 31 Dec 2023 20:25:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8A2A3858C2D 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 C8A2A3858C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054343; cv=none; b=TbPFK8d3blcanLlAc821XYBDGZHlyfY51HWOLybl059FNePWqaq5P3sC+i6q+U2AzmsYJGJm+FFABe+7SVzwS+70r8t+DGZJBNm+RjJvqhq2QnsDORlCTqg+nCxmWeCBiZVwgTGqnXGdrqVoONpOcKNjpuU4fkQI2ZPI2QgndnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054343; c=relaxed/simple; bh=P96JdGjGrgF3iZetiuoWM7BkF90kisLj0eFtEOOxZ8k=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=cqoRGfdVyifWrc/KhPCgp3bHyNj9d6XBkJaT/rO8NPK9khqPly89D1DgrJloEEybintTsSBF2POgpvS2zB6RRQK3cIANPrvFmZ8XHZdj8lgTunhlrE+ARzBe2aK8NI53n2b66CAVj14QL/zlkacTTdJp+TKpTXMXmxCkvgNrY5o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id JyEOrM3ABgpyEK2NQrpb0W; Sun, 31 Dec 2023 20:25:40 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id K2NPrT8uL8vT0K2NQrEycr; Sun, 31 Dec 2023 20:25:40 +0000 X-Authority-Analysis: v=2.4 cv=ffi+dmcF 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=bcTQ-yR6QqYIScYaAiMA: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=rFi1jyf/2DgauDvTAiNZSgxUF5+nvady57fuNulHtKw=; b=ALLhCt3duQu2NMDCvIq63bfSs7 nFVFW+ZJz+TJH/oPGHeunlHDV5XGyjfVoIzOP/mNPkwVoBRPjw4jGD9Zkji/E5s4YBN4NQTPo7Xcv APmgDE8r2cguLQ4ZhbWr49O+2; 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 1rK2NP-002PSB-1v for gdb-patches@sourceware.org; Sun, 31 Dec 2023 13:25:39 -0700 From: Tom Tromey Date: Sun, 31 Dec 2023 13:25:39 -0700 Subject: [PATCH 2/6] Use vector in remote-fileio.c MIME-Version: 1.0 Message-Id: <20231231-remote-fileio-v1-2-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: 1rK2NP-002PSB-1v 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: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEyGA75eYLAEx7NvC61Atr5C5KMLMEJ4r7KS+rt7x6BRPzQcSUkekBm+0/3GixDqR/rKhhu+Xl5p4K5NB1Xsps+JsH6ill6SIZR8L97AnIQ2jmJ9aOQq OV9twpcbtmKFvfxNZrcaWupNcTxpZwkVIEyHDw0NzjIspMaeOVM+U3aI1VW3345NHfzJ1ZhVGig/22l3qygbStQGzl25H41LkMc= 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 changes remote_fio_data to be an object holding a vector. This simplifies the code somewhat. --- gdb/remote-fileio.c | 51 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 367edb54f74..4891b0c5b92 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -37,9 +37,9 @@ #endif #include -static struct { - int *fd_map; - int fd_map_size; +static struct +{ + std::vector fd_map; } remote_fio_data; #define FIO_FD_INVALID -1 @@ -51,16 +51,13 @@ static int remote_fio_system_call_allowed = 0; static int remote_fileio_init_fd_map (void) { - int i; - - if (!remote_fio_data.fd_map) + if (remote_fio_data.fd_map.empty ()) { - remote_fio_data.fd_map = XNEWVEC (int, 10); - remote_fio_data.fd_map_size = 10; + remote_fio_data.fd_map.resize (10); remote_fio_data.fd_map[0] = FIO_FD_CONSOLE_IN; remote_fio_data.fd_map[1] = FIO_FD_CONSOLE_OUT; remote_fio_data.fd_map[2] = FIO_FD_CONSOLE_OUT; - for (i = 3; i < 10; ++i) + for (int i = 3; i < 10; ++i) remote_fio_data.fd_map[i] = FIO_FD_INVALID; } return 3; @@ -69,25 +66,20 @@ remote_fileio_init_fd_map (void) static int remote_fileio_resize_fd_map (void) { - int i = remote_fio_data.fd_map_size; - - if (!remote_fio_data.fd_map) + if (remote_fio_data.fd_map.empty ()) return remote_fileio_init_fd_map (); - remote_fio_data.fd_map_size += 10; - remote_fio_data.fd_map = - (int *) xrealloc (remote_fio_data.fd_map, - remote_fio_data.fd_map_size * sizeof (int)); - for (; i < remote_fio_data.fd_map_size; i++) + + int i = remote_fio_data.fd_map.size (); + remote_fio_data.fd_map.resize (i + 10); + for (; i < remote_fio_data.fd_map.size (); i++) remote_fio_data.fd_map[i] = FIO_FD_INVALID; - return remote_fio_data.fd_map_size - 10; + return remote_fio_data.fd_map.size () - 10; } static int remote_fileio_next_free_fd (void) { - int i; - - for (i = 0; i < remote_fio_data.fd_map_size; ++i) + for (int i = 0; i < remote_fio_data.fd_map.size (); ++i) if (remote_fio_data.fd_map[i] == FIO_FD_INVALID) return i; return remote_fileio_resize_fd_map (); @@ -106,7 +98,7 @@ static int remote_fileio_map_fd (int target_fd) { remote_fileio_init_fd_map (); - if (target_fd < 0 || target_fd >= remote_fio_data.fd_map_size) + if (target_fd < 0 || target_fd >= remote_fio_data.fd_map.size ()) return FIO_FD_INVALID; return remote_fio_data.fd_map[target_fd]; } @@ -115,7 +107,7 @@ static void remote_fileio_close_target_fd (int target_fd) { remote_fileio_init_fd_map (); - if (target_fd >= 0 && target_fd < remote_fio_data.fd_map_size) + if (target_fd >= 0 && target_fd < remote_fio_data.fd_map.size ()) remote_fio_data.fd_map[target_fd] = FIO_FD_INVALID; } @@ -1147,21 +1139,12 @@ do_remote_fileio_request (remote_target *remote, char *buf) void remote_fileio_reset (void) { - int ix; - - for (ix = 0; ix != remote_fio_data.fd_map_size; ix++) + for (int fd : remote_fio_data.fd_map) { - int fd = remote_fio_data.fd_map[ix]; - if (fd >= 0) close (fd); } - if (remote_fio_data.fd_map) - { - xfree (remote_fio_data.fd_map); - remote_fio_data.fd_map = NULL; - remote_fio_data.fd_map_size = 0; - } + remote_fio_data.fd_map.clear (); } /* Handle a file I/O request. BUF points to the packet containing the From patchwork Sun Dec 31 20:25:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 83060 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 EBE3D3858437 for ; Sun, 31 Dec 2023 20:26:31 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id CBF683858C31 for ; Sun, 31 Dec 2023 20:25:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBF683858C31 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 CBF683858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054344; cv=none; b=GGqQewoTRXvVL5yP2HWPeHWzmy0bMG8ZLc/QU5P/u9dw9pctbGRS2k8iFK4IsapISzXHjcsLUPL4WUxXReCTkFbrJElgFhAIxgiVCLr8yIfk3K4vq868sy6Fh/y82FAlhVyzdrov1lkno2O13Sitg/FLupajd+3o7MPrp/L0sEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054344; c=relaxed/simple; bh=tlZn/uFUk2ahiGlTy0IdnbGh5M0BATLzpXYQyhYttmA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QIoqQK+kzbHg73+LzmioP3K728R+HpsH/rne4cjoT0o8OCGCGlbz2q6cB5MmY+PXy/QmybKy505QBNh9Mgg5dJJlhWDliSFalpr317tl47SlzA90rxqHDT+JtjFDTofDdpmN5aZfGJT8qZNSDaNOvOdBcifmsqaGKxBaI62+2p8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id JrjVrLKJKgpyEK2NQrpb0V; Sun, 31 Dec 2023 20:25:40 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id K2NPrT8uV8vT0K2NQrEycw; Sun, 31 Dec 2023 20:25:40 +0000 X-Authority-Analysis: v=2.4 cv=ffi+dmcF 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=94JAvcUx1EORx4uIDcEA: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=TrI0FDHWkTweqJEGw21E00GdleGZFzR1XPchCAHiHVI=; b=Ul+VcfHtLBEVrcmj8O1PpIRaPZ wj12t3owaRx0H4kzl+r1gg/xw+6XcCa66edRXvqrt7QR74V1RKxiow04k+LjOLXdo0gNbsXwVshbD 4QdyJjuvtABOBCbVcohZF3Q5J; 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 1rK2NP-002PSB-2M for gdb-patches@sourceware.org; Sun, 31 Dec 2023 13:25:39 -0700 From: Tom Tromey Date: Sun, 31 Dec 2023 13:25:40 -0700 Subject: [PATCH 3/6] Use methods for remote fileio MIME-Version: 1.0 Message-Id: <20231231-remote-fileio-v1-3-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: 1rK2NP-002PSB-2M 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: 6 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEyGA75eYLAEx7NvC61Atr5C5KMLMEJ4r7KS+rt7x6BRPzQcSUkekBm+0/3GixDqR/rKhhu+Xl5p4K5NB1Xsps+JsH6ill6SIZR8L97AnIQ2jmJ9aOQq OV9twpcbtmKFvfxNZrcaWupNcTxpZwkVIEyHDw0NzjIspMaeOVM+U3aI1VW3345NHfzJ1ZhVGig/22l3qygbStQGzl25H41LkMc= X-Spam-Status: No, score=-3012.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, UNWANTED_LANGUAGE_BODY 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 changes various functions in remote-fileio.c to be methods on the state object. --- gdb/remote-fileio.c | 248 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 146 insertions(+), 102 deletions(-) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 4891b0c5b92..f6990989da6 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -37,9 +37,40 @@ #endif #include -static struct +static struct remote_fileio_data { - std::vector fd_map; +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; #define FIO_FD_INVALID -1 @@ -48,67 +79,78 @@ static struct static int remote_fio_system_call_allowed = 0; -static int -remote_fileio_init_fd_map (void) +int +remote_fileio_data::init_fd_map () { - if (remote_fio_data.fd_map.empty ()) + if (m_fd_map.empty ()) { - remote_fio_data.fd_map.resize (10); - remote_fio_data.fd_map[0] = FIO_FD_CONSOLE_IN; - remote_fio_data.fd_map[1] = FIO_FD_CONSOLE_OUT; - remote_fio_data.fd_map[2] = FIO_FD_CONSOLE_OUT; + m_fd_map.resize (10); + m_fd_map[0] = FIO_FD_CONSOLE_IN; + m_fd_map[1] = FIO_FD_CONSOLE_OUT; + m_fd_map[2] = FIO_FD_CONSOLE_OUT; for (int i = 3; i < 10; ++i) - remote_fio_data.fd_map[i] = FIO_FD_INVALID; + m_fd_map[i] = FIO_FD_INVALID; } return 3; } -static int -remote_fileio_resize_fd_map (void) +int +remote_fileio_data::resize_fd_map () { - if (remote_fio_data.fd_map.empty ()) - return remote_fileio_init_fd_map (); - - int i = remote_fio_data.fd_map.size (); - remote_fio_data.fd_map.resize (i + 10); - for (; i < remote_fio_data.fd_map.size (); i++) - remote_fio_data.fd_map[i] = FIO_FD_INVALID; - return remote_fio_data.fd_map.size () - 10; + if (m_fd_map.empty ()) + return init_fd_map (); + + int i = m_fd_map.size (); + m_fd_map.resize (i + 10); + for (; i < m_fd_map.size (); i++) + m_fd_map[i] = FIO_FD_INVALID; + return m_fd_map.size () - 10; } -static int -remote_fileio_next_free_fd (void) +int +remote_fileio_data::next_free_fd () { - for (int i = 0; i < remote_fio_data.fd_map.size (); ++i) - if (remote_fio_data.fd_map[i] == FIO_FD_INVALID) + for (int i = 0; i < m_fd_map.size (); ++i) + if (m_fd_map[i] == FIO_FD_INVALID) return i; - return remote_fileio_resize_fd_map (); + return resize_fd_map (); } -static int -remote_fileio_fd_to_targetfd (int fd) +int +remote_fileio_data::fd_to_targetfd (int fd) { - int target_fd = remote_fileio_next_free_fd (); + int target_fd = next_free_fd (); - remote_fio_data.fd_map[target_fd] = fd; + m_fd_map[target_fd] = fd; return target_fd; } -static int -remote_fileio_map_fd (int target_fd) +int +remote_fileio_data::map_fd (int target_fd) { - remote_fileio_init_fd_map (); - if (target_fd < 0 || target_fd >= remote_fio_data.fd_map.size ()) + init_fd_map (); + if (target_fd < 0 || target_fd >= m_fd_map.size ()) return FIO_FD_INVALID; - return remote_fio_data.fd_map[target_fd]; + return m_fd_map[target_fd]; } -static void -remote_fileio_close_target_fd (int target_fd) +void +remote_fileio_data::close_target_fd (int target_fd) { - remote_fileio_init_fd_map (); - if (target_fd >= 0 && target_fd < remote_fio_data.fd_map.size ()) - remote_fio_data.fd_map[target_fd] = FIO_FD_INVALID; + init_fd_map (); + if (target_fd >= 0 && target_fd < m_fd_map.size ()) + m_fd_map[target_fd] = FIO_FD_INVALID; +} + +void +remote_fileio_data::reset () +{ + for (int fd : m_fd_map) + { + if (fd >= 0) + close (fd); + } + m_fd_map.clear (); } static int @@ -359,8 +401,8 @@ remote_fileio_return_success (remote_target *remote, int retcode) remote_fileio_reply (remote, retcode, 0); } -static void -remote_fileio_func_open (remote_target *remote, char *buf) +void +remote_fileio_data::func_open (remote_target *remote, char *buf) { CORE_ADDR ptrval; int length; @@ -424,12 +466,12 @@ remote_fileio_func_open (remote_target *remote, char *buf) return; } - fd = remote_fileio_fd_to_targetfd (fd); + fd = fd_to_targetfd (fd); remote_fileio_return_success (remote, fd); } -static void -remote_fileio_func_close (remote_target *remote, char *buf) +void +remote_fileio_data::func_close (remote_target *remote, char *buf) { long num; int fd; @@ -440,7 +482,7 @@ remote_fileio_func_close (remote_target *remote, char *buf) remote_fileio_ioerror (remote); return; } - fd = remote_fileio_map_fd ((int) num); + fd = map_fd ((int) num); if (fd == FIO_FD_INVALID) { remote_fileio_badfd (remote); @@ -449,12 +491,12 @@ remote_fileio_func_close (remote_target *remote, char *buf) if (fd != FIO_FD_CONSOLE_IN && fd != FIO_FD_CONSOLE_OUT && close (fd)) remote_fileio_return_errno (remote, -1); - remote_fileio_close_target_fd ((int) num); + close_target_fd ((int) num); remote_fileio_return_success (remote, 0); } -static void -remote_fileio_func_read (remote_target *remote, char *buf) +void +remote_fileio_data::func_read (remote_target *remote, char *buf) { long target_fd, num; LONGEST lnum; @@ -470,7 +512,7 @@ remote_fileio_func_read (remote_target *remote, char *buf) remote_fileio_ioerror (remote); return; } - fd = remote_fileio_map_fd ((int) target_fd); + fd = map_fd ((int) target_fd); if (fd == FIO_FD_INVALID) { remote_fileio_badfd (remote); @@ -579,8 +621,8 @@ remote_fileio_func_read (remote_target *remote, char *buf) xfree (buffer); } -static void -remote_fileio_func_write (remote_target *remote, char *buf) +void +remote_fileio_data::func_write (remote_target *remote, char *buf) { long target_fd, num; LONGEST lnum; @@ -595,7 +637,7 @@ remote_fileio_func_write (remote_target *remote, char *buf) remote_fileio_ioerror (remote); return; } - fd = remote_fileio_map_fd ((int) target_fd); + fd = map_fd ((int) target_fd); if (fd == FIO_FD_INVALID) { remote_fileio_badfd (remote); @@ -654,8 +696,8 @@ remote_fileio_func_write (remote_target *remote, char *buf) xfree (buffer); } -static void -remote_fileio_func_lseek (remote_target *remote, char *buf) +void +remote_fileio_data::func_lseek (remote_target *remote, char *buf) { long num; LONGEST lnum; @@ -668,7 +710,7 @@ remote_fileio_func_lseek (remote_target *remote, char *buf) remote_fileio_ioerror (remote); return; } - fd = remote_fileio_map_fd ((int) num); + fd = map_fd ((int) num); if (fd == FIO_FD_INVALID) { remote_fileio_badfd (remote); @@ -707,8 +749,8 @@ remote_fileio_func_lseek (remote_target *remote, char *buf) remote_fileio_return_success (remote, ret); } -static void -remote_fileio_func_rename (remote_target *remote, char *buf) +void +remote_fileio_data::func_rename (remote_target *remote, char *buf) { CORE_ADDR old_ptr, new_ptr; int old_len, new_len; @@ -800,8 +842,8 @@ remote_fileio_func_rename (remote_target *remote, char *buf) remote_fileio_return_success (remote, ret); } -static void -remote_fileio_func_unlink (remote_target *remote, char *buf) +void +remote_fileio_data::func_unlink (remote_target *remote, char *buf) { CORE_ADDR ptrval; int length; @@ -839,8 +881,8 @@ remote_fileio_func_unlink (remote_target *remote, char *buf) remote_fileio_return_success (remote, ret); } -static void -remote_fileio_func_stat (remote_target *remote, char *buf) +void +remote_fileio_data::func_stat (remote_target *remote, char *buf) { CORE_ADDR statptr, nameptr; int ret, namelength; @@ -900,8 +942,8 @@ remote_fileio_func_stat (remote_target *remote, char *buf) remote_fileio_return_success (remote, ret); } -static void -remote_fileio_func_fstat (remote_target *remote, char *buf) +void +remote_fileio_data::func_fstat (remote_target *remote, char *buf) { CORE_ADDR ptrval; int fd, ret; @@ -917,7 +959,7 @@ remote_fileio_func_fstat (remote_target *remote, char *buf) remote_fileio_ioerror (remote); return; } - fd = remote_fileio_map_fd ((int) target_fd); + fd = map_fd ((int) target_fd); if (fd == FIO_FD_INVALID) { remote_fileio_badfd (remote); @@ -977,8 +1019,8 @@ remote_fileio_func_fstat (remote_target *remote, char *buf) remote_fileio_return_success (remote, ret); } -static void -remote_fileio_func_gettimeofday (remote_target *remote, char *buf) +void +remote_fileio_data::func_gettimeofday (remote_target *remote, char *buf) { LONGEST lnum; CORE_ADDR ptrval; @@ -1028,8 +1070,8 @@ remote_fileio_func_gettimeofday (remote_target *remote, char *buf) remote_fileio_return_success (remote, ret); } -static void -remote_fileio_func_isatty (remote_target *remote, char *buf) +void +remote_fileio_data::func_isatty (remote_target *remote, char *buf) { long target_fd; int fd; @@ -1040,13 +1082,13 @@ remote_fileio_func_isatty (remote_target *remote, char *buf) remote_fileio_ioerror (remote); return; } - fd = remote_fileio_map_fd ((int) target_fd); + fd = map_fd ((int) target_fd); int ret = fd == FIO_FD_CONSOLE_IN || fd == FIO_FD_CONSOLE_OUT ? 1 : 0; remote_fileio_return_success (remote, ret); } -static void -remote_fileio_func_system (remote_target *remote, char *buf) +void +remote_fileio_data::func_system (remote_target *remote, char *buf) { CORE_ADDR ptrval; int ret, length; @@ -1093,28 +1135,28 @@ remote_fileio_func_system (remote_target *remote, char *buf) remote_fileio_return_success (remote, WEXITSTATUS (ret)); } -static const struct { - const char *name; - void (*func)(remote_target *remote, char *); -} remote_fio_func_map[] = { - { "open", remote_fileio_func_open }, - { "close", remote_fileio_func_close }, - { "read", remote_fileio_func_read }, - { "write", remote_fileio_func_write }, - { "lseek", remote_fileio_func_lseek }, - { "rename", remote_fileio_func_rename }, - { "unlink", remote_fileio_func_unlink }, - { "stat", remote_fileio_func_stat }, - { "fstat", remote_fileio_func_fstat }, - { "gettimeofday", remote_fileio_func_gettimeofday }, - { "isatty", remote_fileio_func_isatty }, - { "system", remote_fileio_func_system }, - { NULL, NULL } -}; - -static void -do_remote_fileio_request (remote_target *remote, char *buf) +void +remote_fileio_data::do_request (remote_target *remote, char *buf) { + static const struct { + const char *name; + void (remote_fileio_data::*func)(remote_target *remote, char *); + } remote_fio_func_map[] = { + { "open", &remote_fileio_data::func_open }, + { "close", &remote_fileio_data::func_close }, + { "read", &remote_fileio_data::func_read }, + { "write", &remote_fileio_data::func_write }, + { "lseek", &remote_fileio_data::func_lseek }, + { "rename", &remote_fileio_data::func_rename }, + { "unlink", &remote_fileio_data::func_unlink }, + { "stat", &remote_fileio_data::func_stat }, + { "fstat", &remote_fileio_data::func_fstat }, + { "gettimeofday", &remote_fileio_data::func_gettimeofday }, + { "isatty", &remote_fileio_data::func_isatty }, + { "system", &remote_fileio_data::func_system }, + { nullptr, nullptr } + }; + char *c; int idx; @@ -1131,20 +1173,15 @@ do_remote_fileio_request (remote_target *remote, char *buf) if (!remote_fio_func_map[idx].name) remote_fileio_reply (remote, -1, FILEIO_ENOSYS); else - remote_fio_func_map[idx].func (remote, c); + (this->*remote_fio_func_map[idx].func) (remote, c); } /* Close any open descriptors, and reinitialize the file mapping. */ void -remote_fileio_reset (void) +remote_fileio_reset () { - for (int fd : remote_fio_data.fd_map) - { - if (fd >= 0) - close (fd); - } - remote_fio_data.fd_map.clear (); + remote_fio_data.reset (); } /* Handle a file I/O request. BUF points to the packet containing the @@ -1152,7 +1189,8 @@ remote_fileio_reset (void) acknowledged the Ctrl-C sent asynchronously earlier. */ void -remote_fileio_request (remote_target *remote, char *buf, int ctrlc_pending_p) +remote_fileio_data::request (remote_target *remote, + char *buf, int ctrlc_pending_p) { /* Save the previous quit handler, so we can restore it. No need for a cleanup since we catch all exceptions below. Note that the @@ -1172,7 +1210,7 @@ remote_fileio_request (remote_target *remote, char *buf, int ctrlc_pending_p) { try { - do_remote_fileio_request (remote, buf); + do_request (remote, buf); } catch (const gdb_exception_forced_quit &ex) { @@ -1190,6 +1228,12 @@ remote_fileio_request (remote_target *remote, char *buf, int ctrlc_pending_p) 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. */ From patchwork Sun Dec 31 20:25:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 83059 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 CC6C23858296 for ; Sun, 31 Dec 2023 20:26:16 +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 42BF03858C35 for ; Sun, 31 Dec 2023 20:25:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42BF03858C35 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 42BF03858C35 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=KC1OyyhfeCVVPpzHyDzFuMz3ICT6O2DNGjziiqmNf/xFtdJj4pUSEXk9PV078fxBbEGAjR2LesiKvo4H7LwTouLFkfMqS3OPBGyVdhuORdml+B/u4eaiAn46+6v3rLgxWz03vbk+dZ5MqXCEDbt6FDq3GKlk/p6G78W/exJ4mHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704054343; c=relaxed/simple; bh=SNNlYiDcPPO46LzpWsmhHbYPvOxWrv+Wk6+bx5O760A=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=lTzxGYstsKq4S2M1z6zZuciFDSXAGi9eC4LrO12YzkId6HmWUCr0gFK/FrHI6wbdI79CvplExD2ola+eQT7sxyrYxh6drRMo9eFaMz77mq28+toSXyv19gSW5v93Jv4pJeDGQ1UtXzLFJKpzym98EvlpJg0RGukEpUxv0xzOSgo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5006a.ext.cloudfilter.net ([10.0.29.179]) by cmsmtp with ESMTPS id K1yerz6T96nOZK2NRrYGBU; Sun, 31 Dec 2023 20:25:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id K2NQrrK5k1J28K2NQrMR6D; Sun, 31 Dec 2023 20:25:40 +0000 X-Authority-Analysis: v=2.4 cv=Tqz1ORbh 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=58UD4nXCBVqX37PKTwcA: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=JxCvWAMFPZg5WFhZMeYM9NSfPdbOr5t4sPP/lK0UVNM=; b=FVTQJtMROQ6n1gGfRTv+ORga1Y GluOYdQBXZpPOfxn2/PTLi/JXfMH1h4ii0lGZF2iJxV425XBzt89tlZsiVbcFjnALi81B9DxIbU4o CPZrJ8YHGpDgaHFYr+x5bOKPC; 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 1rK2NP-002PSB-2s for gdb-patches@sourceware.org; Sun, 31 Dec 2023 13:25:39 -0700 From: Tom Tromey Date: Sun, 31 Dec 2023 13:25:41 -0700 Subject: [PATCH 4/6] Remove sentinel from remote_fio_func_map MIME-Version: 1.0 Message-Id: <20231231-remote-fileio-v1-4-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: 1rK2NP-002PSB-2s 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: 7 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIuBotcJUCTiHgfco6nOGggcY3rHSTAaoMKK44DJbQBm1y6nAKRMx+KsWyovkuLqEztNedqJWjMkadYqhrVMx2rGt0LcvGGyuzdOZM4r9QuM4if6Me8z jwC/H66I6rnEGaQbfh6q4XX6KrgyIIuiLgzXfNh0EkvKTN8vrPZ9YcaGxKhn8oOYvsNH0+qbGMLwvl2iKCuIg0zRdbfpJroGuYI= 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 With foreach, a static array like remote_fio_func_map does not need a sentinel entry. This patch removes it and slightly rearranges the code to suit. --- gdb/remote-fileio.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index f6990989da6..e001c220522 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -1154,11 +1154,9 @@ remote_fileio_data::do_request (remote_target *remote, char *buf) { "gettimeofday", &remote_fileio_data::func_gettimeofday }, { "isatty", &remote_fileio_data::func_isatty }, { "system", &remote_fileio_data::func_system }, - { nullptr, nullptr } }; char *c; - int idx; quit_handler = remote_fileio_quit_handler; @@ -1167,13 +1165,14 @@ remote_fileio_data::do_request (remote_target *remote, char *buf) *c++ = '\0'; else c = strchr (buf, '\0'); - for (idx = 0; remote_fio_func_map[idx].name; ++idx) - if (!strcmp (remote_fio_func_map[idx].name, buf)) - break; - if (!remote_fio_func_map[idx].name) - remote_fileio_reply (remote, -1, FILEIO_ENOSYS); - else - (this->*remote_fio_func_map[idx].func) (remote, c); + for (const auto &entry : remote_fio_func_map) + if (!strcmp (entry.name, buf)) + { + (this->*entry.func) (remote, c); + return; + } + + remote_fileio_reply (remote, -1, FILEIO_ENOSYS); } /* Close any open descriptors, and reinitialize the file mapping. */ 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, 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. */