gdbserver: turn btrace-related target ops into methods

gdbserver/ChangeLog:
2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's btrace-related ops (enable_btrace,
	disable_btrace, read_btrace, read_btrace_conf) into methods of
	process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(target_enable_btrace): Update.
	(target_disable_btrace): Update.
	(target_read_btrace): Update.
	(target_read_btrace_conf): Update.
	* target.cc (process_target::enable_btrace): Define.
	(process_target::disable_btrace): Define.
	(process_target::read_btrace): Define.
	(process_target::read_btrace_conf): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target:enable_btrace): Define as a wrapper around
	linux_enable_btrace.
	(linux_low_disable_btrace): Turn into ...
	(linux_process_target::disable_btrace): ... this.
	(linux_low_read_btrace): Turn into ...
	(linux_process_target::read_btrace): ... this.
	(linux_low_btrace_conf): Turn into ...
	(linux_process_target::read_btrace_conf): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
This commit is contained in:
Tankut Baris Aktemur
2020-02-17 16:12:01 +01:00
parent c0245cb999
commit 79597bdd56
8 changed files with 114 additions and 67 deletions

View File

@@ -70,26 +70,6 @@ class process_target;
shared code. */
struct process_stratum_target
{
/* Enable branch tracing for PTID based on CONF and allocate a branch trace
target information struct for reading and for disabling branch trace. */
struct btrace_target_info *(*enable_btrace)
(ptid_t ptid, const struct btrace_config *conf);
/* Disable branch tracing.
Returns zero on success, non-zero otherwise. */
int (*disable_btrace) (struct btrace_target_info *tinfo);
/* Read branch trace data into buffer.
Return 0 on success; print an error message into BUFFER and return -1,
otherwise. */
int (*read_btrace) (struct btrace_target_info *, struct buffer *,
enum btrace_read_type type);
/* Read the branch trace configuration into BUFFER.
Return 0 on success; print an error message into BUFFER and return -1
otherwise. */
int (*read_btrace_conf) (const struct btrace_target_info *, struct buffer *);
/* Return true if target supports range stepping. */
int (*supports_range_stepping) (void);
@@ -497,6 +477,27 @@ public:
/* Return true if target supports debugging agent. */
virtual bool supports_agent ();
/* Enable branch tracing for PTID based on CONF and allocate a branch trace
target information struct for reading and for disabling branch trace. */
virtual btrace_target_info *enable_btrace (ptid_t ptid,
const btrace_config *conf);
/* Disable branch tracing.
Returns zero on success, non-zero otherwise. */
virtual int disable_btrace (btrace_target_info *tinfo);
/* Read branch trace data into buffer.
Return 0 on success; print an error message into BUFFER and return -1,
otherwise. */
virtual int read_btrace (btrace_target_info *tinfo, buffer *buf,
enum btrace_read_type type);
/* Read the branch trace configuration into BUFFER.
Return 0 on success; print an error message into BUFFER and return -1
otherwise. */
virtual int read_btrace_conf (const btrace_target_info *tinfo,
buffer *buf);
};
extern process_stratum_target *the_target;
@@ -612,19 +613,13 @@ int kill_inferior (process_info *proc);
static inline struct btrace_target_info *
target_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
{
if (the_target->enable_btrace == nullptr)
error (_("Target does not support branch tracing."));
return (*the_target->enable_btrace) (ptid, conf);
return the_target->pt->enable_btrace (ptid, conf);
}
static inline int
target_disable_btrace (struct btrace_target_info *tinfo)
{
if (the_target->disable_btrace == nullptr)
error (_("Target does not support branch tracing."));
return (*the_target->disable_btrace) (tinfo);
return the_target->pt->disable_btrace (tinfo);
}
static inline int
@@ -632,20 +627,14 @@ target_read_btrace (struct btrace_target_info *tinfo,
struct buffer *buffer,
enum btrace_read_type type)
{
if (the_target->read_btrace == nullptr)
error (_("Target does not support branch tracing."));
return (*the_target->read_btrace) (tinfo, buffer, type);
return the_target->pt->read_btrace (tinfo, buffer, type);
}
static inline int
target_read_btrace_conf (struct btrace_target_info *tinfo,
struct buffer *buffer)
{
if (the_target->read_btrace_conf == nullptr)
error (_("Target does not support branch tracing."));
return (*the_target->read_btrace_conf) (tinfo, buffer);
return the_target->pt->read_btrace_conf (tinfo, buffer);
}
#define target_supports_range_stepping() \