gdbserver: turn target op 'hostio_last_error' into a method
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 17 Feb 2020 15:11:56 +0000 (16:11 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 20 Feb 2020 16:35:09 +0000 (17:35 +0100)
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.

gdbserver/ChangeLog
gdbserver/hostio.cc
gdbserver/linux-low.cc
gdbserver/lynx-low.cc
gdbserver/nto-low.cc
gdbserver/target.cc
gdbserver/target.h
gdbserver/win32-low.cc
gdbserver/win32-low.h

index 8b1d55cf4b1fb61dcb85e9801e4b98dd49a7238c..13fd47d65e34cf4d862e4915694bbba631a02b33 100644 (file)
@@ -1,3 +1,25 @@
+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
index 8af4fbf4087aa8866c21990529492ea3bbac002a..a3b32cd0fdcb4a22f0983571fb216a763c1a37ef 100644 (file)
@@ -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
index ee5a6c027122cfbbe1fb2d0aafe2e3c8d6d428ca..a863474991d627e3100e482245ac877a7ddff329 100644 (file)
@@ -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 @@ 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,
index f0d0d4456c47815d442ea26015463cd2b6956ee8..0e904d073280a126f496fef67087c1767017af72 100644 (file)
@@ -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 */
index b9e7ed06337d81dac82a957684d2b124f67c1240..ec0b477abe5945a5f9ac65d6611a26dab989dd8c 100644 (file)
@@ -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,
index f578dbea0da07b83184911c5a037e1d0a4725b39..e09ee7d0fa4dd5142e99e57ea237e2c049398d63 100644 (file)
@@ -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);
+}
index 2c818b3fb124b171b82c124a975674cfde4ee43f..5f603fdf0bc6cca25e33be10dd7fc20cf820e5db 100644 (file)
@@ -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;
index 84223e129bfd909e650c77a64903670ed0c52709..727bc9c8c95acb9f4f3e7069693778cc63ef704e 100644 (file)
@@ -1784,8 +1784,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);
@@ -1844,11 +1844,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 */
index b2b8a6dedc326270005e123d547f62f1b318148e..86447fd541afec6f6474d4b441a44ef8e1e781db 100644 (file)
@@ -152,6 +152,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.  */