+2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ Turn process_stratum_target's stopped_by_watchpoint and
+ stopped_data_address ops into methods of process_target.
+
+ * target.h (struct process_stratum_target): Remove the target ops.
+ (class process_target): Add the target ops.
+ * target.cc (process_target::stopped_by_watchpoint): Define.
+ (process_target::stopped_data_address): Define.
+
+ Update the derived classes and callers below.
+
+ * remote-utils.cc (prepare_resume_reply): Update.
+ * linux-low.cc (linux_target_ops): Update.
+ (linux_stopped_by_watchpoint): Turn into ...
+ (linux_process_target::stopped_by_watchpoint): ... this.
+ (linux_stopped_data_address): Turn into ...
+ (linux_process_target::stopped_data_address): ... this.
+ * linux-low.h (class linux_process_target): Update.
+ * lynx-low.cc (lynx_target_ops): Update.
+ * nto-low.cc (nto_target_ops): Update.
+ (nto_stopped_by_watchpoint): Turn into ...
+ (nto_process_target::stopped_by_watchpoint): ... this.
+ (nto_stopped_data_address): Turn into ...
+ (nto_process_target::stopped_data_address): ... this.
+ * nto-low.h (class nto_process_target): Update.
+ * win32-low.cc (win32_target_ops): Update.
+ (win32_stopped_by_watchpoint): Turn into ...
+ (win32_process_target::stopped_by_watchpoint): ... this.
+ (win32_stopped_data_address): Turn into ...
+ (win32_process_target::stopped_data_address): ... this.
+ * win32-low.h (class win32_process_target): Update.
+
2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Turn process_stratum_target's supports_hardware_single_step op into
int *wstat, int options);
static int linux_wait_for_event (ptid_t ptid, int *wstat, int options);
static struct lwp_info *add_lwp (ptid_t ptid);
-static int linux_stopped_by_watchpoint (void);
static void mark_lwp_dead (struct lwp_info *lwp, int wstat);
static int lwp_is_marked_dead (struct lwp_info *lwp);
static void proceed_all_lwps (void);
return can_software_single_step ();
}
-static int
-linux_stopped_by_watchpoint (void)
+bool
+linux_process_target::stopped_by_watchpoint ()
{
struct lwp_info *lwp = get_thread_lwp (current_thread);
return lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
}
-static CORE_ADDR
-linux_stopped_data_address (void)
+CORE_ADDR
+linux_process_target::stopped_data_address ()
{
struct lwp_info *lwp = get_thread_lwp (current_thread);
static linux_process_target the_linux_target;
static process_stratum_target linux_target_ops = {
- linux_stopped_by_watchpoint,
- linux_stopped_data_address,
#if defined(__UCLIBC__) && defined(HAS_NOMMU) \
&& defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
&& defined(PT_TEXT_END_ADDR)
bool supports_stopped_by_hw_breakpoint () override;
bool supports_hardware_single_step () override;
+
+ bool stopped_by_watchpoint () override;
+
+ CORE_ADDR stopped_data_address () override;
};
#define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
/* The LynxOS target_ops vector. */
static process_stratum_target lynx_target_ops = {
- NULL, /* stopped_by_watchpoint */
- NULL, /* stopped_data_address */
NULL, /* read_offsets */
NULL, /* get_tls_address */
NULL, /* hostio_last_error */
/* Check if the reason of stop for current thread (CURRENT_INFERIOR) is
a watchpoint.
- Return 1 if stopped by watchpoint, 0 otherwise. */
+ Return true if stopped by watchpoint, false otherwise. */
-static int
-nto_stopped_by_watchpoint (void)
+bool
+nto_process_target::stopped_by_watchpoint ()
{
- int ret = 0;
+ bool ret = false;
TRACE ("%s\n", __func__);
if (nto_inferior.ctl_fd != -1 && current_thread != NULL)
err = devctl (nto_inferior.ctl_fd, DCMD_PROC_STATUS, &status,
sizeof (status), 0);
if (err == EOK && (status.flags & watchmask))
- ret = 1;
+ ret = true;
}
}
TRACE ("%s: %s\n", __func__, ret ? "yes" : "no");
Return inferior's instruction pointer value, or 0 on error. */
-static CORE_ADDR
-nto_stopped_data_address (void)
+CORE_ADDR
+nto_process_target::stopped_data_address ()
{
CORE_ADDR ret = (CORE_ADDR)0;
static nto_process_target the_nto_target;
static process_stratum_target nto_target_ops = {
- nto_stopped_by_watchpoint,
- nto_stopped_data_address,
NULL, /* nto_read_offsets */
NULL, /* thread_db_set_tls_address */
hostio_last_error_from_errno,
int size, raw_breakpoint *bp) override;
bool supports_hardware_single_step () override;
+
+ bool stopped_by_watchpoint () override;
+
+ CORE_ADDR stopped_data_address () override;
};
/* The inferior's target description. This is a global because the
regcache = get_thread_regcache (current_thread, 1);
- if (the_target->stopped_by_watchpoint != NULL
- && (*the_target->stopped_by_watchpoint) ())
+ if (the_target->pt->stopped_by_watchpoint ())
{
CORE_ADDR addr;
int i;
memcpy (buf, "watch:", 6);
buf += 6;
- addr = (*the_target->stopped_data_address) ();
+ addr = the_target->pt->stopped_data_address ();
/* Convert each byte of the address into two hexadecimal
chars. Note that we take sizeof (void *) instead of
{
return false;
}
+
+bool
+process_target::stopped_by_watchpoint ()
+{
+ return false;
+}
+
+CORE_ADDR
+process_target::stopped_data_address ()
+{
+ return 0;
+}
shared code. */
struct process_stratum_target
{
- /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
-
- int (*stopped_by_watchpoint) (void);
-
- /* Returns the address associated with the watchpoint that hit, if any;
- returns 0 otherwise. */
-
- CORE_ADDR (*stopped_data_address) (void);
-
/* Reports the text, data offsets of the executable. This is
needed for uclinux where the executable is relocated during load
time. */
/* Returns true if the target can do hardware single step. */
virtual bool supports_hardware_single_step ();
+
+ /* Returns true if target was stopped due to a watchpoint hit, false
+ otherwise. */
+ virtual bool stopped_by_watchpoint ();
+
+ /* Returns the address associated with the watchpoint that hit, if any;
+ returns 0 otherwise. */
+ virtual CORE_ADDR stopped_data_address ();
};
extern process_stratum_target *the_target;
return 1;
}
-static int
-win32_stopped_by_watchpoint (void)
+bool
+win32_process_target::stopped_by_watchpoint ()
{
if (the_low_target.stopped_by_watchpoint != NULL)
return the_low_target.stopped_by_watchpoint ();
else
- return 0;
+ return false;
}
-static CORE_ADDR
-win32_stopped_data_address (void)
+CORE_ADDR
+win32_process_target::stopped_data_address ()
{
if (the_low_target.stopped_data_address != NULL)
return the_low_target.stopped_data_address ();
static win32_process_target the_win32_target;
static process_stratum_target win32_target_ops = {
- win32_stopped_by_watchpoint,
- win32_stopped_data_address,
NULL, /* read_offsets */
NULL, /* get_tls_address */
#ifdef _WIN32_WCE
int size, raw_breakpoint *bp) override;
bool supports_hardware_single_step () override;
+
+ bool stopped_by_watchpoint () override;
+
+ CORE_ADDR stopped_data_address () override;
};
/* Retrieve the context for this thread, if not already retrieved. */