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.
This commit is contained in:
Tankut Baris Aktemur 2020-02-17 16:11:56 +01:00
parent 6e3fd7e948
commit ea06bbaaaa
9 changed files with 40 additions and 16 deletions

View 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

View 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

View 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,

View 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 */

View 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,

View 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);
}

View 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;

View 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 */

View 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. */