From 11b5219af5c54762a68469ade4005e5dd2362f87 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Tue, 17 Dec 2013 21:29:17 -0700
Subject: [PATCH] Add target_ops argument to to_remove_watchpoint

2014-02-19  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_remove_watchpoint>: Add
	argument.
	(target_remove_watchpoint): Add argument.
	* target.c (debug_to_remove_watchpoint): Add argument.
	(update_current_target): Update.
	* s390-linux-nat.c (s390_remove_watchpoint): Add 'self' argument.
	* remote.c (remote_remove_watchpoint): Add 'self' argument.
	* remote-mips.c (mips_remove_watchpoint): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_remove_watchpoint): Add 'self' argument.
	* procfs.c (procfs_remove_watchpoint): Add 'self' argument.
	* ppc-linux-nat.c (ppc_linux_remove_watchpoint): Add 'self'
	argument.
	* nto-procfs.c (procfs_remove_hw_watchpoint): Add 'self' argument.
	* mips-linux-nat.c (mips_linux_remove_watchpoint): Add 'self'
	argument.
	* inf-ttrace.c (inf_ttrace_remove_watchpoint): Add 'self'
	argument.
	* ia64-linux-nat.c (ia64_linux_remove_watchpoint): Add 'self'
	argument.
	* i386-nat.c (i386_remove_watchpoint): Add 'self' argument.
	* arm-linux-nat.c (arm_linux_remove_watchpoint): Add 'self'
	argument.
	* aarch64-linux-nat.c (aarch64_linux_remove_watchpoint): Add
	'self' argument.
---
 gdb/ChangeLog           | 27 +++++++++++++++++++++++++++
 gdb/aarch64-linux-nat.c |  3 ++-
 gdb/arm-linux-nat.c     |  3 ++-
 gdb/i386-nat.c          |  3 ++-
 gdb/ia64-linux-nat.c    |  3 ++-
 gdb/inf-ttrace.c        |  3 ++-
 gdb/mips-linux-nat.c    |  3 ++-
 gdb/nto-procfs.c        |  6 ++++--
 gdb/ppc-linux-nat.c     |  3 ++-
 gdb/procfs.c            |  3 ++-
 gdb/remote-m32r-sdi.c   |  3 ++-
 gdb/remote-mips.c       |  3 ++-
 gdb/remote.c            |  3 ++-
 gdb/s390-linux-nat.c    |  3 ++-
 gdb/target.c            | 12 ++++++++----
 gdb/target.h            |  6 ++++--
 16 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fff135d012c..38ddd87c47a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,30 @@
+2014-02-19  Tom Tromey  <tromey@redhat.com>
+
+	* target.h (struct target_ops) <to_remove_watchpoint>: Add
+	argument.
+	(target_remove_watchpoint): Add argument.
+	* target.c (debug_to_remove_watchpoint): Add argument.
+	(update_current_target): Update.
+	* s390-linux-nat.c (s390_remove_watchpoint): Add 'self' argument.
+	* remote.c (remote_remove_watchpoint): Add 'self' argument.
+	* remote-mips.c (mips_remove_watchpoint): Add 'self' argument.
+	* remote-m32r-sdi.c (m32r_remove_watchpoint): Add 'self' argument.
+	* procfs.c (procfs_remove_watchpoint): Add 'self' argument.
+	* ppc-linux-nat.c (ppc_linux_remove_watchpoint): Add 'self'
+	argument.
+	* nto-procfs.c (procfs_remove_hw_watchpoint): Add 'self' argument.
+	* mips-linux-nat.c (mips_linux_remove_watchpoint): Add 'self'
+	argument.
+	* inf-ttrace.c (inf_ttrace_remove_watchpoint): Add 'self'
+	argument.
+	* ia64-linux-nat.c (ia64_linux_remove_watchpoint): Add 'self'
+	argument.
+	* i386-nat.c (i386_remove_watchpoint): Add 'self' argument.
+	* arm-linux-nat.c (arm_linux_remove_watchpoint): Add 'self'
+	argument.
+	* aarch64-linux-nat.c (aarch64_linux_remove_watchpoint): Add
+	'self' argument.
+
 2014-02-19  Tom Tromey  <tromey@redhat.com>
 
 	* target.h (struct target_ops) <to_remove_hw_breakpoint>: Add
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index cec5e4ada04..d5090314e2e 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -1372,7 +1372,8 @@ aarch64_linux_insert_watchpoint (CORE_ADDR addr, int len, int type,
    type TYPE.  Return 0 on success, -1 on failure.  */
 
 static int
-aarch64_linux_remove_watchpoint (CORE_ADDR addr, int len, int type,
+aarch64_linux_remove_watchpoint (struct target_ops *self,
+				 CORE_ADDR addr, int len, int type,
 				 struct expression *cond)
 {
   int ret;
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 99699aba9b5..d964009391d 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -1126,7 +1126,8 @@ arm_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
 
 /* Remove a hardware breakpoint.  */
 static int
-arm_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
+arm_linux_remove_watchpoint (struct target_ops *self,
+			     CORE_ADDR addr, int len, int rw,
 			     struct expression *cond)
 {
   struct lwp_info *lp;
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 80bb217599b..e1306702c96 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -627,7 +627,8 @@ i386_insert_watchpoint (CORE_ADDR addr, int len, int type,
    address ADDR, whose length is LEN bytes, and for accesses of the
    type TYPE.  Return 0 on success, -1 on failure.  */
 static int
-i386_remove_watchpoint (CORE_ADDR addr, int len, int type,
+i386_remove_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   struct i386_debug_reg_state *state
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index 938807f88e8..31ee479029a 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -596,7 +596,8 @@ ia64_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
 }
 
 static int
-ia64_linux_remove_watchpoint (CORE_ADDR addr, int len, int type,
+ia64_linux_remove_watchpoint (struct target_ops *self,
+			      CORE_ADDR addr, int len, int type,
 			      struct expression *cond)
 {
   int idx;
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index 28b55eb269e..7e77424c97f 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -338,7 +338,8 @@ inf_ttrace_insert_watchpoint (CORE_ADDR addr, int len, int type,
    type TYPE.  */
 
 static int
-inf_ttrace_remove_watchpoint (CORE_ADDR addr, int len, int type,
+inf_ttrace_remove_watchpoint (struct target_ops *self,
+			      CORE_ADDR addr, int len, int type,
 			      struct expression *cond)
 {
   const int pagesize = inf_ttrace_page_dict.pagesize;
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index a92078d2a58..9c1c8cb4459 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -698,7 +698,8 @@ mips_linux_insert_watchpoint (CORE_ADDR addr, int len, int type,
    Return zero on success.  */
 
 static int
-mips_linux_remove_watchpoint (CORE_ADDR addr, int len, int type,
+mips_linux_remove_watchpoint (struct target_ops *self,
+			      CORE_ADDR addr, int len, int type,
 			      struct expression *cond)
 {
   int retval;
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 71c0526e8d0..7407efc63eb 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -73,7 +73,8 @@ static int procfs_can_use_hw_breakpoint (struct target_ops *self,
 static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type,
 					struct expression *cond);
 
-static int procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type,
+static int procfs_remove_hw_watchpoint (struct target_ops *self,
+					CORE_ADDR addr, int len, int type,
 					struct expression *cond);
 
 static int procfs_stopped_by_watchpoint (struct target_ops *ops);
@@ -1496,7 +1497,8 @@ procfs_can_use_hw_breakpoint (struct target_ops *self,
 }
 
 static int
-procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type,
+procfs_remove_hw_watchpoint (struct target_ops *self,
+			     CORE_ADDR addr, int len, int type,
 			     struct expression *cond)
 {
   return procfs_hw_watchpoint (addr, -1, type);
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index eb0ccc6c7f3..b4eae9d7d3b 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2144,7 +2144,8 @@ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
 }
 
 static int
-ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
+ppc_linux_remove_watchpoint (struct target_ops *self,
+			     CORE_ADDR addr, int len, int rw,
 			     struct expression *cond)
 {
   struct lwp_info *lp;
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 5b54a42fd19..26e7ac3fea4 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -4921,7 +4921,8 @@ procfs_insert_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-procfs_remove_watchpoint (CORE_ADDR addr, int len, int type,
+procfs_remove_watchpoint (struct target_ops *self,
+			  CORE_ADDR addr, int len, int type,
 			  struct expression *cond)
 {
   return procfs_set_watchpoint (inferior_ptid, addr, 0, 0, 0);
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 4cd12d86892..6d8eab0c053 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1443,7 +1443,8 @@ m32r_insert_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-m32r_remove_watchpoint (CORE_ADDR addr, int len, int type,
+m32r_remove_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   int i;
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 2e2116c5046..174e9b3e66d 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -2438,7 +2438,8 @@ mips_insert_watchpoint (CORE_ADDR addr, int len, int type,
 /* Remove a watchpoint.  */
 
 static int
-mips_remove_watchpoint (CORE_ADDR addr, int len, int type,
+mips_remove_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   if (mips_clear_breakpoint (addr, len, type))
diff --git a/gdb/remote.c b/gdb/remote.c
index a837882d872..c797530cb79 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8215,7 +8215,8 @@ remote_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr,
 
 
 static int
-remote_remove_watchpoint (CORE_ADDR addr, int len, int type,
+remote_remove_watchpoint (struct target_ops *self,
+			  CORE_ADDR addr, int len, int type,
 			  struct expression *cond)
 {
   struct remote_state *rs = get_remote_state ();
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index ae00a513f7a..8a187aca442 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -529,7 +529,8 @@ s390_insert_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-s390_remove_watchpoint (CORE_ADDR addr, int len, int type,
+s390_remove_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   struct lwp_info *lp;
diff --git a/gdb/target.c b/gdb/target.c
index 95ad27e150a..68504100ddd 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -114,7 +114,8 @@ static int debug_to_remove_hw_breakpoint (struct target_ops *self,
 static int debug_to_insert_watchpoint (CORE_ADDR, int, int,
 				       struct expression *);
 
-static int debug_to_remove_watchpoint (CORE_ADDR, int, int,
+static int debug_to_remove_watchpoint (struct target_ops *self,
+				       CORE_ADDR, int, int,
 				       struct expression *);
 
 static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
@@ -751,7 +752,8 @@ update_current_target (void)
 	    (int (*) (CORE_ADDR, int, int, struct expression *))
 	    return_minus_one);
   de_fault (to_remove_watchpoint,
-	    (int (*) (CORE_ADDR, int, int, struct expression *))
+	    (int (*) (struct target_ops *, CORE_ADDR, int, int,
+		      struct expression *))
 	    return_minus_one);
   de_fault (to_watchpoint_addr_within_range,
 	    default_watchpoint_addr_within_range);
@@ -4767,12 +4769,14 @@ debug_to_insert_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type,
+debug_to_remove_watchpoint (struct target_ops *self,
+			    CORE_ADDR addr, int len, int type,
 			    struct expression *cond)
 {
   int retval;
 
-  retval = debug_target.to_remove_watchpoint (addr, len, type, cond);
+  retval = debug_target.to_remove_watchpoint (&debug_target,
+					      addr, len, type, cond);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_remove_watchpoint (%s, %d, %d, %s) = %ld\n",
diff --git a/gdb/target.h b/gdb/target.h
index 7f94b2b4d61..defb78463a2 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -459,7 +459,8 @@ struct target_ops
 
     /* Documentation of what the two routines below are expected to do is
        provided with the corresponding target_* macros.  */
-    int (*to_remove_watchpoint) (CORE_ADDR, int, int, struct expression *);
+    int (*to_remove_watchpoint) (struct target_ops *,
+				 CORE_ADDR, int, int, struct expression *);
     int (*to_insert_watchpoint) (CORE_ADDR, int, int, struct expression *);
 
     int (*to_insert_mask_watchpoint) (struct target_ops *,
@@ -1617,7 +1618,8 @@ extern char *target_thread_name (struct thread_info *);
      (*current_target.to_insert_watchpoint) (addr, len, type, cond)
 
 #define	target_remove_watchpoint(addr, len, type, cond) \
-     (*current_target.to_remove_watchpoint) (addr, len, type, cond)
+     (*current_target.to_remove_watchpoint) (&current_target,	\
+					     addr, len, type, cond)
 
 /* Insert a new masked watchpoint at ADDR using the mask MASK.
    RW may be hw_read for a read watchpoint, hw_write for a write watchpoint