From patchwork Tue Feb 11 09:01:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 37922 Received: (qmail 121810 invoked by alias); 11 Feb 2020 09:03:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 119201 invoked by uid 89); 11 Feb 2020 09:03:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mga07.intel.com Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Feb 2020 09:03:27 +0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2020 01:03:22 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 11 Feb 2020 01:03:21 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 01B93Klr002217; Tue, 11 Feb 2020 09:03:20 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 01B93KcF010527; Tue, 11 Feb 2020 10:03:20 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 01B93Kca010523; Tue, 11 Feb 2020 10:03:20 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 26/58] gdbserver: turn target op 'hostio_last_error' into a method Date: Tue, 11 Feb 2020 10:01:38 +0100 Message-Id: <2ee5e9775a5eac849fe6a09e9a0a6aa1da29a549.1581410934.git.tankut.baris.aktemur@intel.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes gdbserver/ChangeLog: 2020-02-10 Tankut Baris Aktemur Make process_stratum_target's hostio_last_error op a method of process_target. * target.h (struct process_stratum_target): Remove the target op. (class process_target): Add the target op. * target.c: Add "hostio.h" to includes. (process_target::hostio_last_error): Define. Update the derived structs and callers below. * hostio.c (hostio_error): Update. * linux-low.c: Remove "hostio.h" from includes. (linux_target_ops): Update. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * win32-low.h (class win32_process_target): Update. * win32-low.c (win32_target_ops): Update. (wince_hostio_last_error): Turn into ... (win32_process_target::hostio_last_error): ... this. --- gdbserver/hostio.c | 2 +- gdbserver/linux-low.c | 2 -- gdbserver/lynx-low.c | 1 - gdbserver/nto-low.c | 1 - gdbserver/target.c | 7 +++++++ gdbserver/target.h | 8 ++++---- gdbserver/win32-low.c | 9 ++------- gdbserver/win32-low.h | 4 ++++ 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gdbserver/hostio.c b/gdbserver/hostio.c index 8af4fbf4087..a3b32cd0fdc 100644 --- a/gdbserver/hostio.c +++ b/gdbserver/hostio.c @@ -196,7 +196,7 @@ require_valid_fd (int fd) static void hostio_error (char *own_buf) { - the_target->hostio_last_error (own_buf); + the_target->pt->hostio_last_error (own_buf); } static void diff --git a/gdbserver/linux-low.c b/gdbserver/linux-low.c index 66732a2d77f..d8209527f0e 100644 --- a/gdbserver/linux-low.c +++ b/gdbserver/linux-low.c @@ -45,7 +45,6 @@ #include #include "gdbsupport/filestuff.h" #include "tracepoint.h" -#include "hostio.h" #include #include "gdbsupport/common-inferior.h" #include "nat/fork-inferior.h" @@ -7404,7 +7403,6 @@ linux_get_hwcap2 (int wordsize) static linux_process_target the_linux_target; static process_stratum_target linux_target_ops = { - hostio_last_error_from_errno, linux_qxfer_osdata, linux_xfer_siginfo, linux_supports_non_stop, diff --git a/gdbserver/lynx-low.c b/gdbserver/lynx-low.c index 4525d6e694a..493c48ef355 100644 --- a/gdbserver/lynx-low.c +++ b/gdbserver/lynx-low.c @@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target; /* The LynxOS target_ops vector. */ static process_stratum_target lynx_target_ops = { - NULL, /* hostio_last_error */ NULL, /* qxfer_osdata */ NULL, /* qxfer_siginfo */ NULL, /* supports_non_stop */ diff --git a/gdbserver/nto-low.c b/gdbserver/nto-low.c index 38ddcbaa33a..e5f7af2b66e 100644 --- a/gdbserver/nto-low.c +++ b/gdbserver/nto-low.c @@ -956,7 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size) static nto_process_target the_nto_target; static process_stratum_target nto_target_ops = { - hostio_last_error_from_errno, NULL, /* nto_qxfer_osdata */ NULL, /* xfer_siginfo */ nto_supports_non_stop, diff --git a/gdbserver/target.c b/gdbserver/target.c index f578dbea0da..e09ee7d0fa4 100644 --- a/gdbserver/target.c +++ b/gdbserver/target.c @@ -21,6 +21,7 @@ #include "server.h" #include "tracepoint.h" #include "gdbsupport/byte-vector.h" +#include "hostio.h" process_stratum_target *the_target; @@ -506,3 +507,9 @@ process_target::get_tls_address (thread_info *thread, CORE_ADDR offset, { gdb_assert_not_reached ("target op get_tls_address not supported"); } + +void +process_target::hostio_last_error (char *buf) +{ + hostio_last_error_from_errno (buf); +} diff --git a/gdbserver/target.h b/gdbserver/target.h index aed363991ef..b3ceaa34ad0 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -70,10 +70,6 @@ class process_target; shared code. */ struct process_stratum_target { - /* Fill BUF with an hostio error packet representing the last hostio - error. */ - void (*hostio_last_error) (char *buf); - /* Read/Write OS data using qXfer packets. */ int (*qxfer_osdata) (const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, @@ -479,6 +475,10 @@ public: support the operation. */ virtual int get_tls_address (thread_info *thread, CORE_ADDR offset, CORE_ADDR load_module, CORE_ADDR *address); + + /* Fill BUF with an hostio error packet representing the last hostio + error. */ + virtual void hostio_last_error (char *buf); }; extern process_stratum_target *the_target; diff --git a/gdbserver/win32-low.c b/gdbserver/win32-low.c index 21008ccc7ab..dc75221d361 100644 --- a/gdbserver/win32-low.c +++ b/gdbserver/win32-low.c @@ -1774,8 +1774,8 @@ win32_error_to_fileio_error (DWORD err) return FILEIO_EUNKNOWN; } -static void -wince_hostio_last_error (char *buf) +void +win32_process_target::hostio_last_error (char *buf) { DWORD winerr = GetLastError (); int fileio_err = win32_error_to_fileio_error (winerr); @@ -1834,11 +1834,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size) static win32_process_target the_win32_target; static process_stratum_target win32_target_ops = { -#ifdef _WIN32_WCE - wince_hostio_last_error, -#else - hostio_last_error_from_errno, -#endif NULL, /* qxfer_osdata */ win32_xfer_siginfo, NULL, /* supports_non_stop */ diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index 36926801f1e..776f41faf10 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -151,6 +151,10 @@ public: bool stopped_by_watchpoint () override; CORE_ADDR stopped_data_address () override; + +#ifdef _WIN32_WCE + void hostio_last_error (char *buf) override; +#endif }; /* Retrieve the context for this thread, if not already retrieved. */