gdbserver: turn target op 'hostio_last_error' into a method gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's hostio_last_error op into a method of process_target. * target.h (struct process_stratum_target): Remove the target op. (class process_target): Add the target op. * target.cc: Add "hostio.h" to includes. (process_target::hostio_last_error): Define. Update the derived classes and callers below. * hostio.cc (hostio_error): Update. * linux-low.cc: Remove "hostio.h" from includes. (linux_target_ops): Update. * lynx-low.cc (lynx_target_ops): Update. * nto-low.cc (nto_target_ops): Update. * win32-low.h (class win32_process_target): Update. * win32-low.cc (win32_target_ops): Update. (wince_hostio_last_error): Turn into ... (win32_process_target::hostio_last_error): ... this.
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index 8b1d55c..13fd47d 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog
@@ -1,5 +1,27 @@ 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + Turn process_stratum_target's hostio_last_error op into a + method of process_target. + + * target.h (struct process_stratum_target): Remove the target op. + (class process_target): Add the target op. + * target.cc: Add "hostio.h" to includes. + (process_target::hostio_last_error): Define. + + Update the derived classes and callers below. + + * hostio.cc (hostio_error): Update. + * linux-low.cc: Remove "hostio.h" from includes. + (linux_target_ops): Update. + * lynx-low.cc (lynx_target_ops): Update. + * nto-low.cc (nto_target_ops): Update. + * win32-low.h (class win32_process_target): Update. + * win32-low.cc (win32_target_ops): Update. + (wince_hostio_last_error): Turn into ... + (win32_process_target::hostio_last_error): ... this. + +2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + Turn process_stratum_target's get_tls_address op into a method of process_target.
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc index 8af4fbf..a3b32cd 100644 --- a/gdbserver/hostio.cc +++ b/gdbserver/hostio.cc
@@ -196,7 +196,7 @@ 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.cc b/gdbserver/linux-low.cc index ee5a6c0..a863474 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc
@@ -45,7 +45,6 @@ #include <sys/uio.h> #include "gdbsupport/filestuff.h" #include "tracepoint.h" -#include "hostio.h" #include <inttypes.h> #include "gdbsupport/common-inferior.h" #include "nat/fork-inferior.h" @@ -7415,7 +7414,6 @@ 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.cc b/gdbserver/lynx-low.cc index f0d0d44..0e904d0 100644 --- a/gdbserver/lynx-low.cc +++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ /* 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.cc b/gdbserver/nto-low.cc index b9e7ed0..ec0b477 100644 --- a/gdbserver/nto-low.cc +++ b/gdbserver/nto-low.cc
@@ -956,7 +956,6 @@ 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.cc b/gdbserver/target.cc index f578dbe..e09ee7d 100644 --- a/gdbserver/target.cc +++ b/gdbserver/target.cc
@@ -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 @@ { 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 2c818b3..5f603fd 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ 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 @@ 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.cc b/gdbserver/win32-low.cc index 84223e1..727bc9c 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc
@@ -1784,8 +1784,8 @@ 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); @@ -1844,11 +1844,6 @@ 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 b2b8a6d..86447fd 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h
@@ -152,6 +152,10 @@ 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. */