gdbserver: turn target ops 'stopped_by_watchpoint' and 'stopped_data_address' into...
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 17 Feb 2020 15:11:55 +0000 (16:11 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 20 Feb 2020 16:35:08 +0000 (17:35 +0100)
gdbserver/ChangeLog:
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.

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

index 9757bc0fa3c1eba1f8fa116a9ae94c33bfe0c975..f7ac9a877cecf33490e82d1ae7246668af9f0cdb 100644 (file)
@@ -1,3 +1,36 @@
+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
index fec2c3c56737706579574872a79a72b50ac92ead..5a5c6372823c31e7fcef8d7fc6f9e931396bcefa 100644 (file)
@@ -269,7 +269,6 @@ static int linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
                                          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);
@@ -6044,16 +6043,16 @@ linux_supports_software_single_step (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);
 
@@ -7376,8 +7375,6 @@ linux_get_hwcap2 (int wordsize)
 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)
index 57fc9a594156c7b5733409479f28a6f2f6b491f6..af2a0c6671eba2c44699bd9ef3175ce0c19c0944 100644 (file)
@@ -332,6 +332,10 @@ public:
   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)))
index ea328b7efe335f3155e05cf8fff8db4232fa758a..e9dfccede0581541439ea417bf6041ea80703817 100644 (file)
@@ -735,8 +735,6 @@ static lynx_process_target the_lynx_target;
 /* 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 */
index 3e10436df3dc0702aa44e546caea1f685b9fd8ee..53020a25e733e0575094eccff2be4cd7d5a73ba5 100644 (file)
@@ -878,12 +878,12 @@ nto_process_target::supports_hardware_single_step ()
 /* 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)
@@ -899,7 +899,7 @@ nto_stopped_by_watchpoint (void)
          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");
@@ -910,8 +910,8 @@ nto_stopped_by_watchpoint (void)
 
    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;
 
@@ -956,8 +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 = {
-  nto_stopped_by_watchpoint,
-  nto_stopped_data_address,
   NULL, /* nto_read_offsets */
   NULL, /* thread_db_set_tls_address */
   hostio_last_error_from_errno,
index 001ccb6687cf79b24e9ecd434a4cbee6539ec1f4..c3e7099e702c9f11a76e12489f89cd4070cca0f8 100644 (file)
@@ -94,6 +94,10 @@ public:
                    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
index b5248ab368eadbe7f06f8d90d1aa9c6cda50950a..316f04e32ee34862dfceb7ad24e4d3ee28b3f786 100644 (file)
@@ -1214,8 +1214,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 
        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;
@@ -1223,7 +1222,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
            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
index 09b3a633fc8308e4aedaf6026a3a272f6b03fbd9..00f5f794b85b30070782f003cce57b0cea0d3da2 100644 (file)
@@ -469,3 +469,15 @@ process_target::supports_hardware_single_step ()
 {
   return false;
 }
+
+bool
+process_target::stopped_by_watchpoint ()
+{
+  return false;
+}
+
+CORE_ADDR
+process_target::stopped_data_address ()
+{
+  return 0;
+}
index 92b85cb061eb1d18b8e6c8334e63dcd11d1d2465..83595fad520c683f5f85296bd3d248cba7b1b88c 100644 (file)
@@ -70,15 +70,6 @@ class process_target;
    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.  */
@@ -476,6 +467,14 @@ public:
 
   /* 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;
index 2862a9c241cd3f73b21854b0156dd2cd46d7c4be..ff62bcefb0da89118057fa248991a39f435553be 100644 (file)
@@ -283,17 +283,17 @@ win32_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
     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 ();
@@ -1844,8 +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 = {
-  win32_stopped_by_watchpoint,
-  win32_stopped_data_address,
   NULL, /* read_offsets */
   NULL, /* get_tls_address */
 #ifdef _WIN32_WCE
index c5f9a13e02946e50636609ea74ba9e40c646ac95..b2b8a6dedc326270005e123d547f62f1b318148e 100644 (file)
@@ -148,6 +148,10 @@ public:
                    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.  */