public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC v2 00/38] clean up target delegation
@ 2014-02-06 20:55 Tom Tromey
  2014-02-06 20:55 ` [RFC v2 16/38] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
                   ` (39 more replies)
  0 siblings, 40 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:55 UTC (permalink / raw)
  To: gdb-patches

This is revision 2 of the target delegation cleanup series.  The
original series is here:

    https://sourceware.org/ml/gdb-patches/2014-01/msg00331.html

This submission is, again, a squashed version of the series I actually
developed.  I've redone the squashing using the same patch bundlings
as before.

When the time comes, I plan to merge the atomized series rather than
this one; the squashing having been done to avoid an email flood and
to bundle the more mechanical patches in an attempt to make reviews
less strenuous.

This series differs from the original in several ways, though I
believe none of the changes are truly major.

I believe this version addresses all the reviews.

It required minor changes here and there when I rebased.  I didn't
generally make a record of these fixes, but they were all simply
adaptations either to patches that went in earlier, or to other
patches touching target methods.

A couple of patches from the old series have already been pushed.

Patches 33-38 in this series are new to this revision.  They all arose
from reviews of the first series.  I believe they were all reviewed
already by Pedro.

Built and regtested on x86-64 Fedora 18.  Due to the relatively minor
nature of the changes from revision 1, I did not redo the more
comprehensive testing I did of that revision.

Tom

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 09/38] Add target_ops argument to to_insert_vfork_catchpoint
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
  2014-02-06 20:55 ` [RFC v2 16/38] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
@ 2014-02-06 20:55 ` Tom Tromey
  2014-02-06 20:55 ` [RFC v2 03/38] add make-target-delegates Tom Tromey
                   ` (37 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_insert_vfork_catchpoint>: Add
	argument.
	(target_insert_vfork_catchpoint): Add argument.
	* target.c (debug_to_insert_vfork_catchpoint): Add argument.
	(update_current_target): Update.
	* linux-nat.c (linux_child_insert_vfork_catchpoint): Add 'self'
	argument.

Add target_ops argument to to_remove_vfork_catchpoint

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

	* target.h (struct target_ops) <to_remove_vfork_catchpoint>: Add
	argument.
	(target_remove_vfork_catchpoint): Add argument.
	* target.c (debug_to_remove_vfork_catchpoint): Add argument.
	(update_current_target): Update.
	* linux-nat.c (linux_child_remove_vfork_catchpoint): Add 'self'
	argument.

Add target_ops argument to to_insert_exec_catchpoint

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

	* target.h (struct target_ops) <to_insert_exec_catchpoint>: Add
	argument.
	(target_insert_exec_catchpoint): Add argument.
	* target.c (debug_to_insert_exec_catchpoint): Add argument.
	(update_current_target): Update.
	* linux-nat.c (linux_child_insert_exec_catchpoint): Add 'self'
	argument.

Add target_ops argument to to_remove_exec_catchpoint

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

	* target.h (struct target_ops) <to_remove_exec_catchpoint>: Add
	argument.
	(target_remove_exec_catchpoint): Add argument.
	* target.c (debug_to_remove_exec_catchpoint): Add argument.
	(update_current_target): Update.
	* linux-nat.c (linux_child_remove_exec_catchpoint): Add 'self'
	argument.

Add target_ops argument to to_set_syscall_catchpoint

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

	* target.h (struct target_ops) <to_set_syscall_catchpoint>: Add
	argument.
	(target_set_syscall_catchpoint): Add argument.
	* linux-nat.c (linux_child_set_syscall_catchpoint): Add 'self'
	argument.
	* target.c (update_current_target): Update.

Add target_ops argument to to_has_exited

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

	* target.h (struct target_ops) <to_has_exited>: Add argument.
	(target_has_exited): Add argument.
	* target.c (debug_to_has_exited): Add argument.
	(update_current_target): Update.

Add target_ops argument to to_can_run

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

	* windows-nat.c (windows_can_run): Add 'self' argument.
	* target.h (struct target_ops) <to_can_run>: Add argument.
	(target_can_run): Add argument.
	* target.c (debug_to_can_run): Add argument.
	(update_current_target): Update.
	* nto-procfs.c (procfs_can_run): Add 'self' argument.
	* inf-child.c (inf_child_can_run): Add 'self' argument.
	* go32-nat.c (go32_can_run): Add 'self' argument.

Add target_ops argument to to_pass_signals

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

	* target.h (struct target_ops) <to_pass_signals>: Add argument.
	* target.c (target_pass_signals): Add argument.
	* remote.c (remote_pass_signals): Add 'self' argument.
	(remote_start_remote): Update.
	* procfs.c (procfs_pass_signals): Add 'self' argument.
	* nto-procfs.c (procfs_pass_signals): Add 'self' argument.
	* linux-nat.c (linux_nat_pass_signals): Add 'self' argument.
	(linux_nat_create_inferior, linux_nat_attach): Update.

Add target_ops argument to to_program_signals

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

	* target.h (struct target_ops) <to_program_signals>: Add argument.
	* target.c (target_program_signals): Add argument.
	* remote.c (remote_program_signals): Add 'self' argument.

Add target_ops argument to to_extra_thread_info

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

	* target.h (struct target_ops) <to_extra_thread_info>: Add
	argument.
	(target_extra_thread_info): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_threads_extra_info): Add 'self' argument.
	* ravenscar-thread.c (ravenscar_extra_thread_info): Add 'self'
	argument.
	* nto-tdep.h (nto_extra_thread_info): Add 'self' argument.
	* nto-tdep.c (nto_extra_thread_info): Add 'self' argument.
	* linux-thread-db.c (thread_db_extra_thread_info): Add 'self'
	argument.
	* inf-ttrace.c (inf_ttrace_extra_thread_info): Add 'self'
	argument.
	* bsd-uthread.c (bsd_uthread_extra_thread_info): Add 'self'
	argument.
	* aix-thread.c (aix_thread_extra_thread_info): Add 'self'
	argument.
---
 gdb/ChangeLog          | 104 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/aix-thread.c       |   3 +-
 gdb/bsd-uthread.c      |   3 +-
 gdb/go32-nat.c         |   2 +-
 gdb/inf-child.c        |   2 +-
 gdb/inf-ttrace.c       |   3 +-
 gdb/linux-nat.c        |  18 +++++----
 gdb/linux-thread-db.c  |   3 +-
 gdb/nto-procfs.c       |   7 ++--
 gdb/nto-tdep.c         |   2 +-
 gdb/nto-tdep.h         |   2 +-
 gdb/procfs.c           |   6 ++-
 gdb/ravenscar-thread.c |   5 ++-
 gdb/remote.c           |  10 +++--
 gdb/target.c           |  47 +++++++++++-----------
 gdb/target.h           |  39 ++++++++++---------
 gdb/windows-nat.c      |   2 +-
 17 files changed, 190 insertions(+), 68 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 7218abe..3597d3c 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1750,7 +1750,8 @@ aix_thread_pid_to_str (struct target_ops *ops, ptid_t ptid)
    THREAD, for use in "info threads" output.  */
 
 static char *
-aix_thread_extra_thread_info (struct thread_info *thread)
+aix_thread_extra_thread_info (struct target_ops *self,
+			      struct thread_info *thread)
 {
   struct ui_file *buf;
   int status;
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 39218ba..1703444 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -482,7 +482,8 @@ static char *bsd_uthread_state[] =
    INFO.  */
 
 static char *
-bsd_uthread_extra_thread_info (struct thread_info *info)
+bsd_uthread_extra_thread_info (struct target_ops *self,
+			       struct thread_info *info)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   CORE_ADDR addr = ptid_get_tid (info->ptid);
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 75f6a3e..2e91b12 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -737,7 +737,7 @@ go32_mourn_inferior (struct target_ops *ops)
 }
 
 static int
-go32_can_run (void)
+go32_can_run (struct target_ops *self)
 {
   return 1;
 }
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 7726470..37fac4b 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -128,7 +128,7 @@ inf_child_follow_fork (struct target_ops *ops, int follow_child,
 }
 
 static int
-inf_child_can_run (void)
+inf_child_can_run (struct target_ops *self)
 {
   return 1;
 }
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index e9da0e7..c7b2856 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -1272,7 +1272,8 @@ inf_ttrace_thread_alive (struct target_ops *ops, ptid_t ptid)
    INFO.  */
 
 static char *
-inf_ttrace_extra_thread_info (struct thread_info *info)
+inf_ttrace_extra_thread_info (struct target_ops *self,
+			      struct thread_info *info)
 {
   struct inf_ttrace_private_thread_info* private =
     (struct inf_ttrace_private_thread_info *) info->private;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 45d4053..76877de 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -708,31 +708,32 @@ linux_child_remove_fork_catchpoint (struct target_ops *self, int pid)
 }
 
 static int
-linux_child_insert_vfork_catchpoint (int pid)
+linux_child_insert_vfork_catchpoint (struct target_ops *self, int pid)
 {
   return !linux_supports_tracefork ();
 }
 
 static int
-linux_child_remove_vfork_catchpoint (int pid)
+linux_child_remove_vfork_catchpoint (struct target_ops *self, int pid)
 {
   return 0;
 }
 
 static int
-linux_child_insert_exec_catchpoint (int pid)
+linux_child_insert_exec_catchpoint (struct target_ops *self, int pid)
 {
   return !linux_supports_tracefork ();
 }
 
 static int
-linux_child_remove_exec_catchpoint (int pid)
+linux_child_remove_exec_catchpoint (struct target_ops *self, int pid)
 {
   return 0;
 }
 
 static int
-linux_child_set_syscall_catchpoint (int pid, int needed, int any_count,
+linux_child_set_syscall_catchpoint (struct target_ops *self,
+				    int pid, int needed, int any_count,
 				    int table_size, int *table)
 {
   if (!linux_supports_tracesysgood ())
@@ -823,7 +824,8 @@ static sigset_t pass_mask;
 
 /* Update signals to pass to the inferior.  */
 static void
-linux_nat_pass_signals (int numsigs, unsigned char *pass_signals)
+linux_nat_pass_signals (struct target_ops *self,
+			int numsigs, unsigned char *pass_signals)
 {
   int signo;
 
@@ -1301,7 +1303,7 @@ linux_nat_create_inferior (struct target_ops *ops,
 #endif /* HAVE_PERSONALITY */
 
   /* Make sure we report all signals during startup.  */
-  linux_nat_pass_signals (0, NULL);
+  linux_nat_pass_signals (ops, 0, NULL);
 
   linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty);
 
@@ -1326,7 +1328,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
   volatile struct gdb_exception ex;
 
   /* Make sure we report all signals during attach.  */
-  linux_nat_pass_signals (0, NULL);
+  linux_nat_pass_signals (ops, 0, NULL);
 
   TRY_CATCH (ex, RETURN_MASK_ERROR)
     {
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index c05ebdf..9180464 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1772,7 +1772,8 @@ thread_db_pid_to_str (struct target_ops *ops, ptid_t ptid)
    INFO.  */
 
 static char *
-thread_db_extra_thread_info (struct thread_info *info)
+thread_db_extra_thread_info (struct target_ops *self,
+			     struct thread_info *info)
 {
   if (info->private == NULL)
     return NULL;
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 0a7ed55..5fedb90 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -57,7 +57,7 @@ static procfs_run run;
 
 static void procfs_open (char *, int);
 
-static int procfs_can_run (void);
+static int procfs_can_run (struct target_ops *self);
 
 static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
 			       struct mem_attrib *attrib,
@@ -609,7 +609,7 @@ procfs_files_info (struct target_ops *ignore)
 /* Mark our target-struct as eligible for stray "run" and "attach"
    commands.  */
 static int
-procfs_can_run (void)
+procfs_can_run (struct target_ops *self)
 {
   return 1;
 }
@@ -1336,7 +1336,8 @@ procfs_store_registers (struct target_ops *ops,
 /* Set list of signals to be handled in the target.  */
 
 static void
-procfs_pass_signals (int numsigs, unsigned char *pass_signals)
+procfs_pass_signals (struct target_ops *self,
+		     int numsigs, unsigned char *pass_signals)
 {
   int signo;
 
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index cc61423..a160a9e 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -362,7 +362,7 @@ static const char *nto_thread_state_str[] =
 };
 
 char *
-nto_extra_thread_info (struct thread_info *ti)
+nto_extra_thread_info (struct target_ops *self, struct thread_info *ti)
 {
   if (ti && ti->private
       && ti->private->state < ARRAY_SIZE (nto_thread_state_str))
diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h
index 03fd89d..aa965c5 100644
--- a/gdb/nto-tdep.h
+++ b/gdb/nto-tdep.h
@@ -166,6 +166,6 @@ void nto_dummy_supply_regset (struct regcache *regcache, char *regs);
 
 int nto_in_dynsym_resolve_code (CORE_ADDR pc);
 
-char *nto_extra_thread_info (struct thread_info *);
+char *nto_extra_thread_info (struct target_ops *self, struct thread_info *);
 
 #endif
diff --git a/gdb/procfs.c b/gdb/procfs.c
index bd1ce41..1b01317 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -119,7 +119,8 @@ static void procfs_fetch_registers (struct target_ops *,
 				    struct regcache *, int);
 static void procfs_store_registers (struct target_ops *,
 				    struct regcache *, int);
-static void procfs_pass_signals (int, unsigned char *);
+static void procfs_pass_signals (struct target_ops *self,
+				 int, unsigned char *);
 static void procfs_kill_inferior (struct target_ops *ops);
 static void procfs_mourn_inferior (struct target_ops *ops);
 static void procfs_create_inferior (struct target_ops *, char *,
@@ -4225,7 +4226,8 @@ procfs_resume (struct target_ops *ops,
 /* Set up to trace signals in the child process.  */
 
 static void
-procfs_pass_signals (int numsigs, unsigned char *pass_signals)
+procfs_pass_signals (struct target_ops *self,
+		     int numsigs, unsigned char *pass_signals)
 {
   gdb_sigset_t signals;
   procinfo *pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index fc87d79..12d0247 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -56,7 +56,8 @@ static struct observer *update_target_observer = NULL;
 
 static void ravenscar_find_new_threads (struct target_ops *ops);
 static ptid_t ravenscar_running_thread (void);
-static char *ravenscar_extra_thread_info (struct thread_info *tp);
+static char *ravenscar_extra_thread_info (struct target_ops *self,
+					  struct thread_info *tp);
 static int ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid);
 static void ravenscar_fetch_registers (struct target_ops *ops,
                                        struct regcache *regcache, int regnum);
@@ -242,7 +243,7 @@ ravenscar_running_thread (void)
 }
 
 static char *
-ravenscar_extra_thread_info (struct thread_info *tp)
+ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp)
 {
   return "Ravenscar task";
 }
diff --git a/gdb/remote.c b/gdb/remote.c
index 8179c9a..9d3c6ab 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1700,7 +1700,8 @@ record_currthread (struct remote_state *rs, ptid_t currthread)
    it can simply pass through to the inferior without reporting.  */
 
 static void
-remote_pass_signals (int numsigs, unsigned char *pass_signals)
+remote_pass_signals (struct target_ops *self,
+		     int numsigs, unsigned char *pass_signals)
 {
   if (remote_protocol_packets[PACKET_QPassSignals].support != PACKET_DISABLE)
     {
@@ -1750,7 +1751,8 @@ remote_pass_signals (int numsigs, unsigned char *pass_signals)
    signals it should pass through to the inferior when detaching.  */
 
 static void
-remote_program_signals (int numsigs, unsigned char *signals)
+remote_program_signals (struct target_ops *self,
+			int numsigs, unsigned char *signals)
 {
   if (remote_protocol_packets[PACKET_QProgramSignals].support != PACKET_DISABLE)
     {
@@ -2874,7 +2876,7 @@ remote_threads_info (struct target_ops *ops)
  */
 
 static char *
-remote_threads_extra_info (struct thread_info *tp)
+remote_threads_extra_info (struct target_ops *self, struct thread_info *tp)
 {
   struct remote_state *rs = get_remote_state ();
   int result;
@@ -3660,7 +3662,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
       gdb_assert (wait_status == NULL);
 
       /* Report all signals during attach/startup.  */
-      remote_pass_signals (0, NULL);
+      remote_pass_signals (target, 0, NULL);
     }
 
   /* If we connected to a live target, do some additional setup.  */
diff --git a/gdb/target.c b/gdb/target.c
index 02e4c6b..d948e92 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -144,7 +144,7 @@ static void debug_to_terminal_ours (struct target_ops *self);
 
 static void debug_to_load (struct target_ops *self, char *, int);
 
-static int debug_to_can_run (void);
+static int debug_to_can_run (struct target_ops *self);
 
 static void debug_to_stop (ptid_t);
 
@@ -798,27 +798,28 @@ update_current_target (void)
 	    (int (*) (struct target_ops *, int))
 	    return_one);
   de_fault (to_insert_vfork_catchpoint,
-	    (int (*) (int))
+	    (int (*) (struct target_ops *, int))
 	    return_one);
   de_fault (to_remove_vfork_catchpoint,
-	    (int (*) (int))
+	    (int (*) (struct target_ops *, int))
 	    return_one);
   de_fault (to_insert_exec_catchpoint,
-	    (int (*) (int))
+	    (int (*) (struct target_ops *, int))
 	    return_one);
   de_fault (to_remove_exec_catchpoint,
-	    (int (*) (int))
+	    (int (*) (struct target_ops *, int))
 	    return_one);
   de_fault (to_set_syscall_catchpoint,
-	    (int (*) (int, int, int, int, int *))
+	    (int (*) (struct target_ops *, int, int, int, int, int *))
 	    return_one);
   de_fault (to_has_exited,
-	    (int (*) (int, int, int *))
+	    (int (*) (struct target_ops *, int, int, int *))
 	    return_zero);
   de_fault (to_can_run,
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_extra_thread_info,
-	    (char *(*) (struct thread_info *))
+	    (char *(*) (struct target_ops *, struct thread_info *))
 	    return_null);
   de_fault (to_thread_name,
 	    (char *(*) (struct thread_info *))
@@ -2759,7 +2760,7 @@ target_pass_signals (int numsigs, unsigned char *pass_signals)
 	      fprintf_unfiltered (gdb_stdlog, " })\n");
 	    }
 
-	  (*t->to_pass_signals) (numsigs, pass_signals);
+	  (*t->to_pass_signals) (t, numsigs, pass_signals);
 	  return;
 	}
     }
@@ -2789,7 +2790,7 @@ target_program_signals (int numsigs, unsigned char *program_signals)
 	      fprintf_unfiltered (gdb_stdlog, " })\n");
 	    }
 
-	  (*t->to_program_signals) (numsigs, program_signals);
+	  (*t->to_program_signals) (t, numsigs, program_signals);
 	  return;
 	}
     }
@@ -4831,11 +4832,11 @@ debug_to_remove_fork_catchpoint (struct target_ops *self, int pid)
 }
 
 static int
-debug_to_insert_vfork_catchpoint (int pid)
+debug_to_insert_vfork_catchpoint (struct target_ops *self, int pid)
 {
   int retval;
 
-  retval = debug_target.to_insert_vfork_catchpoint (pid);
+  retval = debug_target.to_insert_vfork_catchpoint (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d) = %d\n",
 		      pid, retval);
@@ -4844,11 +4845,11 @@ debug_to_insert_vfork_catchpoint (int pid)
 }
 
 static int
-debug_to_remove_vfork_catchpoint (int pid)
+debug_to_remove_vfork_catchpoint (struct target_ops *self, int pid)
 {
   int retval;
 
-  retval = debug_target.to_remove_vfork_catchpoint (pid);
+  retval = debug_target.to_remove_vfork_catchpoint (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_remove_vfork_catchpoint (%d) = %d\n",
 		      pid, retval);
@@ -4857,11 +4858,11 @@ debug_to_remove_vfork_catchpoint (int pid)
 }
 
 static int
-debug_to_insert_exec_catchpoint (int pid)
+debug_to_insert_exec_catchpoint (struct target_ops *self, int pid)
 {
   int retval;
 
-  retval = debug_target.to_insert_exec_catchpoint (pid);
+  retval = debug_target.to_insert_exec_catchpoint (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
 		      pid, retval);
@@ -4870,11 +4871,11 @@ debug_to_insert_exec_catchpoint (int pid)
 }
 
 static int
-debug_to_remove_exec_catchpoint (int pid)
+debug_to_remove_exec_catchpoint (struct target_ops *self, int pid)
 {
   int retval;
 
-  retval = debug_target.to_remove_exec_catchpoint (pid);
+  retval = debug_target.to_remove_exec_catchpoint (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_remove_exec_catchpoint (%d) = %d\n",
 		      pid, retval);
@@ -4883,11 +4884,13 @@ debug_to_remove_exec_catchpoint (int pid)
 }
 
 static int
-debug_to_has_exited (int pid, int wait_status, int *exit_status)
+debug_to_has_exited (struct target_ops *self,
+		     int pid, int wait_status, int *exit_status)
 {
   int has_exited;
 
-  has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
+  has_exited = debug_target.to_has_exited (&debug_target,
+					   pid, wait_status, exit_status);
 
   fprintf_unfiltered (gdb_stdlog, "target_has_exited (%d, %d, %d) = %d\n",
 		      pid, wait_status, *exit_status, has_exited);
@@ -4896,11 +4899,11 @@ debug_to_has_exited (int pid, int wait_status, int *exit_status)
 }
 
 static int
-debug_to_can_run (void)
+debug_to_can_run (struct target_ops *self)
 {
   int retval;
 
-  retval = debug_target.to_can_run ();
+  retval = debug_target.to_can_run (&debug_target);
 
   fprintf_unfiltered (gdb_stdlog, "target_can_run () = %d\n", retval);
 
diff --git a/gdb/target.h b/gdb/target.h
index 2eface1..dc560a1 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -491,28 +491,29 @@ struct target_ops
     void (*to_post_startup_inferior) (struct target_ops *, ptid_t);
     int (*to_insert_fork_catchpoint) (struct target_ops *, int);
     int (*to_remove_fork_catchpoint) (struct target_ops *, int);
-    int (*to_insert_vfork_catchpoint) (int);
-    int (*to_remove_vfork_catchpoint) (int);
+    int (*to_insert_vfork_catchpoint) (struct target_ops *, int);
+    int (*to_remove_vfork_catchpoint) (struct target_ops *, int);
     int (*to_follow_fork) (struct target_ops *, int, int);
-    int (*to_insert_exec_catchpoint) (int);
-    int (*to_remove_exec_catchpoint) (int);
-    int (*to_set_syscall_catchpoint) (int, int, int, int, int *);
-    int (*to_has_exited) (int, int, int *);
+    int (*to_insert_exec_catchpoint) (struct target_ops *, int);
+    int (*to_remove_exec_catchpoint) (struct target_ops *, int);
+    int (*to_set_syscall_catchpoint) (struct target_ops *,
+				      int, int, int, int, int *);
+    int (*to_has_exited) (struct target_ops *, int, int, int *);
     void (*to_mourn_inferior) (struct target_ops *);
-    int (*to_can_run) (void);
+    int (*to_can_run) (struct target_ops *);
 
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
-    void (*to_pass_signals) (int, unsigned char *);
+    void (*to_pass_signals) (struct target_ops *, int, unsigned char *);
 
     /* Documentation of this routine is provided with the
        corresponding target_* function.  */
-    void (*to_program_signals) (int, unsigned char *);
+    void (*to_program_signals) (struct target_ops *, int, unsigned char *);
 
     int (*to_thread_alive) (struct target_ops *, ptid_t ptid);
     void (*to_find_new_threads) (struct target_ops *);
     char *(*to_pid_to_str) (struct target_ops *, ptid_t);
-    char *(*to_extra_thread_info) (struct thread_info *);
+    char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *);
     char *(*to_thread_name) (struct thread_info *);
     void (*to_stop) (ptid_t);
     void (*to_rcmd) (char *command, struct ui_file *output);
@@ -1299,10 +1300,10 @@ void target_create_inferior (char *exec_file, char *args,
      (*current_target.to_remove_fork_catchpoint) (&current_target, pid)
 
 #define target_insert_vfork_catchpoint(pid) \
-     (*current_target.to_insert_vfork_catchpoint) (pid)
+     (*current_target.to_insert_vfork_catchpoint) (&current_target, pid)
 
 #define target_remove_vfork_catchpoint(pid) \
-     (*current_target.to_remove_vfork_catchpoint) (pid)
+     (*current_target.to_remove_vfork_catchpoint) (&current_target, pid)
 
 /* If the inferior forks or vforks, this function will be called at
    the next resume in order to perform any bookkeeping and fiddling
@@ -1320,10 +1321,10 @@ int target_follow_fork (int follow_child, int detach_fork);
    catchpoint type is not supported and -1 for failure.  */
 
 #define target_insert_exec_catchpoint(pid) \
-     (*current_target.to_insert_exec_catchpoint) (pid)
+     (*current_target.to_insert_exec_catchpoint) (&current_target, pid)
 
 #define target_remove_exec_catchpoint(pid) \
-     (*current_target.to_remove_exec_catchpoint) (pid)
+     (*current_target.to_remove_exec_catchpoint) (&current_target, pid)
 
 /* Syscall catch.
 
@@ -1346,14 +1347,16 @@ int target_follow_fork (int follow_child, int detach_fork);
    for failure.  */
 
 #define target_set_syscall_catchpoint(pid, needed, any_count, table_size, table) \
-     (*current_target.to_set_syscall_catchpoint) (pid, needed, any_count, \
+     (*current_target.to_set_syscall_catchpoint) (&current_target,	\
+						  pid, needed, any_count, \
 						  table_size, table)
 
 /* Returns TRUE if PID has exited.  And, also sets EXIT_STATUS to the
    exit code of PID, if any.  */
 
 #define target_has_exited(pid,wait_status,exit_status) \
-     (*current_target.to_has_exited) (pid,wait_status,exit_status)
+     (*current_target.to_has_exited) (&current_target, \
+				      pid,wait_status,exit_status)
 
 /* The debugger has completed a blocking wait() call.  There is now
    some process event that must be processed.  This function should
@@ -1367,7 +1370,7 @@ void target_mourn_inferior (void);
 /* Does target have enough data to do a run or attach command? */
 
 #define target_can_run(t) \
-     ((t)->to_can_run) ()
+     ((t)->to_can_run) (t)
 
 /* Set list of signals to be handled in the target.
 
@@ -1508,7 +1511,7 @@ extern char *normal_pid_to_str (ptid_t ptid);
    is okay.  */
 
 #define target_extra_thread_info(TP) \
-     (current_target.to_extra_thread_info (TP))
+     (current_target.to_extra_thread_info (&current_target, TP))
 
 /* Return the thread's name.  A NULL result means that the target
    could not determine this thread's name.  */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index b0ed3f6..ef844be 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2474,7 +2474,7 @@ windows_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 }
 
 static int
-windows_can_run (void)
+windows_can_run (struct target_ops *self)
 {
   return 1;
 }
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 02/38] introduce and use find_target_at
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (3 preceding siblings ...)
  2014-02-06 20:55 ` [RFC v2 08/38] Add target_ops argument to to_terminal_init Tom Tromey
@ 2014-02-06 20:55 ` Tom Tromey
  2014-02-07 15:43   ` Pedro Alves
  2014-02-06 20:56 ` [RFC v2 22/38] convert to_thread_architecture Tom Tromey
                   ` (34 subsequent siblings)
  39 siblings, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

RECORD_IS_USED looks at current_target.to_stratum to determine whether
a record target is in use.  This is bad because arch_stratum is
greater than record_stratum.

To fix this, this patch adds find_target_at to determine whether a
target appears at a given stratum.  This may seem like overkill
somehow, but I have a subsequent patch series that uses it more
heavily.

This new function lets us clean up find_record_target a bit as well.

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

	* record.c (find_record_target): Use find_target_at.
	* record.h (RECORD_IS_REPLAY): Use find_target_at.
	* target.c (find_target_at): New function.
	* target.h (find_target_at): Declare.
---
 gdb/ChangeLog |  7 +++++++
 gdb/record.c  |  8 +-------
 gdb/target.c  | 14 ++++++++++++++
 gdb/target.h  |  5 +++++
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/gdb/record.c b/gdb/record.c
index 4c67192..41e167f 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -62,13 +62,7 @@ struct cmd_list_element *info_record_cmdlist = NULL;
 struct target_ops *
 find_record_target (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_stratum == record_stratum)
-      return t;
-
-  return NULL;
+  return find_target_at (record_stratum);
 }
 
 /* Check that recording is active.  Throw an error, if it isn't.  */
diff --git a/gdb/target.c b/gdb/target.c
index 6723562..c9f004a 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3685,6 +3685,20 @@ find_target_beneath (struct target_ops *t)
   return t->beneath;
 }
 
+/* See target.h.  */
+
+struct target_ops *
+find_target_at (enum strata stratum)
+{
+  struct target_ops *t;
+
+  for (t = current_target.beneath; t != NULL; t = t->beneath)
+    if (t->to_stratum == stratum)
+      return t;
+
+  return NULL;
+}
+
 \f
 /* The inferior process has died.  Long live the inferior!  */
 
diff --git a/gdb/target.h b/gdb/target.h
index e3479e2..07d0afd 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1955,6 +1955,11 @@ extern void find_default_create_inferior (struct target_ops *,
 
 extern struct target_ops *find_target_beneath (struct target_ops *);
 
+/* Find the target at STRATUM.  If no target is at that stratum,
+   return NULL.  */
+
+struct target_ops *find_target_at (enum strata stratum);
+
 /* Read OS data object of type TYPE from the target, and return it in
    XML format.  The result is NUL-terminated and returned as a string,
    allocated using xmalloc.  If an error occurs or the transfer is
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 03/38] add make-target-delegates
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
  2014-02-06 20:55 ` [RFC v2 16/38] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
  2014-02-06 20:55 ` [RFC v2 09/38] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
@ 2014-02-06 20:55 ` Tom Tromey
  2014-02-06 20:55 ` [RFC v2 08/38] Add target_ops argument to to_terminal_init Tom Tromey
                   ` (36 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch adds a new script, call make-target-delegates, which
auto-generates some target delegation code based on annotations in
target.h.  This adds the new delegation macros, the new generated
file, and adds the necessary calls to the new generated functions to
target.c.  It doesn't, however, add any actual annotations to the
target methods, leaving these for separate patches.

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

	PR build/7701:
	* target-delegates.c: New file.
	* target.c: Include target-delegates.c.
	(init_dummy_target): Call install_dummy_methods.
	(complete_target_initialization): Call install_delegators.
	* target.h (TARGET_DEFAULT_IGNORE, TARGET_DEFAULT_NORETURN)
	(TARGET_DEFAULT_RETURN, TARGET_DEFAULT_FUNC): New defines.
	* make-target-delegates: New file.
---
 gdb/ChangeLog             |  11 ++
 gdb/make-target-delegates | 253 ++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target-delegates.c    |  14 +++
 gdb/target.c              |   9 ++
 gdb/target.h              |  24 +++++
 5 files changed, 311 insertions(+)
 create mode 100755 gdb/make-target-delegates
 create mode 100644 gdb/target-delegates.c

diff --git a/gdb/make-target-delegates b/gdb/make-target-delegates
new file mode 100755
index 0000000..f09f89d
--- /dev/null
+++ b/gdb/make-target-delegates
@@ -0,0 +1,253 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2013-2014 Free Software Foundation, Inc.
+#
+# This file is part of GDB.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# Usage:
+#    make-target-delegates target.h > target-delegates.c
+
+# The line we search for in target.h that marks where we should start
+# looking for methods.
+$TRIGGER = qr,^struct target_ops$,;
+# The end of the methods part.
+$ENDER = qr,^\s*};$,;
+
+# Match a C symbol.
+$SYMBOL = qr,[a-zA-Z_][a-zA-Z0-9_]*,;
+# Match the name part of a method in struct target_ops.
+$NAME_PART = qr,\(\*(?<name>${SYMBOL}+)\)\s,;
+# Match the start of arguments to a method.
+$ARGS_PART = qr,(?<args>\(.*)$,;
+# Match indentation.
+$INTRO_PART = qr,^\s*,;
+
+# Match the return type when it is "ordinary".
+$SIMPLE_RETURN_PART = qr,[^\(]+,;
+# Match the return type when it is a VEC.
+$VEC_RETURN_PART = qr,VEC\s*\([^\)]+\)[^\(]*,;
+
+# Match the TARGET_DEFAULT_* attribute for a method.
+$TARGET_DEFAULT_PART = qr,TARGET_DEFAULT_(?<style>[A-Z_]+)\s*\((?<default_arg>.*)\),;
+
+# Match the introductory line to a method definition.
+$METHOD = ($INTRO_PART . "(?<return_type>" . $SIMPLE_RETURN_PART
+	   . "|" . $VEC_RETURN_PART . ")"
+	   . $NAME_PART . $ARGS_PART);
+
+# Match the arguments and trailing attribute of a method definition.
+$METHOD_TRAILER = qr,(?<args>\(.+\))\s*${TARGET_DEFAULT_PART};$,;
+
+sub trim($) {
+    my ($result) = @_;
+    $result =~ s,^\s*(\S*)\s*$,\1,;
+    return $result;
+}
+
+# Read from the input files until we find the trigger line.
+# Die if not found.
+sub find_trigger() {
+    while (<>) {
+	chomp;
+	return if m/$TRIGGER/;
+    }
+
+    die "could not find trigger line\n";
+}
+
+# Parse arguments into a list.
+sub parse_argtypes($) {
+    my ($typestr) = @_;
+
+    $typestr =~ s/^\((.*)\)$/\1/;
+
+    my (@typelist) = split (/,\s*/, $typestr);
+    my (@result, $iter, $onetype);
+
+    foreach $iter (@typelist) {
+	if ($iter =~ m/^(enum\s+${SYMBOL}\s*)(${SYMBOL})?$/) {
+	    $onetype = $1;
+	} elsif ($iter =~ m/^(.*(enum\s+)?${SYMBOL}.*(\s|\*))${SYMBOL}+$/) {
+	    $onetype = $1;
+	} elsif ($iter eq 'void') {
+	    next;
+	} else {
+	    $onetype = $iter;
+	}
+	push @result, trim ($onetype);
+    }
+
+    return @result;
+}
+
+sub dname($) {
+    my ($name) = @_;
+    $name =~ s/to_/delegate_/;
+    return $name;
+}
+
+# Write function header given name, return type, and argtypes.
+# Returns a list of actual argument names.
+sub write_function_header($$@) {
+    my ($name, $return_type, @argtypes) = @_;
+
+    print "static " . $return_type . "\n";
+    print $name . ' (';
+
+    my $iter;
+    my @argdecls;
+    my @actuals;
+    my $i = 0;
+    foreach $iter (@argtypes) {
+	my $val = $iter;
+
+	if ($iter !~ m,\*$,) {
+	    $val .= ' ';
+	}
+
+	my $vname;
+	if ($i == 0) {
+	    # Just a random nicety.
+	    $vname = 'self';
+	} else {
+	    $vname .= "arg$i";
+	}
+	$val .= $vname;
+
+	push @argdecls, $val;
+	push @actuals, $vname;
+	++$i;
+    }
+
+    print join (', ', @argdecls) . ")\n";
+    print "{\n";
+
+    return @actuals;
+}
+
+# Write out a delegation function.
+sub write_delegator($$@) {
+    my ($name, $return_type, @argtypes) = @_;
+
+    my (@names) = write_function_header (dname ($name), $return_type,
+					 @argtypes);
+
+    print "  $names[0] = $names[0]->beneath;\n";
+    print "  ";
+    if ($return_type ne 'void') {
+	print "return ";
+    }
+    print "$names[0]->" . $name . " (";
+    print join (', ', @names);
+    print ");\n";
+    print "}\n\n";
+}
+
+sub tdname ($) {
+    my ($name) = @_;
+    $name =~ s/to_/tdefault_/;
+    return $name;
+}
+
+# Write out a default function.
+sub write_tdefault($$$$@) {
+    my ($content, $style, $name, $return_type, @argtypes) = @_;
+
+    if ($style eq 'FUNC') {
+	return $content;
+    }
+
+    write_function_header (tdname ($name), $return_type, @argtypes);
+
+    if ($style eq 'RETURN') {
+	print "  return $content;\n";
+    } elsif ($style eq 'NORETURN') {
+	print "  $content;\n";
+    } elsif ($style eq 'IGNORE') {
+	# Nothing.
+    } else {
+	die "unrecognized style: $style\n";
+    }
+
+    print "}\n\n";
+
+    return tdname ($name);
+}
+
+print "/* THIS FILE IS GENERATED -*- buffer-read-only: t -*- */\n";
+print "/* vi:set ro: */\n\n";
+print "/* To regenerate this file, run:*/\n";
+print "/*      make-target-delegates target.h > target-delegates.c */\n";
+
+find_trigger();
+
+%tdefault_names = ();
+@delegators = ();
+$current_line = '';
+while (<>) {
+    chomp;
+    last if m/$ENDER/;
+
+    if ($current_line ne '') {
+	s/^\s*//;
+	$current_line .= $_;
+    } elsif (m/$METHOD/) {
+	$name = $+{name};
+	$current_line = $+{args};
+	$return_type = trim ($+{return_type});
+    }
+
+    if ($current_line =~ /\);\s*$/) {
+	if ($current_line =~ m,$METHOD_TRAILER,) {
+	    $current_args = $+{args};
+	    $tdefault = $+{default_arg};
+	    $style = $+{style};
+
+	    @argtypes = parse_argtypes ($current_args);
+
+	    # The first argument must be "this" to be delegatable.
+	    if ($argtypes[0] =~ /\s*struct\s+target_ops\s*\*\s*/) {
+		write_delegator ($name, $return_type, @argtypes);
+
+		push @delegators, $name;
+
+		$tdefault_names{$name} = write_tdefault ($tdefault, $style,
+							 $name, $return_type,
+							 @argtypes);
+	    }
+	}
+
+	$current_line = '';
+    }
+}
+
+# Now the delegation code.
+print "static void\ninstall_delegators (struct target_ops *ops)\n{\n";
+
+for $iter (@delegators) {
+    print "  if (ops->" . $iter . " == NULL)\n";
+    print "    ops->" . $iter . " = " . dname ($iter) . ";\n";
+}
+print "}\n\n";
+
+# Now the default method code.
+print "static void\ninstall_dummy_methods (struct target_ops *ops)\n{\n";
+
+for $iter (@delegators) {
+    print "  ops->" . $iter . " = " . $tdefault_names{$iter} . ";\n";
+}
+print "}\n";
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
new file mode 100644
index 0000000..cf6364d
--- /dev/null
+++ b/gdb/target-delegates.c
@@ -0,0 +1,14 @@
+/* THIS FILE IS GENERATED -*- buffer-read-only: t -*- */
+/* vi:set ro: */
+
+/* To regenerate this file, run:*/
+/*      make-target-delegates target.h > target-delegates.c */
+static void
+install_delegators (struct target_ops *ops)
+{
+}
+
+static void
+install_dummy_methods (struct target_ops *ops)
+{
+}
diff --git a/gdb/target.c b/gdb/target.c
index c9f004a..3109559 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -79,6 +79,8 @@ static target_xfer_partial_ftype current_xfer_partial;
 static struct gdbarch *default_thread_architecture (struct target_ops *ops,
 						    ptid_t ptid);
 
+#include "target-delegates.c"
+
 static void init_dummy_target (void);
 
 static struct target_ops debug_target;
@@ -353,6 +355,8 @@ complete_target_initialization (struct target_ops *t)
 
   if (t->to_has_execution == NULL)
     t->to_has_execution = (int (*) (struct target_ops *, ptid_t)) return_zero;
+
+  install_delegators (t);
 }
 
 /* Add possible target architecture T to the list and add a new
@@ -560,6 +564,9 @@ update_current_target (void)
   /* First, reset current's contents.  */
   memset (&current_target, 0, sizeof (current_target));
 
+  /* Install the delegators.  */
+  install_delegators (&current_target);
+
 #define INHERIT(FIELD, TARGET) \
       if (!current_target.FIELD) \
 	current_target.FIELD = (TARGET)->FIELD
@@ -3820,6 +3827,8 @@ init_dummy_target (void)
   dummy_target.to_stopped_data_address =
     (int (*) (struct target_ops *, CORE_ADDR *)) return_zero;
   dummy_target.to_magic = OPS_MAGIC;
+
+  install_dummy_methods (&dummy_target);
 }
 \f
 static void
diff --git a/gdb/target.h b/gdb/target.h
index 07d0afd..19db907 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -350,6 +350,30 @@ struct thread_info;		/* fwd decl for parameter list below: */
 typedef void async_callback_ftype (enum inferior_event_type event_type,
 				   void *context);
 
+/* These defines are used to mark target_ops methods.  The script
+   make-target-delegates scans these and auto-generates the base
+   method implementations.  There are four macros that can be used:
+   
+   1. TARGET_DEFAULT_IGNORE.  There is no argument.  The base method
+   does nothing.  This is only valid if the method return type is
+   'void'.
+   
+   2. TARGET_DEFAULT_NORETURN.  The argument is a function call, like
+   'tcomplain ()'.  The base method simply makes this call, which is
+   assumed not to return.
+   
+   3. TARGET_DEFAULT_RETURN.  The argument is a C expression.  The
+   base method returns this expression's value.
+   
+   4. TARGET_DEFAULT_FUNC.  The argument is the name of a function.
+   make-target-delegates does not generate a base method in this case,
+   but instead uses the argument function as the base method.  */
+
+#define TARGET_DEFAULT_IGNORE()
+#define TARGET_DEFAULT_NORETURN(ARG)
+#define TARGET_DEFAULT_RETURN(ARG)
+#define TARGET_DEFAULT_FUNC(ARG)
+
 struct target_ops
   {
     struct target_ops *beneath;	/* To the target under this one.  */
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 16/38] Add target_ops argument to to_static_tracepoint_markers_by_strid
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
@ 2014-02-06 20:55 ` Tom Tromey
  2014-02-06 20:55 ` [RFC v2 09/38] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
                   ` (38 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (target_static_tracepoint_markers_by_strid): Add
	argument.
	(struct target_ops) <to_static_tracepoint_markers_by_strid>: Add
	'self' argument.
	* target.c (update_current_target): Update.
	* remote.c (struct target_ops)
	<to_static_tracepoint_markers_by_strid>: Add 'self' argument.
	* linux-nat.c (struct target_ops)
	<to_static_tracepoint_markers_by_strid>: Add 'self' argument.

Add target_ops argument to to_traceframe_info

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

	* tracepoint.c (tfile_traceframe_info): Add 'self' argument.
	* target.h (struct target_ops) <to_traceframe_info>: Add argument.
	(target_traceframe_info): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_traceframe_info): Add 'self' argument.
	* ctf.c (ctf_traceframe_info): Add 'self' argument.

Add target_ops argument to to_use_agent

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

	* target.h (struct target_ops) <to_use_agent>: Add argument.
	(target_use_agent): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_use_agent): Add 'self' argument.
	* inf-child.c (inf_child_use_agent): Add 'self' argument.

Add target_ops argument to to_can_use_agent

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

	* target.h (struct target_ops) <to_can_use_agent>: Add argument.
	(target_can_use_agent): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_can_use_agent): Add 'self' argument.
	* inf-child.c (inf_child_can_use_agent): Add 'self' argument.

Add target_ops argument to to_enable_btrace

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

	* target.h (struct target_ops) <to_enable_btrace>: Add argument.
	* target.c (target_enable_btrace): Add argument.
	* remote.c (remote_enable_btrace): Add 'self' argument.
	* i386-linux-nat.c (i386_linux_enable_btrace): Add 'self'
	argument.
	* amd64-linux-nat.c (amd64_linux_enable_btrace): Add 'self'
	argument.

Add target_ops argument to to_disable_btrace

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

	* target.h (struct target_ops) <to_disable_btrace>: Add argument.
	* target.c (target_disable_btrace): Add argument.
	* remote.c (remote_disable_btrace): Add 'self' argument.
	* i386-linux-nat.c (i386_linux_disable_btrace): Add 'self'
	argument.
	* amd64-linux-nat.c (amd64_linux_disable_btrace): Add 'self'
	argument.

Add target_ops argument to to_teardown_btrace

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

	* target.h (struct target_ops) <to_teardown_btrace>: Add argument.
	* target.c (target_teardown_btrace): Add argument.
	* remote.c (remote_teardown_btrace): Add 'self' argument.
	* i386-linux-nat.c (i386_linux_teardown_btrace): Add 'self'
	argument.
	* amd64-linux-nat.c (amd64_linux_teardown_btrace): Add 'self'
	argument.

Add target_ops argument to to_read_btrace

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

	* target.h (struct target_ops) <to_read_btrace>: Add argument.
	* target.c (struct target_ops) <to_read_btrace>: Add argument.
	* remote.c (struct target_ops) <to_read_btrace>: Add 'self'
	argument.
	* amd64-linux-nat.c (amd64_linux_read_btrace): New function.
	(_initialize_amd64_linux_nat): Use it.
	* i386-linux-nat.c (i386_linux_read_btrace): New function.
	(_initialize_i386_linux_nat): Use it.

Add target_ops argument to to_stop_recording

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

	* target.h (struct target_ops) <to_stop_recording>: Add argument.
	* target.c (target_stop_recording): Add argument.
	* record.c (record_stop): Add argument.
	* record-btrace.c (record_btrace_stop_recording): Add 'self'
	argument.

Add target_ops argument to to_info_record

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

	* target.h (struct target_ops) <to_info_record>: Add argument.
	* target.c (target_info_record): Add argument.
	* record.c (info_record_command): Add argument.
	* record-full.c (record_full_info): Add 'self' argument.
	* record-btrace.c (record_btrace_info): Add 'self' argument.
---
 gdb/ChangeLog         | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/amd64-linux-nat.c | 19 ++++++++---
 gdb/ctf.c             |  2 +-
 gdb/i386-linux-nat.c  | 19 ++++++++---
 gdb/inf-child.c       |  4 +--
 gdb/linux-nat.c       |  3 +-
 gdb/record-btrace.c   |  4 +--
 gdb/record-full.c     |  2 +-
 gdb/record.c          |  4 +--
 gdb/remote.c          | 20 ++++++-----
 gdb/target.c          | 21 ++++++------
 gdb/target.h          | 33 ++++++++++--------
 gdb/tracepoint.c      |  2 +-
 13 files changed, 177 insertions(+), 50 deletions(-)

diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index af84142..b7b889b 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -1150,7 +1150,7 @@ amd64_linux_read_description (struct target_ops *ops)
 /* Enable branch tracing.  */
 
 static struct btrace_target_info *
-amd64_linux_enable_btrace (ptid_t ptid)
+amd64_linux_enable_btrace (struct target_ops *self, ptid_t ptid)
 {
   struct btrace_target_info *tinfo;
   struct gdbarch *gdbarch;
@@ -1172,7 +1172,8 @@ amd64_linux_enable_btrace (ptid_t ptid)
 /* Disable branch tracing.  */
 
 static void
-amd64_linux_disable_btrace (struct btrace_target_info *tinfo)
+amd64_linux_disable_btrace (struct target_ops *self,
+			    struct btrace_target_info *tinfo)
 {
   enum btrace_error errcode = linux_disable_btrace (tinfo);
 
@@ -1183,12 +1184,22 @@ amd64_linux_disable_btrace (struct btrace_target_info *tinfo)
 /* Teardown branch tracing.  */
 
 static void
-amd64_linux_teardown_btrace (struct btrace_target_info *tinfo)
+amd64_linux_teardown_btrace (struct target_ops *self,
+			     struct btrace_target_info *tinfo)
 {
   /* Ignore errors.  */
   linux_disable_btrace (tinfo);
 }
 
+static enum btrace_error
+amd64_linux_read_btrace (struct target_ops *self,
+			 VEC (btrace_block_s) **data,
+			 struct btrace_target_info *btinfo,
+			 enum btrace_read_type type)
+{
+  return linux_read_btrace (data, btinfo, type);
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_amd64_linux_nat (void);
 
@@ -1232,7 +1243,7 @@ _initialize_amd64_linux_nat (void)
   t->to_enable_btrace = amd64_linux_enable_btrace;
   t->to_disable_btrace = amd64_linux_disable_btrace;
   t->to_teardown_btrace = amd64_linux_teardown_btrace;
-  t->to_read_btrace = linux_read_btrace;
+  t->to_read_btrace = amd64_linux_read_btrace;
 
   /* Register the target.  */
   linux_nat_add_target (t);
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 67cc1c7..8b6a717 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1755,7 +1755,7 @@ ctf_thread_alive (struct target_ops *ops, ptid_t ptid)
    traceframe_info.  */
 
 static struct traceframe_info *
-ctf_traceframe_info (void)
+ctf_traceframe_info (struct target_ops *self)
 {
   struct traceframe_info *info = XCNEW (struct traceframe_info);
   const char *name;
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index f7be40c..84f20ab 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -1061,7 +1061,7 @@ i386_linux_read_description (struct target_ops *ops)
 /* Enable branch tracing.  */
 
 static struct btrace_target_info *
-i386_linux_enable_btrace (ptid_t ptid)
+i386_linux_enable_btrace (struct target_ops *self, ptid_t ptid)
 {
   struct btrace_target_info *tinfo;
   struct gdbarch *gdbarch;
@@ -1083,7 +1083,8 @@ i386_linux_enable_btrace (ptid_t ptid)
 /* Disable branch tracing.  */
 
 static void
-i386_linux_disable_btrace (struct btrace_target_info *tinfo)
+i386_linux_disable_btrace (struct target_ops *self,
+			   struct btrace_target_info *tinfo)
 {
   enum btrace_error errcode = linux_disable_btrace (tinfo);
 
@@ -1094,12 +1095,22 @@ i386_linux_disable_btrace (struct btrace_target_info *tinfo)
 /* Teardown branch tracing.  */
 
 static void
-i386_linux_teardown_btrace (struct btrace_target_info *tinfo)
+i386_linux_teardown_btrace (struct target_ops *self,
+			    struct btrace_target_info *tinfo)
 {
   /* Ignore errors.  */
   linux_disable_btrace (tinfo);
 }
 
+static enum btrace_error
+i386_linux_read_btrace (struct target_ops *self,
+			VEC (btrace_block_s) **data,
+			struct btrace_target_info *btinfo,
+			enum btrace_read_type type)
+{
+  return linux_read_btrace (data, btinfo, type);
+}
+
 /* -Wmissing-prototypes */
 extern initialize_file_ftype _initialize_i386_linux_nat;
 
@@ -1138,7 +1149,7 @@ _initialize_i386_linux_nat (void)
   t->to_enable_btrace = i386_linux_enable_btrace;
   t->to_disable_btrace = i386_linux_disable_btrace;
   t->to_teardown_btrace = i386_linux_teardown_btrace;
-  t->to_read_btrace = linux_read_btrace;
+  t->to_read_btrace = i386_linux_read_btrace;
 
   /* Register the target.  */
   linux_nat_add_target (t);
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 054e279..fd03a9f 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -372,7 +372,7 @@ inf_child_fileio_readlink (struct target_ops *self,
 }
 
 static int
-inf_child_use_agent (int use)
+inf_child_use_agent (struct target_ops *self, int use)
 {
   if (agent_loaded_p ())
     {
@@ -384,7 +384,7 @@ inf_child_use_agent (int use)
 }
 
 static int
-inf_child_can_use_agent (void)
+inf_child_can_use_agent (struct target_ops *self)
 {
   return agent_loaded_p ();
 }
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index a1dc8fa..e0d6bd0 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4392,7 +4392,8 @@ cleanup_target_stop (void *arg)
 }
 
 static VEC(static_tracepoint_marker_p) *
-linux_child_static_tracepoint_markers_by_strid (const char *strid)
+linux_child_static_tracepoint_markers_by_strid (struct target_ops *self,
+						const char *strid)
 {
   char s[IPA_CMD_BUF_SIZE];
   struct cleanup *old_chain;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 94ff83d..9f7951d 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -195,7 +195,7 @@ record_btrace_open (char *args, int from_tty)
 /* The to_stop_recording method of target record-btrace.  */
 
 static void
-record_btrace_stop_recording (void)
+record_btrace_stop_recording (struct target_ops *self)
 {
   struct thread_info *tp;
 
@@ -228,7 +228,7 @@ record_btrace_close (struct target_ops *self)
 /* The to_info_record method of target record-btrace.  */
 
 static void
-record_btrace_info (void)
+record_btrace_info (struct target_ops *self)
 {
   struct btrace_thread_info *btinfo;
   struct thread_info *tp;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 755c815..2b62f3e 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1770,7 +1770,7 @@ record_full_execution_direction (struct target_ops *self)
 }
 
 static void
-record_full_info (void)
+record_full_info (struct target_ops *self)
 {
   struct record_full_entry *p;
 
diff --git a/gdb/record.c b/gdb/record.c
index 41e167f..9dd02e8 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -115,7 +115,7 @@ record_stop (struct target_ops *t)
   DEBUG ("stop %s", t->to_shortname);
 
   if (t->to_stop_recording != NULL)
-    t->to_stop_recording ();
+    t->to_stop_recording (t);
 }
 
 /* Unpush the record target.  */
@@ -287,7 +287,7 @@ info_record_command (char *args, int from_tty)
 
   printf_filtered (_("Active record target: %s\n"), t->to_shortname);
   if (t->to_info_record != NULL)
-    t->to_info_record ();
+    t->to_info_record (t);
 }
 
 /* The "record save" command.  */
diff --git a/gdb/remote.c b/gdb/remote.c
index ce9bfd4..e2cefe0 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2986,7 +2986,8 @@ remote_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR addr,
 }
 
 static VEC(static_tracepoint_marker_p) *
-remote_static_tracepoint_markers_by_strid (const char *strid)
+remote_static_tracepoint_markers_by_strid (struct target_ops *self,
+					   const char *strid)
 {
   struct remote_state *rs = get_remote_state ();
   VEC(static_tracepoint_marker_p) *markers = NULL;
@@ -11243,7 +11244,7 @@ remote_set_circular_trace_buffer (struct target_ops *self, int val)
 }
 
 static struct traceframe_info *
-remote_traceframe_info (void)
+remote_traceframe_info (struct target_ops *self)
 {
   char *text;
 
@@ -11381,7 +11382,7 @@ remote_set_trace_notes (struct target_ops *self,
 }
 
 static int
-remote_use_agent (int use)
+remote_use_agent (struct target_ops *self, int use)
 {
   if (remote_protocol_packets[PACKET_QAgent].support != PACKET_DISABLE)
     {
@@ -11403,7 +11404,7 @@ remote_use_agent (int use)
 }
 
 static int
-remote_can_use_agent (void)
+remote_can_use_agent (struct target_ops *self)
 {
   return (remote_protocol_packets[PACKET_QAgent].support != PACKET_DISABLE);
 }
@@ -11432,7 +11433,7 @@ remote_supports_btrace (struct target_ops *self)
 /* Enable branch tracing.  */
 
 static struct btrace_target_info *
-remote_enable_btrace (ptid_t ptid)
+remote_enable_btrace (struct target_ops *self, ptid_t ptid)
 {
   struct btrace_target_info *tinfo = NULL;
   struct packet_config *packet = &remote_protocol_packets[PACKET_Qbtrace_bts];
@@ -11468,7 +11469,8 @@ remote_enable_btrace (ptid_t ptid)
 /* Disable branch tracing.  */
 
 static void
-remote_disable_btrace (struct btrace_target_info *tinfo)
+remote_disable_btrace (struct target_ops *self,
+		       struct btrace_target_info *tinfo)
 {
   struct packet_config *packet = &remote_protocol_packets[PACKET_Qbtrace_off];
   struct remote_state *rs = get_remote_state ();
@@ -11500,7 +11502,8 @@ remote_disable_btrace (struct btrace_target_info *tinfo)
 /* Teardown branch tracing.  */
 
 static void
-remote_teardown_btrace (struct btrace_target_info *tinfo)
+remote_teardown_btrace (struct target_ops *self,
+			struct btrace_target_info *tinfo)
 {
   /* We must not talk to the target during teardown.  */
   xfree (tinfo);
@@ -11509,7 +11512,8 @@ remote_teardown_btrace (struct btrace_target_info *tinfo)
 /* Read the branch trace.  */
 
 static enum btrace_error
-remote_read_btrace (VEC (btrace_block_s) **btrace,
+remote_read_btrace (struct target_ops *self,
+		    VEC (btrace_block_s) **btrace,
 		    struct btrace_target_info *tinfo,
 		    enum btrace_read_type type)
 {
diff --git a/gdb/target.c b/gdb/target.c
index 379c4d2..ab4f1ff 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -928,10 +928,11 @@ update_current_target (void)
 		      CORE_ADDR, struct static_tracepoint_marker *))
 	    return_zero);
   de_fault (to_static_tracepoint_markers_by_strid,
-	    (VEC(static_tracepoint_marker_p) * (*) (const char *))
+	    (VEC(static_tracepoint_marker_p) * (*) (struct target_ops *,
+						    const char *))
 	    tcomplain);
   de_fault (to_traceframe_info,
-	    (struct traceframe_info * (*) (void))
+	    (struct traceframe_info * (*) (struct target_ops *))
 	    return_null);
   de_fault (to_supports_evaluation_of_breakpoint_conditions,
 	    (int (*) (struct target_ops *))
@@ -940,10 +941,10 @@ update_current_target (void)
 	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_use_agent,
-	    (int (*) (int))
+	    (int (*) (struct target_ops *, int))
 	    tcomplain);
   de_fault (to_can_use_agent,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_augmented_libraries_svr4_read,
 	    (int (*) (void))
@@ -4137,7 +4138,7 @@ target_enable_btrace (ptid_t ptid)
 
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_enable_btrace != NULL)
-      return t->to_enable_btrace (ptid);
+      return t->to_enable_btrace (t, ptid);
 
   tcomplain ();
   return NULL;
@@ -4153,7 +4154,7 @@ target_disable_btrace (struct btrace_target_info *btinfo)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_disable_btrace != NULL)
       {
-	t->to_disable_btrace (btinfo);
+	t->to_disable_btrace (t, btinfo);
 	return;
       }
 
@@ -4170,7 +4171,7 @@ target_teardown_btrace (struct btrace_target_info *btinfo)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_teardown_btrace != NULL)
       {
-	t->to_teardown_btrace (btinfo);
+	t->to_teardown_btrace (t, btinfo);
 	return;
       }
 
@@ -4188,7 +4189,7 @@ target_read_btrace (VEC (btrace_block_s) **btrace,
 
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_read_btrace != NULL)
-      return t->to_read_btrace (btrace, btinfo, type);
+      return t->to_read_btrace (t, btrace, btinfo, type);
 
   tcomplain ();
   return BTRACE_ERR_NOT_SUPPORTED;
@@ -4204,7 +4205,7 @@ target_stop_recording (void)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_stop_recording != NULL)
       {
-	t->to_stop_recording ();
+	t->to_stop_recording (t);
 	return;
       }
 
@@ -4221,7 +4222,7 @@ target_info_record (void)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_info_record != NULL)
       {
-	t->to_info_record ();
+	t->to_info_record (t);
 	return;
       }
 
diff --git a/gdb/target.h b/gdb/target.h
index 56fbd96..572671c 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -860,7 +860,7 @@ struct target_ops
     /* Return a vector of all tracepoints markers string id ID, or all
        markers if ID is NULL.  */
     VEC(static_tracepoint_marker_p) *(*to_static_tracepoint_markers_by_strid)
-      (const char *id);
+      (struct target_ops *, const char *id);
 
     /* Return a traceframe info object describing the current
        traceframe's contents.  If the target doesn't support
@@ -875,14 +875,14 @@ struct target_ops
        is available in the read-only sections.  This method should not
        cache data; higher layers take care of caching, invalidating,
        and re-fetching when necessary.  */
-    struct traceframe_info *(*to_traceframe_info) (void);
+    struct traceframe_info *(*to_traceframe_info) (struct target_ops *);
 
     /* Ask the target to use or not to use agent according to USE.  Return 1
        successful, 0 otherwise.  */
-    int (*to_use_agent) (int use);
+    int (*to_use_agent) (struct target_ops *, int use);
 
     /* Is the target able to use agent in current state?  */
-    int (*to_can_use_agent) (void);
+    int (*to_can_use_agent) (struct target_ops *);
 
     /* Check whether the target supports branch tracing.  */
     int (*to_supports_btrace) (struct target_ops *)
@@ -890,30 +890,34 @@ struct target_ops
 
     /* Enable branch tracing for PTID and allocate a branch trace target
        information struct for reading and for disabling branch trace.  */
-    struct btrace_target_info *(*to_enable_btrace) (ptid_t ptid);
+    struct btrace_target_info *(*to_enable_btrace) (struct target_ops *,
+						    ptid_t ptid);
 
     /* Disable branch tracing and deallocate TINFO.  */
-    void (*to_disable_btrace) (struct btrace_target_info *tinfo);
+    void (*to_disable_btrace) (struct target_ops *,
+			       struct btrace_target_info *tinfo);
 
     /* Disable branch tracing and deallocate TINFO.  This function is similar
        to to_disable_btrace, except that it is called during teardown and is
        only allowed to perform actions that are safe.  A counter-example would
        be attempting to talk to a remote target.  */
-    void (*to_teardown_btrace) (struct btrace_target_info *tinfo);
+    void (*to_teardown_btrace) (struct target_ops *,
+				struct btrace_target_info *tinfo);
 
     /* Read branch trace data for the thread indicated by BTINFO into DATA.
        DATA is cleared before new trace is added.
        The branch trace will start with the most recent block and continue
        towards older blocks.  */
-    enum btrace_error (*to_read_btrace) (VEC (btrace_block_s) **data,
+    enum btrace_error (*to_read_btrace) (struct target_ops *self,
+					 VEC (btrace_block_s) **data,
 					 struct btrace_target_info *btinfo,
 					 enum btrace_read_type type);
 
     /* Stop trace recording.  */
-    void (*to_stop_recording) (void);
+    void (*to_stop_recording) (struct target_ops *);
 
     /* Print information about the recording.  */
-    void (*to_info_record) (void);
+    void (*to_info_record) (struct target_ops *);
 
     /* Save the recorded execution trace into a file.  */
     void (*to_save_record) (const char *filename);
@@ -1859,16 +1863,17 @@ extern char *target_fileio_read_stralloc (const char *filename);
 						    addr, marker)
 
 #define target_static_tracepoint_markers_by_strid(marker_id) \
-  (*current_target.to_static_tracepoint_markers_by_strid) (marker_id)
+  (*current_target.to_static_tracepoint_markers_by_strid) (&current_target, \
+							   marker_id)
 
 #define target_traceframe_info() \
-  (*current_target.to_traceframe_info) ()
+  (*current_target.to_traceframe_info) (&current_target)
 
 #define target_use_agent(use) \
-  (*current_target.to_use_agent) (use)
+  (*current_target.to_use_agent) (&current_target, use)
 
 #define target_can_use_agent() \
-  (*current_target.to_can_use_agent) ()
+  (*current_target.to_can_use_agent) (&current_target)
 
 #define target_augmented_libraries_svr4_read() \
   (*current_target.to_augmented_libraries_svr4_read) ()
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index a3d5405..e745edb 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -5325,7 +5325,7 @@ build_traceframe_info (char blocktype, void *data)
 }
 
 static struct traceframe_info *
-tfile_traceframe_info (void)
+tfile_traceframe_info (struct target_ops *self)
 {
   struct traceframe_info *info = XCNEW (struct traceframe_info);
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 08/38] Add target_ops argument to to_terminal_init
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (2 preceding siblings ...)
  2014-02-06 20:55 ` [RFC v2 03/38] add make-target-delegates Tom Tromey
@ 2014-02-06 20:55 ` Tom Tromey
  2014-02-06 20:55 ` [RFC v2 02/38] introduce and use find_target_at Tom Tromey
                   ` (35 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_terminal_init>: Add argument.
	(target_terminal_init): Add argument.
	* target.c (debug_to_terminal_init): Add argument.
	(update_current_target): Update.
	* inflow.c (terminal_init_inferior): Add 'self' argument.
	* inferior.h (terminal_init_inferior): Add 'self' argument.
	* go32-nat.c (go32_terminal_init): Add 'self' argument.
	* gnu-nat.c (gnu_terminal_init_inferior): Add 'self' argument.

Add target_ops argument to to_terminal_inferior

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

	* target.h (struct target_ops) <to_terminal_inferior>: Add
	argument.
	* target.c (target_terminal_inferior): Add argument.
	(update_current_target): Update.
	* remote.c (remote_terminal_inferior): Add 'self' argument.
	* linux-nat.c (linux_nat_terminal_inferior): Add 'self' argument.
	* inflow.c (terminal_inferior): Add 'self' argument.
	* inferior.h (terminal_inferior): Add 'self' argument.
	* go32-nat.c (go32_terminal_inferior): Add 'self' argument.
	(go32_terminal_inferior): Add 'self' argument.

Add target_ops argument to to_terminal_ours_for_output

2014-02-06  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_terminal_ours_for_output>: Add
	argument.
	(target_terminal_ours_for_output): Add argument.
	* target.c (debug_to_terminal_ours_for_output): Add argument.
	(update_current_target): Update.
	* inflow.c (terminal_ours_for_output): Add 'self' argument.
	* inferior.h (terminal_ours_for_output): Add 'self' argument.
	* go32-nat.c (go32_terminal_ours): Add 'self' argument.

Add target_ops argument to to_terminal_ours

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

	* target.h (struct target_ops) <to_terminal_ours>: Add argument.
	(target_terminal_ours): Add argument.
	* target.c (debug_to_terminal_ours): Add argument.
	(update_current_target): Update.
	* remote.c (remote_terminal_ours): Add 'self' argument.
	(remote_close): Update.
	* linux-nat.c (linux_nat_terminal_ours): Add 'self' argument.
	* inflow.c (terminal_ours): Add 'self' argument.
	* inferior.h (terminal_ours): Add 'self' argument.
	* go32-nat.c (go32_terminal_ours): Add 'self' argument.

Add target_ops argument to to_terminal_save_ours

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

	* target.h (struct target_ops) <to_terminal_save_ours>: Add
	argument.
	(target_terminal_save_ours): Add argument.
	* target.c (debug_to_terminal_save_ours): Add argument.
	(update_current_target): Update.
	* inflow.c (terminal_save_ours): Add 'self' argument.
	* inferior.h (terminal_save_ours): Add 'self' argument.

Add target_ops argument to to_terminal_info

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

	* target.h (struct target_ops) <to_terminal_info>: Add argument.
	(target_terminal_info): Add argument.
	* target.c (debug_to_terminal_info): Add argument.
	(default_terminal_info): Likewise.
	* inflow.c (child_terminal_info): Add 'self' argument.
	* inferior.h (child_terminal_info): Add 'self' argument.
	* go32-nat.c (go32_terminal_info): Add 'self' argument.

Add target_ops argument to to_load

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

	* target.h (struct target_ops) <to_load>: Add argument.
	* target.c (target_load): Add argument.
	(debug_to_load): Add argument.
	(update_current_target): Update.
	* remote.c (remote_load): Add 'self' argument.
	* remote-sim.c (gdbsim_load): Add 'self' argument.
	* remote-mips.c (mips_load): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_load): Add 'self' argument.
	* monitor.c (monitor_load): Add 'self' argument.
	* m32r-rom.c (m32r_load_gen): Add 'self' argument.

Add target_ops argument to to_post_startup_inferior

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

	* target.h (struct target_ops) <to_post_startup_inferior>: Add
	argument.
	(target_post_startup_inferior): Add argument.
	* target.c (debug_to_post_startup_inferior): Add argument.
	(update_current_target): Update.
	* spu-linux-nat.c (spu_child_post_startup_inferior): Add 'self'
	argument.
	* linux-nat.c (linux_child_post_startup_inferior): Add 'self'
	argument.
	* inf-ptrace.c (inf_ptrace_post_startup_inferior): Add 'self'
	argument.
	* inf-child.c (inf_child_post_startup_inferior): Add 'self'
	argument.
	* i386-linux-nat.c (i386_linux_child_post_startup_inferior): Add
	'self' argument.
	(super_post_startup_inferior): Likewise.
	* amd64-linux-nat.c (amd64_linux_child_post_startup_inferior): Add
	'self' argument.
	(super_post_startup_inferior): Likewise.
	* aarch64-linux-nat.c (aarch64_linux_child_post_startup_inferior):
	Add 'self' argument.
	(super_post_startup_inferior): Likewise.

Add target_ops argument to to_insert_fork_catchpoint

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

	* target.h (struct target_ops) <to_insert_fork_catchpoint>: Add
	argument.
	(target_insert_fork_catchpoint): Add argument.
	* target.c (debug_to_insert_fork_catchpoint): Add argument.
	(update_current_target): Update.
	* linux-nat.c (linux_child_insert_fork_catchpoint): Add 'self'
	argument.

Add target_ops argument to to_remove_fork_catchpoint

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

	* target.h (struct target_ops) <to_remove_fork_catchpoint>: Add
	argument.
	(target_remove_fork_catchpoint): Add argument.
	* target.c (debug_to_remove_fork_catchpoint): Add argument.
	(update_current_target): Update.
	* linux-nat.c (linux_child_remove_fork_catchpoint): Add 'self'
	argument.
---
 gdb/ChangeLog           | 127 ++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/aarch64-linux-nat.c |   8 +--
 gdb/amd64-linux-nat.c   |   7 +--
 gdb/gnu-nat.c           |   2 +-
 gdb/go32-nat.c          |   8 +--
 gdb/i386-linux-nat.c    |   7 +--
 gdb/inf-child.c         |   2 +-
 gdb/inf-ptrace.c        |   2 +-
 gdb/inferior.h          |  12 ++---
 gdb/inflow.c            |  12 ++---
 gdb/linux-nat.c         |  18 +++----
 gdb/m32r-rom.c          |   2 +-
 gdb/monitor.c           |   2 +-
 gdb/remote-m32r-sdi.c   |   2 +-
 gdb/remote-mips.c       |   4 +-
 gdb/remote-sim.c        |   4 +-
 gdb/remote.c            |  10 ++--
 gdb/spu-linux-nat.c     |   2 +-
 gdb/target.c            |  79 +++++++++++++++---------------
 gdb/target.h            |  36 +++++++-------
 20 files changed, 239 insertions(+), 107 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index c6437fe..28ad38b 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -828,16 +828,18 @@ aarch64_linux_get_debug_reg_capacity (void)
     }
 }
 
-static void (*super_post_startup_inferior) (ptid_t ptid);
+static void (*super_post_startup_inferior) (struct target_ops *self,
+					    ptid_t ptid);
 
 /* Implement the "to_post_startup_inferior" target_ops method.  */
 
 static void
-aarch64_linux_child_post_startup_inferior (ptid_t ptid)
+aarch64_linux_child_post_startup_inferior (struct target_ops *self,
+					   ptid_t ptid)
 {
   aarch64_forget_process (ptid_get_pid (ptid));
   aarch64_linux_get_debug_reg_capacity ();
-  super_post_startup_inferior (ptid);
+  super_post_startup_inferior (self, ptid);
 }
 
 /* Implement the "to_read_description" target_ops method.  */
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 55973a6..af84142 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -568,13 +568,14 @@ ps_get_thread_area (const struct ps_prochandle *ph,
 }
 \f
 
-static void (*super_post_startup_inferior) (ptid_t ptid);
+static void (*super_post_startup_inferior) (struct target_ops *self,
+					    ptid_t ptid);
 
 static void
-amd64_linux_child_post_startup_inferior (ptid_t ptid)
+amd64_linux_child_post_startup_inferior (struct target_ops *self, ptid_t ptid)
 {
   i386_cleanup_dregs ();
-  super_post_startup_inferior (ptid);
+  super_post_startup_inferior (self, ptid);
 }
 \f
 
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index ca61c11..8591293 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2244,7 +2244,7 @@ gnu_detach (struct target_ops *ops, const char *args, int from_tty)
 }
 \f
 static void
-gnu_terminal_init_inferior (void)
+gnu_terminal_init_inferior (struct target_ops *self)
 {
   gdb_assert (gnu_current_inf);
   terminal_init_inferior_with_pgrp (gnu_current_inf->pid);
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 1529cc3..75f6a3e 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -845,14 +845,14 @@ static int inf_terminal_mode;
 static int terminal_is_ours = 1;
 
 static void
-go32_terminal_init (void)
+go32_terminal_init (struct target_ops *self)
 {
   inf_mode_valid = 0;	/* Reinitialize, in case they are restarting child.  */
   terminal_is_ours = 1;
 }
 
 static void
-go32_terminal_info (const char *args, int from_tty)
+go32_terminal_info (struct target_ops *self, const char *args, int from_tty)
 {
   printf_unfiltered ("Inferior's terminal is in %s mode.\n",
 		     !inf_mode_valid
@@ -882,7 +882,7 @@ go32_terminal_info (const char *args, int from_tty)
 }
 
 static void
-go32_terminal_inferior (void)
+go32_terminal_inferior (struct target_ops *self)
 {
   /* Redirect standard handles as child wants them.  */
   errno = 0;
@@ -903,7 +903,7 @@ go32_terminal_inferior (void)
 }
 
 static void
-go32_terminal_ours (void)
+go32_terminal_ours (struct target_ops *self)
 {
   /* Switch to cooked mode on the gdb terminal and save the inferior
      terminal mode to be restored when it is resumed.  */
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index fdf5dee..f7be40c 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -982,13 +982,14 @@ i386_linux_resume (struct target_ops *ops,
     perror_with_name (("ptrace"));
 }
 
-static void (*super_post_startup_inferior) (ptid_t ptid);
+static void (*super_post_startup_inferior) (struct target_ops *self,
+					    ptid_t ptid);
 
 static void
-i386_linux_child_post_startup_inferior (ptid_t ptid)
+i386_linux_child_post_startup_inferior (struct target_ops *self, ptid_t ptid)
 {
   i386_cleanup_dregs ();
-  super_post_startup_inferior (ptid);
+  super_post_startup_inferior (self, ptid);
 }
 
 /* Get Linux/x86 target description from running target.  */
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index c142912..7726470 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -112,7 +112,7 @@ inf_child_open (char *arg, int from_tty)
 }
 
 static void
-inf_child_post_startup_inferior (ptid_t ptid)
+inf_child_post_startup_inferior (struct target_ops *self, ptid_t ptid)
 {
   /* This version of Unix doesn't require a meaningful "post startup
      inferior" operation by a debugger.  */
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index d054126..7180fb4 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -147,7 +147,7 @@ inf_ptrace_create_inferior (struct target_ops *ops,
 #ifdef PT_GET_PROCESS_STATE
 
 static void
-inf_ptrace_post_startup_inferior (ptid_t pid)
+inf_ptrace_post_startup_inferior (struct target_ops *self, ptid_t pid)
 {
   ptrace_event_t pe;
 
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 290980a8..43e035b 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -125,9 +125,9 @@ extern int disable_randomization;
 
 extern void generic_mourn_inferior (void);
 
-extern void terminal_save_ours (void);
+extern void terminal_save_ours (struct target_ops *self);
 
-extern void terminal_ours (void);
+extern void terminal_ours (struct target_ops *self);
 
 extern CORE_ADDR unsigned_pointer_to_address (struct gdbarch *gdbarch,
 					      struct type *type,
@@ -170,15 +170,15 @@ extern void default_print_registers_info (struct gdbarch *gdbarch,
 					  struct frame_info *frame,
 					  int regnum, int all);
 
-extern void child_terminal_info (const char *, int);
+extern void child_terminal_info (struct target_ops *self, const char *, int);
 
 extern void term_info (char *, int);
 
-extern void terminal_ours_for_output (void);
+extern void terminal_ours_for_output (struct target_ops *self);
 
-extern void terminal_inferior (void);
+extern void terminal_inferior (struct target_ops *self);
 
-extern void terminal_init_inferior (void);
+extern void terminal_init_inferior (struct target_ops *self);
 
 extern void terminal_init_inferior_with_pgrp (int pgrp);
 
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 5503a42..09623ab 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -245,7 +245,7 @@ terminal_init_inferior_with_pgrp (int pgrp)
    and gdb must be able to restore it correctly.  */
 
 void
-terminal_save_ours (void)
+terminal_save_ours (struct target_ops *self)
 {
   if (gdb_has_a_terminal ())
     {
@@ -255,7 +255,7 @@ terminal_save_ours (void)
 }
 
 void
-terminal_init_inferior (void)
+terminal_init_inferior (struct target_ops *self)
 {
 #ifdef PROCESS_GROUP_TYPE
   /* This is for Lynx, and should be cleaned up by having Lynx be a separate
@@ -272,7 +272,7 @@ terminal_init_inferior (void)
    This is preparation for starting or resuming the inferior.  */
 
 void
-terminal_inferior (void)
+terminal_inferior (struct target_ops *self)
 {
   struct inferior *inf;
   struct terminal_info *tinfo;
@@ -353,7 +353,7 @@ terminal_inferior (void)
    should be called to get back to a normal state of affairs.  */
 
 void
-terminal_ours_for_output (void)
+terminal_ours_for_output (struct target_ops *self)
 {
   terminal_ours_1 (1);
 }
@@ -363,7 +363,7 @@ terminal_ours_for_output (void)
    so they can be restored properly later.  */
 
 void
-terminal_ours (void)
+terminal_ours (struct target_ops *self)
 {
   terminal_ours_1 (0);
 }
@@ -562,7 +562,7 @@ term_info (char *arg, int from_tty)
 }
 
 void
-child_terminal_info (const char *args, int from_tty)
+child_terminal_info (struct target_ops *self, const char *args, int from_tty)
 {
   struct inferior *inf;
   struct terminal_info *tinfo;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 0475eb3..45d4053 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -335,7 +335,7 @@ linux_child_post_attach (struct target_ops *self, int pid)
 }
 
 static void
-linux_child_post_startup_inferior (ptid_t ptid)
+linux_child_post_startup_inferior (struct target_ops *self, ptid_t ptid)
 {
   linux_init_ptrace (ptid_get_pid (ptid));
 }
@@ -696,13 +696,13 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
 
 \f
 static int
-linux_child_insert_fork_catchpoint (int pid)
+linux_child_insert_fork_catchpoint (struct target_ops *self, int pid)
 {
   return !linux_supports_tracefork ();
 }
 
 static int
-linux_child_remove_fork_catchpoint (int pid)
+linux_child_remove_fork_catchpoint (struct target_ops *self, int pid)
 {
   return 0;
 }
@@ -4546,16 +4546,16 @@ static int async_terminal_is_ours = 1;
 /* target_terminal_inferior implementation.  */
 
 static void
-linux_nat_terminal_inferior (void)
+linux_nat_terminal_inferior (struct target_ops *self)
 {
   if (!target_is_async_p ())
     {
       /* Async mode is disabled.  */
-      terminal_inferior ();
+      terminal_inferior (self);
       return;
     }
 
-  terminal_inferior ();
+  terminal_inferior (self);
 
   /* Calls to target_terminal_*() are meant to be idempotent.  */
   if (!async_terminal_is_ours)
@@ -4569,19 +4569,19 @@ linux_nat_terminal_inferior (void)
 /* target_terminal_ours implementation.  */
 
 static void
-linux_nat_terminal_ours (void)
+linux_nat_terminal_ours (struct target_ops *self)
 {
   if (!target_is_async_p ())
     {
       /* Async mode is disabled.  */
-      terminal_ours ();
+      terminal_ours (self);
       return;
     }
 
   /* GDB should never give the terminal to the inferior if the
      inferior is running in the background (run&, continue&, etc.),
      but claiming it sure should.  */
-  terminal_ours ();
+  terminal_ours (self);
 
   if (async_terminal_is_ours)
     return;
diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c
index 6219891..2ca23ae 100644
--- a/gdb/m32r-rom.c
+++ b/gdb/m32r-rom.c
@@ -196,7 +196,7 @@ m32r_load (char *filename, int from_tty)
 }
 
 static void
-m32r_load_gen (char *filename, int from_tty)
+m32r_load_gen (struct target_ops *self, char *filename, int from_tty)
 {
   generic_load (filename, from_tty);
 }
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 8129d20..3f5a067 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -2194,7 +2194,7 @@ monitor_wait_srec_ack (void)
 /* monitor_load -- download a file.  */
 
 static void
-monitor_load (char *args, int from_tty)
+monitor_load (struct target_ops *self, char *args, int from_tty)
 {
   CORE_ADDR load_offset = 0;
   char **argv;
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 37649e4..0af8cfc 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1213,7 +1213,7 @@ m32r_remove_breakpoint (struct target_ops *ops,
 }
 
 static void
-m32r_load (char *args, int from_tty)
+m32r_load (struct target_ops *self, char *args, int from_tty)
 {
   struct cleanup *old_chain;
   asection *section;
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index e8ef449..4338ffa 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -128,7 +128,7 @@ static void pmon_download (char *buffer, int length);
 
 static void pmon_load_fast (char *file);
 
-static void mips_load (char *file, int from_tty);
+static void mips_load (struct target_ops *self, char *file, int from_tty);
 
 static int mips_make_srec (char *buffer, int type, CORE_ADDR memaddr,
 			   unsigned char *myaddr, int len);
@@ -3530,7 +3530,7 @@ pmon_load_fast (char *file)
 /* mips_load -- download a file.  */
 
 static void
-mips_load (char *file, int from_tty)
+mips_load (struct target_ops *self, char *file, int from_tty)
 {
   struct regcache *regcache;
 
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 220ce9d..31107f7 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -72,7 +72,7 @@ static void gdb_os_error (host_callback *, const char *, ...)
 
 static void gdbsim_kill (struct target_ops *);
 
-static void gdbsim_load (char *prog, int fromtty);
+static void gdbsim_load (struct target_ops *self, char *prog, int fromtty);
 
 static void gdbsim_open (char *args, int from_tty);
 
@@ -561,7 +561,7 @@ gdbsim_kill (struct target_ops *ops)
    GDB's symbol tables to match.  */
 
 static void
-gdbsim_load (char *args, int fromtty)
+gdbsim_load (struct target_ops *self, char *args, int fromtty)
 {
   char **argv;
   char *prog;
diff --git a/gdb/remote.c b/gdb/remote.c
index dedfc77..8179c9a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -225,7 +225,7 @@ static int peek_stop_reply (ptid_t ptid);
 
 static void remote_async_inferior_event_handler (gdb_client_data);
 
-static void remote_terminal_ours (void);
+static void remote_terminal_ours (struct target_ops *self);
 
 static int remote_read_description_p (struct target_ops *target);
 
@@ -3068,7 +3068,7 @@ remote_close (struct target_ops *self)
 
   /* Make sure we leave stdin registered in the event loop, and we
      don't leave the async SIGINT signal handler installed.  */
-  remote_terminal_ours ();
+  remote_terminal_ours (self);
 
   serial_close (rs->remote_desc);
   rs->remote_desc = NULL;
@@ -5255,7 +5255,7 @@ Give up (and stop debugging it)? ")))
    is required.  */
 
 static void
-remote_terminal_inferior (void)
+remote_terminal_inferior (struct target_ops *self)
 {
   if (!target_async_permitted)
     /* Nothing to do.  */
@@ -5278,7 +5278,7 @@ remote_terminal_inferior (void)
 }
 
 static void
-remote_terminal_ours (void)
+remote_terminal_ours (struct target_ops *self)
 {
   if (!target_async_permitted)
     /* Nothing to do.  */
@@ -11542,7 +11542,7 @@ remote_augmented_libraries_svr4_read (void)
 /* Implementation of to_load.  */
 
 static void
-remote_load (char *name, int from_tty)
+remote_load (struct target_ops *self, char *name, int from_tty)
 {
   generic_load (name, from_tty);
 }
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index ab80abf..ec924cb 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -390,7 +390,7 @@ spu_symbol_file_add_from_memory (int inferior_fd)
 /* Override the post_startup_inferior routine to continue running
    the inferior until the first spu_run system call.  */
 static void
-spu_child_post_startup_inferior (ptid_t ptid)
+spu_child_post_startup_inferior (struct target_ops *self, ptid_t ptid)
 {
   int fd;
   ULONGEST addr;
diff --git a/gdb/target.c b/gdb/target.c
index 7ed433f..02e4c6b 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -47,7 +47,7 @@
 
 static void target_info (char *, int);
 
-static void default_terminal_info (const char *, int);
+static void default_terminal_info (struct target_ops *, const char *, int);
 
 static int default_watchpoint_addr_within_range (struct target_ops *,
 						 CORE_ADDR, CORE_ADDR, int);
@@ -132,17 +132,17 @@ static int debug_to_can_accel_watchpoint_condition (struct target_ops *self,
 						    CORE_ADDR, int, int,
 						    struct expression *);
 
-static void debug_to_terminal_init (void);
+static void debug_to_terminal_init (struct target_ops *self);
 
-static void debug_to_terminal_inferior (void);
+static void debug_to_terminal_inferior (struct target_ops *self);
 
-static void debug_to_terminal_ours_for_output (void);
+static void debug_to_terminal_ours_for_output (struct target_ops *self);
 
-static void debug_to_terminal_save_ours (void);
+static void debug_to_terminal_save_ours (struct target_ops *self);
 
-static void debug_to_terminal_ours (void);
+static void debug_to_terminal_ours (struct target_ops *self);
 
-static void debug_to_load (char *, int);
+static void debug_to_load (struct target_ops *self, char *, int);
 
 static int debug_to_can_run (void);
 
@@ -462,7 +462,7 @@ void
 target_load (char *arg, int from_tty)
 {
   target_dcache_invalidate ();
-  (*current_target.to_load) (arg, from_tty);
+  (*current_target.to_load) (&current_target, arg, from_tty);
 }
 
 void
@@ -500,7 +500,7 @@ target_terminal_inferior (void)
 
   /* If GDB is resuming the inferior in the foreground, install
      inferior's terminal modes.  */
-  (*current_target.to_terminal_inferior) ();
+  (*current_target.to_terminal_inferior) (&current_target);
 }
 
 static int
@@ -525,7 +525,7 @@ noprocess (void)
 }
 
 static void
-default_terminal_info (const char *args, int from_tty)
+default_terminal_info (struct target_ops *self, const char *args, int from_tty)
 {
   printf_unfiltered (_("No saved terminal information.\n"));
 }
@@ -769,33 +769,33 @@ update_current_target (void)
 		      struct expression *))
             return_zero);
   de_fault (to_terminal_init,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_terminal_inferior,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_terminal_ours_for_output,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_terminal_ours,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_terminal_save_ours,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_terminal_info,
 	    default_terminal_info);
   de_fault (to_load,
-	    (void (*) (char *, int))
+	    (void (*) (struct target_ops *, char *, int))
 	    tcomplain);
   de_fault (to_post_startup_inferior,
-	    (void (*) (ptid_t))
+	    (void (*) (struct target_ops *, ptid_t))
 	    target_ignore);
   de_fault (to_insert_fork_catchpoint,
-	    (int (*) (int))
+	    (int (*) (struct target_ops *, int))
 	    return_one);
   de_fault (to_remove_fork_catchpoint,
-	    (int (*) (int))
+	    (int (*) (struct target_ops *, int))
 	    return_one);
   de_fault (to_insert_vfork_catchpoint,
 	    (int (*) (int))
@@ -4738,77 +4738,78 @@ debug_to_remove_watchpoint (struct target_ops *self,
 }
 
 static void
-debug_to_terminal_init (void)
+debug_to_terminal_init (struct target_ops *self)
 {
-  debug_target.to_terminal_init ();
+  debug_target.to_terminal_init (&debug_target);
 
   fprintf_unfiltered (gdb_stdlog, "target_terminal_init ()\n");
 }
 
 static void
-debug_to_terminal_inferior (void)
+debug_to_terminal_inferior (struct target_ops *self)
 {
-  debug_target.to_terminal_inferior ();
+  debug_target.to_terminal_inferior (&debug_target);
 
   fprintf_unfiltered (gdb_stdlog, "target_terminal_inferior ()\n");
 }
 
 static void
-debug_to_terminal_ours_for_output (void)
+debug_to_terminal_ours_for_output (struct target_ops *self)
 {
-  debug_target.to_terminal_ours_for_output ();
+  debug_target.to_terminal_ours_for_output (&debug_target);
 
   fprintf_unfiltered (gdb_stdlog, "target_terminal_ours_for_output ()\n");
 }
 
 static void
-debug_to_terminal_ours (void)
+debug_to_terminal_ours (struct target_ops *self)
 {
-  debug_target.to_terminal_ours ();
+  debug_target.to_terminal_ours (&debug_target);
 
   fprintf_unfiltered (gdb_stdlog, "target_terminal_ours ()\n");
 }
 
 static void
-debug_to_terminal_save_ours (void)
+debug_to_terminal_save_ours (struct target_ops *self)
 {
-  debug_target.to_terminal_save_ours ();
+  debug_target.to_terminal_save_ours (&debug_target);
 
   fprintf_unfiltered (gdb_stdlog, "target_terminal_save_ours ()\n");
 }
 
 static void
-debug_to_terminal_info (const char *arg, int from_tty)
+debug_to_terminal_info (struct target_ops *self,
+			const char *arg, int from_tty)
 {
-  debug_target.to_terminal_info (arg, from_tty);
+  debug_target.to_terminal_info (&debug_target, arg, from_tty);
 
   fprintf_unfiltered (gdb_stdlog, "target_terminal_info (%s, %d)\n", arg,
 		      from_tty);
 }
 
 static void
-debug_to_load (char *args, int from_tty)
+debug_to_load (struct target_ops *self, char *args, int from_tty)
 {
-  debug_target.to_load (args, from_tty);
+  debug_target.to_load (&debug_target, args, from_tty);
 
   fprintf_unfiltered (gdb_stdlog, "target_load (%s, %d)\n", args, from_tty);
 }
 
 static void
-debug_to_post_startup_inferior (ptid_t ptid)
+debug_to_post_startup_inferior (struct target_ops *self, ptid_t ptid)
 {
-  debug_target.to_post_startup_inferior (ptid);
+  debug_target.to_post_startup_inferior (&debug_target, ptid);
 
   fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n",
 		      ptid_get_pid (ptid));
 }
 
 static int
-debug_to_insert_fork_catchpoint (int pid)
+debug_to_insert_fork_catchpoint (struct target_ops *self, int pid)
 {
   int retval;
 
-  retval = debug_target.to_insert_fork_catchpoint (pid);
+  retval = debug_target.to_insert_fork_catchpoint (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
 		      pid, retval);
@@ -4817,11 +4818,11 @@ debug_to_insert_fork_catchpoint (int pid)
 }
 
 static int
-debug_to_remove_fork_catchpoint (int pid)
+debug_to_remove_fork_catchpoint (struct target_ops *self, int pid)
 {
   int retval;
 
-  retval = debug_target.to_remove_fork_catchpoint (pid);
+  retval = debug_target.to_remove_fork_catchpoint (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_remove_fork_catchpoint (%d) = %d\n",
 		      pid, retval);
diff --git a/gdb/target.h b/gdb/target.h
index 50d5c20..2eface1 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -478,19 +478,19 @@ struct target_ops
 					      struct expression *);
     int (*to_masked_watch_num_registers) (struct target_ops *,
 					  CORE_ADDR, CORE_ADDR);
-    void (*to_terminal_init) (void);
-    void (*to_terminal_inferior) (void);
-    void (*to_terminal_ours_for_output) (void);
-    void (*to_terminal_ours) (void);
-    void (*to_terminal_save_ours) (void);
-    void (*to_terminal_info) (const char *, int);
+    void (*to_terminal_init) (struct target_ops *);
+    void (*to_terminal_inferior) (struct target_ops *);
+    void (*to_terminal_ours_for_output) (struct target_ops *);
+    void (*to_terminal_ours) (struct target_ops *);
+    void (*to_terminal_save_ours) (struct target_ops *);
+    void (*to_terminal_info) (struct target_ops *, const char *, int);
     void (*to_kill) (struct target_ops *);
-    void (*to_load) (char *, int);
+    void (*to_load) (struct target_ops *, char *, int);
     void (*to_create_inferior) (struct target_ops *, 
 				char *, char *, char **, int);
-    void (*to_post_startup_inferior) (ptid_t);
-    int (*to_insert_fork_catchpoint) (int);
-    int (*to_remove_fork_catchpoint) (int);
+    void (*to_post_startup_inferior) (struct target_ops *, ptid_t);
+    int (*to_insert_fork_catchpoint) (struct target_ops *, int);
+    int (*to_remove_fork_catchpoint) (struct target_ops *, int);
     int (*to_insert_vfork_catchpoint) (int);
     int (*to_remove_vfork_catchpoint) (int);
     int (*to_follow_fork) (struct target_ops *, int, int);
@@ -1209,7 +1209,7 @@ extern int target_remove_breakpoint (struct gdbarch *gdbarch,
    before we actually run the inferior.  */
 
 #define target_terminal_init() \
-     (*current_target.to_terminal_init) ()
+     (*current_target.to_terminal_init) (&current_target)
 
 /* Put the inferior's terminal settings into effect.
    This is preparation for starting or resuming the inferior.  */
@@ -1225,14 +1225,14 @@ extern void target_terminal_inferior (void);
    should be called to get back to a normal state of affairs.  */
 
 #define target_terminal_ours_for_output() \
-     (*current_target.to_terminal_ours_for_output) ()
+     (*current_target.to_terminal_ours_for_output) (&current_target)
 
 /* Put our terminal settings into effect.
    First record the inferior's terminal settings
    so they can be restored properly later.  */
 
 #define target_terminal_ours() \
-     (*current_target.to_terminal_ours) ()
+     (*current_target.to_terminal_ours) (&current_target)
 
 /* Save our terminal settings.
    This is called from TUI after entering or leaving the curses
@@ -1240,13 +1240,13 @@ extern void target_terminal_inferior (void);
    to take this change into account.  */
 
 #define target_terminal_save_ours() \
-     (*current_target.to_terminal_save_ours) ()
+     (*current_target.to_terminal_save_ours) (&current_target)
 
 /* Print useful information about our terminal status, if such a thing
    exists.  */
 
 #define target_terminal_info(arg, from_tty) \
-     (*current_target.to_terminal_info) (arg, from_tty)
+     (*current_target.to_terminal_info) (&current_target, arg, from_tty)
 
 /* Kill the inferior process.   Make it go away.  */
 
@@ -1285,7 +1285,7 @@ void target_create_inferior (char *exec_file, char *args,
    Such targets will supply an appropriate definition for this function.  */
 
 #define target_post_startup_inferior(ptid) \
-     (*current_target.to_post_startup_inferior) (ptid)
+     (*current_target.to_post_startup_inferior) (&current_target, ptid)
 
 /* On some targets, we can catch an inferior fork or vfork event when
    it occurs.  These functions insert/remove an already-created
@@ -1293,10 +1293,10 @@ void target_create_inferior (char *exec_file, char *args,
    catchpoint type is not supported and -1 for failure.  */
 
 #define target_insert_fork_catchpoint(pid) \
-     (*current_target.to_insert_fork_catchpoint) (pid)
+     (*current_target.to_insert_fork_catchpoint) (&current_target, pid)
 
 #define target_remove_fork_catchpoint(pid) \
-     (*current_target.to_remove_fork_catchpoint) (pid)
+     (*current_target.to_remove_fork_catchpoint) (&current_target, pid)
 
 #define target_insert_vfork_catchpoint(pid) \
      (*current_target.to_insert_vfork_catchpoint) (pid)
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 10/38] Add target_ops argument to to_thread_name
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (8 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 23/38] convert to_disable_tracepoint Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 01/38] add "this" pointers to more target APIs Tom Tromey
                   ` (29 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_thread_name>: Add argument.
	* target.c (target_thread_name): Add argument.
	(update_current_target): Update.
	* linux-nat.c (linux_nat_thread_name): Add 'self' argument.

Add target_ops argument to to_stop

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

	* windows-nat.c (windows_stop): Add 'self' argument.
	* target.h (struct target_ops) <to_stop>: Add argument.
	* target.c (target_stop): Add argument.
	(debug_to_stop): Add argument.
	(update_current_target): Update.
	* remote.c (remote_stop): Add 'self' argument.
	* remote-sim.c (gdbsim_stop): Add 'self' argument.
	(gdbsim_cntrl_c): Update.
	* remote-m32r-sdi.c (m32r_stop): Add 'self' argument.
	* procfs.c (procfs_stop): Add 'self' argument.
	* nto-procfs.c (procfs_stop): Add 'self' argument.
	* monitor.c (monitor_stop): Add 'self' argument.
	(monitor_open): Update.
	* linux-nat.c (linux_nat_stop): Add argument.
	* inf-ptrace.c (inf_ptrace_stop): Add 'self' argument.
	* gnu-nat.c (gnu_stop): Add 'self' argument.
	* darwin-nat.c (darwin_stop): Add 'self' argument.

Add target_ops argument to to_rcmd

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

	* target.h (struct target_ops) <to_rcmd>: Add argument.
	(target_rcmd): Add argument.
	* target.c (debug_to_rcmd): Add argument.
	(update_current_target, do_monitor_command): Update.
	* remote.c (remote_rcmd): Add 'self' argument.
	* monitor.c (monitor_rcmd): Add 'self' argument.

Add target_ops argument to to_pid_to_exec_file

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

	* windows-nat.c (windows_pid_to_exec_file): Add 'self' argument.
	* target.h (struct target_ops) <to_pid_to_exec_file>: Add
	argument.
	(target_pid_to_exec_file): Add argument.
	* target.c (debug_to_pid_to_exec_file): Add argument.
	(update_current_target): Update.
	* nbsd-nat.h (nbsd_pid_to_exec_file): Add 'self' argument.
	* nbsd-nat.c (nbsd_pid_to_exec_file): Add 'self' argument.
	* linux-nat.c (linux_child_pid_to_exec_file): Add 'self' argument.
	(linux_handle_extended_wait): Update.
	* inf-child.c (inf_child_pid_to_exec_file): Add 'self' argument.
	* fbsd-nat.h (fbsd_pid_to_exec_file): Add 'self' argument.
	* fbsd-nat.c (fbsd_pid_to_exec_file): Add 'self' argument.
	* darwin-nat.c (darwin_pid_to_exec_file): Add 'self' argument.

Add target_ops argument to to_log_command

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

	* target.h (struct target_ops) <to_log_command>: Add argument.
	(target_log_command): Add argument.
	* serial.h (serial_log_command): Add 'self' argument.
	* serial.c (serial_log_command): Add 'self' argument.

Add target_ops argument to to_supports_non_stop

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

	* target.h (struct target_ops) <to_supports_non_stop>: Add
	argument.
	* target.c (find_default_supports_non_stop): Add argument.
	(target_supports_non_stop): Add argument.
	(find_default_supports_non_stop): Add 'self' argument.
	* remote.c (remote_supports_non_stop): Add 'self' argument.
	* linux-nat.c (linux_nat_supports_non_stop): Add 'self' argument.

Add target_ops argument to to_find_memory_regions

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

	* target.h (struct target_ops) <to_find_memory_regions>: Add
	argument.
	(target_find_memory_regions): Add argument.
	* target.c (dummy_find_memory_regions): Add 'self' argument.
	* procfs.c (proc_find_memory_regions): Add 'self' argument.
	* gnu-nat.c (gnu_find_memory_regions): Add 'self' argument.
	* fbsd-nat.h (fbsd_find_memory_regions): Add 'self' argument.
	* fbsd-nat.c (fbsd_find_memory_regions): Add 'self' argument.
	* exec. (exec_do_find_memory_regions): New global.
	(exec_set_find_memory_regions): Rewrite.
	(exec_find_memory_regions): New function.
	(init_exec_ops): Use exec_find_memory_regions.

Add target_ops argument to to_make_corefile_notes

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

	* target.h (struct target_ops) <to_make_corefile_notes>: Add
	argument.
	(target_make_corefile_notes): Add argument.
	* target.c (dummy_make_corefile_notes): Add 'self' argument.
	* procfs.c (procfs_make_note_section): Add 'self' argument.
	(procfs_make_note_section): Add 'self' argument.
	(procfs_make_note_section): Add 'self' argument.
	* linux-nat.c (linux_nat_make_corefile_notes): Add 'self'
	argument.
	* fbsd-nat.h (fbsd_make_corefile_notes): Add 'self' argument.
	* fbsd-nat.c (fbsd_make_corefile_notes): Add 'self' argument.
	* exec.c (exec_make_note_section): Add 'self' argument.
	(exec_make_note_section): Add 'self' argument.

Add target_ops argument to to_get_bookmark

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

	* target.h (struct target_ops) <to_get_bookmark>: Add argument.
	(target_get_bookmark): Add argument.
	* target.c (dummy_get_bookmark): Add 'self' argument.
	* record-full.c (record_full_get_bookmark): Add 'self' argument.

Add target_ops argument to to_goto_bookmark

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

	* target.h (struct target_ops) <to_goto_bookmark>: Add argument.
	(target_goto_bookmark): Add argument.
	* target.c (dummy_goto_bookmark): Add 'self' argument.
	* record-full.c (record_full_goto_bookmark): Add 'self' argument.
---
 gdb/ChangeLog         | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/darwin-nat.c      |   6 +--
 gdb/exec.c            |  18 ++++++--
 gdb/fbsd-nat.c        |   7 +--
 gdb/fbsd-nat.h        |   8 ++--
 gdb/gnu-nat.c         |   5 ++-
 gdb/inf-child.c       |   2 +-
 gdb/inf-ptrace.c      |   2 +-
 gdb/linux-nat.c       |  17 ++++----
 gdb/monitor.c         |   8 ++--
 gdb/nbsd-nat.c        |   2 +-
 gdb/nbsd-nat.h        |   2 +-
 gdb/nto-procfs.c      |   2 +-
 gdb/procfs.c          |  17 +++++---
 gdb/record-full.c     |   5 ++-
 gdb/remote-m32r-sdi.c |   2 +-
 gdb/remote-sim.c      |   6 +--
 gdb/remote.c          |   8 ++--
 gdb/serial.c          |   2 +-
 gdb/serial.h          |   2 +-
 gdb/target.c          |  47 +++++++++++----------
 gdb/target.h          |  37 ++++++++--------
 gdb/windows-nat.c     |   6 +--
 23 files changed, 234 insertions(+), 92 deletions(-)

diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index dd4b3ce..70b03a9 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -87,7 +87,7 @@
 
 extern boolean_t exc_server (mach_msg_header_t *in, mach_msg_header_t *out);
 
-static void darwin_stop (ptid_t);
+static void darwin_stop (struct target_ops *self, ptid_t);
 
 static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step,
                               enum gdb_signal signal);
@@ -1144,7 +1144,7 @@ darwin_wait_to (struct target_ops *ops,
 }
 
 static void
-darwin_stop (ptid_t t)
+darwin_stop (struct target_ops *self, ptid_t t)
 {
   struct inferior *inf = current_inferior ();
 
@@ -1976,7 +1976,7 @@ set_enable_mach_exceptions (char *args, int from_tty,
 }
 
 static char *
-darwin_pid_to_exec_file (int pid)
+darwin_pid_to_exec_file (struct target_ops *self, int pid)
 {
   char *path;
   int res;
diff --git a/gdb/exec.c b/gdb/exec.c
index cc7fa13..da0f367 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -62,6 +62,10 @@ void _initialize_exec (void);
 
 struct target_ops exec_ops;
 
+/* Function used to implement to_find_memory_regions.  */
+
+static int (*exec_do_find_memory_regions) (find_memory_region_ftype, void *);
+
 /* True if the exec target is pushed on the stack.  */
 static int using_exec_ops;
 
@@ -821,10 +825,17 @@ exec_has_memory (struct target_ops *ops)
 extern void
 exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *))
 {
-  exec_ops.to_find_memory_regions = func;
+  exec_do_find_memory_regions = func;
+}
+
+static int
+exec_find_memory_regions (struct target_ops *self,
+			  find_memory_region_ftype func, void *data)
+{
+  return exec_do_find_memory_regions (func, data);
 }
 
-static char *exec_make_note_section (bfd *, int *);
+static char *exec_make_note_section (struct target_ops *self, bfd *, int *);
 
 /* Fill in the exec file target vector.  Very few entries need to be
    defined.  */
@@ -848,6 +859,7 @@ Specify the filename of the executable file.";
   exec_ops.to_stratum = file_stratum;
   exec_ops.to_has_memory = exec_has_memory;
   exec_ops.to_make_corefile_notes = exec_make_note_section;
+  exec_ops.to_find_memory_regions = exec_find_memory_regions;
   exec_ops.to_magic = OPS_MAGIC;
 }
 
@@ -895,7 +907,7 @@ Show writing into executable and core files."), NULL,
 }
 
 static char *
-exec_make_note_section (bfd *obfd, int *note_size)
+exec_make_note_section (struct target_ops *self, bfd *obfd, int *note_size)
 {
   error (_("Can't create a corefile"));
 }
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 662fa55..a2a1f60 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -37,7 +37,7 @@
    the child process identified by PID.  */
 
 char *
-fbsd_pid_to_exec_file (int pid)
+fbsd_pid_to_exec_file (struct target_ops *self, int pid)
 {
   size_t len = PATH_MAX;
   char *buf = xcalloc (len, sizeof (char));
@@ -91,7 +91,8 @@ fbsd_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end,
    argument to FUNC.  */
 
 int
-fbsd_find_memory_regions (find_memory_region_ftype func, void *obfd)
+fbsd_find_memory_regions (struct target_ops *self,
+			  find_memory_region_ftype func, void *obfd)
 {
   pid_t pid = ptid_get_pid (inferior_ptid);
   char *mapfilename;
@@ -166,7 +167,7 @@ find_stop_signal (void)
    allocated memory.  */
 
 char *
-fbsd_make_corefile_notes (bfd *obfd, int *note_size)
+fbsd_make_corefile_notes (struct target_ops *self, bfd *obfd, int *note_size)
 {
   const struct regcache *regcache = get_current_regcache ();
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index d9d1443..a3f51d6 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -23,17 +23,19 @@
 /* Return the name of a file that can be opened to get the symbols for
    the child process identified by PID.  */
 
-extern char *fbsd_pid_to_exec_file (int pid);
+extern char *fbsd_pid_to_exec_file (struct target_ops *self, int pid);
 
 /* Iterate over all the memory regions in the current inferior,
    calling FUNC for each memory region.  OBFD is passed as the last
    argument to FUNC.  */
 
-extern int fbsd_find_memory_regions (find_memory_region_ftype func, void *obfd);
+extern int fbsd_find_memory_regions (struct target_ops *self,
+				     find_memory_region_ftype func, void *obfd);
 
 /* Create appropriate note sections for a corefile, returning them in
    allocated memory.  */
 
-extern char *fbsd_make_corefile_notes (bfd *obfd, int *note_size);
+extern char *fbsd_make_corefile_notes (struct target_ops *self,
+				       bfd *obfd, int *note_size);
 
 #endif /* fbsd-nat.h */
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 8591293..da8df80 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2251,7 +2251,7 @@ gnu_terminal_init_inferior (struct target_ops *self)
 }
 
 static void
-gnu_stop (ptid_t ptid)
+gnu_stop (struct target_ops *self, ptid_t ptid)
 {
   error (_("to_stop target function not implemented"));
 }
@@ -2526,7 +2526,8 @@ gnu_xfer_partial (struct target_ops *ops, enum target_object object,
 
 /* Call FUNC on each memory region in the task.  */
 static int
-gnu_find_memory_regions (find_memory_region_ftype func, void *data)
+gnu_find_memory_regions (struct target_ops *self,
+			 find_memory_region_ftype func, void *data)
 {
   error_t err;
   task_t task;
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 37fac4b..e047636 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -134,7 +134,7 @@ inf_child_can_run (struct target_ops *self)
 }
 
 static char *
-inf_child_pid_to_exec_file (int pid)
+inf_child_pid_to_exec_file (struct target_ops *self, int pid)
 {
   /* This version of Unix doesn't support translation of a process ID
      to the filename of the executable file.  */
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 7180fb4..89265a0 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -321,7 +321,7 @@ inf_ptrace_kill (struct target_ops *ops)
 /* Stop the inferior.  */
 
 static void
-inf_ptrace_stop (ptid_t ptid)
+inf_ptrace_stop (struct target_ops *self, ptid_t ptid)
 {
   /* Send a SIGINT to the process group.  This acts just like the user
      typed a ^C on the controlling terminal.  Note that using a
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 76877de..2181648 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -844,7 +844,7 @@ linux_nat_pass_signals (struct target_ops *self,
 /* Prototypes for local functions.  */
 static int stop_wait_callback (struct lwp_info *lp, void *data);
 static int linux_thread_alive (ptid_t ptid);
-static char *linux_child_pid_to_exec_file (int pid);
+static char *linux_child_pid_to_exec_file (struct target_ops *self, int pid);
 
 \f
 /* Convert wait status STATUS to a string.  Used for printing debug
@@ -2193,7 +2193,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
 
       ourstatus->kind = TARGET_WAITKIND_EXECD;
       ourstatus->value.execd_pathname
-	= xstrdup (linux_child_pid_to_exec_file (pid));
+	= xstrdup (linux_child_pid_to_exec_file (NULL, pid));
 
       return 0;
     }
@@ -3991,7 +3991,7 @@ linux_nat_pid_to_str (struct target_ops *ops, ptid_t ptid)
 }
 
 static char *
-linux_nat_thread_name (struct thread_info *thr)
+linux_nat_thread_name (struct target_ops *self, struct thread_info *thr)
 {
   int pid = ptid_get_pid (thr->ptid);
   long lwp = ptid_get_lwp (thr->ptid);
@@ -4031,7 +4031,7 @@ linux_nat_thread_name (struct thread_info *thr)
    can be opened to get the symbols for the child process.  */
 
 static char *
-linux_child_pid_to_exec_file (int pid)
+linux_child_pid_to_exec_file (struct target_ops *self, int pid)
 {
   char *name1, *name2;
 
@@ -4095,7 +4095,8 @@ linux_nat_collect_thread_registers (const struct regcache *regcache,
    section for a corefile, and returns it in a malloc buffer.  */
 
 static char *
-linux_nat_make_corefile_notes (bfd *obfd, int *note_size)
+linux_nat_make_corefile_notes (struct target_ops *self,
+			       bfd *obfd, int *note_size)
 {
   /* FIXME: uweigand/2011-10-06: Once all GNU/Linux architectures have been
      converted to gdbarch_core_regset_sections, this function can go away.  */
@@ -4517,7 +4518,7 @@ linux_nat_can_async_p (struct target_ops *ops)
 }
 
 static int
-linux_nat_supports_non_stop (void)
+linux_nat_supports_non_stop (struct target_ops *self)
 {
   return 1;
 }
@@ -4744,12 +4745,12 @@ linux_nat_stop_lwp (struct lwp_info *lwp, void *data)
 }
 
 static void
-linux_nat_stop (ptid_t ptid)
+linux_nat_stop (struct target_ops *self, ptid_t ptid)
 {
   if (non_stop)
     iterate_over_lwps (ptid, linux_nat_stop_lwp, NULL);
   else
-    linux_ops->to_stop (ptid);
+    linux_ops->to_stop (linux_ops, ptid);
 }
 
 static void
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 3f5a067..20bd4c2 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -61,7 +61,7 @@ static struct target_ops *targ_ops;
 
 static void monitor_interrupt_query (void);
 static void monitor_interrupt_twice (int);
-static void monitor_stop (ptid_t);
+static void monitor_stop (struct target_ops *self, ptid_t);
 static void monitor_dump_regs (struct regcache *regcache);
 
 #if 0
@@ -783,7 +783,7 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
 
   if (current_monitor->stop)
     {
-      monitor_stop (inferior_ptid);
+      monitor_stop (targ_ops, inferior_ptid);
       if ((current_monitor->flags & MO_NO_ECHO_ON_OPEN) == 0)
 	{
 	  monitor_debug ("EXP Open echo\n");
@@ -2262,7 +2262,7 @@ monitor_load (struct target_ops *self, char *args, int from_tty)
 }
 
 static void
-monitor_stop (ptid_t ptid)
+monitor_stop (struct target_ops *self, ptid_t ptid)
 {
   monitor_debug ("MON stop\n");
   if ((current_monitor->flags & MO_SEND_BREAK_ON_STOP) != 0)
@@ -2276,7 +2276,7 @@ monitor_stop (ptid_t ptid)
    ourseleves here cause of a nasty echo.  */
 
 static void
-monitor_rcmd (char *command,
+monitor_rcmd (struct target_ops *self, char *command,
 	      struct ui_file *outbuf)
 {
   char *p;
diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c
index 347636f..72c471b 100644
--- a/gdb/nbsd-nat.c
+++ b/gdb/nbsd-nat.c
@@ -25,7 +25,7 @@
    the child process identified by PID.  */
 
 char *
-nbsd_pid_to_exec_file (int pid)
+nbsd_pid_to_exec_file (struct target_ops *self, int pid)
 {
   size_t len = PATH_MAX;
   char *buf = xcalloc (len, sizeof (char));
diff --git a/gdb/nbsd-nat.h b/gdb/nbsd-nat.h
index dc6a570..145505d 100644
--- a/gdb/nbsd-nat.h
+++ b/gdb/nbsd-nat.h
@@ -23,6 +23,6 @@
 /* Return the name of a file that can be opened to get the symbols for
    the child process identified by PID.  */
 
-extern char *nbsd_pid_to_exec_file (int pid);
+extern char *nbsd_pid_to_exec_file (struct target_ops *self, int pid);
 
 #endif /* nbsd-nat.h */
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 5fedb90..1b2b2ff 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -1218,7 +1218,7 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file,
 }
 
 static void
-procfs_stop (ptid_t ptid)
+procfs_stop (struct target_ops *self, ptid_t ptid)
 {
   devctl (ctl_fd, DCMD_PROC_STOP, NULL, 0, 0);
 }
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 1b01317..06592a0 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -113,7 +113,7 @@ static void procfs_attach (struct target_ops *, char *, int);
 static void procfs_detach (struct target_ops *, const char *, int);
 static void procfs_resume (struct target_ops *,
 			   ptid_t, int, enum gdb_signal);
-static void procfs_stop (ptid_t);
+static void procfs_stop (struct target_ops *self, ptid_t);
 static void procfs_files_info (struct target_ops *);
 static void procfs_fetch_registers (struct target_ops *,
 				    struct regcache *, int);
@@ -137,9 +137,11 @@ static int procfs_thread_alive (struct target_ops *ops, ptid_t);
 static void procfs_find_new_threads (struct target_ops *ops);
 static char *procfs_pid_to_str (struct target_ops *, ptid_t);
 
-static int proc_find_memory_regions (find_memory_region_ftype, void *);
+static int proc_find_memory_regions (struct target_ops *self,
+				     find_memory_region_ftype, void *);
 
-static char * procfs_make_note_section (bfd *, int *);
+static char * procfs_make_note_section (struct target_ops *self,
+					bfd *, int *);
 
 static int procfs_can_use_hw_breakpoint (struct target_ops *self,
 					 int, int, int);
@@ -4263,7 +4265,7 @@ procfs_files_info (struct target_ops *ignore)
    kill(SIGINT) to the child's process group.  */
 
 static void
-procfs_stop (ptid_t ptid)
+procfs_stop (struct target_ops *self, ptid_t ptid)
 {
   kill (-inferior_process_group (), SIGINT);
 }
@@ -5056,7 +5058,8 @@ find_memory_regions_callback (struct prmap *map,
    the callback.  */
 
 static int
-proc_find_memory_regions (find_memory_region_ftype func, void *data)
+proc_find_memory_regions (struct target_ops *self,
+			  find_memory_region_ftype func, void *data)
 {
   procinfo *pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
 
@@ -5471,7 +5474,7 @@ find_stop_signal (void)
 }
 
 static char *
-procfs_make_note_section (bfd *obfd, int *note_size)
+procfs_make_note_section (struct target_ops *self, bfd *obfd, int *note_size)
 {
   struct cleanup *old_chain;
   gdb_gregset_t gregs;
@@ -5541,7 +5544,7 @@ procfs_make_note_section (bfd *obfd, int *note_size)
 }
 #else /* !Solaris */
 static char *
-procfs_make_note_section (bfd *obfd, int *note_size)
+procfs_make_note_section (struct target_ops *self, bfd *obfd, int *note_size)
 {
   error (_("gcore not implemented for this host."));
   return NULL;	/* lint */
diff --git a/gdb/record-full.c b/gdb/record-full.c
index fa9fbf5..a825f5a 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1701,7 +1701,7 @@ record_full_can_execute_reverse (void)
 /* "to_get_bookmark" method for process record and prec over core.  */
 
 static gdb_byte *
-record_full_get_bookmark (char *args, int from_tty)
+record_full_get_bookmark (struct target_ops *self, char *args, int from_tty)
 {
   char *ret = NULL;
 
@@ -1724,7 +1724,8 @@ record_full_get_bookmark (char *args, int from_tty)
 /* "to_goto_bookmark" method for process record and prec over core.  */
 
 static void
-record_full_goto_bookmark (gdb_byte *raw_bookmark, int from_tty)
+record_full_goto_bookmark (struct target_ops *self,
+			   gdb_byte *raw_bookmark, int from_tty)
 {
   char *bookmark = (char *) raw_bookmark;
 
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 0af8cfc..02a812a 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1391,7 +1391,7 @@ m32r_load (struct target_ops *self, char *args, int from_tty)
 }
 
 static void
-m32r_stop (ptid_t ptid)
+m32r_stop (struct target_ops *self, ptid_t ptid)
 {
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog, "m32r_stop()\n");
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 31107f7..3e81927 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -88,7 +88,7 @@ static void gdbsim_files_info (struct target_ops *target);
 
 static void gdbsim_mourn_inferior (struct target_ops *target);
 
-static void gdbsim_stop (ptid_t ptid);
+static void gdbsim_stop (struct target_ops *self, ptid_t ptid);
 
 void simulator_command (char *args, int from_tty);
 
@@ -919,7 +919,7 @@ gdbsim_stop_inferior (struct inferior *inf, void *arg)
 }
 
 static void
-gdbsim_stop (ptid_t ptid)
+gdbsim_stop (struct target_ops *self, ptid_t ptid)
 {
   struct sim_inferior_data *sim_data;
 
@@ -963,7 +963,7 @@ gdb_os_poll_quit (host_callback *p)
 static void
 gdbsim_cntrl_c (int signo)
 {
-  gdbsim_stop (minus_one_ptid);
+  gdbsim_stop (NULL, minus_one_ptid);
 }
 
 static ptid_t
diff --git a/gdb/remote.c b/gdb/remote.c
index 9d3c6ab..fde6942 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -154,7 +154,7 @@ static void init_remote_ops (void);
 
 static void init_extended_remote_ops (void);
 
-static void remote_stop (ptid_t);
+static void remote_stop (struct target_ops *self, ptid_t);
 
 static int ishex (int ch, int *val);
 
@@ -5215,7 +5215,7 @@ remote_stop_as (ptid_t ptid)
    will eventually end up here.  */
 
 static void
-remote_stop (ptid_t ptid)
+remote_stop (struct target_ops *self, ptid_t ptid)
 {
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog, "remote_stop called\n");
@@ -9152,7 +9152,7 @@ remote_search_memory (struct target_ops* ops,
 }
 
 static void
-remote_rcmd (char *command,
+remote_rcmd (struct target_ops *self, char *command,
 	     struct ui_file *outbuf)
 {
   struct remote_state *rs = get_remote_state ();
@@ -10415,7 +10415,7 @@ remote_can_execute_reverse (void)
 }
 
 static int
-remote_supports_non_stop (void)
+remote_supports_non_stop (struct target_ops *self)
 {
   return 1;
 }
diff --git a/gdb/serial.c b/gdb/serial.c
index 2b1eced..7471a6b 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -130,7 +130,7 @@ serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout)
 }
 
 void
-serial_log_command (const char *cmd)
+serial_log_command (struct target_ops *self, const char *cmd)
 {
   if (!serial_logfp)
     return;
diff --git a/gdb/serial.h b/gdb/serial.h
index 0351f5d..f4ab31e 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -304,7 +304,7 @@ extern void serial_add_interface (const struct serial_ops * optable);
 
 /* File in which to record the remote debugging session.  */
 
-extern void serial_log_command (const char *);
+extern void serial_log_command (struct target_ops *self, const char *);
 
 #ifdef USE_WIN32API
 
diff --git a/gdb/target.c b/gdb/target.c
index d948e92..ec48d40 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -146,7 +146,7 @@ static void debug_to_load (struct target_ops *self, char *, int);
 
 static int debug_to_can_run (struct target_ops *self);
 
-static void debug_to_stop (ptid_t);
+static void debug_to_stop (struct target_ops *self, ptid_t);
 
 /* Pointer to array of target architecture structures; the size of the
    array; the current index into the array; the allocated size of the
@@ -822,16 +822,16 @@ update_current_target (void)
 	    (char *(*) (struct target_ops *, struct thread_info *))
 	    return_null);
   de_fault (to_thread_name,
-	    (char *(*) (struct thread_info *))
+	    (char *(*) (struct target_ops *, struct thread_info *))
 	    return_null);
   de_fault (to_stop,
-	    (void (*) (ptid_t))
+	    (void (*) (struct target_ops *, ptid_t))
 	    target_ignore);
   de_fault (to_rcmd,
-	    (void (*) (char *, struct ui_file *))
+	    (void (*) (struct target_ops *, char *, struct ui_file *))
 	    tcomplain);
   de_fault (to_pid_to_exec_file,
-	    (char *(*) (int))
+	    (char *(*) (struct target_ops *, int))
 	    return_null);
   de_fault (to_thread_architecture,
 	    default_thread_architecture);
@@ -2710,7 +2710,7 @@ target_thread_name (struct thread_info *info)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     {
       if (t->to_thread_name != NULL)
-	return (*t->to_thread_name) (info);
+	return (*t->to_thread_name) (t, info);
     }
 
   return NULL;
@@ -3151,13 +3151,13 @@ find_default_is_async_p (struct target_ops *ignore)
 }
 
 static int
-find_default_supports_non_stop (void)
+find_default_supports_non_stop (struct target_ops *self)
 {
   struct target_ops *t;
 
   t = find_default_run_target (NULL);
   if (t && t->to_supports_non_stop)
-    return (t->to_supports_non_stop) ();
+    return (t->to_supports_non_stop) (t);
   return 0;
 }
 
@@ -3168,7 +3168,7 @@ target_supports_non_stop (void)
 
   for (t = &current_target; t != NULL; t = t->beneath)
     if (t->to_supports_non_stop)
-      return t->to_supports_non_stop ();
+      return t->to_supports_non_stop (t);
 
   return 0;
 }
@@ -3709,7 +3709,8 @@ dummy_pid_to_str (struct target_ops *ops, ptid_t ptid)
 
 /* Error-catcher for target_find_memory_regions.  */
 static int
-dummy_find_memory_regions (find_memory_region_ftype ignore1, void *ignore2)
+dummy_find_memory_regions (struct target_ops *self,
+			   find_memory_region_ftype ignore1, void *ignore2)
 {
   error (_("Command not implemented for this target."));
   return 0;
@@ -3717,7 +3718,8 @@ dummy_find_memory_regions (find_memory_region_ftype ignore1, void *ignore2)
 
 /* Error-catcher for target_make_corefile_notes.  */
 static char *
-dummy_make_corefile_notes (bfd *ignore1, int *ignore2)
+dummy_make_corefile_notes (struct target_ops *self,
+			   bfd *ignore1, int *ignore2)
 {
   error (_("Command not implemented for this target."));
   return NULL;
@@ -3725,7 +3727,7 @@ dummy_make_corefile_notes (bfd *ignore1, int *ignore2)
 
 /* Error-catcher for target_get_bookmark.  */
 static gdb_byte *
-dummy_get_bookmark (char *ignore1, int ignore2)
+dummy_get_bookmark (struct target_ops *self, char *ignore1, int ignore2)
 {
   tcomplain ();
   return NULL;
@@ -3733,7 +3735,7 @@ dummy_get_bookmark (char *ignore1, int ignore2)
 
 /* Error-catcher for target_goto_bookmark.  */
 static void
-dummy_goto_bookmark (gdb_byte *ignore, int from_tty)
+dummy_goto_bookmark (struct target_ops *self, gdb_byte *ignore, int from_tty)
 {
   tcomplain ();
 }
@@ -3864,7 +3866,7 @@ target_stop (ptid_t ptid)
       return;
     }
 
-  (*current_target.to_stop) (ptid);
+  (*current_target.to_stop) (&current_target, ptid);
 }
 
 static void
@@ -4926,28 +4928,28 @@ debug_to_thread_architecture (struct target_ops *ops, ptid_t ptid)
 }
 
 static void
-debug_to_stop (ptid_t ptid)
+debug_to_stop (struct target_ops *self, ptid_t ptid)
 {
-  debug_target.to_stop (ptid);
+  debug_target.to_stop (&debug_target, ptid);
 
   fprintf_unfiltered (gdb_stdlog, "target_stop (%s)\n",
 		      target_pid_to_str (ptid));
 }
 
 static void
-debug_to_rcmd (char *command,
+debug_to_rcmd (struct target_ops *self, char *command,
 	       struct ui_file *outbuf)
 {
-  debug_target.to_rcmd (command, outbuf);
+  debug_target.to_rcmd (&debug_target, command, outbuf);
   fprintf_unfiltered (gdb_stdlog, "target_rcmd (%s, ...)\n", command);
 }
 
 static char *
-debug_to_pid_to_exec_file (int pid)
+debug_to_pid_to_exec_file (struct target_ops *self, int pid)
 {
   char *exec_file;
 
-  exec_file = debug_target.to_pid_to_exec_file (pid);
+  exec_file = debug_target.to_pid_to_exec_file (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_pid_to_exec_file (%d) = %s\n",
 		      pid, exec_file);
@@ -5014,10 +5016,11 @@ do_monitor_command (char *cmd,
 		 int from_tty)
 {
   if ((current_target.to_rcmd
-       == (void (*) (char *, struct ui_file *)) tcomplain)
+       == (void (*) (struct target_ops *, char *, struct ui_file *)) tcomplain)
       || (current_target.to_rcmd == debug_to_rcmd
 	  && (debug_target.to_rcmd
-	      == (void (*) (char *, struct ui_file *)) tcomplain)))
+	      == (void (*) (struct target_ops *,
+			    char *, struct ui_file *)) tcomplain)))
     error (_("\"monitor\" command not supported by this target."));
   target_rcmd (cmd, gdb_stdtarg);
 }
diff --git a/gdb/target.h b/gdb/target.h
index dc560a1..c315bcb 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -514,11 +514,12 @@ struct target_ops
     void (*to_find_new_threads) (struct target_ops *);
     char *(*to_pid_to_str) (struct target_ops *, ptid_t);
     char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *);
-    char *(*to_thread_name) (struct thread_info *);
-    void (*to_stop) (ptid_t);
-    void (*to_rcmd) (char *command, struct ui_file *output);
-    char *(*to_pid_to_exec_file) (int pid);
-    void (*to_log_command) (const char *);
+    char *(*to_thread_name) (struct target_ops *, struct thread_info *);
+    void (*to_stop) (struct target_ops *, ptid_t);
+    void (*to_rcmd) (struct target_ops *,
+		     char *command, struct ui_file *output);
+    char *(*to_pid_to_exec_file) (struct target_ops *, int pid);
+    void (*to_log_command) (struct target_ops *, const char *);
     struct target_section_table *(*to_get_section_table) (struct target_ops *);
     enum strata to_stratum;
     int (*to_has_all_memory) (struct target_ops *);
@@ -535,15 +536,16 @@ struct target_ops
       TARGET_DEFAULT_FUNC (find_default_is_async_p);
     void (*to_async) (struct target_ops *, async_callback_ftype *, void *)
       TARGET_DEFAULT_NORETURN (tcomplain ());
-    int (*to_supports_non_stop) (void);
+    int (*to_supports_non_stop) (struct target_ops *);
     /* find_memory_regions support method for gcore */
-    int (*to_find_memory_regions) (find_memory_region_ftype func, void *data);
+    int (*to_find_memory_regions) (struct target_ops *,
+				   find_memory_region_ftype func, void *data);
     /* make_corefile_notes support method for gcore */
-    char * (*to_make_corefile_notes) (bfd *, int *);
+    char * (*to_make_corefile_notes) (struct target_ops *, bfd *, int *);
     /* get_bookmark support method for bookmarks */
-    gdb_byte * (*to_get_bookmark) (char *, int);
+    gdb_byte * (*to_get_bookmark) (struct target_ops *, char *, int);
     /* goto_bookmark support method for bookmarks */
-    void (*to_goto_bookmark) (gdb_byte *, int);
+    void (*to_goto_bookmark) (struct target_ops *, gdb_byte *, int);
     /* Return the thread-local address at OFFSET in the
        thread-local storage for the thread PTID and the shared library
        or executable file given by OBJFILE.  If that block of
@@ -1421,7 +1423,7 @@ extern void target_stop (ptid_t ptid);
    placed in OUTBUF.  */
 
 #define target_rcmd(command, outbuf) \
-     (*current_target.to_rcmd) (command, outbuf)
+     (*current_target.to_rcmd) (&current_target, command, outbuf)
 
 
 /* Does the target include all of memory, or only part of it?  This
@@ -1531,7 +1533,7 @@ extern char *target_thread_name (struct thread_info *);
    it must persist.  */
 
 #define target_pid_to_exec_file(pid) \
-     (current_target.to_pid_to_exec_file) (pid)
+     (current_target.to_pid_to_exec_file) (&current_target, pid)
 
 /* See the to_thread_architecture description in struct target_ops.  */
 
@@ -1546,21 +1548,21 @@ extern char *target_thread_name (struct thread_info *);
  */
 
 #define target_find_memory_regions(FUNC, DATA) \
-     (current_target.to_find_memory_regions) (FUNC, DATA)
+     (current_target.to_find_memory_regions) (&current_target, FUNC, DATA)
 
 /*
  * Compose corefile .note section.
  */
 
 #define target_make_corefile_notes(BFD, SIZE_P) \
-     (current_target.to_make_corefile_notes) (BFD, SIZE_P)
+     (current_target.to_make_corefile_notes) (&current_target, BFD, SIZE_P)
 
 /* Bookmark interfaces.  */
 #define target_get_bookmark(ARGS, FROM_TTY) \
-     (current_target.to_get_bookmark) (ARGS, FROM_TTY)
+     (current_target.to_get_bookmark) (&current_target, ARGS, FROM_TTY)
 
 #define target_goto_bookmark(ARG, FROM_TTY) \
-     (current_target.to_goto_bookmark) (ARG, FROM_TTY)
+     (current_target.to_goto_bookmark) (&current_target, ARG, FROM_TTY)
 
 /* Hardware watchpoint interfaces.  */
 
@@ -1854,7 +1856,8 @@ extern char *target_fileio_read_stralloc (const char *filename);
 #define target_log_command(p)						\
   do									\
     if (current_target.to_log_command)					\
-      (*current_target.to_log_command) (p);				\
+      (*current_target.to_log_command) (&current_target,		\
+					p);				\
   while (0)
 
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index ef844be..91af87b 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -165,7 +165,7 @@ static int windows_initialization_done;
 #define DEBUG_MEM(x)	if (debug_memory)	printf_unfiltered x
 #define DEBUG_EXCEPT(x)	if (debug_exceptions)	printf_unfiltered x
 
-static void windows_stop (ptid_t);
+static void windows_stop (struct target_ops *self, ptid_t);
 static int windows_thread_alive (struct target_ops *, ptid_t);
 static void windows_kill_inferior (struct target_ops *);
 
@@ -1994,7 +1994,7 @@ windows_detach (struct target_ops *ops, const char *args, int from_tty)
 }
 
 static char *
-windows_pid_to_exec_file (int pid)
+windows_pid_to_exec_file (struct target_ops *self, int pid)
 {
   static char path[__PMAX];
 #ifdef __CYGWIN__
@@ -2403,7 +2403,7 @@ windows_mourn_inferior (struct target_ops *ops)
    ^C on the controlling terminal.  */
 
 static void
-windows_stop (ptid_t ptid)
+windows_stop (struct target_ops *self, ptid_t ptid)
 {
   DEBUG_EVENTS (("gdb: GenerateConsoleCtrlEvent (CTRLC_EVENT, 0)\n"));
   CHECK (GenerateConsoleCtrlEvent (CTRL_C_EVENT, current_event.dwProcessId));
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 23/38] convert to_disable_tracepoint
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (7 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 34/38] remove exec_set_find_memory_regions Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 10/38] Add target_ops argument to to_thread_name Tom Tromey
                   ` (30 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_disable_tracepoint.
	* target.h (struct target_ops) <to_disable_tracepoint>: Use
	TARGET_DEFAULT_NORETURN.

convert to_trace_set_readonly_regions

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_trace_set_readonly_regions.
	* target.h (struct target_ops) <to_trace_set_readonly_regions>:
	Use TARGET_DEFAULT_NORETURN.

convert to_trace_start

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_trace_start.
	* target.h (struct target_ops) <to_trace_start>: Use
	TARGET_DEFAULT_NORETURN.

convert to_get_trace_status

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_trace_status.
	* target.h (struct target_ops) <to_get_trace_status>: Use
	TARGET_DEFAULT_RETURN.

convert to_get_tracepoint_status

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_tracepoint_status.
	* target.h (struct target_ops) <to_get_tracepoint_status>: Use
	TARGET_DEFAULT_NORETURN.

convert to_trace_stop

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_trace_stop.
	* target.h (struct target_ops) <to_trace_stop>: Use
	TARGET_DEFAULT_NORETURN.

convert to_trace_find

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_trace_find.
	* target.h (struct target_ops): Use TARGET_DEFAULT_RETURN.

convert to_get_trace_state_variable_value

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_trace_state_variable_value.
	* target.h (struct target_ops)
	<to_get_trace_state_variable_value>: Use TARGET_DEFAULT_RETURN.

convert to_save_trace_data

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_save_trace_data.
	* target.h (struct target_ops) <to_save_trace_data>: Use
	TARGET_DEFAULT_NORETURN.

convert to_upload_tracepoints

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_upload_tracepoints.
	* target.h (struct target_ops) <to_upload_tracepoints>: Use
	TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          |  79 ++++++++++++++++++++++++
 gdb/target-delegates.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  52 ++++------------
 gdb/target.h           |  30 ++++++----
 4 files changed, 269 insertions(+), 52 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 358a64b..d8d3dbd 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -702,6 +702,136 @@ tdefault_enable_tracepoint (struct target_ops *self, struct bp_location *arg1)
   tcomplain ();
 }
 
+static void
+delegate_disable_tracepoint (struct target_ops *self, struct bp_location *arg1)
+{
+  self = self->beneath;
+  self->to_disable_tracepoint (self, arg1);
+}
+
+static void
+tdefault_disable_tracepoint (struct target_ops *self, struct bp_location *arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_trace_set_readonly_regions (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_trace_set_readonly_regions (self);
+}
+
+static void
+tdefault_trace_set_readonly_regions (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static void
+delegate_trace_start (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_trace_start (self);
+}
+
+static void
+tdefault_trace_start (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static int
+delegate_get_trace_status (struct target_ops *self, struct trace_status *arg1)
+{
+  self = self->beneath;
+  return self->to_get_trace_status (self, arg1);
+}
+
+static int
+tdefault_get_trace_status (struct target_ops *self, struct trace_status *arg1)
+{
+  return -1;
+}
+
+static void
+delegate_get_tracepoint_status (struct target_ops *self, struct breakpoint *arg1, struct uploaded_tp *arg2)
+{
+  self = self->beneath;
+  self->to_get_tracepoint_status (self, arg1, arg2);
+}
+
+static void
+tdefault_get_tracepoint_status (struct target_ops *self, struct breakpoint *arg1, struct uploaded_tp *arg2)
+{
+  tcomplain ();
+}
+
+static void
+delegate_trace_stop (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_trace_stop (self);
+}
+
+static void
+tdefault_trace_stop (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static int
+delegate_trace_find (struct target_ops *self, enum trace_find_type  arg1, int arg2, CORE_ADDR arg3, CORE_ADDR arg4, int *arg5)
+{
+  self = self->beneath;
+  return self->to_trace_find (self, arg1, arg2, arg3, arg4, arg5);
+}
+
+static int
+tdefault_trace_find (struct target_ops *self, enum trace_find_type  arg1, int arg2, CORE_ADDR arg3, CORE_ADDR arg4, int *arg5)
+{
+  return -1;
+}
+
+static int
+delegate_get_trace_state_variable_value (struct target_ops *self, int arg1, LONGEST *arg2)
+{
+  self = self->beneath;
+  return self->to_get_trace_state_variable_value (self, arg1, arg2);
+}
+
+static int
+tdefault_get_trace_state_variable_value (struct target_ops *self, int arg1, LONGEST *arg2)
+{
+  return 0;
+}
+
+static int
+delegate_save_trace_data (struct target_ops *self, const char *arg1)
+{
+  self = self->beneath;
+  return self->to_save_trace_data (self, arg1);
+}
+
+static int
+tdefault_save_trace_data (struct target_ops *self, const char *arg1)
+{
+  tcomplain ();
+}
+
+static int
+delegate_upload_tracepoints (struct target_ops *self, struct uploaded_tp **arg1)
+{
+  self = self->beneath;
+  return self->to_upload_tracepoints (self, arg1);
+}
+
+static int
+tdefault_upload_tracepoints (struct target_ops *self, struct uploaded_tp **arg1)
+{
+  return 0;
+}
+
 static int
 delegate_supports_btrace (struct target_ops *self)
 {
@@ -840,6 +970,26 @@ install_delegators (struct target_ops *ops)
     ops->to_download_trace_state_variable = delegate_download_trace_state_variable;
   if (ops->to_enable_tracepoint == NULL)
     ops->to_enable_tracepoint = delegate_enable_tracepoint;
+  if (ops->to_disable_tracepoint == NULL)
+    ops->to_disable_tracepoint = delegate_disable_tracepoint;
+  if (ops->to_trace_set_readonly_regions == NULL)
+    ops->to_trace_set_readonly_regions = delegate_trace_set_readonly_regions;
+  if (ops->to_trace_start == NULL)
+    ops->to_trace_start = delegate_trace_start;
+  if (ops->to_get_trace_status == NULL)
+    ops->to_get_trace_status = delegate_get_trace_status;
+  if (ops->to_get_tracepoint_status == NULL)
+    ops->to_get_tracepoint_status = delegate_get_tracepoint_status;
+  if (ops->to_trace_stop == NULL)
+    ops->to_trace_stop = delegate_trace_stop;
+  if (ops->to_trace_find == NULL)
+    ops->to_trace_find = delegate_trace_find;
+  if (ops->to_get_trace_state_variable_value == NULL)
+    ops->to_get_trace_state_variable_value = delegate_get_trace_state_variable_value;
+  if (ops->to_save_trace_data == NULL)
+    ops->to_save_trace_data = delegate_save_trace_data;
+  if (ops->to_upload_tracepoints == NULL)
+    ops->to_upload_tracepoints = delegate_upload_tracepoints;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
 }
@@ -908,5 +1058,15 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_can_download_tracepoint = tdefault_can_download_tracepoint;
   ops->to_download_trace_state_variable = tdefault_download_trace_state_variable;
   ops->to_enable_tracepoint = tdefault_enable_tracepoint;
+  ops->to_disable_tracepoint = tdefault_disable_tracepoint;
+  ops->to_trace_set_readonly_regions = tdefault_trace_set_readonly_regions;
+  ops->to_trace_start = tdefault_trace_start;
+  ops->to_get_trace_status = tdefault_get_trace_status;
+  ops->to_get_tracepoint_status = tdefault_get_tracepoint_status;
+  ops->to_trace_stop = tdefault_trace_stop;
+  ops->to_trace_find = tdefault_trace_find;
+  ops->to_get_trace_state_variable_value = tdefault_get_trace_state_variable_value;
+  ops->to_save_trace_data = tdefault_save_trace_data;
+  ops->to_upload_tracepoints = tdefault_upload_tracepoints;
   ops->to_supports_btrace = tdefault_supports_btrace;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 2efd21f..4657120 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -693,16 +693,16 @@ update_current_target (void)
       /* Do not inherit to_can_download_tracepoint.  */
       /* Do not inherit to_download_trace_state_variable.  */
       /* Do not inherit to_enable_tracepoint.  */
-      INHERIT (to_disable_tracepoint, t);
-      INHERIT (to_trace_set_readonly_regions, t);
-      INHERIT (to_trace_start, t);
-      INHERIT (to_get_trace_status, t);
-      INHERIT (to_get_tracepoint_status, t);
-      INHERIT (to_trace_stop, t);
-      INHERIT (to_trace_find, t);
-      INHERIT (to_get_trace_state_variable_value, t);
-      INHERIT (to_save_trace_data, t);
-      INHERIT (to_upload_tracepoints, t);
+      /* Do not inherit to_disable_tracepoint.  */
+      /* Do not inherit to_trace_set_readonly_regions.  */
+      /* Do not inherit to_trace_start.  */
+      /* Do not inherit to_get_trace_status.  */
+      /* Do not inherit to_get_tracepoint_status.  */
+      /* Do not inherit to_trace_stop.  */
+      /* Do not inherit to_trace_find.  */
+      /* Do not inherit to_get_trace_state_variable_value.  */
+      /* Do not inherit to_save_trace_data.  */
+      /* Do not inherit to_upload_tracepoints.  */
       INHERIT (to_upload_trace_state_variables, t);
       INHERIT (to_get_raw_trace_data, t);
       INHERIT (to_get_min_fast_tracepoint_insn_len, t);
@@ -752,38 +752,6 @@ update_current_target (void)
 	    (void (*) (struct target_ops *, ptid_t))
 	    target_ignore);
   current_target.to_read_description = NULL;
-  de_fault (to_disable_tracepoint,
-	    (void (*) (struct target_ops *, struct bp_location *))
-	    tcomplain);
-  de_fault (to_trace_set_readonly_regions,
-	    (void (*) (struct target_ops *))
-	    tcomplain);
-  de_fault (to_trace_start,
-	    (void (*) (struct target_ops *))
-	    tcomplain);
-  de_fault (to_get_trace_status,
-	    (int (*) (struct target_ops *, struct trace_status *))
-	    return_minus_one);
-  de_fault (to_get_tracepoint_status,
-	    (void (*) (struct target_ops *, struct breakpoint *,
-		       struct uploaded_tp *))
-	    tcomplain);
-  de_fault (to_trace_stop,
-	    (void (*) (struct target_ops *))
-	    tcomplain);
-  de_fault (to_trace_find,
-	    (int (*) (struct target_ops *,
-		      enum trace_find_type, int, CORE_ADDR, CORE_ADDR, int *))
-	    return_minus_one);
-  de_fault (to_get_trace_state_variable_value,
-	    (int (*) (struct target_ops *, int, LONGEST *))
-	    return_zero);
-  de_fault (to_save_trace_data,
-	    (int (*) (struct target_ops *, const char *))
-	    tcomplain);
-  de_fault (to_upload_tracepoints,
-	    (int (*) (struct target_ops *, struct uploaded_tp **))
-	    return_zero);
   de_fault (to_upload_trace_state_variables,
 	    (int (*) (struct target_ops *, struct uploaded_tsv **))
 	    return_zero);
diff --git a/gdb/target.h b/gdb/target.h
index bd76453..4286874 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -813,25 +813,31 @@ struct target_ops
 
     /* Disable a tracepoint on the target.  */
     void (*to_disable_tracepoint) (struct target_ops *,
-				   struct bp_location *location);
+				   struct bp_location *location)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Inform the target info of memory regions that are readonly
        (such as text sections), and so it should return data from
        those rather than look in the trace buffer.  */
-    void (*to_trace_set_readonly_regions) (struct target_ops *);
+    void (*to_trace_set_readonly_regions) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Start a trace run.  */
-    void (*to_trace_start) (struct target_ops *);
+    void (*to_trace_start) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Get the current status of a tracing run.  */
-    int (*to_get_trace_status) (struct target_ops *, struct trace_status *ts);
+    int (*to_get_trace_status) (struct target_ops *, struct trace_status *ts)
+      TARGET_DEFAULT_RETURN (-1);
 
     void (*to_get_tracepoint_status) (struct target_ops *,
 				      struct breakpoint *tp,
-				      struct uploaded_tp *utp);
+				      struct uploaded_tp *utp)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Stop a trace run.  */
-    void (*to_trace_stop) (struct target_ops *);
+    void (*to_trace_stop) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
    /* Ask the target to find a trace frame of the given type TYPE,
       using NUM, ADDR1, and ADDR2 as search parameters.  Returns the
@@ -840,18 +846,22 @@ struct target_ops
       operation fails.  */
     int (*to_trace_find) (struct target_ops *,
 			  enum trace_find_type type, int num,
-			  CORE_ADDR addr1, CORE_ADDR addr2, int *tpp);
+			  CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
+      TARGET_DEFAULT_RETURN (-1);
 
     /* Get the value of the trace state variable number TSV, returning
        1 if the value is known and writing the value itself into the
        location pointed to by VAL, else returning 0.  */
     int (*to_get_trace_state_variable_value) (struct target_ops *,
-					      int tsv, LONGEST *val);
+					      int tsv, LONGEST *val)
+      TARGET_DEFAULT_RETURN (0);
 
-    int (*to_save_trace_data) (struct target_ops *, const char *filename);
+    int (*to_save_trace_data) (struct target_ops *, const char *filename)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     int (*to_upload_tracepoints) (struct target_ops *,
-				  struct uploaded_tp **utpp);
+				  struct uploaded_tp **utpp)
+      TARGET_DEFAULT_RETURN (0);
 
     int (*to_upload_trace_state_variables) (struct target_ops *,
 					    struct uploaded_tsv **utsvp);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 26/38] convert to_insert_mask_watchpoint
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (13 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 24/38] convert to_upload_trace_state_variables Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 07/38] Add target_ops argument to to_close Tom Tromey
                   ` (24 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (target_insert_mask_watchpoint): Unconditionally
	delegate.
	* target.h (struct target_ops) <to_insert_mask_watchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_remove_mask_watchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (target_remove_mask_watchpoint): Unconditionally
	delegate.
	* target.h (struct target_ops) <to_remove_mask_watchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_masked_watch_num_registers

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

	* target-delegates.c: Rebuild.
	* target.c (target_masked_watch_num_registers): Unconditionally
	delegate.
	* target.h (struct target_ops) <to_masked_watch_num_registers>:
	Use TARGET_DEFAULT_RETURN.

convert to_kill

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

	* target-delegates.c: Rebuild.
	* target.c (target_kill): Unconditionally delegate.
	* target.h (struct target_ops) <to_kill>: Use
	TARGET_DEFAULT_NORETURN.

convert to_follow_fork

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

	* target-delegates.c: Rebuild.
	* target.c (default_follow_fork): New function.
	(target_follow_fork): Unconditionally delegate.
	* target.h (struct target_ops) <to_follow_fork>: Use
	TARGET_DEFAULT_FUNC.

convert to_mourn_inferior

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

	* target-delegates.c: Rebuild.
	* target.c (default_mourn_inferior): New function.
	(target_mourn_inferior): Unconditionally delegate.
	* target.h (struct target_ops) <to_mourn_inferior>: Use
	TARGET_DEFAULT_FUNC.

convert to_pass_signals

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

	* target-delegates.c: Rebuild.
	* target.c (target_pass_signals): Unconditionally delegate.
	* target.h (struct target_ops) <to_pass_signals>: Use
	TARGET_DEFAULT_IGNORE.

convert to_program_signals

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

	* target-delegates.c: Rebuild.
	* target.c (target_program_signals): Unconditionally delegate.
	* target.h (struct target_ops) <to_program_signals>: Use
	TARGET_DEFAULT_IGNORE.

convert to_find_new_threads

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

	* target-delegates.c: Rebuild.
	* target.c (target_find_new_threads): Unconditionally delegate.
	* target.h (struct target_ops) <to_find_new_threads>: Use
	TARGET_DEFAULT_RETURN.

convert to_pid_to_str

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

	* target-delegates.c: Rebuild.
	* target.c (target_pid_to_str): Unconditionally delegate.
	(init_dummy_target): Don't initialize to_pid_to_str.
	(default_pid_to_str): Rename from dummy_pid_to_str.
	* target.h (struct target_ops) <to_pid_to_str>: Use
	TARGET_DEFAULT_FUNC.
---
 gdb/ChangeLog          |  77 ++++++++++++++++
 gdb/target-delegates.c | 139 +++++++++++++++++++++++++++++
 gdb/target.c           | 235 ++++++++++++++++++-------------------------------
 gdb/target.h           |  30 ++++---
 4 files changed, 321 insertions(+), 160 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 98d3f17..b59f199 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -203,6 +203,32 @@ tdefault_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, i
 }
 
 static int
+delegate_insert_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3)
+{
+  self = self->beneath;
+  return self->to_insert_mask_watchpoint (self, arg1, arg2, arg3);
+}
+
+static int
+tdefault_insert_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3)
+{
+  return 1;
+}
+
+static int
+delegate_remove_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3)
+{
+  self = self->beneath;
+  return self->to_remove_mask_watchpoint (self, arg1, arg2, arg3);
+}
+
+static int
+tdefault_remove_mask_watchpoint (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3)
+{
+  return 1;
+}
+
+static int
 delegate_stopped_by_watchpoint (struct target_ops *self)
 {
   self = self->beneath;
@@ -255,6 +281,19 @@ tdefault_can_accel_watchpoint_condition (struct target_ops *self, CORE_ADDR arg1
   return 0;
 }
 
+static int
+delegate_masked_watch_num_registers (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2)
+{
+  self = self->beneath;
+  return self->to_masked_watch_num_registers (self, arg1, arg2);
+}
+
+static int
+tdefault_masked_watch_num_registers (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2)
+{
+  return -1;
+}
+
 static void
 delegate_terminal_init (struct target_ops *self)
 {
@@ -323,6 +362,19 @@ delegate_terminal_info (struct target_ops *self, const char *arg1, int arg2)
 }
 
 static void
+delegate_kill (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_kill (self);
+}
+
+static void
+tdefault_kill (struct target_ops *self)
+{
+  noprocess ();
+}
+
+static void
 delegate_load (struct target_ops *self, char *arg1, int arg2)
 {
   self = self->beneath;
@@ -400,6 +452,13 @@ tdefault_remove_vfork_catchpoint (struct target_ops *self, int arg1)
 }
 
 static int
+delegate_follow_fork (struct target_ops *self, int arg1, int arg2)
+{
+  self = self->beneath;
+  return self->to_follow_fork (self, arg1, arg2);
+}
+
+static int
 delegate_insert_exec_catchpoint (struct target_ops *self, int arg1)
 {
   self = self->beneath;
@@ -451,6 +510,56 @@ tdefault_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3)
   return 0;
 }
 
+static void
+delegate_mourn_inferior (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_mourn_inferior (self);
+}
+
+static void
+delegate_pass_signals (struct target_ops *self, int arg1, unsigned char *arg2)
+{
+  self = self->beneath;
+  self->to_pass_signals (self, arg1, arg2);
+}
+
+static void
+tdefault_pass_signals (struct target_ops *self, int arg1, unsigned char *arg2)
+{
+}
+
+static void
+delegate_program_signals (struct target_ops *self, int arg1, unsigned char *arg2)
+{
+  self = self->beneath;
+  self->to_program_signals (self, arg1, arg2);
+}
+
+static void
+tdefault_program_signals (struct target_ops *self, int arg1, unsigned char *arg2)
+{
+}
+
+static void
+delegate_find_new_threads (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_find_new_threads (self);
+}
+
+static void
+tdefault_find_new_threads (struct target_ops *self)
+{
+}
+
+static char *
+delegate_pid_to_str (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  return self->to_pid_to_str (self, arg1);
+}
+
 static char *
 delegate_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
 {
@@ -1136,6 +1245,10 @@ install_delegators (struct target_ops *ops)
     ops->to_remove_watchpoint = delegate_remove_watchpoint;
   if (ops->to_insert_watchpoint == NULL)
     ops->to_insert_watchpoint = delegate_insert_watchpoint;
+  if (ops->to_insert_mask_watchpoint == NULL)
+    ops->to_insert_mask_watchpoint = delegate_insert_mask_watchpoint;
+  if (ops->to_remove_mask_watchpoint == NULL)
+    ops->to_remove_mask_watchpoint = delegate_remove_mask_watchpoint;
   if (ops->to_stopped_by_watchpoint == NULL)
     ops->to_stopped_by_watchpoint = delegate_stopped_by_watchpoint;
   if (ops->to_stopped_data_address == NULL)
@@ -1146,6 +1259,8 @@ install_delegators (struct target_ops *ops)
     ops->to_region_ok_for_hw_watchpoint = delegate_region_ok_for_hw_watchpoint;
   if (ops->to_can_accel_watchpoint_condition == NULL)
     ops->to_can_accel_watchpoint_condition = delegate_can_accel_watchpoint_condition;
+  if (ops->to_masked_watch_num_registers == NULL)
+    ops->to_masked_watch_num_registers = delegate_masked_watch_num_registers;
   if (ops->to_terminal_init == NULL)
     ops->to_terminal_init = delegate_terminal_init;
   if (ops->to_terminal_inferior == NULL)
@@ -1158,6 +1273,8 @@ install_delegators (struct target_ops *ops)
     ops->to_terminal_save_ours = delegate_terminal_save_ours;
   if (ops->to_terminal_info == NULL)
     ops->to_terminal_info = delegate_terminal_info;
+  if (ops->to_kill == NULL)
+    ops->to_kill = delegate_kill;
   if (ops->to_load == NULL)
     ops->to_load = delegate_load;
   if (ops->to_post_startup_inferior == NULL)
@@ -1170,6 +1287,8 @@ install_delegators (struct target_ops *ops)
     ops->to_insert_vfork_catchpoint = delegate_insert_vfork_catchpoint;
   if (ops->to_remove_vfork_catchpoint == NULL)
     ops->to_remove_vfork_catchpoint = delegate_remove_vfork_catchpoint;
+  if (ops->to_follow_fork == NULL)
+    ops->to_follow_fork = delegate_follow_fork;
   if (ops->to_insert_exec_catchpoint == NULL)
     ops->to_insert_exec_catchpoint = delegate_insert_exec_catchpoint;
   if (ops->to_remove_exec_catchpoint == NULL)
@@ -1178,6 +1297,16 @@ install_delegators (struct target_ops *ops)
     ops->to_set_syscall_catchpoint = delegate_set_syscall_catchpoint;
   if (ops->to_has_exited == NULL)
     ops->to_has_exited = delegate_has_exited;
+  if (ops->to_mourn_inferior == NULL)
+    ops->to_mourn_inferior = delegate_mourn_inferior;
+  if (ops->to_pass_signals == NULL)
+    ops->to_pass_signals = delegate_pass_signals;
+  if (ops->to_program_signals == NULL)
+    ops->to_program_signals = delegate_program_signals;
+  if (ops->to_find_new_threads == NULL)
+    ops->to_find_new_threads = delegate_find_new_threads;
+  if (ops->to_pid_to_str == NULL)
+    ops->to_pid_to_str = delegate_pid_to_str;
   if (ops->to_extra_thread_info == NULL)
     ops->to_extra_thread_info = delegate_extra_thread_info;
   if (ops->to_thread_name == NULL)
@@ -1308,27 +1437,37 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_remove_hw_breakpoint = tdefault_remove_hw_breakpoint;
   ops->to_remove_watchpoint = tdefault_remove_watchpoint;
   ops->to_insert_watchpoint = tdefault_insert_watchpoint;
+  ops->to_insert_mask_watchpoint = tdefault_insert_mask_watchpoint;
+  ops->to_remove_mask_watchpoint = tdefault_remove_mask_watchpoint;
   ops->to_stopped_by_watchpoint = tdefault_stopped_by_watchpoint;
   ops->to_stopped_data_address = tdefault_stopped_data_address;
   ops->to_watchpoint_addr_within_range = default_watchpoint_addr_within_range;
   ops->to_region_ok_for_hw_watchpoint = default_region_ok_for_hw_watchpoint;
   ops->to_can_accel_watchpoint_condition = tdefault_can_accel_watchpoint_condition;
+  ops->to_masked_watch_num_registers = tdefault_masked_watch_num_registers;
   ops->to_terminal_init = tdefault_terminal_init;
   ops->to_terminal_inferior = tdefault_terminal_inferior;
   ops->to_terminal_ours_for_output = tdefault_terminal_ours_for_output;
   ops->to_terminal_ours = tdefault_terminal_ours;
   ops->to_terminal_save_ours = tdefault_terminal_save_ours;
   ops->to_terminal_info = default_terminal_info;
+  ops->to_kill = tdefault_kill;
   ops->to_load = tdefault_load;
   ops->to_post_startup_inferior = tdefault_post_startup_inferior;
   ops->to_insert_fork_catchpoint = tdefault_insert_fork_catchpoint;
   ops->to_remove_fork_catchpoint = tdefault_remove_fork_catchpoint;
   ops->to_insert_vfork_catchpoint = tdefault_insert_vfork_catchpoint;
   ops->to_remove_vfork_catchpoint = tdefault_remove_vfork_catchpoint;
+  ops->to_follow_fork = default_follow_fork;
   ops->to_insert_exec_catchpoint = tdefault_insert_exec_catchpoint;
   ops->to_remove_exec_catchpoint = tdefault_remove_exec_catchpoint;
   ops->to_set_syscall_catchpoint = tdefault_set_syscall_catchpoint;
   ops->to_has_exited = tdefault_has_exited;
+  ops->to_mourn_inferior = default_mourn_inferior;
+  ops->to_pass_signals = tdefault_pass_signals;
+  ops->to_program_signals = tdefault_program_signals;
+  ops->to_find_new_threads = tdefault_find_new_threads;
+  ops->to_pid_to_str = default_pid_to_str;
   ops->to_extra_thread_info = tdefault_extra_thread_info;
   ops->to_thread_name = tdefault_thread_name;
   ops->to_stop = tdefault_stop;
diff --git a/gdb/target.c b/gdb/target.c
index 8d041b7..9fbe19f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -60,6 +60,11 @@ static void default_rcmd (struct target_ops *, char *, struct ui_file *);
 static ptid_t default_get_ada_task_ptid (struct target_ops *self,
 					 long lwp, long tid);
 
+static int default_follow_fork (struct target_ops *self, int follow_child,
+				int detach_fork);
+
+static void default_mourn_inferior (struct target_ops *self);
+
 static void tcomplain (void) ATTRIBUTE_NORETURN;
 
 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
@@ -84,6 +89,8 @@ static int dummy_find_memory_regions (struct target_ops *self,
 static char *dummy_make_corefile_notes (struct target_ops *self,
 					bfd *ignore1, int *ignore2);
 
+static char *default_pid_to_str (struct target_ops *ops, ptid_t ptid);
+
 static int find_default_can_async_p (struct target_ops *ignore);
 
 static int find_default_is_async_p (struct target_ops *ignore);
@@ -452,19 +459,10 @@ target_ignore (void)
 void
 target_kill (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_kill != NULL)
-      {
-	if (targetdebug)
-	  fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
-
-        t->to_kill (t);
-	return;
-      }
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
 
-  noprocess ();
+  current_target.to_kill (&current_target);
 }
 
 void
@@ -2483,15 +2481,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 char *
 target_pid_to_str (ptid_t ptid)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_pid_to_str != NULL)
-	return (*t->to_pid_to_str) (t, ptid);
-    }
-
-  return normal_pid_to_str (ptid);
+  return (*current_target.to_pid_to_str) (&current_target, ptid);
 }
 
 char *
@@ -2523,61 +2513,53 @@ target_resume (ptid_t ptid, int step, enum gdb_signal signal)
 void
 target_pass_signals (int numsigs, unsigned char *pass_signals)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
+  if (targetdebug)
     {
-      if (t->to_pass_signals != NULL)
-	{
-	  if (targetdebug)
-	    {
-	      int i;
+      int i;
 
-	      fprintf_unfiltered (gdb_stdlog, "target_pass_signals (%d, {",
-				  numsigs);
+      fprintf_unfiltered (gdb_stdlog, "target_pass_signals (%d, {",
+			  numsigs);
 
-	      for (i = 0; i < numsigs; i++)
-		if (pass_signals[i])
-		  fprintf_unfiltered (gdb_stdlog, " %s",
-				      gdb_signal_to_name (i));
+      for (i = 0; i < numsigs; i++)
+	if (pass_signals[i])
+	  fprintf_unfiltered (gdb_stdlog, " %s",
+			      gdb_signal_to_name (i));
 
-	      fprintf_unfiltered (gdb_stdlog, " })\n");
-	    }
-
-	  (*t->to_pass_signals) (t, numsigs, pass_signals);
-	  return;
-	}
+      fprintf_unfiltered (gdb_stdlog, " })\n");
     }
+
+  (*current_target.to_pass_signals) (&current_target, numsigs, pass_signals);
 }
 
 void
 target_program_signals (int numsigs, unsigned char *program_signals)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
+  if (targetdebug)
     {
-      if (t->to_program_signals != NULL)
-	{
-	  if (targetdebug)
-	    {
-	      int i;
-
-	      fprintf_unfiltered (gdb_stdlog, "target_program_signals (%d, {",
-				  numsigs);
+      int i;
 
-	      for (i = 0; i < numsigs; i++)
-		if (program_signals[i])
-		  fprintf_unfiltered (gdb_stdlog, " %s",
-				      gdb_signal_to_name (i));
+      fprintf_unfiltered (gdb_stdlog, "target_program_signals (%d, {",
+			  numsigs);
 
-	      fprintf_unfiltered (gdb_stdlog, " })\n");
-	    }
+      for (i = 0; i < numsigs; i++)
+	if (program_signals[i])
+	  fprintf_unfiltered (gdb_stdlog, " %s",
+			      gdb_signal_to_name (i));
 
-	  (*t->to_program_signals) (t, numsigs, program_signals);
-	  return;
-	}
+      fprintf_unfiltered (gdb_stdlog, " })\n");
     }
+
+  (*current_target.to_program_signals) (&current_target,
+					numsigs, program_signals);
+}
+
+static int
+default_follow_fork (struct target_ops *self, int follow_child,
+		     int detach_fork)
+{
+  /* Some target returned a fork event, but did not know how to follow it.  */
+  internal_error (__FILE__, __LINE__,
+		  _("could not find a target to follow fork"));
 }
 
 /* Look through the list of possible targets for a target that can
@@ -2586,51 +2568,34 @@ target_program_signals (int numsigs, unsigned char *program_signals)
 int
 target_follow_fork (int follow_child, int detach_fork)
 {
-  struct target_ops *t;
+  int retval = current_target.to_follow_fork (&current_target,
+					      follow_child, detach_fork);
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_follow_fork != NULL)
-	{
-	  int retval = t->to_follow_fork (t, follow_child, detach_fork);
-
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog,
-				"target_follow_fork (%d, %d) = %d\n",
-				follow_child, detach_fork, retval);
-	  return retval;
-	}
-    }
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog,
+			"target_follow_fork (%d, %d) = %d\n",
+			follow_child, detach_fork, retval);
+  return retval;
+}
 
-  /* Some target returned a fork event, but did not know how to follow it.  */
+static void
+default_mourn_inferior (struct target_ops *self)
+{
   internal_error (__FILE__, __LINE__,
-		  _("could not find a target to follow fork"));
+		  _("could not find a target to follow mourn inferior"));
 }
 
 void
 target_mourn_inferior (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_mourn_inferior != NULL)	
-	{
-	  t->to_mourn_inferior (t);
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
-
-          /* We no longer need to keep handles on any of the object files.
-             Make sure to release them to avoid unnecessarily locking any
-             of them while we're not actually debugging.  */
-          bfd_cache_close_all ();
-
-	  return;
-	}
-    }
+  current_target.to_mourn_inferior (&current_target);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
 
-  internal_error (__FILE__, __LINE__,
-		  _("could not find a target to follow mourn inferior"));
+  /* We no longer need to keep handles on any of the object files.
+     Make sure to release them to avoid unnecessarily locking any
+     of them while we're not actually debugging.  */
+  bfd_cache_close_all ();
 }
 
 /* Look for a target which can describe architectural features, starting
@@ -3468,7 +3433,7 @@ normal_pid_to_str (ptid_t ptid)
 }
 
 static char *
-dummy_pid_to_str (struct target_ops *ops, ptid_t ptid)
+default_pid_to_str (struct target_ops *ops, ptid_t ptid)
 {
   return normal_pid_to_str (ptid);
 }
@@ -3504,7 +3469,6 @@ init_dummy_target (void)
   dummy_target.to_supports_non_stop = find_default_supports_non_stop;
   dummy_target.to_supports_disable_randomization
     = find_default_supports_disable_randomization;
-  dummy_target.to_pid_to_str = dummy_pid_to_str;
   dummy_target.to_stratum = dummy_stratum;
   dummy_target.to_has_all_memory = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_memory = (int (*) (struct target_ops *)) return_zero;
@@ -3574,19 +3538,9 @@ target_thread_alive (ptid_t ptid)
 void
 target_find_new_threads (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_find_new_threads != NULL)
-	{
-	  t->to_find_new_threads (t);
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_find_new_threads ()\n");
-
-	  return;
-	}
-    }
+  current_target.to_find_new_threads (&current_target);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_find_new_threads ()\n");
 }
 
 void
@@ -3769,25 +3723,18 @@ target_verify_memory (const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size)
 int
 target_insert_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask, int rw)
 {
-  struct target_ops *t;
+  int ret;
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_insert_mask_watchpoint != NULL)
-      {
-	int ret;
+  ret = current_target.to_insert_mask_watchpoint (&current_target,
+						  addr, mask, rw);
 
-	ret = t->to_insert_mask_watchpoint (t, addr, mask, rw);
-
-	if (targetdebug)
-	  fprintf_unfiltered (gdb_stdlog, "\
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "\
 target_insert_mask_watchpoint (%s, %s, %d) = %d\n",
-			      core_addr_to_string (addr),
-			      core_addr_to_string (mask), rw, ret);
-
-	return ret;
-      }
-
-  return 1;
+			core_addr_to_string (addr),
+			core_addr_to_string (mask), rw, ret);
+  
+  return ret;
 }
 
 /* The documentation for this function is in its prototype declaration in
@@ -3796,25 +3743,18 @@ target_insert_mask_watchpoint (%s, %s, %d) = %d\n",
 int
 target_remove_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask, int rw)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_remove_mask_watchpoint != NULL)
-      {
-	int ret;
+  int ret;
 
-	ret = t->to_remove_mask_watchpoint (t, addr, mask, rw);
+  ret = current_target.to_remove_mask_watchpoint (&current_target,
+						  addr, mask, rw);
 
-	if (targetdebug)
-	  fprintf_unfiltered (gdb_stdlog, "\
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "\
 target_remove_mask_watchpoint (%s, %s, %d) = %d\n",
-			      core_addr_to_string (addr),
-			      core_addr_to_string (mask), rw, ret);
-
-	return ret;
-      }
+			core_addr_to_string (addr),
+			core_addr_to_string (mask), rw, ret);
 
-  return 1;
+  return ret;
 }
 
 /* The documentation for this function is in its prototype declaration
@@ -3823,13 +3763,8 @@ target_remove_mask_watchpoint (%s, %s, %d) = %d\n",
 int
 target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_masked_watch_num_registers != NULL)
-      return t->to_masked_watch_num_registers (t, addr, mask);
-
-  return -1;
+  return current_target.to_masked_watch_num_registers (&current_target,
+						       addr, mask);
 }
 
 /* The documentation for this function is in its prototype declaration
diff --git a/gdb/target.h b/gdb/target.h
index 29b3b96..0e3ce22 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -468,9 +468,11 @@ struct target_ops
       TARGET_DEFAULT_RETURN (-1);
 
     int (*to_insert_mask_watchpoint) (struct target_ops *,
-				      CORE_ADDR, CORE_ADDR, int);
+				      CORE_ADDR, CORE_ADDR, int)
+      TARGET_DEFAULT_RETURN (1);
     int (*to_remove_mask_watchpoint) (struct target_ops *,
-				      CORE_ADDR, CORE_ADDR, int);
+				      CORE_ADDR, CORE_ADDR, int)
+      TARGET_DEFAULT_RETURN (1);
     int (*to_stopped_by_watchpoint) (struct target_ops *)
       TARGET_DEFAULT_RETURN (0);
     int to_have_steppable_watchpoint;
@@ -492,7 +494,8 @@ struct target_ops
 					      struct expression *)
       TARGET_DEFAULT_RETURN (0);
     int (*to_masked_watch_num_registers) (struct target_ops *,
-					  CORE_ADDR, CORE_ADDR);
+					  CORE_ADDR, CORE_ADDR)
+      TARGET_DEFAULT_RETURN (-1);
     void (*to_terminal_init) (struct target_ops *)
       TARGET_DEFAULT_IGNORE ();
     void (*to_terminal_inferior) (struct target_ops *)
@@ -505,7 +508,8 @@ struct target_ops
       TARGET_DEFAULT_IGNORE ();
     void (*to_terminal_info) (struct target_ops *, const char *, int)
       TARGET_DEFAULT_FUNC (default_terminal_info);
-    void (*to_kill) (struct target_ops *);
+    void (*to_kill) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (noprocess ());
     void (*to_load) (struct target_ops *, char *, int)
       TARGET_DEFAULT_NORETURN (tcomplain ());
     void (*to_create_inferior) (struct target_ops *, 
@@ -520,7 +524,8 @@ struct target_ops
       TARGET_DEFAULT_RETURN (1);
     int (*to_remove_vfork_catchpoint) (struct target_ops *, int)
       TARGET_DEFAULT_RETURN (1);
-    int (*to_follow_fork) (struct target_ops *, int, int);
+    int (*to_follow_fork) (struct target_ops *, int, int)
+      TARGET_DEFAULT_FUNC (default_follow_fork);
     int (*to_insert_exec_catchpoint) (struct target_ops *, int)
       TARGET_DEFAULT_RETURN (1);
     int (*to_remove_exec_catchpoint) (struct target_ops *, int)
@@ -530,20 +535,25 @@ struct target_ops
       TARGET_DEFAULT_RETURN (1);
     int (*to_has_exited) (struct target_ops *, int, int, int *)
       TARGET_DEFAULT_RETURN (0);
-    void (*to_mourn_inferior) (struct target_ops *);
+    void (*to_mourn_inferior) (struct target_ops *)
+      TARGET_DEFAULT_FUNC (default_mourn_inferior);
     int (*to_can_run) (struct target_ops *);
 
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
-    void (*to_pass_signals) (struct target_ops *, int, unsigned char *);
+    void (*to_pass_signals) (struct target_ops *, int, unsigned char *)
+      TARGET_DEFAULT_IGNORE ();
 
     /* Documentation of this routine is provided with the
        corresponding target_* function.  */
-    void (*to_program_signals) (struct target_ops *, int, unsigned char *);
+    void (*to_program_signals) (struct target_ops *, int, unsigned char *)
+      TARGET_DEFAULT_IGNORE ();
 
     int (*to_thread_alive) (struct target_ops *, ptid_t ptid);
-    void (*to_find_new_threads) (struct target_ops *);
-    char *(*to_pid_to_str) (struct target_ops *, ptid_t);
+    void (*to_find_new_threads) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
+    char *(*to_pid_to_str) (struct target_ops *, ptid_t)
+      TARGET_DEFAULT_FUNC (default_pid_to_str);
     char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *)
       TARGET_DEFAULT_RETURN (0);
     char *(*to_thread_name) (struct target_ops *, struct thread_info *)
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 32/38] remove function casts from target.c
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (17 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 27/38] convert to_get_section_table Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 29/38] convert to_search_memory Tom Tromey
                   ` (20 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This cleans up target.c to avoid function casts.

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

	* target.c (complete_target_initialization): Remove casts.  Use
	return_zero_has_execution.
	(return_zero): Add "ignore" argument.
	(return_zero_has_execution): New function.
	(init_dummy_target): Remove casts.  Use
	return_zero_has_execution.
---
 gdb/ChangeLog |  9 +++++++++
 gdb/target.c  | 33 ++++++++++++++++++++-------------
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/gdb/target.c b/gdb/target.c
index eded617..8de7487 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -77,7 +77,9 @@ static void tcomplain (void) ATTRIBUTE_NORETURN;
 
 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
 
-static int return_zero (void);
+static int return_zero (struct target_ops *);
+
+static int return_zero_has_execution (struct target_ops *, ptid_t);
 
 void target_ignore (void);
 
@@ -376,19 +378,19 @@ complete_target_initialization (struct target_ops *t)
     t->to_xfer_partial = default_xfer_partial;
 
   if (t->to_has_all_memory == NULL)
-    t->to_has_all_memory = (int (*) (struct target_ops *)) return_zero;
+    t->to_has_all_memory = return_zero;
 
   if (t->to_has_memory == NULL)
-    t->to_has_memory = (int (*) (struct target_ops *)) return_zero;
+    t->to_has_memory = return_zero;
 
   if (t->to_has_stack == NULL)
-    t->to_has_stack = (int (*) (struct target_ops *)) return_zero;
+    t->to_has_stack = return_zero;
 
   if (t->to_has_registers == NULL)
-    t->to_has_registers = (int (*) (struct target_ops *)) return_zero;
+    t->to_has_registers = return_zero;
 
   if (t->to_has_execution == NULL)
-    t->to_has_execution = (int (*) (struct target_ops *, ptid_t)) return_zero;
+    t->to_has_execution = return_zero_has_execution;
 
   install_delegators (t);
 }
@@ -3185,7 +3187,13 @@ default_thread_architecture (struct target_ops *ops, ptid_t ptid)
 }
 
 static int
-return_zero (void)
+return_zero (struct target_ops *ignore)
+{
+  return 0;
+}
+
+static int
+return_zero_has_execution (struct target_ops *ignore, ptid_t ignore2)
 {
   return 0;
 }
@@ -3300,12 +3308,11 @@ init_dummy_target (void)
   dummy_target.to_supports_disable_randomization
     = find_default_supports_disable_randomization;
   dummy_target.to_stratum = dummy_stratum;
-  dummy_target.to_has_all_memory = (int (*) (struct target_ops *)) return_zero;
-  dummy_target.to_has_memory = (int (*) (struct target_ops *)) return_zero;
-  dummy_target.to_has_stack = (int (*) (struct target_ops *)) return_zero;
-  dummy_target.to_has_registers = (int (*) (struct target_ops *)) return_zero;
-  dummy_target.to_has_execution
-    = (int (*) (struct target_ops *, ptid_t)) return_zero;
+  dummy_target.to_has_all_memory = return_zero;
+  dummy_target.to_has_memory = return_zero;
+  dummy_target.to_has_stack = return_zero;
+  dummy_target.to_has_registers = return_zero;
+  dummy_target.to_has_execution = return_zero_has_execution;
   dummy_target.to_magic = OPS_MAGIC;
 
   install_dummy_methods (&dummy_target);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 24/38] convert to_upload_trace_state_variables
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (12 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 37/38] fix buglet in nto-procfs.c Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 26/38] convert to_insert_mask_watchpoint Tom Tromey
                   ` (25 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_upload_trace_state_variables.
	* target.h (struct target_ops) <to_upload_trace_state_variables>:
	Use TARGET_DEFAULT_RETURN.

convert to_get_raw_trace_data

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_raw_trace_data.
	* target.h (struct target_ops) <to_get_raw_trace_data>: Use
	TARGET_DEFAULT_NORETURN.

convert to_get_min_fast_tracepoint_insn_len

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_min_fast_tracepoint_insn_len.
	(return_minus_one): Remove.
	* target.h (struct target_ops)
	<to_get_min_fast_tracepoint_insn_len>: Use TARGET_DEFAULT_RETURN.

convert to_set_disconnected_tracing

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_set_disconnected_tracing.
	* target.h (struct target_ops) <to_set_disconnected_tracing>: Use
	TARGET_DEFAULT_IGNORE.

convert to_set_circular_trace_buffer

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_set_circular_trace_buffer.
	* target.h (struct target_ops) <to_set_circular_trace_buffer>: Use
	TARGET_DEFAULT_IGNORE.

convert to_set_trace_buffer_size

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't initialize
	to_set_trace_buffer_size.
	* target.h (struct target_ops) <to_set_trace_buffer_size>: Use
	TARGET_DEFAULT_IGNORE.

convert to_set_trace_notes

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_set_trace_notes.
	* target.h (struct target_ops) <to_set_trace_notes>: Use
	TARGET_DEFAULT_RETURN.

convert to_get_tib_address

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_tib_address.
	* target.h (struct target_ops) <to_get_tib_address>: Use
	TARGET_DEFAULT_NORETURN.

convert to_set_permissions

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_set_permissions.
	* target.h (struct target_ops) <to_set_permissions>: Use
	TARGET_DEFAULT_IGNORE.

convert to_static_tracepoint_marker_at

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_static_tracepoint_marker_at.
	* target.h (struct target_ops) <to_static_tracepoint_marker_at>:
	Use TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          |  81 +++++++++++++++++++++++++
 gdb/target-delegates.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  60 ++++---------------
 gdb/target.h           |  30 ++++++----
 4 files changed, 267 insertions(+), 60 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index d8d3dbd..968d2fd 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -833,6 +833,132 @@ tdefault_upload_tracepoints (struct target_ops *self, struct uploaded_tp **arg1)
 }
 
 static int
+delegate_upload_trace_state_variables (struct target_ops *self, struct uploaded_tsv **arg1)
+{
+  self = self->beneath;
+  return self->to_upload_trace_state_variables (self, arg1);
+}
+
+static int
+tdefault_upload_trace_state_variables (struct target_ops *self, struct uploaded_tsv **arg1)
+{
+  return 0;
+}
+
+static LONGEST
+delegate_get_raw_trace_data (struct target_ops *self, gdb_byte *arg1, ULONGEST arg2, LONGEST arg3)
+{
+  self = self->beneath;
+  return self->to_get_raw_trace_data (self, arg1, arg2, arg3);
+}
+
+static LONGEST
+tdefault_get_raw_trace_data (struct target_ops *self, gdb_byte *arg1, ULONGEST arg2, LONGEST arg3)
+{
+  tcomplain ();
+}
+
+static int
+delegate_get_min_fast_tracepoint_insn_len (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_get_min_fast_tracepoint_insn_len (self);
+}
+
+static int
+tdefault_get_min_fast_tracepoint_insn_len (struct target_ops *self)
+{
+  return -1;
+}
+
+static void
+delegate_set_disconnected_tracing (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  self->to_set_disconnected_tracing (self, arg1);
+}
+
+static void
+tdefault_set_disconnected_tracing (struct target_ops *self, int arg1)
+{
+}
+
+static void
+delegate_set_circular_trace_buffer (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  self->to_set_circular_trace_buffer (self, arg1);
+}
+
+static void
+tdefault_set_circular_trace_buffer (struct target_ops *self, int arg1)
+{
+}
+
+static void
+delegate_set_trace_buffer_size (struct target_ops *self, LONGEST arg1)
+{
+  self = self->beneath;
+  self->to_set_trace_buffer_size (self, arg1);
+}
+
+static void
+tdefault_set_trace_buffer_size (struct target_ops *self, LONGEST arg1)
+{
+}
+
+static int
+delegate_set_trace_notes (struct target_ops *self, const char *arg1, const char *arg2, const char *arg3)
+{
+  self = self->beneath;
+  return self->to_set_trace_notes (self, arg1, arg2, arg3);
+}
+
+static int
+tdefault_set_trace_notes (struct target_ops *self, const char *arg1, const char *arg2, const char *arg3)
+{
+  return 0;
+}
+
+static int
+delegate_get_tib_address (struct target_ops *self, ptid_t arg1, CORE_ADDR *arg2)
+{
+  self = self->beneath;
+  return self->to_get_tib_address (self, arg1, arg2);
+}
+
+static int
+tdefault_get_tib_address (struct target_ops *self, ptid_t arg1, CORE_ADDR *arg2)
+{
+  tcomplain ();
+}
+
+static void
+delegate_set_permissions (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_set_permissions (self);
+}
+
+static void
+tdefault_set_permissions (struct target_ops *self)
+{
+}
+
+static int
+delegate_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
+{
+  self = self->beneath;
+  return self->to_static_tracepoint_marker_at (self, arg1, arg2);
+}
+
+static int
+tdefault_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
+{
+  return 0;
+}
+
+static int
 delegate_supports_btrace (struct target_ops *self)
 {
   self = self->beneath;
@@ -990,6 +1116,26 @@ install_delegators (struct target_ops *ops)
     ops->to_save_trace_data = delegate_save_trace_data;
   if (ops->to_upload_tracepoints == NULL)
     ops->to_upload_tracepoints = delegate_upload_tracepoints;
+  if (ops->to_upload_trace_state_variables == NULL)
+    ops->to_upload_trace_state_variables = delegate_upload_trace_state_variables;
+  if (ops->to_get_raw_trace_data == NULL)
+    ops->to_get_raw_trace_data = delegate_get_raw_trace_data;
+  if (ops->to_get_min_fast_tracepoint_insn_len == NULL)
+    ops->to_get_min_fast_tracepoint_insn_len = delegate_get_min_fast_tracepoint_insn_len;
+  if (ops->to_set_disconnected_tracing == NULL)
+    ops->to_set_disconnected_tracing = delegate_set_disconnected_tracing;
+  if (ops->to_set_circular_trace_buffer == NULL)
+    ops->to_set_circular_trace_buffer = delegate_set_circular_trace_buffer;
+  if (ops->to_set_trace_buffer_size == NULL)
+    ops->to_set_trace_buffer_size = delegate_set_trace_buffer_size;
+  if (ops->to_set_trace_notes == NULL)
+    ops->to_set_trace_notes = delegate_set_trace_notes;
+  if (ops->to_get_tib_address == NULL)
+    ops->to_get_tib_address = delegate_get_tib_address;
+  if (ops->to_set_permissions == NULL)
+    ops->to_set_permissions = delegate_set_permissions;
+  if (ops->to_static_tracepoint_marker_at == NULL)
+    ops->to_static_tracepoint_marker_at = delegate_static_tracepoint_marker_at;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
 }
@@ -1068,5 +1214,15 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_get_trace_state_variable_value = tdefault_get_trace_state_variable_value;
   ops->to_save_trace_data = tdefault_save_trace_data;
   ops->to_upload_tracepoints = tdefault_upload_tracepoints;
+  ops->to_upload_trace_state_variables = tdefault_upload_trace_state_variables;
+  ops->to_get_raw_trace_data = tdefault_get_raw_trace_data;
+  ops->to_get_min_fast_tracepoint_insn_len = tdefault_get_min_fast_tracepoint_insn_len;
+  ops->to_set_disconnected_tracing = tdefault_set_disconnected_tracing;
+  ops->to_set_circular_trace_buffer = tdefault_set_circular_trace_buffer;
+  ops->to_set_trace_buffer_size = tdefault_set_trace_buffer_size;
+  ops->to_set_trace_notes = tdefault_set_trace_notes;
+  ops->to_get_tib_address = tdefault_get_tib_address;
+  ops->to_set_permissions = tdefault_set_permissions;
+  ops->to_static_tracepoint_marker_at = tdefault_static_tracepoint_marker_at;
   ops->to_supports_btrace = tdefault_supports_btrace;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 4657120..31be211 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -66,8 +66,6 @@ static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
 
 static int return_zero (void);
 
-static int return_minus_one (void);
-
 static void *return_null (void);
 
 void target_ignore (void);
@@ -703,16 +701,16 @@ update_current_target (void)
       /* Do not inherit to_get_trace_state_variable_value.  */
       /* Do not inherit to_save_trace_data.  */
       /* Do not inherit to_upload_tracepoints.  */
-      INHERIT (to_upload_trace_state_variables, t);
-      INHERIT (to_get_raw_trace_data, t);
-      INHERIT (to_get_min_fast_tracepoint_insn_len, t);
-      INHERIT (to_set_disconnected_tracing, t);
-      INHERIT (to_set_circular_trace_buffer, t);
-      INHERIT (to_set_trace_buffer_size, t);
-      INHERIT (to_set_trace_notes, t);
-      INHERIT (to_get_tib_address, t);
-      INHERIT (to_set_permissions, t);
-      INHERIT (to_static_tracepoint_marker_at, t);
+      /* Do not inherit to_upload_trace_state_variables.  */
+      /* Do not inherit to_get_raw_trace_data.  */
+      /* Do not inherit to_get_min_fast_tracepoint_insn_len.  */
+      /* Do not inherit to_set_disconnected_tracing.  */
+      /* Do not inherit to_set_circular_trace_buffer.  */
+      /* Do not inherit to_set_trace_buffer_size.  */
+      /* Do not inherit to_set_trace_notes.  */
+      /* Do not inherit to_get_tib_address.  */
+      /* Do not inherit to_set_permissions.  */
+      /* Do not inherit to_static_tracepoint_marker_at.  */
       INHERIT (to_static_tracepoint_markers_by_strid, t);
       INHERIT (to_traceframe_info, t);
       INHERIT (to_use_agent, t);
@@ -752,38 +750,6 @@ update_current_target (void)
 	    (void (*) (struct target_ops *, ptid_t))
 	    target_ignore);
   current_target.to_read_description = NULL;
-  de_fault (to_upload_trace_state_variables,
-	    (int (*) (struct target_ops *, struct uploaded_tsv **))
-	    return_zero);
-  de_fault (to_get_raw_trace_data,
-	    (LONGEST (*) (struct target_ops *, gdb_byte *, ULONGEST, LONGEST))
-	    tcomplain);
-  de_fault (to_get_min_fast_tracepoint_insn_len,
-	    (int (*) (struct target_ops *))
-	    return_minus_one);
-  de_fault (to_set_disconnected_tracing,
-	    (void (*) (struct target_ops *, int))
-	    target_ignore);
-  de_fault (to_set_circular_trace_buffer,
-	    (void (*) (struct target_ops *, int))
-	    target_ignore);
-  de_fault (to_set_trace_buffer_size,
-	    (void (*) (struct target_ops *, LONGEST))
-	    target_ignore);
-  de_fault (to_set_trace_notes,
-	    (int (*) (struct target_ops *,
-		      const char *, const char *, const char *))
-	    return_zero);
-  de_fault (to_get_tib_address,
-	    (int (*) (struct target_ops *, ptid_t, CORE_ADDR *))
-	    tcomplain);
-  de_fault (to_set_permissions,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
-  de_fault (to_static_tracepoint_marker_at,
-	    (int (*) (struct target_ops *,
-		      CORE_ADDR, struct static_tracepoint_marker *))
-	    return_zero);
   de_fault (to_static_tracepoint_markers_by_strid,
 	    (VEC(static_tracepoint_marker_p) * (*) (struct target_ops *,
 						    const char *))
@@ -3455,12 +3421,6 @@ return_zero (void)
   return 0;
 }
 
-static int
-return_minus_one (void)
-{
-  return -1;
-}
-
 static void *
 return_null (void)
 {
diff --git a/gdb/target.h b/gdb/target.h
index 4286874..40b3e57 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -864,29 +864,36 @@ struct target_ops
       TARGET_DEFAULT_RETURN (0);
 
     int (*to_upload_trace_state_variables) (struct target_ops *,
-					    struct uploaded_tsv **utsvp);
+					    struct uploaded_tsv **utsvp)
+      TARGET_DEFAULT_RETURN (0);
 
     LONGEST (*to_get_raw_trace_data) (struct target_ops *, gdb_byte *buf,
-				      ULONGEST offset, LONGEST len);
+				      ULONGEST offset, LONGEST len)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Get the minimum length of instruction on which a fast tracepoint
        may be set on the target.  If this operation is unsupported,
        return -1.  If for some reason the minimum length cannot be
        determined, return 0.  */
-    int (*to_get_min_fast_tracepoint_insn_len) (struct target_ops *);
+    int (*to_get_min_fast_tracepoint_insn_len) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (-1);
 
     /* Set the target's tracing behavior in response to unexpected
        disconnection - set VAL to 1 to keep tracing, 0 to stop.  */
-    void (*to_set_disconnected_tracing) (struct target_ops *, int val);
-    void (*to_set_circular_trace_buffer) (struct target_ops *, int val);
+    void (*to_set_disconnected_tracing) (struct target_ops *, int val)
+      TARGET_DEFAULT_IGNORE ();
+    void (*to_set_circular_trace_buffer) (struct target_ops *, int val)
+      TARGET_DEFAULT_IGNORE ();
     /* Set the size of trace buffer in the target.  */
-    void (*to_set_trace_buffer_size) (struct target_ops *, LONGEST val);
+    void (*to_set_trace_buffer_size) (struct target_ops *, LONGEST val)
+      TARGET_DEFAULT_IGNORE ();
 
     /* Add/change textual notes about the trace run, returning 1 if
        successful, 0 otherwise.  */
     int (*to_set_trace_notes) (struct target_ops *,
 			       const char *user, const char *notes,
-			       const char *stopnotes);
+			       const char *stopnotes)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Return the processor core that thread PTID was last seen on.
        This information is updated only when:
@@ -907,15 +914,18 @@ struct target_ops
     /* Return the address of the start of the Thread Information Block
        a Windows OS specific feature.  */
     int (*to_get_tib_address) (struct target_ops *,
-			       ptid_t ptid, CORE_ADDR *addr);
+			       ptid_t ptid, CORE_ADDR *addr)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Send the new settings of write permission variables.  */
-    void (*to_set_permissions) (struct target_ops *);
+    void (*to_set_permissions) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
 
     /* Look for a static tracepoint marker at ADDR, and fill in MARKER
        with its details.  Return 1 on success, 0 on failure.  */
     int (*to_static_tracepoint_marker_at) (struct target_ops *, CORE_ADDR,
-					   struct static_tracepoint_marker *marker);
+					   struct static_tracepoint_marker *marker)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Return a vector of all tracepoints markers string id ID, or all
        markers if ID is NULL.  */
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 22/38] convert to_thread_architecture
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (4 preceding siblings ...)
  2014-02-06 20:55 ` [RFC v2 02/38] introduce and use find_target_at Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 36/38] convert to_decr_pc_after_break Tom Tromey
                   ` (33 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_thread_architecture.
	* target.h (struct target_ops) <to_thread_architecture>: Use
	TARGET_DEFAULT_FUNC.

convert to_get_ada_task_ptid

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_ada_task_ptid.
	* target.h (struct target_ops) <to_get_ada_task_ptid>: Use
	TARGET_DEFAULT_FUNC.

convert to_supports_multi_process

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_supports_multi_process.
	* target.h (struct target_ops) <to_supports_multi_process>: Use
	TARGET_DEFAULT_RETURN.

convert to_supports_enable_disable_tracepoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_supports_enable_disable_tracepoint.
	* target.h (struct target_ops)
	<to_supports_enable_disable_tracepoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_supports_string_tracing

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_supports_string_tracing.
	* target.h (struct target_ops) <to_supports_string_tracing>: Use
	TARGET_DEFAULT_RETURN.

convert to_trace_init

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_trace_init.
	* target.h (struct target_ops) <to_trace_init>: Use
	TARGET_DEFAULT_RETURN.

convert to_download_tracepoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_download_tracepoint.
	* target.h (struct target_ops) <to_download_tracepoint>: Use
	TARGET_DEFAULT_NORETURN.

convert to_can_download_tracepoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_can_download_tracepoint.
	* target.h (struct target_ops) <to_can_download_tracepoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_download_trace_state_variable

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_download_trace_state_variable.
	* target.h (struct target_ops) <to_download_trace_state_variable>:
	Use TARGET_DEFAULT_NORETURN.

convert to_enable_tracepoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_enable_tracepoint.
	* target.h (struct target_ops) <to_enable_tracepoint>: Use
	TARGET_DEFAULT_NORETURN.
---
 gdb/ChangeLog          |  81 +++++++++++++++++++++++++++
 gdb/target-delegates.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  52 +++++------------
 gdb/target.h           |  30 ++++++----
 4 files changed, 262 insertions(+), 49 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 13e547d..358a64b 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -564,6 +564,13 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object  arg1, const
   return -1;
 }
 
+static ptid_t
+delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
+{
+  self = self->beneath;
+  return self->to_get_ada_task_ptid (self, arg1, arg2);
+}
+
 static int
 delegate_can_execute_reverse (struct target_ops *self)
 {
@@ -585,6 +592,117 @@ delegate_execution_direction (struct target_ops *self)
 }
 
 static int
+delegate_supports_multi_process (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_supports_multi_process (self);
+}
+
+static int
+tdefault_supports_multi_process (struct target_ops *self)
+{
+  return 0;
+}
+
+static int
+delegate_supports_enable_disable_tracepoint (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_supports_enable_disable_tracepoint (self);
+}
+
+static int
+tdefault_supports_enable_disable_tracepoint (struct target_ops *self)
+{
+  return 0;
+}
+
+static int
+delegate_supports_string_tracing (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_supports_string_tracing (self);
+}
+
+static int
+tdefault_supports_string_tracing (struct target_ops *self)
+{
+  return 0;
+}
+
+static struct gdbarch *
+delegate_thread_architecture (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  return self->to_thread_architecture (self, arg1);
+}
+
+static void
+delegate_trace_init (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_trace_init (self);
+}
+
+static void
+tdefault_trace_init (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static void
+delegate_download_tracepoint (struct target_ops *self, struct bp_location *arg1)
+{
+  self = self->beneath;
+  self->to_download_tracepoint (self, arg1);
+}
+
+static void
+tdefault_download_tracepoint (struct target_ops *self, struct bp_location *arg1)
+{
+  tcomplain ();
+}
+
+static int
+delegate_can_download_tracepoint (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_can_download_tracepoint (self);
+}
+
+static int
+tdefault_can_download_tracepoint (struct target_ops *self)
+{
+  return 0;
+}
+
+static void
+delegate_download_trace_state_variable (struct target_ops *self, struct trace_state_variable *arg1)
+{
+  self = self->beneath;
+  self->to_download_trace_state_variable (self, arg1);
+}
+
+static void
+tdefault_download_trace_state_variable (struct target_ops *self, struct trace_state_variable *arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_enable_tracepoint (struct target_ops *self, struct bp_location *arg1)
+{
+  self = self->beneath;
+  self->to_enable_tracepoint (self, arg1);
+}
+
+static void
+tdefault_enable_tracepoint (struct target_ops *self, struct bp_location *arg1)
+{
+  tcomplain ();
+}
+
+static int
 delegate_supports_btrace (struct target_ops *self)
 {
   self = self->beneath;
@@ -698,10 +816,30 @@ install_delegators (struct target_ops *ops)
     ops->to_goto_bookmark = delegate_goto_bookmark;
   if (ops->to_xfer_partial == NULL)
     ops->to_xfer_partial = delegate_xfer_partial;
+  if (ops->to_get_ada_task_ptid == NULL)
+    ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
   if (ops->to_can_execute_reverse == NULL)
     ops->to_can_execute_reverse = delegate_can_execute_reverse;
   if (ops->to_execution_direction == NULL)
     ops->to_execution_direction = delegate_execution_direction;
+  if (ops->to_supports_multi_process == NULL)
+    ops->to_supports_multi_process = delegate_supports_multi_process;
+  if (ops->to_supports_enable_disable_tracepoint == NULL)
+    ops->to_supports_enable_disable_tracepoint = delegate_supports_enable_disable_tracepoint;
+  if (ops->to_supports_string_tracing == NULL)
+    ops->to_supports_string_tracing = delegate_supports_string_tracing;
+  if (ops->to_thread_architecture == NULL)
+    ops->to_thread_architecture = delegate_thread_architecture;
+  if (ops->to_trace_init == NULL)
+    ops->to_trace_init = delegate_trace_init;
+  if (ops->to_download_tracepoint == NULL)
+    ops->to_download_tracepoint = delegate_download_tracepoint;
+  if (ops->to_can_download_tracepoint == NULL)
+    ops->to_can_download_tracepoint = delegate_can_download_tracepoint;
+  if (ops->to_download_trace_state_variable == NULL)
+    ops->to_download_trace_state_variable = delegate_download_trace_state_variable;
+  if (ops->to_enable_tracepoint == NULL)
+    ops->to_enable_tracepoint = delegate_enable_tracepoint;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
 }
@@ -758,7 +896,17 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_get_bookmark = tdefault_get_bookmark;
   ops->to_goto_bookmark = tdefault_goto_bookmark;
   ops->to_xfer_partial = tdefault_xfer_partial;
+  ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
   ops->to_can_execute_reverse = tdefault_can_execute_reverse;
   ops->to_execution_direction = default_execution_direction;
+  ops->to_supports_multi_process = tdefault_supports_multi_process;
+  ops->to_supports_enable_disable_tracepoint = tdefault_supports_enable_disable_tracepoint;
+  ops->to_supports_string_tracing = tdefault_supports_string_tracing;
+  ops->to_thread_architecture = default_thread_architecture;
+  ops->to_trace_init = tdefault_trace_init;
+  ops->to_download_tracepoint = tdefault_download_tracepoint;
+  ops->to_can_download_tracepoint = tdefault_can_download_tracepoint;
+  ops->to_download_trace_state_variable = tdefault_download_trace_state_variable;
+  ops->to_enable_tracepoint = tdefault_enable_tracepoint;
   ops->to_supports_btrace = tdefault_supports_btrace;
 }
diff --git a/gdb/target.c b/gdb/target.c
index b657900..2efd21f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -57,6 +57,9 @@ static int default_region_ok_for_hw_watchpoint (struct target_ops *,
 
 static void default_rcmd (struct target_ops *, char *, struct ui_file *);
 
+static ptid_t default_get_ada_task_ptid (struct target_ops *self,
+					 long lwp, long tid);
+
 static void tcomplain (void) ATTRIBUTE_NORETURN;
 
 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
@@ -678,18 +681,18 @@ update_current_target (void)
       /* Do not inherit to_get_thread_local_address.  */
       /* Do not inherit to_can_execute_reverse.  */
       /* Do not inherit to_execution_direction.  */
-      INHERIT (to_thread_architecture, t);
+      /* Do not inherit to_thread_architecture.  */
       /* Do not inherit to_read_description.  */
-      INHERIT (to_get_ada_task_ptid, t);
+      /* Do not inherit to_get_ada_task_ptid.  */
       /* Do not inherit to_search_memory.  */
-      INHERIT (to_supports_multi_process, t);
-      INHERIT (to_supports_enable_disable_tracepoint, t);
-      INHERIT (to_supports_string_tracing, t);
-      INHERIT (to_trace_init, t);
-      INHERIT (to_download_tracepoint, t);
-      INHERIT (to_can_download_tracepoint, t);
-      INHERIT (to_download_trace_state_variable, t);
-      INHERIT (to_enable_tracepoint, t);
+      /* Do not inherit to_supports_multi_process.  */
+      /* Do not inherit to_supports_enable_disable_tracepoint.  */
+      /* Do not inherit to_supports_string_tracing.  */
+      /* Do not inherit to_trace_init.  */
+      /* Do not inherit to_download_tracepoint.  */
+      /* Do not inherit to_can_download_tracepoint.  */
+      /* Do not inherit to_download_trace_state_variable.  */
+      /* Do not inherit to_enable_tracepoint.  */
       INHERIT (to_disable_tracepoint, t);
       INHERIT (to_trace_set_readonly_regions, t);
       INHERIT (to_trace_start, t);
@@ -748,36 +751,7 @@ update_current_target (void)
   de_fault (to_stop,
 	    (void (*) (struct target_ops *, ptid_t))
 	    target_ignore);
-  de_fault (to_thread_architecture,
-	    default_thread_architecture);
   current_target.to_read_description = NULL;
-  de_fault (to_get_ada_task_ptid,
-            (ptid_t (*) (struct target_ops *, long, long))
-            default_get_ada_task_ptid);
-  de_fault (to_supports_multi_process,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_supports_enable_disable_tracepoint,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_supports_string_tracing,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_trace_init,
-	    (void (*) (struct target_ops *))
-	    tcomplain);
-  de_fault (to_download_tracepoint,
-	    (void (*) (struct target_ops *, struct bp_location *))
-	    tcomplain);
-  de_fault (to_can_download_tracepoint,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_download_trace_state_variable,
-	    (void (*) (struct target_ops *, struct trace_state_variable *))
-	    tcomplain);
-  de_fault (to_enable_tracepoint,
-	    (void (*) (struct target_ops *, struct bp_location *))
-	    tcomplain);
   de_fault (to_disable_tracepoint,
 	    (void (*) (struct target_ops *, struct bp_location *))
 	    tcomplain);
diff --git a/gdb/target.h b/gdb/target.h
index 625968c..bd76453 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -667,7 +667,8 @@ struct target_ops
        task Private_Data section of the Ada Task Control Block, and
        their interpretation depends on the target.  */
     ptid_t (*to_get_ada_task_ptid) (struct target_ops *,
-				    long lwp, long thread);
+				    long lwp, long thread)
+      TARGET_DEFAULT_FUNC (default_get_ada_task_ptid);
 
     /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
        Return 0 if *READPTR is already at the end of the buffer.
@@ -699,17 +700,20 @@ struct target_ops
 
     /* Does this target support debugging multiple processes
        simultaneously?  */
-    int (*to_supports_multi_process) (struct target_ops *);
+    int (*to_supports_multi_process) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Does this target support enabling and disabling tracepoints while a trace
        experiment is running?  */
-    int (*to_supports_enable_disable_tracepoint) (struct target_ops *);
+    int (*to_supports_enable_disable_tracepoint) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Does this target support disabling address space randomization?  */
     int (*to_supports_disable_randomization) (struct target_ops *);
 
     /* Does this target support the tracenz bytecode for string collection?  */
-    int (*to_supports_string_tracing) (struct target_ops *);
+    int (*to_supports_string_tracing) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Does this target support evaluation of breakpoint conditions on its
        end?  */
@@ -729,7 +733,8 @@ struct target_ops
        ptrace operations need to operate according to target_gdbarch ().
 
        The default implementation always returns target_gdbarch ().  */
-    struct gdbarch *(*to_thread_architecture) (struct target_ops *, ptid_t);
+    struct gdbarch *(*to_thread_architecture) (struct target_ops *, ptid_t)
+      TARGET_DEFAULT_FUNC (default_thread_architecture);
 
     /* Determine current address space of thread PTID.
 
@@ -783,23 +788,28 @@ struct target_ops
     /* Tracepoint-related operations.  */
 
     /* Prepare the target for a tracing run.  */
-    void (*to_trace_init) (struct target_ops *);
+    void (*to_trace_init) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Send full details of a tracepoint location to the target.  */
     void (*to_download_tracepoint) (struct target_ops *,
-				    struct bp_location *location);
+				    struct bp_location *location)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Is the target able to download tracepoint locations in current
        state?  */
-    int (*to_can_download_tracepoint) (struct target_ops *);
+    int (*to_can_download_tracepoint) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Send full details of a trace state variable to the target.  */
     void (*to_download_trace_state_variable) (struct target_ops *,
-					      struct trace_state_variable *tsv);
+					      struct trace_state_variable *tsv)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Enable a tracepoint on the target.  */
     void (*to_enable_tracepoint) (struct target_ops *,
-				  struct bp_location *location);
+				  struct bp_location *location)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disable a tracepoint on the target.  */
     void (*to_disable_tracepoint) (struct target_ops *,
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 07/38] Add target_ops argument to to_close
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (14 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 26/38] convert to_insert_mask_watchpoint Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-08  3:00   ` Yao Qi
  2014-02-06 20:56 ` [RFC v2 35/38] remove some calls to INHERIT and de_fault Tom Tromey
                   ` (23 subsequent siblings)
  39 siblings, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* windows-nat.c (windows_close): Add 'self' argument.
	* tracepoint.c (tfile_close): Add 'self' argument.
	* target.h (struct target_ops) <to_close>: Add argument.
	* target.c (target_close): Add argument.
	(update_current_target): Update.
	* remote.c (remote_close): Add 'self' argument.
	* remote-sim.c (gdbsim_close): Add 'self' argument.
	* remote-mips.c (mips_close): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_close): Add 'self' argument.
	* record-full.c (record_full_close): Add 'self' argument.
	* record-btrace.c (record_btrace_close): Add 'self' argument.
	* monitor.h (monitor_close): Add 'self' argument.
	* monitor.c (monitor_close): Add 'self' argument.
	* mips-linux-nat.c (mips_linux_close): Add 'self' argument.
	* linux-nat.c (linux_nat_close): Add argument.
	* go32-nat.c (go32_close): Add 'self' argument.
	* exec.c (exec_close_1): Add 'self' argument.
	* ctf.c (ctf_close): Add 'self' argument.
	* corelow.c (core_close): Add 'self' argument.
	(core_close_cleanup): Update.
	* bsd-uthread.c (bsd_uthread_close): Add 'self' argument.
	* bsd-kvm.c (bsd_kvm_close): Add 'self' argument.

Add target_ops argument to to_post_attach

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

	* target.h (struct target_ops) <to_post_attach>: Add argument.
	(target_post_attach): Add argument.
	* target.c (debug_to_post_attach): Add argument.
	(update_current_target): Update.
	* spu-linux-nat.c (spu_child_post_attach): Add 'self' argument.
	* nto-procfs.c (procfs_post_attach): Add 'self' argument.
	* linux-nat.c (linux_child_post_attach): Add 'self' argument.
	* inf-ptrace.c (inf_ptrace_post_attach): Add 'self' argument.
	* inf-child.c (inf_child_post_attach): Add 'self' argument.

Add target_ops argument to to_can_use_hw_breakpoint

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

	* target.h (struct target_ops) <to_can_use_hw_breakpoint>: Add
	argument.
	(target_can_use_hardware_watchpoint): Add argument.
	* target.c (debug_to_can_use_hw_breakpoint): Add argument.
	(update_current_target): Update.
	* spu-linux-nat.c (spu_can_use_hw_breakpoint): Add 'self'
	argument.
	* s390-linux-nat.c (s390_can_use_hw_breakpoint): Add 'self'
	argument.
	* remote.c (remote_check_watch_resources): Add 'self' argument.
	* remote-mips.c (mips_can_use_watchpoint): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_can_use_hw_watchpoint): Add 'self'
	argument.
	* procfs.c (procfs_can_use_hw_breakpoint): Add 'self' argument.
	* ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Add 'self'
	argument.
	* nto-procfs.c (procfs_can_use_hw_breakpoint): Add 'self'
	argument.
	* mips-linux-nat.c (mips_linux_can_use_hw_breakpoint): Add 'self'
	argument.
	* inf-ttrace.c (inf_ttrace_can_use_hw_breakpoint): Add 'self'
	argument.
	* ia64-linux-nat.c (ia64_linux_can_use_hw_breakpoint): Add 'self'
	argument.
	* ia64-hpux-nat.c (ia64_hpux_can_use_hw_breakpoint): Add 'self'
	argument.
	* i386-nat.c (i386_can_use_hw_breakpoint): Add 'self' argument.
	* arm-linux-nat.c (arm_linux_can_use_hw_breakpoint): Add 'self'
	argument.
	* aarch64-linux-nat.c (aarch64_linux_can_use_hw_breakpoint): Add
	'self' argument.

Add target_ops argument to to_insert_hw_breakpoint

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

	* target.h (struct target_ops) <to_insert_hw_breakpoint>: Add
	argument.
	(target_insert_hw_breakpoint): Add argument.
	* target.c (debug_to_insert_hw_breakpoint): Add argument.
	(update_current_target): Update.
	* remote.c (remote_insert_hw_breakpoint): Add 'self' argument.
	* ppc-linux-nat.c (ppc_linux_insert_hw_breakpoint): Add 'self'
	argument.
	* nto-procfs.c (procfs_insert_hw_breakpoint): Add 'self' argument.
	* i386-nat.c (i386_insert_hw_breakpoint): Add 'self' argument.
	* arm-linux-nat.c (arm_linux_insert_hw_breakpoint): Add 'self'
	argument.
	* aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Add
	'self' argument.

Add target_ops argument to to_remove_hw_breakpoint

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

	* target.h (struct target_ops) <to_remove_hw_breakpoint>: Add
	argument.
	(target_remove_hw_breakpoint): Add argument.
	* target.c (debug_to_remove_hw_breakpoint): Add argument.
	(update_current_target): Update.
	* remote.c (remote_remove_hw_breakpoint): Add 'self' argument.
	* ppc-linux-nat.c (ppc_linux_remove_hw_breakpoint): Add 'self'
	argument.
	* i386-nat.c (i386_remove_hw_breakpoint): Add 'self' argument.
	* arm-linux-nat.c (arm_linux_remove_hw_breakpoint): Add 'self'
	argument.
	* aarch64-linux-nat.c (aarch64_linux_remove_hw_breakpoint): Add
	'self' argument.

Add target_ops argument to to_remove_watchpoint

2014-02-06  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.

Add target_ops argument to to_insert_watchpoint

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

	* target.h (struct target_ops) <to_insert_watchpoint>: Add
	argument.
	(target_insert_watchpoint): Add argument.
	* target.c (debug_to_insert_watchpoint): Add argument.
	(update_current_target): Update.
	* s390-linux-nat.c (s390_insert_watchpoint): Add 'self' argument.
	* remote.c (remote_insert_watchpoint): Add 'self' argument.
	* remote-mips.c (mips_insert_watchpoint): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_insert_watchpoint): Add 'self' argument.
	* procfs.c (procfs_insert_watchpoint): Add 'self' argument.
	* ppc-linux-nat.c (ppc_linux_insert_watchpoint): Add 'self'
	argument.
	* nto-procfs.c (procfs_insert_hw_watchpoint): Add 'self' argument.
	(procfs_insert_hw_watchpoint): Add 'self' argument.
	* mips-linux-nat.c (mips_linux_insert_watchpoint): Add 'self'
	argument.
	* inf-ttrace.c (inf_ttrace_insert_watchpoint): Add 'self'
	argument.
	* ia64-linux-nat.c (ia64_linux_insert_watchpoint): Add 'self'
	argument.
	* i386-nat.c (i386_insert_watchpoint): Add 'self' argument.
	* arm-linux-nat.c (arm_linux_insert_watchpoint): Add 'self'
	argument.
	* aarch64-linux-nat.c (aarch64_linux_insert_watchpoint): Add
	'self' argument.

Add target_ops argument to to_region_ok_for_hw_watchpoint

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

	* target.h (struct target_ops) <to_region_ok_for_hw_watchpoint>:
	Add argument.
	(target_region_ok_for_hw_watchpoint): Add argument.
	* target.c (debug_to_region_ok_for_hw_watchpoint): Add argument.
	(default_region_ok_for_hw_watchpoint): Add argument.
	* spu-multiarch.c (spu_region_ok_for_hw_watchpoint): Add argument.
	* s390-linux-nat.c (s390_region_ok_for_hw_watchpoint): Add 'self'
	argument.
	* remote.c (remote_region_ok_for_hw_watchpoint): Add 'self'
	argument.
	* procfs.c (procfs_region_ok_for_hw_watchpoint): Add 'self'
	argument.
	* ppc-linux-nat.c (ppc_linux_region_ok_for_hw_watchpoint): Add
	'self' argument.
	* mips-linux-nat.c (mips_linux_region_ok_for_hw_watchpoint): Add
	'self' argument.
	* inf-ttrace.c (inf_ttrace_region_ok_for_hw_watchpoint): Add
	'self' argument.
	* i386-nat.c (i386_region_ok_for_watchpoint): Add 'self' argument.
	* arm-linux-nat.c (arm_linux_region_ok_for_hw_watchpoint): Add
	'self' argument.
	* aarch64-linux-nat.c (aarch64_linux_region_ok_for_hw_watchpoint):
	Add 'self' argument.

Add target_ops argument to to_can_accel_watchpoint_condition

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

	* target.h (struct target_ops)
	<to_can_accel_watchpoint_condition>: Add argument.
	(target_can_accel_watchpoint_condition): Add argument.
	* target.c (debug_to_can_accel_watchpoint_condition): Add
	argument.
	(update_current_target): Update.
	* ppc-linux-nat.c (ppc_linux_can_accel_watchpoint_condition): Add
	'self' argument.
---
 gdb/ChangeLog           | 196 ++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/aarch64-linux-nat.c |  18 +++--
 gdb/arm-linux-nat.c     |  18 +++--
 gdb/bsd-kvm.c           |   2 +-
 gdb/bsd-uthread.c       |   2 +-
 gdb/corelow.c           |   6 +-
 gdb/ctf.c               |   2 +-
 gdb/exec.c              |   2 +-
 gdb/go32-nat.c          |   3 +-
 gdb/i386-nat.c          |  16 ++--
 gdb/ia64-hpux-nat.c     |   3 +-
 gdb/ia64-linux-nat.c    |   9 ++-
 gdb/inf-child.c         |   2 +-
 gdb/inf-ptrace.c        |   2 +-
 gdb/inf-ttrace.c        |  12 ++-
 gdb/linux-nat.c         |   6 +-
 gdb/mips-linux-nat.c    |  14 ++--
 gdb/monitor.c           |   2 +-
 gdb/monitor.h           |   2 +-
 gdb/nto-procfs.c        |  22 ++++--
 gdb/ppc-linux-nat.c     |  21 ++++--
 gdb/procfs.c            |  15 ++--
 gdb/record-btrace.c     |   2 +-
 gdb/record-full.c       |   2 +-
 gdb/remote-m32r-sdi.c   |  11 ++-
 gdb/remote-mips.c       |  13 ++--
 gdb/remote-sim.c        |   4 +-
 gdb/remote.c            |  20 +++--
 gdb/s390-linux-nat.c    |  12 ++-
 gdb/spu-linux-nat.c     |   5 +-
 gdb/spu-multiarch.c     |   6 +-
 gdb/target.c            |  96 +++++++++++++++---------
 gdb/target.h            |  47 +++++++-----
 gdb/tracepoint.c        |   2 +-
 gdb/windows-nat.c       |   2 +-
 35 files changed, 448 insertions(+), 149 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 703c4ed..c6437fe 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -941,7 +941,8 @@ aarch64_align_watchpoint (CORE_ADDR addr, int len, CORE_ADDR *aligned_addr_p,
    sharing implemented via reference counts.  */
 
 static int
-aarch64_linux_can_use_hw_breakpoint (int type, int cnt, int othertype)
+aarch64_linux_can_use_hw_breakpoint (struct target_ops *self,
+				     int type, int cnt, int othertype)
 {
   return 1;
 }
@@ -1201,7 +1202,8 @@ aarch64_handle_breakpoint (int type, CORE_ADDR addr, int len, int is_insert)
    Return 0 on success, -1 on failure.  */
 
 static int
-aarch64_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
+aarch64_linux_insert_hw_breakpoint (struct target_ops *self,
+				    struct gdbarch *gdbarch,
 				    struct bp_target_info *bp_tgt)
 {
   int ret;
@@ -1233,7 +1235,8 @@ aarch64_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
    Return 0 on success, -1 on failure.  */
 
 static int
-aarch64_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
+aarch64_linux_remove_hw_breakpoint (struct target_ops *self,
+				    struct gdbarch *gdbarch,
 				    struct bp_target_info *bp_tgt)
 {
   int ret;
@@ -1337,7 +1340,8 @@ aarch64_handle_watchpoint (int type, CORE_ADDR addr, int len, int is_insert)
    of the type TYPE.  Return 0 on success, -1 on failure.  */
 
 static int
-aarch64_linux_insert_watchpoint (CORE_ADDR addr, int len, int type,
+aarch64_linux_insert_watchpoint (struct target_ops *self,
+				 CORE_ADDR addr, int len, int type,
 				 struct expression *cond)
 {
   int ret;
@@ -1369,7 +1373,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;
@@ -1398,7 +1403,8 @@ aarch64_linux_remove_watchpoint (CORE_ADDR addr, int len, int type,
 /* Implement the "to_region_ok_for_hw_watchpoint" target_ops method.  */
 
 static int
-aarch64_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+aarch64_linux_region_ok_for_hw_watchpoint (struct target_ops *self,
+					   CORE_ADDR addr, int len)
 {
   CORE_ADDR aligned_addr;
 
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 9fa5f5b..75f58ca 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -747,7 +747,8 @@ arm_linux_get_hw_watchpoint_count (void)
 /* Have we got a free break-/watch-point available for use?  Returns -1 if
    there is not an appropriate resource available, otherwise returns 1.  */
 static int
-arm_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
+arm_linux_can_use_hw_breakpoint (struct target_ops *self,
+				 int type, int cnt, int ot)
 {
   if (type == bp_hardware_watchpoint || type == bp_read_watchpoint
       || type == bp_access_watchpoint || type == bp_watchpoint)
@@ -1036,7 +1037,8 @@ arm_linux_remove_hw_breakpoint1 (const struct arm_linux_hw_breakpoint *bpt,
 
 /* Insert a Hardware breakpoint.  */
 static int
-arm_linux_insert_hw_breakpoint (struct gdbarch *gdbarch, 
+arm_linux_insert_hw_breakpoint (struct target_ops *self,
+				struct gdbarch *gdbarch, 
 				struct bp_target_info *bp_tgt)
 {
   struct lwp_info *lp;
@@ -1054,7 +1056,8 @@ arm_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
 
 /* Remove a hardware breakpoint.  */
 static int
-arm_linux_remove_hw_breakpoint (struct gdbarch *gdbarch, 
+arm_linux_remove_hw_breakpoint (struct target_ops *self,
+				struct gdbarch *gdbarch, 
 				struct bp_target_info *bp_tgt)
 {
   struct lwp_info *lp;
@@ -1073,7 +1076,8 @@ arm_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
 /* Are we able to use a hardware watchpoint for the LEN bytes starting at 
    ADDR?  */
 static int
-arm_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+arm_linux_region_ok_for_hw_watchpoint (struct target_ops *self,
+				       CORE_ADDR addr, int len)
 {
   const struct arm_linux_hwbp_cap *cap = arm_linux_get_hwbp_cap ();
   CORE_ADDR max_wp_length, aligned_addr;
@@ -1105,7 +1109,8 @@ arm_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
 
 /* Insert a Hardware breakpoint.  */
 static int
-arm_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
+arm_linux_insert_watchpoint (struct target_ops *self,
+			     CORE_ADDR addr, int len, int rw,
 			     struct expression *cond)
 {
   struct lwp_info *lp;
@@ -1123,7 +1128,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/bsd-kvm.c b/gdb/bsd-kvm.c
index cfa8867..f57ae72 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -105,7 +105,7 @@ bsd_kvm_open (char *filename, int from_tty)
 }
 
 static void
-bsd_kvm_close (void)
+bsd_kvm_close (struct target_ops *self)
 {
   if (core_kd)
     {
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 4683abf..39218ba 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -204,7 +204,7 @@ bsd_uthread_activate (struct objfile *objfile)
 /* Cleanup due to deactivation.  */
 
 static void
-bsd_uthread_close (void)
+bsd_uthread_close (struct target_ops *self)
 {
   bsd_uthread_active = 0;
   bsd_uthread_thread_run_addr = 0;
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 2d4a719..1198a51 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -85,7 +85,7 @@ static int gdb_check_format (bfd *);
 
 static void core_open (char *, int);
 
-static void core_close (void);
+static void core_close (struct target_ops *self);
 
 static void core_close_cleanup (void *ignore);
 
@@ -192,7 +192,7 @@ gdb_check_format (bfd *abfd)
    stack spaces as empty.  */
 
 static void
-core_close (void)
+core_close (struct target_ops *self)
 {
   if (core_bfd)
     {
@@ -223,7 +223,7 @@ core_close (void)
 static void
 core_close_cleanup (void *ignore)
 {
-  core_close ();
+  core_close (NULL);
 }
 
 /* Look for sections whose names start with `.reg/' so that we can
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 6035c2b..6caca5f 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1204,7 +1204,7 @@ ctf_open (char *dirname, int from_tty)
    CTF iterator and context.  */
 
 static void
-ctf_close (void)
+ctf_close (struct target_ops *self)
 {
   int pid;
 
diff --git a/gdb/exec.c b/gdb/exec.c
index b5aa7f2..cc7fa13 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -112,7 +112,7 @@ exec_close (void)
    sections and closes all executable bfds from all program spaces.  */
 
 static void
-exec_close_1 (void)
+exec_close_1 (struct target_ops *self)
 {
   using_exec_ops = 0;
 
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 7dc6307..1529cc3 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -234,7 +234,6 @@ static int dr_ref_count[4];
 #define SOME_PID 42
 
 static int prog_has_started = 0;
-
 static void go32_mourn_inferior (struct target_ops *ops);
 
 static struct target_ops go32_ops;
@@ -347,7 +346,7 @@ go32_open (char *name, int from_tty)
 }
 
 static void
-go32_close (void)
+go32_close (struct target_ops *self)
 {
 }
 
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 23edc38..2f80a6e 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -589,7 +589,8 @@ i386_update_inferior_debug_regs (struct i386_debug_reg_state *new_state)
    of the type TYPE.  Return 0 on success, -1 on failure.  */
 
 static int
-i386_insert_watchpoint (CORE_ADDR addr, int len, int type,
+i386_insert_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   struct i386_debug_reg_state *state
@@ -627,7 +628,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
@@ -662,7 +664,8 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type,
    address ADDR and whose length is LEN bytes.  */
 
 static int
-i386_region_ok_for_watchpoint (CORE_ADDR addr, int len)
+i386_region_ok_for_watchpoint (struct target_ops *self,
+			       CORE_ADDR addr, int len)
 {
   struct i386_debug_reg_state *state
     = i386_debug_reg_state (ptid_get_pid (inferior_ptid));
@@ -765,7 +768,7 @@ i386_stopped_by_watchpoint (struct target_ops *ops)
 /* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
    Return 0 on success, EBUSY on failure.  */
 static int
-i386_insert_hw_breakpoint (struct gdbarch *gdbarch,
+i386_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
 			   struct bp_target_info *bp_tgt)
 {
   struct i386_debug_reg_state *state
@@ -791,7 +794,7 @@ i386_insert_hw_breakpoint (struct gdbarch *gdbarch,
    Return 0 on success, -1 on failure.  */
 
 static int
-i386_remove_hw_breakpoint (struct gdbarch *gdbarch,
+i386_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
 			   struct bp_target_info *bp_tgt)
 {
   struct i386_debug_reg_state *state
@@ -831,7 +834,8 @@ i386_remove_hw_breakpoint (struct gdbarch *gdbarch,
    sharing implemented via reference counts in i386-nat.c.  */
 
 static int
-i386_can_use_hw_breakpoint (int type, int cnt, int othertype)
+i386_can_use_hw_breakpoint (struct target_ops *self,
+			    int type, int cnt, int othertype)
 {
   return 1;
 }
diff --git a/gdb/ia64-hpux-nat.c b/gdb/ia64-hpux-nat.c
index 2b0e889..c5053fc 100644
--- a/gdb/ia64-hpux-nat.c
+++ b/gdb/ia64-hpux-nat.c
@@ -694,7 +694,8 @@ ia64_hpux_xfer_partial (struct target_ops *ops, enum target_object object,
 /* The "to_can_use_hw_breakpoint" target_ops routine for ia64-hpux.  */
 
 static int
-ia64_hpux_can_use_hw_breakpoint (int type, int cnt, int othertype)
+ia64_hpux_can_use_hw_breakpoint (struct target_ops *self,
+				 int type, int cnt, int othertype)
 {
   /* No hardware watchpoint/breakpoint support yet.  */
   return 0;
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index ea575c8..ccd55b2 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -542,7 +542,8 @@ is_power_of_2 (int val)
 }
 
 static int
-ia64_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
+ia64_linux_insert_watchpoint (struct target_ops *self,
+			      CORE_ADDR addr, int len, int rw,
 			      struct expression *cond)
 {
   struct lwp_info *lp;
@@ -596,7 +597,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;
@@ -676,7 +678,8 @@ ia64_linux_stopped_by_watchpoint (struct target_ops *ops)
 }
 
 static int
-ia64_linux_can_use_hw_breakpoint (int type, int cnt, int othertype)
+ia64_linux_can_use_hw_breakpoint (struct target_ops *self,
+				  int type, int cnt, int othertype)
 {
   return 1;
 }
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 549e44a..c142912 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -87,7 +87,7 @@ inf_child_store_inferior_registers (struct target_ops *ops,
 }
 
 static void
-inf_child_post_attach (int pid)
+inf_child_post_attach (struct target_ops *self, int pid)
 {
   /* This version of Unix doesn't require a meaningful "post attach"
      operation by a debugger.  */
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index a64c876..d054126 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -246,7 +246,7 @@ inf_ptrace_attach (struct target_ops *ops, char *args, int from_tty)
 #ifdef PT_GET_PROCESS_STATE
 
 static void
-inf_ptrace_post_attach (int pid)
+inf_ptrace_post_attach (struct target_ops *self, int pid)
 {
   ptrace_event_t pe;
 
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index de95ec7..e9da0e7 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -314,7 +314,8 @@ inf_ttrace_disable_page_protections (pid_t pid)
    type TYPE.  */
 
 static int
-inf_ttrace_insert_watchpoint (CORE_ADDR addr, int len, int type,
+inf_ttrace_insert_watchpoint (struct target_ops *self,
+			      CORE_ADDR addr, int len, int type,
 			      struct expression *cond)
 {
   const int pagesize = inf_ttrace_page_dict.pagesize;
@@ -338,7 +339,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;
@@ -359,13 +361,15 @@ inf_ttrace_remove_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-inf_ttrace_can_use_hw_breakpoint (int type, int len, int ot)
+inf_ttrace_can_use_hw_breakpoint (struct target_ops *self,
+				  int type, int len, int ot)
 {
   return (type == bp_hardware_watchpoint);
 }
 
 static int
-inf_ttrace_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+inf_ttrace_region_ok_for_hw_watchpoint (struct target_ops *self,
+					CORE_ADDR addr, int len)
 {
   return 1;
 }
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index e5938d3..0475eb3 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -329,7 +329,7 @@ linux_init_ptrace (pid_t pid)
 }
 
 static void
-linux_child_post_attach (int pid)
+linux_child_post_attach (struct target_ops *self, int pid)
 {
   linux_init_ptrace (pid);
 }
@@ -4751,14 +4751,14 @@ linux_nat_stop (ptid_t ptid)
 }
 
 static void
-linux_nat_close (void)
+linux_nat_close (struct target_ops *self)
 {
   /* Unregister from the event loop.  */
   if (linux_nat_is_async_p (NULL))
     linux_nat_async (NULL, NULL, 0);
 
   if (linux_ops->to_close)
-    linux_ops->to_close ();
+    linux_ops->to_close (linux_ops);
 }
 
 /* When requests are passed down from the linux-nat layer to the
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 627241f..4c28733 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -512,7 +512,8 @@ mips_show_dr (const char *func, CORE_ADDR addr,
    handle the specified watch type.  */
 
 static int
-mips_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
+mips_linux_can_use_hw_breakpoint (struct target_ops *self,
+				  int type, int cnt, int ot)
 {
   int i;
   uint32_t wanted_mask, irw_mask;
@@ -588,7 +589,8 @@ mips_linux_stopped_data_address (struct target_ops *t, CORE_ADDR *paddr)
    the specified region can be covered by the watch registers.  */
 
 static int
-mips_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+mips_linux_region_ok_for_hw_watchpoint (struct target_ops *self,
+					CORE_ADDR addr, int len)
 {
   struct pt_watch_regs dummy_regs;
   int i;
@@ -644,7 +646,8 @@ mips_linux_new_thread (struct lwp_info *lp)
    watch.  Return zero on success.  */
 
 static int
-mips_linux_insert_watchpoint (CORE_ADDR addr, int len, int type,
+mips_linux_insert_watchpoint (struct target_ops *self,
+			      CORE_ADDR addr, int len, int type,
 			      struct expression *cond)
 {
   struct pt_watch_regs regs;
@@ -697,7 +700,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;
@@ -744,7 +748,7 @@ mips_linux_remove_watchpoint (CORE_ADDR addr, int len, int type,
    super implementation.  */
 
 static void
-mips_linux_close (void)
+mips_linux_close (struct target_ops *self)
 {
   struct mips_watchpoint *w;
   struct mips_watchpoint *nw;
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 29c3f71..8129d20 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -853,7 +853,7 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
    control.  */
 
 void
-monitor_close (void)
+monitor_close (struct target_ops *self)
 {
   if (monitor_desc)
     serial_close (monitor_desc);
diff --git a/gdb/monitor.h b/gdb/monitor.h
index c7e7af8..07caf97 100644
--- a/gdb/monitor.h
+++ b/gdb/monitor.h
@@ -240,7 +240,7 @@ struct monitor_ops
 #define SREC_SIZE 160
 
 extern void monitor_open (char *args, struct monitor_ops *ops, int from_tty);
-extern void monitor_close (void);
+extern void monitor_close (struct target_ops *self);
 extern char *monitor_supply_register (struct regcache *regcache,
 				      int regno, char *valstr);
 extern int monitor_expect (char *prompt, char *buf, int buflen);
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 7739197..0a7ed55 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -67,12 +67,15 @@ static void init_procfs_ops (void);
 
 static ptid_t do_attach (ptid_t ptid);
 
-static int procfs_can_use_hw_breakpoint (int, int, int);
+static int procfs_can_use_hw_breakpoint (struct target_ops *self,
+					 int, int, int);
 
-static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type,
+static int procfs_insert_hw_watchpoint (struct target_ops *self,
+					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);
@@ -648,7 +651,7 @@ procfs_attach (struct target_ops *ops, char *args, int from_tty)
 }
 
 static void
-procfs_post_attach (pid_t pid)
+procfs_post_attach (struct target_ops *self, pid_t pid)
 {
   if (exec_bfd)
     solib_create_inferior_hook (0);
@@ -936,7 +939,7 @@ procfs_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 }
 
 static int
-procfs_insert_hw_breakpoint (struct gdbarch *gdbarch,
+procfs_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
 			     struct bp_target_info *bp_tgt)
 {
   return procfs_breakpoint (bp_tgt->placed_address,
@@ -1488,20 +1491,23 @@ procfs_hw_watchpoint (int addr, int len, int type)
 }
 
 static int
-procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
+procfs_can_use_hw_breakpoint (struct target_ops *self,
+			      int type, int cnt, int othertype)
 {
   return 1;
 }
 
 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);
 }
 
 static int
-procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type,
+procfs_insert_hw_watchpoint (struct target_ops *self,
+			     CORE_ADDR addr, int len, int type,
 			     struct expression *cond)
 {
   return procfs_hw_watchpoint (addr, len, type);
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index b38b33e..fcfd452 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1444,7 +1444,8 @@ have_ptrace_hwdebug_interface (void)
 }
 
 static int
-ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
+ppc_linux_can_use_hw_breakpoint (struct target_ops *self,
+				 int type, int cnt, int ot)
 {
   int total_hw_wp, total_hw_bp;
 
@@ -1496,7 +1497,8 @@ ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
 }
 
 static int
-ppc_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+ppc_linux_region_ok_for_hw_watchpoint (struct target_ops *self,
+				       CORE_ADDR addr, int len)
 {
   /* Handle sub-8-byte quantities.  */
   if (len <= 0)
@@ -1672,7 +1674,8 @@ ppc_linux_ranged_break_num_registers (struct target_ops *target)
    success, 1 if hardware breakpoints are not supported or -1 for failure.  */
 
 static int
-ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
+ppc_linux_insert_hw_breakpoint (struct target_ops *self,
+				struct gdbarch *gdbarch,
 				  struct bp_target_info *bp_tgt)
 {
   struct lwp_info *lp;
@@ -1708,7 +1711,8 @@ ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
 }
 
 static int
-ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
+ppc_linux_remove_hw_breakpoint (struct target_ops *self,
+				struct gdbarch *gdbarch,
 				  struct bp_target_info *bp_tgt)
 {
   struct lwp_info *lp;
@@ -2011,7 +2015,8 @@ check_condition (CORE_ADDR watch_addr, struct expression *cond,
    the condition expression, thus only triggering the watchpoint when it is
    true.  */
 static int
-ppc_linux_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int rw,
+ppc_linux_can_accel_watchpoint_condition (struct target_ops *self,
+					  CORE_ADDR addr, int len, int rw,
 					  struct expression *cond)
 {
   CORE_ADDR data_value;
@@ -2073,7 +2078,8 @@ create_watchpoint_request (struct ppc_hw_breakpoint *p, CORE_ADDR addr,
 }
 
 static int
-ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
+ppc_linux_insert_watchpoint (struct target_ops *self,
+			     CORE_ADDR addr, int len, int rw,
 			     struct expression *cond)
 {
   struct lwp_info *lp;
@@ -2141,7 +2147,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 bd0829d..bd1ce41 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -140,7 +140,8 @@ static int proc_find_memory_regions (find_memory_region_ftype, void *);
 
 static char * procfs_make_note_section (bfd *, int *);
 
-static int procfs_can_use_hw_breakpoint (int, int, int);
+static int procfs_can_use_hw_breakpoint (struct target_ops *self,
+					 int, int, int);
 
 static void procfs_info_proc (struct target_ops *, char *,
 			      enum info_proc_what);
@@ -4832,7 +4833,8 @@ procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag,
    target_can_use_hardware_watchpoint.  */
 
 static int
-procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
+procfs_can_use_hw_breakpoint (struct target_ops *self,
+			      int type, int cnt, int othertype)
 {
   /* Due to the way that proc_set_watchpoint() is implemented, host
      and target pointers must be of the same size.  If they are not,
@@ -4895,7 +4897,8 @@ procfs_stopped_data_address (struct target_ops *targ, CORE_ADDR *addr)
 }
 
 static int
-procfs_insert_watchpoint (CORE_ADDR addr, int len, int type,
+procfs_insert_watchpoint (struct target_ops *self,
+			  CORE_ADDR addr, int len, int type,
 			  struct expression *cond)
 {
   if (!target_have_steppable_watchpoint
@@ -4917,14 +4920,16 @@ 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);
 }
 
 static int
-procfs_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+procfs_region_ok_for_hw_watchpoint (struct target_ops *self,
+				    CORE_ADDR addr, int len)
 {
   /* The man page for proc(4) on Solaris 2.6 and up says that the
      system can support "thousands" of hardware watchpoints, but gives
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index e1125b5..7d43330 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -211,7 +211,7 @@ record_btrace_stop_recording (void)
 /* The to_close method of target record-btrace.  */
 
 static void
-record_btrace_close (void)
+record_btrace_close (struct target_ops *self)
 {
   struct thread_info *tp;
 
diff --git a/gdb/record-full.c b/gdb/record-full.c
index d330892..fa9fbf5 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -877,7 +877,7 @@ record_full_open (char *name, int from_tty)
 /* "to_close" target method.  Close the process record target.  */
 
 static void
-record_full_close (void)
+record_full_close (struct target_ops *self)
 {
   struct record_full_core_buf_entry *entry;
 
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 48c4b4b..37649e4 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -429,7 +429,7 @@ m32r_open (char *args, int from_tty)
 /* Close out all files and local state before this target loses control.  */
 
 static void
-m32r_close (void)
+m32r_close (struct target_ops *self)
 {
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog, "m32r_close()\n");
@@ -1407,7 +1407,8 @@ m32r_stop (ptid_t ptid)
    implements the target_can_use_hardware_watchpoint macro.  */
 
 static int
-m32r_can_use_hw_watchpoint (int type, int cnt, int othertype)
+m32r_can_use_hw_watchpoint (struct target_ops *self,
+			    int type, int cnt, int othertype)
 {
   return sdi_desc != NULL && cnt < max_access_breaks;
 }
@@ -1417,7 +1418,8 @@ m32r_can_use_hw_watchpoint (int type, int cnt, int othertype)
    watchpoint.  */
 
 static int
-m32r_insert_watchpoint (CORE_ADDR addr, int len, int type,
+m32r_insert_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   int i;
@@ -1442,7 +1444,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 6109e64..e8ef449 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -84,7 +84,7 @@ static void ddb_open (char *name, int from_tty);
 
 static void lsi_open (char *name, int from_tty);
 
-static void mips_close (void);
+static void mips_close (struct target_ops *self);
 
 static int mips_map_regno (struct gdbarch *, int);
 
@@ -1732,7 +1732,7 @@ lsi_open (char *name, int from_tty)
 /* Close a connection to the remote board.  */
 
 static void
-mips_close (void)
+mips_close (struct target_ops *self)
 {
   if (mips_is_open)
     {
@@ -2391,7 +2391,8 @@ mips_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
    implements the target_can_use_hardware_watchpoint macro.  */
 
 static int
-mips_can_use_watchpoint (int type, int cnt, int othertype)
+mips_can_use_watchpoint (struct target_ops *self,
+			 int type, int cnt, int othertype)
 {
   return cnt < MAX_LSI_BREAKPOINTS && strcmp (target_shortname, "lsi") == 0;
 }
@@ -2425,7 +2426,8 @@ calculate_mask (CORE_ADDR addr, int len)
    watchpoint.  */
 
 static int
-mips_insert_watchpoint (CORE_ADDR addr, int len, int type,
+mips_insert_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   if (mips_set_breakpoint (addr, len, type))
@@ -2437,7 +2439,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-sim.c b/gdb/remote-sim.c
index 9309087..220ce9d 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -76,7 +76,7 @@ static void gdbsim_load (char *prog, int fromtty);
 
 static void gdbsim_open (char *args, int from_tty);
 
-static void gdbsim_close (void);
+static void gdbsim_close (struct target_ops *self);
 
 static void gdbsim_detach (struct target_ops *ops, const char *args,
 			   int from_tty);
@@ -788,7 +788,7 @@ gdbsim_close_inferior (struct inferior *inf, void *arg)
 /* Close out all files and local state before this target loses control.  */
 
 static void
-gdbsim_close (void)
+gdbsim_close (struct target_ops *self)
 {
   struct sim_inferior_data *sim_data
     = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
diff --git a/gdb/remote.c b/gdb/remote.c
index 88feab0..dedfc77 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -106,7 +106,7 @@ static void extended_remote_open (char *name, int from_tty);
 
 static void remote_open_1 (char *, int, struct target_ops *, int extended_p);
 
-static void remote_close (void);
+static void remote_close (struct target_ops *self);
 
 static void remote_mourn (struct target_ops *ops);
 
@@ -3059,7 +3059,7 @@ extended_remote_restart (void)
 /* Clean up connection to a remote debugger.  */
 
 static void
-remote_close (void)
+remote_close (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -8371,7 +8371,8 @@ watchpoint_to_Z_packet (int type)
 }
 
 static int
-remote_insert_watchpoint (CORE_ADDR addr, int len, int type,
+remote_insert_watchpoint (struct target_ops *self,
+			  CORE_ADDR addr, int len, int type,
 			  struct expression *cond)
 {
   struct remote_state *rs = get_remote_state ();
@@ -8420,7 +8421,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 ();
@@ -8462,7 +8464,8 @@ int remote_hw_watchpoint_length_limit = -1;
 int remote_hw_breakpoint_limit = -1;
 
 static int
-remote_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+remote_region_ok_for_hw_watchpoint (struct target_ops *self,
+				    CORE_ADDR addr, int len)
 {
   if (remote_hw_watchpoint_length_limit == 0)
     return 0;
@@ -8475,7 +8478,8 @@ remote_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
 }
 
 static int
-remote_check_watch_resources (int type, int cnt, int ot)
+remote_check_watch_resources (struct target_ops *self,
+			      int type, int cnt, int ot)
 {
   if (type == bp_hardware_breakpoint)
     {
@@ -8525,7 +8529,7 @@ remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
 
 
 static int
-remote_insert_hw_breakpoint (struct gdbarch *gdbarch,
+remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
 			     struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr;
@@ -8589,7 +8593,7 @@ remote_insert_hw_breakpoint (struct gdbarch *gdbarch,
 
 
 static int
-remote_remove_hw_breakpoint (struct gdbarch *gdbarch,
+remote_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
 			     struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr;
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 8cc9060..5c38952 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -508,7 +508,8 @@ s390_fix_watch_points (struct lwp_info *lp)
 }
 
 static int
-s390_insert_watchpoint (CORE_ADDR addr, int len, int type,
+s390_insert_watchpoint (struct target_ops *self,
+			CORE_ADDR addr, int len, int type,
 			struct expression *cond)
 {
   struct lwp_info *lp;
@@ -529,7 +530,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;
@@ -557,13 +559,15 @@ s390_remove_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-s390_can_use_hw_breakpoint (int type, int cnt, int othertype)
+s390_can_use_hw_breakpoint (struct target_ops *self,
+			    int type, int cnt, int othertype)
 {
   return type == bp_hardware_watchpoint;
 }
 
 static int
-s390_region_ok_for_hw_watchpoint (CORE_ADDR addr, int cnt)
+s390_region_ok_for_hw_watchpoint (struct target_ops *self,
+				  CORE_ADDR addr, int cnt)
 {
   return 1;
 }
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index 784939b..ab80abf 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -409,7 +409,7 @@ spu_child_post_startup_inferior (ptid_t ptid)
 /* Override the post_attach routine to try load the SPE executable
    file image from its copy inside the target process.  */
 static void
-spu_child_post_attach (int pid)
+spu_child_post_attach (struct target_ops *self, int pid)
 {
   int fd;
   ULONGEST addr;
@@ -606,7 +606,8 @@ spu_xfer_partial (struct target_ops *ops,
 
 /* Override the to_can_use_hw_breakpoint routine.  */
 static int
-spu_can_use_hw_breakpoint (int type, int cnt, int othertype)
+spu_can_use_hw_breakpoint (struct target_ops *self,
+			   int type, int cnt, int othertype)
 {
   return 0;
 }
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index 11a566a..dd842f1 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -118,7 +118,8 @@ spu_thread_architecture (struct target_ops *ops, ptid_t ptid)
 
 /* Override the to_region_ok_for_hw_watchpoint routine.  */
 static int
-spu_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+spu_region_ok_for_hw_watchpoint (struct target_ops *self,
+				 CORE_ADDR addr, int len)
 {
   struct target_ops *ops_beneath = find_target_beneath (&spu_ops);
   while (ops_beneath && !ops_beneath->to_region_ok_for_hw_watchpoint)
@@ -129,7 +130,8 @@ spu_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
     return 0;
 
   if (ops_beneath)
-    return ops_beneath->to_region_ok_for_hw_watchpoint (addr, len);
+    return ops_beneath->to_region_ok_for_hw_watchpoint (ops_beneath,
+							addr, len);
 
   return 0;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 8ab9cbf..7ed433f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -52,7 +52,8 @@ static void default_terminal_info (const char *, int);
 static int default_watchpoint_addr_within_range (struct target_ops *,
 						 CORE_ADDR, CORE_ADDR, int);
 
-static int default_region_ok_for_hw_watchpoint (CORE_ADDR, int);
+static int default_region_ok_for_hw_watchpoint (struct target_ops *,
+						CORE_ADDR, int);
 
 static void tcomplain (void) ATTRIBUTE_NORETURN;
 
@@ -100,18 +101,23 @@ static int debug_to_insert_breakpoint (struct target_ops *, struct gdbarch *,
 static int debug_to_remove_breakpoint (struct target_ops *, struct gdbarch *,
 				       struct bp_target_info *);
 
-static int debug_to_can_use_hw_breakpoint (int, int, int);
+static int debug_to_can_use_hw_breakpoint (struct target_ops *self,
+					   int, int, int);
 
-static int debug_to_insert_hw_breakpoint (struct gdbarch *,
+static int debug_to_insert_hw_breakpoint (struct target_ops *self,
+					  struct gdbarch *,
 					  struct bp_target_info *);
 
-static int debug_to_remove_hw_breakpoint (struct gdbarch *,
+static int debug_to_remove_hw_breakpoint (struct target_ops *self,
+					  struct gdbarch *,
 					  struct bp_target_info *);
 
-static int debug_to_insert_watchpoint (CORE_ADDR, int, int,
+static int debug_to_insert_watchpoint (struct target_ops *self,
+				       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 *);
@@ -119,9 +125,11 @@ static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
 static int debug_to_watchpoint_addr_within_range (struct target_ops *,
 						  CORE_ADDR, CORE_ADDR, int);
 
-static int debug_to_region_ok_for_hw_watchpoint (CORE_ADDR, int);
+static int debug_to_region_ok_for_hw_watchpoint (struct target_ops *self,
+						 CORE_ADDR, int);
 
-static int debug_to_can_accel_watchpoint_condition (CORE_ADDR, int, int,
+static int debug_to_can_accel_watchpoint_condition (struct target_ops *self,
+						    CORE_ADDR, int, int,
 						    struct expression *);
 
 static void debug_to_terminal_init (void);
@@ -718,10 +726,10 @@ update_current_target (void)
 	    (void (*) (char *, int))
 	    tcomplain);
   de_fault (to_close,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_post_attach,
-	    (void (*) (int))
+	    (void (*) (struct target_ops *, int))
 	    target_ignore);
   de_fault (to_prepare_to_store,
 	    (void (*) (struct target_ops *, struct regcache *))
@@ -734,26 +742,31 @@ update_current_target (void)
 	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_can_use_hw_breakpoint,
-	    (int (*) (int, int, int))
+	    (int (*) (struct target_ops *, int, int, int))
 	    return_zero);
   de_fault (to_insert_hw_breakpoint,
-	    (int (*) (struct gdbarch *, struct bp_target_info *))
+	    (int (*) (struct target_ops *, struct gdbarch *,
+		      struct bp_target_info *))
 	    return_minus_one);
   de_fault (to_remove_hw_breakpoint,
-	    (int (*) (struct gdbarch *, struct bp_target_info *))
+	    (int (*) (struct target_ops *, struct gdbarch *,
+		      struct bp_target_info *))
 	    return_minus_one);
   de_fault (to_insert_watchpoint,
-	    (int (*) (CORE_ADDR, int, int, struct expression *))
+	    (int (*) (struct target_ops *, 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);
   de_fault (to_region_ok_for_hw_watchpoint,
 	    default_region_ok_for_hw_watchpoint);
   de_fault (to_can_accel_watchpoint_condition,
-            (int (*) (CORE_ADDR, int, int, struct expression *))
+            (int (*) (struct target_ops *, CORE_ADDR, int, int,
+		      struct expression *))
             return_zero);
   de_fault (to_terminal_init,
 	    (void (*) (void))
@@ -3571,7 +3584,8 @@ target_fileio_read_stralloc (const char *filename)
 
 
 static int
-default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+default_region_ok_for_hw_watchpoint (struct target_ops *self,
+				     CORE_ADDR addr, int len)
 {
   return (len <= gdbarch_ptr_bit (target_gdbarch ()) / TARGET_CHAR_BIT);
 }
@@ -3772,7 +3786,7 @@ target_close (struct target_ops *targ)
   if (targ->to_xclose != NULL)
     targ->to_xclose (targ);
   else if (targ->to_close != NULL)
-    targ->to_close ();
+    targ->to_close (targ);
 
   if (targetdebug)
     fprintf_unfiltered (gdb_stdlog, "target_close ()\n");
@@ -3853,9 +3867,9 @@ target_stop (ptid_t ptid)
 }
 
 static void
-debug_to_post_attach (int pid)
+debug_to_post_attach (struct target_ops *self, int pid)
 {
-  debug_target.to_post_attach (pid);
+  debug_target.to_post_attach (&debug_target, pid);
 
   fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
 }
@@ -4559,11 +4573,13 @@ debug_to_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 }
 
 static int
-debug_to_can_use_hw_breakpoint (int type, int cnt, int from_tty)
+debug_to_can_use_hw_breakpoint (struct target_ops *self,
+				int type, int cnt, int from_tty)
 {
   int retval;
 
-  retval = debug_target.to_can_use_hw_breakpoint (type, cnt, from_tty);
+  retval = debug_target.to_can_use_hw_breakpoint (&debug_target,
+						  type, cnt, from_tty);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_can_use_hw_breakpoint (%ld, %ld, %ld) = %ld\n",
@@ -4575,11 +4591,13 @@ debug_to_can_use_hw_breakpoint (int type, int cnt, int from_tty)
 }
 
 static int
-debug_to_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+debug_to_region_ok_for_hw_watchpoint (struct target_ops *self,
+				      CORE_ADDR addr, int len)
 {
   CORE_ADDR retval;
 
-  retval = debug_target.to_region_ok_for_hw_watchpoint (addr, len);
+  retval = debug_target.to_region_ok_for_hw_watchpoint (&debug_target,
+							addr, len);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_region_ok_for_hw_watchpoint (%s, %ld) = %s\n",
@@ -4589,12 +4607,14 @@ debug_to_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
 }
 
 static int
-debug_to_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int rw,
+debug_to_can_accel_watchpoint_condition (struct target_ops *self,
+					 CORE_ADDR addr, int len, int rw,
 					 struct expression *cond)
 {
   int retval;
 
-  retval = debug_target.to_can_accel_watchpoint_condition (addr, len,
+  retval = debug_target.to_can_accel_watchpoint_condition (&debug_target,
+							   addr, len,
 							   rw, cond);
 
   fprintf_unfiltered (gdb_stdlog,
@@ -4650,12 +4670,14 @@ debug_to_watchpoint_addr_within_range (struct target_ops *target,
 }
 
 static int
-debug_to_insert_hw_breakpoint (struct gdbarch *gdbarch,
+debug_to_insert_hw_breakpoint (struct target_ops *self,
+			       struct gdbarch *gdbarch,
 			       struct bp_target_info *bp_tgt)
 {
   int retval;
 
-  retval = debug_target.to_insert_hw_breakpoint (gdbarch, bp_tgt);
+  retval = debug_target.to_insert_hw_breakpoint (&debug_target,
+						 gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_insert_hw_breakpoint (%s, xxx) = %ld\n",
@@ -4665,12 +4687,14 @@ debug_to_insert_hw_breakpoint (struct gdbarch *gdbarch,
 }
 
 static int
-debug_to_remove_hw_breakpoint (struct gdbarch *gdbarch,
+debug_to_remove_hw_breakpoint (struct target_ops *self,
+			       struct gdbarch *gdbarch,
 			       struct bp_target_info *bp_tgt)
 {
   int retval;
 
-  retval = debug_target.to_remove_hw_breakpoint (gdbarch, bp_tgt);
+  retval = debug_target.to_remove_hw_breakpoint (&debug_target,
+						 gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_remove_hw_breakpoint (%s, xxx) = %ld\n",
@@ -4680,12 +4704,14 @@ debug_to_remove_hw_breakpoint (struct gdbarch *gdbarch,
 }
 
 static int
-debug_to_insert_watchpoint (CORE_ADDR addr, int len, int type,
+debug_to_insert_watchpoint (struct target_ops *self,
+			    CORE_ADDR addr, int len, int type,
 			    struct expression *cond)
 {
   int retval;
 
-  retval = debug_target.to_insert_watchpoint (addr, len, type, cond);
+  retval = debug_target.to_insert_watchpoint (&debug_target,
+					      addr, len, type, cond);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_insert_watchpoint (%s, %d, %d, %s) = %ld\n",
@@ -4695,12 +4721,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 76a2d1b..50d5c20 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -393,9 +393,9 @@ struct target_ops
        New re-entrant targets provide "to_xclose" and that is expected
        to xfree everything (including the "struct target_ops").  */
     void (*to_xclose) (struct target_ops *targ);
-    void (*to_close) (void);
+    void (*to_close) (struct target_ops *);
     void (*to_attach) (struct target_ops *ops, char *, int);
-    void (*to_post_attach) (int);
+    void (*to_post_attach) (struct target_ops *, int);
     void (*to_detach) (struct target_ops *ops, const char *, int);
     void (*to_disconnect) (struct target_ops *, char *, int);
     void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal)
@@ -441,15 +441,19 @@ struct target_ops
     int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
 				 struct bp_target_info *)
       TARGET_DEFAULT_FUNC (memory_remove_breakpoint);
-    int (*to_can_use_hw_breakpoint) (int, int, int);
+    int (*to_can_use_hw_breakpoint) (struct target_ops *, int, int, int);
     int (*to_ranged_break_num_registers) (struct target_ops *);
-    int (*to_insert_hw_breakpoint) (struct gdbarch *, struct bp_target_info *);
-    int (*to_remove_hw_breakpoint) (struct gdbarch *, struct bp_target_info *);
+    int (*to_insert_hw_breakpoint) (struct target_ops *,
+				    struct gdbarch *, struct bp_target_info *);
+    int (*to_remove_hw_breakpoint) (struct target_ops *,
+				    struct gdbarch *, struct bp_target_info *);
 
     /* 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_insert_watchpoint) (CORE_ADDR, int, int, struct expression *);
+    int (*to_remove_watchpoint) (struct target_ops *,
+				 CORE_ADDR, int, int, struct expression *);
+    int (*to_insert_watchpoint) (struct target_ops *,
+				 CORE_ADDR, int, int, struct expression *);
 
     int (*to_insert_mask_watchpoint) (struct target_ops *,
 				      CORE_ADDR, CORE_ADDR, int);
@@ -466,9 +470,11 @@ struct target_ops
 
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
-    int (*to_region_ok_for_hw_watchpoint) (CORE_ADDR, int);
+    int (*to_region_ok_for_hw_watchpoint) (struct target_ops *,
+					   CORE_ADDR, int);
 
-    int (*to_can_accel_watchpoint_condition) (CORE_ADDR, int, int,
+    int (*to_can_accel_watchpoint_condition) (struct target_ops *,
+					      CORE_ADDR, int, int,
 					      struct expression *);
     int (*to_masked_watch_num_registers) (struct target_ops *,
 					  CORE_ADDR, CORE_ADDR);
@@ -1006,7 +1012,7 @@ void target_attach (char *, int);
    This operation provides a target-specific hook that allows the
    necessary bookkeeping to be performed after an attach completes.  */
 #define target_post_attach(pid) \
-     (*current_target.to_post_attach) (pid)
+     (*current_target.to_post_attach) (&current_target, pid)
 
 /* Takes a program previously attached to and detaches it.
    The program may resume execution (some targets do, some don't) and will
@@ -1582,13 +1588,15 @@ extern char *target_thread_name (struct thread_info *);
    (including this one?).  OTHERTYPE is who knows what...  */
 
 #define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \
- (*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE);
+ (*current_target.to_can_use_hw_breakpoint) (&current_target,  \
+					     TYPE, CNT, OTHERTYPE);
 
 /* Returns the number of debug registers needed to watch the given
    memory region, or zero if not supported.  */
 
 #define target_region_ok_for_hw_watchpoint(addr, len) \
-    (*current_target.to_region_ok_for_hw_watchpoint) (addr, len)
+    (*current_target.to_region_ok_for_hw_watchpoint) (&current_target,	\
+						      addr, len)
 
 
 /* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes.
@@ -1598,10 +1606,12 @@ extern char *target_thread_name (struct thread_info *);
    -1 for failure.  */
 
 #define	target_insert_watchpoint(addr, len, type, cond) \
-     (*current_target.to_insert_watchpoint) (addr, len, type, cond)
+     (*current_target.to_insert_watchpoint) (&current_target,	\
+					     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
@@ -1623,10 +1633,12 @@ extern int target_remove_mask_watchpoint (CORE_ADDR, CORE_ADDR, int);
    message) otherwise.  */
 
 #define target_insert_hw_breakpoint(gdbarch, bp_tgt) \
-     (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt)
+     (*current_target.to_insert_hw_breakpoint) (&current_target,	\
+						gdbarch, bp_tgt)
 
 #define target_remove_hw_breakpoint(gdbarch, bp_tgt) \
-     (*current_target.to_remove_hw_breakpoint) (gdbarch, bp_tgt)
+     (*current_target.to_remove_hw_breakpoint) (&current_target,	\
+						gdbarch, bp_tgt)
 
 /* Return number of debug registers needed for a ranged breakpoint,
    or -1 if ranged breakpoints are not supported.  */
@@ -1655,7 +1667,8 @@ extern int target_ranged_break_num_registers (void);
    For this reason, GDB will still evaluate the condition expression when
    the watchpoint triggers.  */
 #define target_can_accel_watchpoint_condition(addr, len, type, cond) \
-  (*current_target.to_can_accel_watchpoint_condition) (addr, len, type, cond)
+  (*current_target.to_can_accel_watchpoint_condition) (&current_target,	\
+						       addr, len, type, cond)
 
 /* Return number of debug registers needed for a masked watchpoint,
    -1 if masked watchpoints are not supported or -2 if the given address
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 0a50606..d4937be 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4755,7 +4755,7 @@ parse_tsv_definition (char *line, struct uploaded_tsv **utsvp)
 /* Close the trace file and generally clean up.  */
 
 static void
-tfile_close (void)
+tfile_close (struct target_ops *self)
 {
   int pid;
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 5bcb7b7..b0ed3f6 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2480,7 +2480,7 @@ windows_can_run (void)
 }
 
 static void
-windows_close (void)
+windows_close (struct target_ops *self)
 {
   DEBUG_EVENTS (("gdb: windows_close, inferior_ptid=%d\n",
 		ptid_get_pid (inferior_ptid)));
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 28/38] convert to_insn_history
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (10 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 01/38] add "this" pointers to more target APIs Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 37/38] fix buglet in nto-procfs.c Tom Tromey
                   ` (27 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (target_insn_history): Unconditionally delegate.
	* target.h (struct target_ops) <to_insn_history>: Use
	TARGET_DEFAULT_NORETURN.

convert to_goto_record

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

	* target-delegates.c: Rebuild.
	* target.c (target_goto_record): Unconditionally delegate.
	* target.h (struct target_ops) <to_goto_record>: Use
	TARGET_DEFAULT_NORETURN.

convert to_goto_record_end

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

	* target-delegates.c: Rebuild.
	* target.c (target_goto_record_end): Unconditionally delegate.
	* target.h (struct target_ops) <to_goto_record_end>: Use
	TARGET_DEFAULT_NORETURN.

convert to_goto_record_begin

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

	* target-delegates.c: Rebuild.
	* target.c (target_goto_record_begin): Unconditionally delegate.
	* target.h (struct target_ops) <to_goto_record_begin>: Use
	TARGET_DEFAULT_NORETURN.

convert to_record_is_replaying

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

	* target-delegates.c: Rebuild.
	* target.c (target_record_is_replaying): Unconditionally
	delegate.
	* target.h (struct target_ops) <to_record_is_replaying>: Use
	TARGET_DEFAULT_RETURN.

convert to_delete_record

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

	* target-delegates.c: Rebuild.
	* target.c (target_delete_record): Unconditionally delegate.
	* target.h (struct target_ops) <to_delete_record>: Use
	TARGET_DEFAULT_NORETURN.

convert to_save_record

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

	* target-delegates.c: Rebuild.
	* target.c (target_save_record): Unconditionally delegate.
	* target.h (struct target_ops) <to_save_record>: Use
	TARGET_DEFAULT_NORETURN.

convert to_thread_alive

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

	* target-delegates.c: Rebuild.
	* target.c (target_thread_alive): Unconditionally delegate.
	* target.h (struct target_ops) <to_thread_alive>: Use
	TARGET_DEFAULT_RETURN.

convert to_memory_map

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

	* target-delegates.c: Rebuild.
	* target.c (target_memory_map): Unconditionally delegate.
	* target.h (struct target_ops) <to_memory_map>: Use
	TARGET_DEFAULT_RETURN.

convert to_auxv_parse

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

	* auxv.c (default_auxv_parse): No longer static.
	(target_auxv_parse): Unconditionally delegate.
	* auxv.h (default_auxv_parse): Declare.
	* target-delegates.c: Rebuild.
	* target.c: Include auxv.h.
	* target.h (struct target_ops) <to_auxv_parse>: Use
	TARGET_DEFAULT_FUNC.
---
 gdb/ChangeLog          |  74 ++++++++++++++++++++++++
 gdb/auxv.c             |  11 +---
 gdb/auxv.h             |   7 +++
 gdb/target-delegates.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           | 106 +++++-----------------------------
 gdb/target.h           |  30 ++++++----
 6 files changed, 273 insertions(+), 109 deletions(-)

diff --git a/gdb/auxv.c b/gdb/auxv.c
index dd13237..7d4d606 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -237,7 +237,7 @@ memory_xfer_auxv (struct target_ops *ops,
    Return 0 if *READPTR is already at the end of the buffer.
    Return -1 if there is insufficient buffer for a whole entry.
    Return 1 if an entry was read into *TYPEP and *VALP.  */
-static int
+int
 default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
 		   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
@@ -269,13 +269,8 @@ int
 target_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
                   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
-  struct target_ops *t;
-
-  for (t = ops; t != NULL; t = t->beneath)
-    if (t->to_auxv_parse != NULL)
-      return t->to_auxv_parse (t, readptr, endptr, typep, valp);
-  
-  return default_auxv_parse (ops, readptr, endptr, typep, valp);
+  return current_target.to_auxv_parse (&current_target, readptr, endptr,
+				       typep, valp);
 }
 
 
diff --git a/gdb/auxv.h b/gdb/auxv.h
index c3f2322..ace6c04 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -24,6 +24,13 @@
 
 /* See "include/elf/common.h" for the definition of valid AT_* values.  */
 
+/* The default implementation of to_auxv_parse, used by the target
+   stack.  */
+
+extern int default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
+			       gdb_byte *endptr, CORE_ADDR *typep,
+			       CORE_ADDR *valp);
+
 /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
    Return 0 if *READPTR is already at the end of the buffer.
    Return -1 if there is insufficient buffer for a whole entry.
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index e6c0cf3..50f04c8 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -541,6 +541,19 @@ tdefault_program_signals (struct target_ops *self, int arg1, unsigned char *arg2
 {
 }
 
+static int
+delegate_thread_alive (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  return self->to_thread_alive (self, arg1);
+}
+
+static int
+tdefault_thread_alive (struct target_ops *self, ptid_t arg1)
+{
+  return 0;
+}
+
 static void
 delegate_find_new_threads (struct target_ops *self)
 {
@@ -723,6 +736,19 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object  arg1, const
   return -1;
 }
 
+static VEC(mem_region_s) *
+delegate_memory_map (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_memory_map (self);
+}
+
+static VEC(mem_region_s) *
+tdefault_memory_map (struct target_ops *self)
+{
+  return 0;
+}
+
 static void
 delegate_flash_erase (struct target_ops *self, ULONGEST arg1, LONGEST arg2)
 {
@@ -757,6 +783,13 @@ delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
 }
 
 static int
+delegate_auxv_parse (struct target_ops *self, gdb_byte **arg1, gdb_byte *arg2, CORE_ADDR *arg3, CORE_ADDR *arg4)
+{
+  self = self->beneath;
+  return self->to_auxv_parse (self, arg1, arg2, arg3, arg4);
+}
+
+static int
 delegate_can_execute_reverse (struct target_ops *self)
 {
   self = self->beneath;
@@ -1261,6 +1294,97 @@ tdefault_supports_btrace (struct target_ops *self)
 }
 
 static void
+delegate_save_record (struct target_ops *self, const char *arg1)
+{
+  self = self->beneath;
+  self->to_save_record (self, arg1);
+}
+
+static void
+tdefault_save_record (struct target_ops *self, const char *arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_delete_record (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_delete_record (self);
+}
+
+static void
+tdefault_delete_record (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static int
+delegate_record_is_replaying (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_record_is_replaying (self);
+}
+
+static int
+tdefault_record_is_replaying (struct target_ops *self)
+{
+  return 0;
+}
+
+static void
+delegate_goto_record_begin (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_goto_record_begin (self);
+}
+
+static void
+tdefault_goto_record_begin (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static void
+delegate_goto_record_end (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_goto_record_end (self);
+}
+
+static void
+tdefault_goto_record_end (struct target_ops *self)
+{
+  tcomplain ();
+}
+
+static void
+delegate_goto_record (struct target_ops *self, ULONGEST arg1)
+{
+  self = self->beneath;
+  self->to_goto_record (self, arg1);
+}
+
+static void
+tdefault_goto_record (struct target_ops *self, ULONGEST arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_insn_history (struct target_ops *self, int arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_insn_history (self, arg1, arg2);
+}
+
+static void
+tdefault_insn_history (struct target_ops *self, int arg1, int arg2)
+{
+  tcomplain ();
+}
+
+static void
 delegate_insn_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
 {
   self = self->beneath;
@@ -1433,6 +1557,8 @@ install_delegators (struct target_ops *ops)
     ops->to_pass_signals = delegate_pass_signals;
   if (ops->to_program_signals == NULL)
     ops->to_program_signals = delegate_program_signals;
+  if (ops->to_thread_alive == NULL)
+    ops->to_thread_alive = delegate_thread_alive;
   if (ops->to_find_new_threads == NULL)
     ops->to_find_new_threads = delegate_find_new_threads;
   if (ops->to_pid_to_str == NULL)
@@ -1467,12 +1593,16 @@ install_delegators (struct target_ops *ops)
     ops->to_goto_bookmark = delegate_goto_bookmark;
   if (ops->to_xfer_partial == NULL)
     ops->to_xfer_partial = delegate_xfer_partial;
+  if (ops->to_memory_map == NULL)
+    ops->to_memory_map = delegate_memory_map;
   if (ops->to_flash_erase == NULL)
     ops->to_flash_erase = delegate_flash_erase;
   if (ops->to_flash_done == NULL)
     ops->to_flash_done = delegate_flash_done;
   if (ops->to_get_ada_task_ptid == NULL)
     ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
+  if (ops->to_auxv_parse == NULL)
+    ops->to_auxv_parse = delegate_auxv_parse;
   if (ops->to_can_execute_reverse == NULL)
     ops->to_can_execute_reverse = delegate_can_execute_reverse;
   if (ops->to_execution_direction == NULL)
@@ -1553,6 +1683,20 @@ install_delegators (struct target_ops *ops)
     ops->to_can_use_agent = delegate_can_use_agent;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
+  if (ops->to_save_record == NULL)
+    ops->to_save_record = delegate_save_record;
+  if (ops->to_delete_record == NULL)
+    ops->to_delete_record = delegate_delete_record;
+  if (ops->to_record_is_replaying == NULL)
+    ops->to_record_is_replaying = delegate_record_is_replaying;
+  if (ops->to_goto_record_begin == NULL)
+    ops->to_goto_record_begin = delegate_goto_record_begin;
+  if (ops->to_goto_record_end == NULL)
+    ops->to_goto_record_end = delegate_goto_record_end;
+  if (ops->to_goto_record == NULL)
+    ops->to_goto_record = delegate_goto_record;
+  if (ops->to_insn_history == NULL)
+    ops->to_insn_history = delegate_insn_history;
   if (ops->to_insn_history_from == NULL)
     ops->to_insn_history_from = delegate_insn_history_from;
   if (ops->to_insn_history_range == NULL)
@@ -1616,6 +1760,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_mourn_inferior = default_mourn_inferior;
   ops->to_pass_signals = tdefault_pass_signals;
   ops->to_program_signals = tdefault_program_signals;
+  ops->to_thread_alive = tdefault_thread_alive;
   ops->to_find_new_threads = tdefault_find_new_threads;
   ops->to_pid_to_str = default_pid_to_str;
   ops->to_extra_thread_info = tdefault_extra_thread_info;
@@ -1633,9 +1778,11 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_get_bookmark = tdefault_get_bookmark;
   ops->to_goto_bookmark = tdefault_goto_bookmark;
   ops->to_xfer_partial = tdefault_xfer_partial;
+  ops->to_memory_map = tdefault_memory_map;
   ops->to_flash_erase = tdefault_flash_erase;
   ops->to_flash_done = tdefault_flash_done;
   ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
+  ops->to_auxv_parse = default_auxv_parse;
   ops->to_can_execute_reverse = tdefault_can_execute_reverse;
   ops->to_execution_direction = default_execution_direction;
   ops->to_supports_multi_process = tdefault_supports_multi_process;
@@ -1676,6 +1823,13 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_use_agent = tdefault_use_agent;
   ops->to_can_use_agent = tdefault_can_use_agent;
   ops->to_supports_btrace = tdefault_supports_btrace;
+  ops->to_save_record = tdefault_save_record;
+  ops->to_delete_record = tdefault_delete_record;
+  ops->to_record_is_replaying = tdefault_record_is_replaying;
+  ops->to_goto_record_begin = tdefault_goto_record_begin;
+  ops->to_goto_record_end = tdefault_goto_record_end;
+  ops->to_goto_record = tdefault_goto_record;
+  ops->to_insn_history = tdefault_insn_history;
   ops->to_insn_history_from = tdefault_insn_history_from;
   ops->to_insn_history_range = tdefault_insn_history_range;
   ops->to_call_history = tdefault_call_history;
diff --git a/gdb/target.c b/gdb/target.c
index 0ef82b3..c51e3ec 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -44,6 +44,7 @@
 #include "tracepoint.h"
 #include "gdb/fileio.h"
 #include "agent.h"
+#include "auxv.h"
 
 static void target_info (char *, int);
 
@@ -1685,14 +1686,7 @@ target_memory_map (void)
   if (targetdebug)
     fprintf_unfiltered (gdb_stdlog, "target_memory_map ()\n");
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_memory_map != NULL)
-      break;
-
-  if (t == NULL)
-    return NULL;
-
-  result = t->to_memory_map (t);
+  result = current_target.to_memory_map (&current_target);
   if (result == NULL)
     return NULL;
 
@@ -3491,24 +3485,14 @@ target_attach (char *args, int from_tty)
 int
 target_thread_alive (ptid_t ptid)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_thread_alive != NULL)
-	{
-	  int retval;
-
-	  retval = t->to_thread_alive (t, ptid);
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
-				ptid_get_pid (ptid), retval);
+  int retval;
 
-	  return retval;
-	}
-    }
+  retval = current_target.to_thread_alive (&current_target, ptid);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
+			ptid_get_pid (ptid), retval);
 
-  return 0;
+  return retval;
 }
 
 void
@@ -3838,16 +3822,7 @@ target_info_record (void)
 void
 target_save_record (const char *filename)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_save_record != NULL)
-      {
-	t->to_save_record (t, filename);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_save_record (&current_target, filename);
 }
 
 /* See target.h.  */
@@ -3869,16 +3844,7 @@ target_supports_delete_record (void)
 void
 target_delete_record (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_delete_record != NULL)
-      {
-	t->to_delete_record (t);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_delete_record (&current_target);
 }
 
 /* See target.h.  */
@@ -3886,13 +3852,7 @@ target_delete_record (void)
 int
 target_record_is_replaying (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_record_is_replaying != NULL)
-	return t->to_record_is_replaying (t);
-
-  return 0;
+  return current_target.to_record_is_replaying (&current_target);
 }
 
 /* See target.h.  */
@@ -3900,16 +3860,7 @@ target_record_is_replaying (void)
 void
 target_goto_record_begin (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_goto_record_begin != NULL)
-      {
-	t->to_goto_record_begin (t);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_goto_record_begin (&current_target);
 }
 
 /* See target.h.  */
@@ -3917,16 +3868,7 @@ target_goto_record_begin (void)
 void
 target_goto_record_end (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_goto_record_end != NULL)
-      {
-	t->to_goto_record_end (t);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_goto_record_end (&current_target);
 }
 
 /* See target.h.  */
@@ -3934,16 +3876,7 @@ target_goto_record_end (void)
 void
 target_goto_record (ULONGEST insn)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_goto_record != NULL)
-      {
-	t->to_goto_record (t, insn);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_goto_record (&current_target, insn);
 }
 
 /* See target.h.  */
@@ -3951,16 +3884,7 @@ target_goto_record (ULONGEST insn)
 void
 target_insn_history (int size, int flags)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_insn_history != NULL)
-      {
-	t->to_insn_history (t, size, flags);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_insn_history (&current_target, size, flags);
 }
 
 /* See target.h.  */
diff --git a/gdb/target.h b/gdb/target.h
index 45bc361..91d620f 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -549,7 +549,8 @@ struct target_ops
     void (*to_program_signals) (struct target_ops *, int, unsigned char *)
       TARGET_DEFAULT_IGNORE ();
 
-    int (*to_thread_alive) (struct target_ops *, ptid_t ptid);
+    int (*to_thread_alive) (struct target_ops *, ptid_t ptid)
+      TARGET_DEFAULT_RETURN (0);
     void (*to_find_new_threads) (struct target_ops *)
       TARGET_DEFAULT_IGNORE ();
     char *(*to_pid_to_str) (struct target_ops *, ptid_t)
@@ -655,7 +656,8 @@ struct target_ops
        This method should not cache data; if the memory map could
        change unexpectedly, it should be invalidated, and higher
        layers will re-fetch it.  */
-    VEC(mem_region_s) *(*to_memory_map) (struct target_ops *);
+    VEC(mem_region_s) *(*to_memory_map) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Erases the region of flash memory starting at ADDRESS, of
        length LENGTH.
@@ -691,7 +693,8 @@ struct target_ops
        Return -1 if there is insufficient buffer for a whole entry.
        Return 1 if an entry was read into *TYPEP and *VALP.  */
     int (*to_auxv_parse) (struct target_ops *ops, gdb_byte **readptr,
-                         gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
+                         gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
+      TARGET_DEFAULT_FUNC (default_auxv_parse);
 
     /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
        sequence of bytes in PATTERN with length PATTERN_LEN.
@@ -1013,28 +1016,35 @@ struct target_ops
     void (*to_info_record) (struct target_ops *);
 
     /* Save the recorded execution trace into a file.  */
-    void (*to_save_record) (struct target_ops *, const char *filename);
+    void (*to_save_record) (struct target_ops *, const char *filename)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Delete the recorded execution trace from the current position onwards.  */
-    void (*to_delete_record) (struct target_ops *);
+    void (*to_delete_record) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Query if the record target is currently replaying.  */
-    int (*to_record_is_replaying) (struct target_ops *);
+    int (*to_record_is_replaying) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Go to the begin of the execution trace.  */
-    void (*to_goto_record_begin) (struct target_ops *);
+    void (*to_goto_record_begin) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Go to the end of the execution trace.  */
-    void (*to_goto_record_end) (struct target_ops *);
+    void (*to_goto_record_end) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Go to a specific location in the recorded execution trace.  */
-    void (*to_goto_record) (struct target_ops *, ULONGEST insn);
+    void (*to_goto_record) (struct target_ops *, ULONGEST insn)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disassemble SIZE instructions in the recorded execution trace from
        the current position.
        If SIZE < 0, disassemble abs (SIZE) preceding instructions; otherwise,
        disassemble SIZE succeeding instructions.  */
-    void (*to_insn_history) (struct target_ops *, int size, int flags);
+    void (*to_insn_history) (struct target_ops *, int size, int flags)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disassemble SIZE instructions in the recorded execution trace around
        FROM.
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 34/38] remove exec_set_find_memory_regions
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (6 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 36/38] convert to_decr_pc_after_break Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 23/38] convert to_disable_tracepoint Tom Tromey
                   ` (31 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

exec_set_find_memory_regions is used to modify the exec target.
However, it only has a single caller, and so it is much clearer to
simply set the appropriate field directly.  It's also better for the
coming multi-target world to avoid this kind of global state change
anyway.

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

	* gcore.h (objfile_find_memory_regions): Declare.
	* gcore.c (objfile_find_memory_regions): No longer static.  Add
	"self" argument.
	(_initialize_gcore): Don't call exec_set_find_memory_regions.
	* exec.c: Include gcore.h.
	(exec_set_find_memory_regions): Remove.
	(exec_find_memory_regions): Remove.
	(exec_do_find_memory_regions): Remove.
	(init_exec_ops): Update.
	* defs.h (exec_set_find_memory_regions): Remove.
---
 gdb/ChangeLog | 13 +++++++++++++
 gdb/defs.h    |  4 ----
 gdb/exec.c    | 22 ++--------------------
 gdb/gcore.c   |  6 +++---
 gdb/gcore.h   |  3 +++
 5 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index d86f4a9..c405cad 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -372,10 +372,6 @@ typedef int (*find_memory_region_ftype) (CORE_ADDR addr, unsigned long size,
 					 int read, int write, int exec,
 					 int modified, void *data);
 
-/* Take over the 'find_mapped_memory' vector from exec.c.  */
-extern void exec_set_find_memory_regions
-  (int (*func) (find_memory_region_ftype func, void *data));
-
 /* Possible lvalue types.  Like enum language, this should be in
    value.h, but needs to be here for the same reason.  */
 
diff --git a/gdb/exec.c b/gdb/exec.c
index da0f367..01d79e2 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -34,6 +34,7 @@
 #include "gdbthread.h"
 #include "progspace.h"
 #include "gdb_bfd.h"
+#include "gcore.h"
 
 #include <fcntl.h>
 #include "readline/readline.h"
@@ -62,10 +63,6 @@ void _initialize_exec (void);
 
 struct target_ops exec_ops;
 
-/* Function used to implement to_find_memory_regions.  */
-
-static int (*exec_do_find_memory_regions) (find_memory_region_ftype, void *);
-
 /* True if the exec target is pushed on the stack.  */
 static int using_exec_ops;
 
@@ -820,21 +817,6 @@ exec_has_memory (struct target_ops *ops)
 	  != current_target_sections->sections_end);
 }
 
-/* Find mapped memory.  */
-
-extern void
-exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *))
-{
-  exec_do_find_memory_regions = func;
-}
-
-static int
-exec_find_memory_regions (struct target_ops *self,
-			  find_memory_region_ftype func, void *data)
-{
-  return exec_do_find_memory_regions (func, data);
-}
-
 static char *exec_make_note_section (struct target_ops *self, bfd *, int *);
 
 /* Fill in the exec file target vector.  Very few entries need to be
@@ -859,7 +841,7 @@ Specify the filename of the executable file.";
   exec_ops.to_stratum = file_stratum;
   exec_ops.to_has_memory = exec_has_memory;
   exec_ops.to_make_corefile_notes = exec_make_note_section;
-  exec_ops.to_find_memory_regions = exec_find_memory_regions;
+  exec_ops.to_find_memory_regions = objfile_find_memory_regions;
   exec_ops.to_magic = OPS_MAGIC;
 }
 
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 67fbf30..b80a97b 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -471,8 +471,9 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
   return 0;
 }
 
-static int
-objfile_find_memory_regions (find_memory_region_ftype func, void *obfd)
+int
+objfile_find_memory_regions (struct target_ops *self,
+			     find_memory_region_ftype func, void *obfd)
 {
   /* Use objfile data to create memory sections.  */
   struct objfile *objfile;
@@ -607,5 +608,4 @@ Save a core file with the current state of the debugged process.\n\
 Argument is optional filename.  Default filename is 'core.<process_id>'."));
 
   add_com_alias ("gcore", "generate-core-file", class_files, 1);
-  exec_set_find_memory_regions (objfile_find_memory_regions);
 }
diff --git a/gdb/gcore.h b/gdb/gcore.h
index fa64211..7a6271b 100644
--- a/gdb/gcore.h
+++ b/gdb/gcore.h
@@ -23,5 +23,8 @@
 extern bfd *create_gcore_bfd (const char *filename);
 extern void write_gcore_file (bfd *obfd);
 extern bfd *load_corefile (char *filename, int from_tty);
+extern int objfile_find_memory_regions (struct target_ops *self,
+					find_memory_region_ftype func,
+					void *obfd);
 
 #endif /* GCORE_H */
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 37/38] fix buglet in nto-procfs.c
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (11 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 28/38] convert to_insn_history Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-07 16:01   ` Pedro Alves
  2014-02-06 20:56 ` [RFC v2 24/38] convert to_upload_trace_state_variables Tom Tromey
                   ` (26 subsequent siblings)
  39 siblings, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I happened to notice that nto-procfs.c defines
procfs_remove_hw_breakpoint but never uses it.  This caused it not to
be updated by my target-method-updating script.  This patch fixes the
function and installs it properly.  I have no way to test this,
however.

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

	* nto-procfs.c (procfs_remove_hw_breakpoint): Add 'self'
	argument.
	(init_procfs_ops): Correctly set to_remove_hw_breakpoint.
---
 gdb/ChangeLog    | 6 ++++++
 gdb/nto-procfs.c | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 1b2b2ff..d0bdc90 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -947,7 +947,8 @@ procfs_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
 }
 
 static int
-procfs_remove_hw_breakpoint (struct gdbarch *gdbarch,
+procfs_remove_hw_breakpoint (struct target_ops *self,
+			     struct gdbarch *gdbarch,
 			     struct bp_target_info *bp_tgt)
 {
   return procfs_breakpoint (bp_tgt->placed_address,
@@ -1402,7 +1403,7 @@ init_procfs_ops (void)
   procfs_ops.to_remove_breakpoint = procfs_remove_breakpoint;
   procfs_ops.to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
   procfs_ops.to_insert_hw_breakpoint = procfs_insert_hw_breakpoint;
-  procfs_ops.to_remove_hw_breakpoint = procfs_remove_breakpoint;
+  procfs_ops.to_remove_hw_breakpoint = procfs_remove_hw_breakpoint;
   procfs_ops.to_insert_watchpoint = procfs_insert_hw_watchpoint;
   procfs_ops.to_remove_watchpoint = procfs_remove_hw_watchpoint;
   procfs_ops.to_stopped_by_watchpoint = procfs_stopped_by_watchpoint;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 29/38] convert to_search_memory
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (18 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 32/38] remove function casts from target.c Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 21/38] convert to_extra_thread_info Tom Tromey
                   ` (19 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (default_search_memory): New function.
	(simple_search_memory): Update comment.
	(target_search_memory): Unconditionally delegate.
	* target.h (struct target_ops) <to_search_memory>: Use
	TARGET_DEFAULT_FUNC.

convert to_disable_btrace

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

	* target-delegates.c: Rebuild.
	* target.c (target_disable_btrace): Unconditionally delegate.
	* target.h (struct target_ops) <to_disable_btrace>: Use
	TARGET_DEFAULT_NORETURN.

convert to_teardown_btrace

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

	* target-delegates.c: Rebuild.
	* target.c (target_teardown_btrace): Unconditionally delegate.
	* target.h (struct target_ops) <to_teardown_btrace>: Use
	TARGET_DEFAULT_NORETURN.

convert to_read_btrace

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

	* target-delegates.c: Rebuild.
	* target.c (target_read_btrace): Unconditionally delegate.
	* target.h (struct target_ops) <to_read_btrace>: Use
	TARGET_DEFAULT_NORETURN.

convert to_enable_btrace

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

	* target-delegates.c: Rebuild.
	* target.c (target_enable_btrace): Unconditionally delegate.
	* target.h (struct target_ops) <to_enable_btrace>: Use
	TARGET_DEFAULT_NORETURN.

convert to_stop_recording

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

	* record.c (record_stop): Unconditionally delegate.
	* target-delegates.c: Rebuild.
	* target.c (target_stop_recording): Unconditionally delegate.
	* target.h (struct target_ops) <to_stop_recording>: Use
	TARGET_DEFAULT_IGNORE.

convert to_disconnect

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

	* target-delegates.c: Rebuild.
	* target.c (target_disconnect): Unconditionally delegate.
	* target.h (struct target_ops) <to_disconnect>: Use
	TARGET_DEFAULT_NORETURN.

convert to_can_run

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_can_run.
	(find_default_run_target): Check against delegate_can_run.
	* target.h (struct target_ops) <to_can_run>: Use
	TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          |  61 ++++++++++++++++++++++++
 gdb/record.c           |   3 +-
 gdb/target-delegates.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           | 124 ++++++++++++++-----------------------------------
 gdb/target.h           |  24 ++++++----
 5 files changed, 235 insertions(+), 98 deletions(-)

diff --git a/gdb/record.c b/gdb/record.c
index 9dd02e8..5a7a88c 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -114,8 +114,7 @@ record_stop (struct target_ops *t)
 {
   DEBUG ("stop %s", t->to_shortname);
 
-  if (t->to_stop_recording != NULL)
-    t->to_stop_recording (t);
+  t->to_stop_recording (t);
 }
 
 /* Unpush the record target.  */
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 50f04c8..6174685 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -35,6 +35,19 @@ tdefault_detach (struct target_ops *self, const char *arg1, int arg2)
 }
 
 static void
+delegate_disconnect (struct target_ops *self, char *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_disconnect (self, arg1, arg2);
+}
+
+static void
+tdefault_disconnect (struct target_ops *self, char *arg1, int arg2)
+{
+  tcomplain ();
+}
+
+static void
 delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
 {
   self = self->beneath;
@@ -517,6 +530,19 @@ delegate_mourn_inferior (struct target_ops *self)
   self->to_mourn_inferior (self);
 }
 
+static int
+delegate_can_run (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_can_run (self);
+}
+
+static int
+tdefault_can_run (struct target_ops *self)
+{
+  return 0;
+}
+
 static void
 delegate_pass_signals (struct target_ops *self, int arg1, unsigned char *arg2)
 {
@@ -790,6 +816,13 @@ delegate_auxv_parse (struct target_ops *self, gdb_byte **arg1, gdb_byte *arg2, C
 }
 
 static int
+delegate_search_memory (struct target_ops *self, CORE_ADDR arg1, ULONGEST arg2, const gdb_byte *arg3, ULONGEST arg4, CORE_ADDR *arg5)
+{
+  self = self->beneath;
+  return self->to_search_memory (self, arg1, arg2, arg3, arg4, arg5);
+}
+
+static int
 delegate_can_execute_reverse (struct target_ops *self)
 {
   self = self->beneath;
@@ -1293,6 +1326,70 @@ tdefault_supports_btrace (struct target_ops *self)
   return 0;
 }
 
+static struct btrace_target_info *
+delegate_enable_btrace (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  return self->to_enable_btrace (self, arg1);
+}
+
+static struct btrace_target_info *
+tdefault_enable_btrace (struct target_ops *self, ptid_t arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_disable_btrace (struct target_ops *self, struct btrace_target_info *arg1)
+{
+  self = self->beneath;
+  self->to_disable_btrace (self, arg1);
+}
+
+static void
+tdefault_disable_btrace (struct target_ops *self, struct btrace_target_info *arg1)
+{
+  tcomplain ();
+}
+
+static void
+delegate_teardown_btrace (struct target_ops *self, struct btrace_target_info *arg1)
+{
+  self = self->beneath;
+  self->to_teardown_btrace (self, arg1);
+}
+
+static void
+tdefault_teardown_btrace (struct target_ops *self, struct btrace_target_info *arg1)
+{
+  tcomplain ();
+}
+
+static enum btrace_error 
+delegate_read_btrace (struct target_ops *self, VEC (btrace_block_s) **arg1, struct btrace_target_info *arg2, enum btrace_read_type  arg3)
+{
+  self = self->beneath;
+  return self->to_read_btrace (self, arg1, arg2, arg3);
+}
+
+static enum btrace_error 
+tdefault_read_btrace (struct target_ops *self, VEC (btrace_block_s) **arg1, struct btrace_target_info *arg2, enum btrace_read_type  arg3)
+{
+  tcomplain ();
+}
+
+static void
+delegate_stop_recording (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_stop_recording (self);
+}
+
+static void
+tdefault_stop_recording (struct target_ops *self)
+{
+}
+
 static void
 delegate_save_record (struct target_ops *self, const char *arg1)
 {
@@ -1471,6 +1568,8 @@ install_delegators (struct target_ops *ops)
     ops->to_post_attach = delegate_post_attach;
   if (ops->to_detach == NULL)
     ops->to_detach = delegate_detach;
+  if (ops->to_disconnect == NULL)
+    ops->to_disconnect = delegate_disconnect;
   if (ops->to_resume == NULL)
     ops->to_resume = delegate_resume;
   if (ops->to_wait == NULL)
@@ -1553,6 +1652,8 @@ install_delegators (struct target_ops *ops)
     ops->to_has_exited = delegate_has_exited;
   if (ops->to_mourn_inferior == NULL)
     ops->to_mourn_inferior = delegate_mourn_inferior;
+  if (ops->to_can_run == NULL)
+    ops->to_can_run = delegate_can_run;
   if (ops->to_pass_signals == NULL)
     ops->to_pass_signals = delegate_pass_signals;
   if (ops->to_program_signals == NULL)
@@ -1603,6 +1704,8 @@ install_delegators (struct target_ops *ops)
     ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
   if (ops->to_auxv_parse == NULL)
     ops->to_auxv_parse = delegate_auxv_parse;
+  if (ops->to_search_memory == NULL)
+    ops->to_search_memory = delegate_search_memory;
   if (ops->to_can_execute_reverse == NULL)
     ops->to_can_execute_reverse = delegate_can_execute_reverse;
   if (ops->to_execution_direction == NULL)
@@ -1683,6 +1786,16 @@ install_delegators (struct target_ops *ops)
     ops->to_can_use_agent = delegate_can_use_agent;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
+  if (ops->to_enable_btrace == NULL)
+    ops->to_enable_btrace = delegate_enable_btrace;
+  if (ops->to_disable_btrace == NULL)
+    ops->to_disable_btrace = delegate_disable_btrace;
+  if (ops->to_teardown_btrace == NULL)
+    ops->to_teardown_btrace = delegate_teardown_btrace;
+  if (ops->to_read_btrace == NULL)
+    ops->to_read_btrace = delegate_read_btrace;
+  if (ops->to_stop_recording == NULL)
+    ops->to_stop_recording = delegate_stop_recording;
   if (ops->to_save_record == NULL)
     ops->to_save_record = delegate_save_record;
   if (ops->to_delete_record == NULL)
@@ -1717,6 +1830,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_attach = find_default_attach;
   ops->to_post_attach = tdefault_post_attach;
   ops->to_detach = tdefault_detach;
+  ops->to_disconnect = tdefault_disconnect;
   ops->to_resume = tdefault_resume;
   ops->to_wait = tdefault_wait;
   ops->to_fetch_registers = tdefault_fetch_registers;
@@ -1758,6 +1872,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_set_syscall_catchpoint = tdefault_set_syscall_catchpoint;
   ops->to_has_exited = tdefault_has_exited;
   ops->to_mourn_inferior = default_mourn_inferior;
+  ops->to_can_run = tdefault_can_run;
   ops->to_pass_signals = tdefault_pass_signals;
   ops->to_program_signals = tdefault_program_signals;
   ops->to_thread_alive = tdefault_thread_alive;
@@ -1783,6 +1898,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_flash_done = tdefault_flash_done;
   ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
   ops->to_auxv_parse = default_auxv_parse;
+  ops->to_search_memory = default_search_memory;
   ops->to_can_execute_reverse = tdefault_can_execute_reverse;
   ops->to_execution_direction = default_execution_direction;
   ops->to_supports_multi_process = tdefault_supports_multi_process;
@@ -1823,6 +1939,11 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_use_agent = tdefault_use_agent;
   ops->to_can_use_agent = tdefault_can_use_agent;
   ops->to_supports_btrace = tdefault_supports_btrace;
+  ops->to_enable_btrace = tdefault_enable_btrace;
+  ops->to_disable_btrace = tdefault_disable_btrace;
+  ops->to_teardown_btrace = tdefault_teardown_btrace;
+  ops->to_read_btrace = tdefault_read_btrace;
+  ops->to_stop_recording = tdefault_stop_recording;
   ops->to_save_record = tdefault_save_record;
   ops->to_delete_record = tdefault_delete_record;
   ops->to_record_is_replaying = tdefault_record_is_replaying;
diff --git a/gdb/target.c b/gdb/target.c
index c51e3ec..4016128 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -66,6 +66,13 @@ static int default_follow_fork (struct target_ops *self, int follow_child,
 
 static void default_mourn_inferior (struct target_ops *self);
 
+static int default_search_memory (struct target_ops *ops,
+				  CORE_ADDR start_addr,
+				  ULONGEST search_space_len,
+				  const gdb_byte *pattern,
+				  ULONGEST pattern_len,
+				  CORE_ADDR *found_addrp);
+
 static void tcomplain (void) ATTRIBUTE_NORETURN;
 
 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
@@ -646,7 +653,7 @@ update_current_target (void)
       /* Do not inherit to_set_syscall_catchpoint.  */
       /* Do not inherit to_has_exited.  */
       /* Do not inherit to_mourn_inferior.  */
-      INHERIT (to_can_run, t);
+      /* Do not inherit to_can_run.  */
       /* Do not inherit to_pass_signals.  */
       /* Do not inherit to_program_signals.  */
       /* Do not inherit to_thread_alive.  */
@@ -741,9 +748,6 @@ update_current_target (void)
 	    (int (*) (CORE_ADDR, gdb_byte *, int, int,
 		      struct mem_attrib *, struct target_ops *))
 	    nomemory);
-  de_fault (to_can_run,
-	    (int (*) (struct target_ops *))
-	    return_zero);
   current_target.to_read_description = NULL;
 
 #undef de_fault
@@ -2402,24 +2406,15 @@ target_detach (const char *args, int from_tty)
 void
 target_disconnect (char *args, int from_tty)
 {
-  struct target_ops *t;
-
   /* If we're in breakpoints-always-inserted mode or if breakpoints
      are global across processes, we have to remove them before
      disconnecting.  */
   remove_breakpoints ();
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_disconnect != NULL)
-	{
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_disconnect (%s, %d)\n",
-				args, from_tty);
-	  t->to_disconnect (t, args, from_tty);
-	  return;
-	}
-
-  tcomplain ();
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_disconnect (%s, %d)\n",
+			args, from_tty);
+  current_target.to_disconnect (&current_target, args, from_tty);
 }
 
 ptid_t
@@ -2589,8 +2584,7 @@ target_read_description (struct target_ops *target)
   return NULL;
 }
 
-/* The default implementation of to_search_memory.
-   This implements a basic search of memory, reading target memory and
+/* This implements a basic search of memory, reading target memory and
    performing the search here (as opposed to performing the search in on the
    target side with, for example, gdbserver).  */
 
@@ -2697,6 +2691,20 @@ simple_search_memory (struct target_ops *ops,
   return 0;
 }
 
+/* Default implementation of memory-searching.  */
+
+static int
+default_search_memory (struct target_ops *self,
+		       CORE_ADDR start_addr, ULONGEST search_space_len,
+		       const gdb_byte *pattern, ULONGEST pattern_len,
+		       CORE_ADDR *found_addrp)
+{
+  /* Start over from the top of the target stack.  */
+  return simple_search_memory (current_target.beneath,
+			       start_addr, search_space_len,
+			       pattern, pattern_len, found_addrp);
+}
+
 /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
    sequence of bytes in PATTERN with length PATTERN_LEN.
 
@@ -2709,34 +2717,15 @@ target_search_memory (CORE_ADDR start_addr, ULONGEST search_space_len,
 		      const gdb_byte *pattern, ULONGEST pattern_len,
 		      CORE_ADDR *found_addrp)
 {
-  struct target_ops *t;
   int found;
 
-  /* We don't use INHERIT to set current_target.to_search_memory,
-     so we have to scan the target stack and handle targetdebug
-     ourselves.  */
-
   if (targetdebug)
     fprintf_unfiltered (gdb_stdlog, "target_search_memory (%s, ...)\n",
 			hex_string (start_addr));
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_search_memory != NULL)
-      break;
-
-  if (t != NULL)
-    {
-      found = t->to_search_memory (t, start_addr, search_space_len,
-				   pattern, pattern_len, found_addrp);
-    }
-  else
-    {
-      /* If a special version of to_search_memory isn't available, use the
-	 simple version.  */
-      found = simple_search_memory (current_target.beneath,
-				    start_addr, search_space_len,
-				    pattern, pattern_len, found_addrp);
-    }
+  found = current_target.to_search_memory (&current_target, start_addr,
+					   search_space_len,
+					   pattern, pattern_len, found_addrp);
 
   if (targetdebug)
     fprintf_unfiltered (gdb_stdlog, "  = %d\n", found);
@@ -2799,7 +2788,7 @@ find_default_run_target (char *do_mesg)
   for (t = target_structs; t < target_structs + target_struct_size;
        ++t)
     {
-      if ((*t)->to_can_run && target_can_run (*t))
+      if ((*t)->to_can_run != delegate_can_run && target_can_run (*t))
 	{
 	  runable = *t;
 	  ++count;
@@ -3722,14 +3711,7 @@ target_ranged_break_num_registers (void)
 struct btrace_target_info *
 target_enable_btrace (ptid_t ptid)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_enable_btrace != NULL)
-      return t->to_enable_btrace (t, ptid);
-
-  tcomplain ();
-  return NULL;
+  return current_target.to_enable_btrace (&current_target, ptid);
 }
 
 /* See target.h.  */
@@ -3737,16 +3719,7 @@ target_enable_btrace (ptid_t ptid)
 void
 target_disable_btrace (struct btrace_target_info *btinfo)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_disable_btrace != NULL)
-      {
-	t->to_disable_btrace (t, btinfo);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_disable_btrace (&current_target, btinfo);
 }
 
 /* See target.h.  */
@@ -3754,16 +3727,7 @@ target_disable_btrace (struct btrace_target_info *btinfo)
 void
 target_teardown_btrace (struct btrace_target_info *btinfo)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_teardown_btrace != NULL)
-      {
-	t->to_teardown_btrace (t, btinfo);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_teardown_btrace (&current_target, btinfo);
 }
 
 /* See target.h.  */
@@ -3773,14 +3737,7 @@ target_read_btrace (VEC (btrace_block_s) **btrace,
 		    struct btrace_target_info *btinfo,
 		    enum btrace_read_type type)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_read_btrace != NULL)
-      return t->to_read_btrace (t, btrace, btinfo, type);
-
-  tcomplain ();
-  return BTRACE_ERR_NOT_SUPPORTED;
+  return current_target.to_read_btrace (&current_target, btrace, btinfo, type);
 }
 
 /* See target.h.  */
@@ -3788,16 +3745,7 @@ target_read_btrace (VEC (btrace_block_s) **btrace,
 void
 target_stop_recording (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_stop_recording != NULL)
-      {
-	t->to_stop_recording (t);
-	return;
-      }
-
-  /* This is optional.  */
+  current_target.to_stop_recording (&current_target);
 }
 
 /* See target.h.  */
diff --git a/gdb/target.h b/gdb/target.h
index 91d620f..47a92d0 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -400,7 +400,8 @@ struct target_ops
       TARGET_DEFAULT_IGNORE ();
     void (*to_detach) (struct target_ops *ops, const char *, int)
       TARGET_DEFAULT_IGNORE ();
-    void (*to_disconnect) (struct target_ops *, char *, int);
+    void (*to_disconnect) (struct target_ops *, char *, int)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
     void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal)
       TARGET_DEFAULT_NORETURN (noprocess ());
     ptid_t (*to_wait) (struct target_ops *,
@@ -537,7 +538,8 @@ struct target_ops
       TARGET_DEFAULT_RETURN (0);
     void (*to_mourn_inferior) (struct target_ops *)
       TARGET_DEFAULT_FUNC (default_mourn_inferior);
-    int (*to_can_run) (struct target_ops *);
+    int (*to_can_run) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
@@ -705,7 +707,8 @@ struct target_ops
     int (*to_search_memory) (struct target_ops *ops,
 			     CORE_ADDR start_addr, ULONGEST search_space_len,
 			     const gdb_byte *pattern, ULONGEST pattern_len,
-			     CORE_ADDR *found_addrp);
+			     CORE_ADDR *found_addrp)
+      TARGET_DEFAULT_FUNC (default_search_memory);
 
     /* Can target execute in reverse?  */
     int (*to_can_execute_reverse) (struct target_ops *)
@@ -987,18 +990,21 @@ struct target_ops
     /* Enable branch tracing for PTID and allocate a branch trace target
        information struct for reading and for disabling branch trace.  */
     struct btrace_target_info *(*to_enable_btrace) (struct target_ops *,
-						    ptid_t ptid);
+						    ptid_t ptid)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disable branch tracing and deallocate TINFO.  */
     void (*to_disable_btrace) (struct target_ops *,
-			       struct btrace_target_info *tinfo);
+			       struct btrace_target_info *tinfo)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disable branch tracing and deallocate TINFO.  This function is similar
        to to_disable_btrace, except that it is called during teardown and is
        only allowed to perform actions that are safe.  A counter-example would
        be attempting to talk to a remote target.  */
     void (*to_teardown_btrace) (struct target_ops *,
-				struct btrace_target_info *tinfo);
+				struct btrace_target_info *tinfo)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Read branch trace data for the thread indicated by BTINFO into DATA.
        DATA is cleared before new trace is added.
@@ -1007,10 +1013,12 @@ struct target_ops
     enum btrace_error (*to_read_btrace) (struct target_ops *self,
 					 VEC (btrace_block_s) **data,
 					 struct btrace_target_info *btinfo,
-					 enum btrace_read_type type);
+					 enum btrace_read_type type)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Stop trace recording.  */
-    void (*to_stop_recording) (struct target_ops *);
+    void (*to_stop_recording) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
 
     /* Print information about the recording.  */
     void (*to_info_record) (struct target_ops *);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 01/38] add "this" pointers to more target APIs
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (9 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 10/38] Add target_ops argument to to_thread_name Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-08  5:19   ` Doug Evans
  2014-02-06 20:56 ` [RFC v2 28/38] convert to_insn_history Tom Tromey
                   ` (28 subsequent siblings)
  39 siblings, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A subsequent pass introduces delegation helper functions to the target
API.  This delegation is much cleaner if the target_ops pointer is
directly available at delegation time.

This patch adds the "this" pointer to various to_* methods for this
purpose.

This updates a number of ports which I am unable to test.  Please give
them a look-over.  Any possible problem here is trivial, though, as
all that is required is adding an argument to a function.

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

	* aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint):
	Add 'ops' argument.
	* arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add
	'ops' argument.
	* i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument.
	* ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add
	'ops' argument.
	* inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops'
	argument.
	* linux-nat.c (save_sigtrap): Update.
	(linux_nat_stopped_by_watchpoint, linux_nat_is_async_p)
	(linux_nat_can_async_p, linux_nat_async): Add 'ops' argument.
	(linux_nat_close): Update.
	* mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops'
	argument.
	* ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops'
	argument.
	* procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument.
	* record-full.c (record_full_beneath_to_stopped_by_watchpoint)
	(record_full_beneath_to_async, tmp_to_stopped_by_watchpoint)
	(tmp_to_async): Add 'ops' argument.
	(record_full_stopped_by_watchpoint, record_full_async)
	(record_full_can_async_p, record_full_is_async_p): Add 'ops'
	argument.
	* remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint)
	(m32r_stopped_by_watchpoint): Add 'ops' argument.
	* remote-mips.c	(mips_stopped_by_watchpoint): Add 'ops' argument.
	* remote.c (remote_stopped_by_watchpoint_p, remote_can_async_p)
	(remote_is_async_p, remote_async): Add 'ops' argument.
	(remote_stopped_data_address): Update.
	* s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument.
	* target.c (update_current_target)
	(find_default_can_async_p, find_default_is_async_p): Update.
	(init_dummy_target): Update.
	(debug_to_stopped_by_watchpoint): Add 'ops' argument.
	* target.h (struct target_ops) <to_stopped_by_watchpoint,
	to_can_async_p, to_is_async_p, to_async>: Add 'ops' argument.
	(target_can_async_p, target_is_async_p, target_async)
	(target_stopped_by_watchpoint): Update.
---
 gdb/ChangeLog           | 42 ++++++++++++++++++++++++++++++++++++++++++
 gdb/aarch64-linux-nat.c |  4 ++--
 gdb/arm-linux-nat.c     |  4 ++--
 gdb/i386-nat.c          |  4 ++--
 gdb/ia64-linux-nat.c    |  4 ++--
 gdb/inf-ttrace.c        |  2 +-
 gdb/linux-nat.c         | 22 ++++++++++------------
 gdb/mips-linux-nat.c    |  2 +-
 gdb/nto-procfs.c        |  4 ++--
 gdb/ppc-linux-nat.c     |  4 ++--
 gdb/procfs.c            |  2 +-
 gdb/record-full.c       | 28 +++++++++++++++++-----------
 gdb/remote-m32r-sdi.c   |  2 +-
 gdb/remote-mips.c       |  2 +-
 gdb/remote.c            | 24 ++++++++++++++----------
 gdb/s390-linux-nat.c    |  2 +-
 gdb/target.c            | 23 ++++++++++++-----------
 gdb/target.h            | 19 ++++++++++---------
 18 files changed, 123 insertions(+), 71 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 31c26c6..703c4ed 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -1476,11 +1476,11 @@ aarch64_linux_stopped_data_address (struct target_ops *target,
 /* Implement the "to_stopped_by_watchpoint" target_ops method.  */
 
 static int
-aarch64_linux_stopped_by_watchpoint (void)
+aarch64_linux_stopped_by_watchpoint (struct target_ops *ops)
 {
   CORE_ADDR addr;
 
-  return aarch64_linux_stopped_data_address (&current_target, &addr);
+  return aarch64_linux_stopped_data_address (ops, &addr);
 }
 
 /* Implement the "to_watchpoint_addr_within_range" target_ops method.  */
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 6f56634..9fa5f5b 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -1171,10 +1171,10 @@ arm_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
 
 /* Has the target been stopped by hitting a watchpoint?  */
 static int
-arm_linux_stopped_by_watchpoint (void)
+arm_linux_stopped_by_watchpoint (struct target_ops *ops)
 {
   CORE_ADDR addr;
-  return arm_linux_stopped_data_address (&current_target, &addr);
+  return arm_linux_stopped_data_address (ops, &addr);
 }
 
 static int
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 034bf51..23edc38 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -756,10 +756,10 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
 }
 
 static int
-i386_stopped_by_watchpoint (void)
+i386_stopped_by_watchpoint (struct target_ops *ops)
 {
   CORE_ADDR addr = 0;
-  return i386_stopped_data_address (&current_target, &addr);
+  return i386_stopped_data_address (ops, &addr);
 }
 
 /* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index 072c8fd..ea575c8 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -669,10 +669,10 @@ ia64_linux_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
 }
 
 static int
-ia64_linux_stopped_by_watchpoint (void)
+ia64_linux_stopped_by_watchpoint (struct target_ops *ops)
 {
   CORE_ADDR addr;
-  return ia64_linux_stopped_data_address (&current_target, &addr);
+  return ia64_linux_stopped_data_address (ops, &addr);
 }
 
 static int
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index ea76153..de95ec7 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -374,7 +374,7 @@ inf_ttrace_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
    by hitting a "hardware" watchpoint.  */
 
 static int
-inf_ttrace_stopped_by_watchpoint (void)
+inf_ttrace_stopped_by_watchpoint (struct target_ops *ops)
 {
   pid_t pid = ptid_get_pid (inferior_ptid);
   lwpid_t lwpid = ptid_get_lwp (inferior_ptid);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index d144c77..e5938d3 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -262,10 +262,6 @@ async_file_mark (void)
      be awakened anyway.  */
 }
 
-static void linux_nat_async (void (*callback)
-			     (enum inferior_event_type event_type,
-			      void *context),
-			     void *context);
 static int kill_lwp (int lwpid, int signo);
 
 static int stop_callback (struct lwp_info *lp, void *data);
@@ -2484,7 +2480,7 @@ save_sigtrap (struct lwp_info *lp)
   old_chain = save_inferior_ptid ();
   inferior_ptid = lp->ptid;
 
-  lp->stopped_by_watchpoint = linux_ops->to_stopped_by_watchpoint ();
+  lp->stopped_by_watchpoint = linux_ops->to_stopped_by_watchpoint (linux_ops);
 
   if (lp->stopped_by_watchpoint)
     {
@@ -2502,7 +2498,7 @@ save_sigtrap (struct lwp_info *lp)
 /* See save_sigtrap.  */
 
 static int
-linux_nat_stopped_by_watchpoint (void)
+linux_nat_stopped_by_watchpoint (struct target_ops *ops)
 {
   struct lwp_info *lp = find_lwp_pid (inferior_ptid);
 
@@ -4499,7 +4495,7 @@ linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int))
 /* target_is_async_p implementation.  */
 
 static int
-linux_nat_is_async_p (void)
+linux_nat_is_async_p (struct target_ops *ops)
 {
   /* NOTE: palves 2008-03-21: We're only async when the user requests
      it explicitly with the "set target-async" command.
@@ -4510,7 +4506,7 @@ linux_nat_is_async_p (void)
 /* target_can_async_p implementation.  */
 
 static int
-linux_nat_can_async_p (void)
+linux_nat_can_async_p (struct target_ops *ops)
 {
   /* NOTE: palves 2008-03-21: We're only async when the user requests
      it explicitly with the "set target-async" command.
@@ -4670,8 +4666,10 @@ linux_async_pipe (int enable)
 /* target_async implementation.  */
 
 static void
-linux_nat_async (void (*callback) (enum inferior_event_type event_type,
-				   void *context), void *context)
+linux_nat_async (struct target_ops *ops,
+		 void (*callback) (enum inferior_event_type event_type,
+				   void *context),
+		 void *context)
 {
   if (callback != NULL)
     {
@@ -4756,8 +4754,8 @@ static void
 linux_nat_close (void)
 {
   /* Unregister from the event loop.  */
-  if (linux_nat_is_async_p ())
-    linux_nat_async (NULL, 0);
+  if (linux_nat_is_async_p (NULL))
+    linux_nat_async (NULL, NULL, 0);
 
   if (linux_ops->to_close)
     linux_ops->to_close ();
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index ce0d135..627241f 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -553,7 +553,7 @@ mips_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
    register triggered.  */
 
 static int
-mips_linux_stopped_by_watchpoint (void)
+mips_linux_stopped_by_watchpoint (struct target_ops *ops)
 {
   int n;
   int num_valid;
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 4669345..7739197 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -75,7 +75,7 @@ static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type,
 static int procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type,
 					struct expression *cond);
 
-static int procfs_stopped_by_watchpoint (void);
+static int procfs_stopped_by_watchpoint (struct target_ops *ops);
 
 /* These two globals are only ever set in procfs_open(), but are
    referenced elsewhere.  'nto_procfs_node' is a flag used to say
@@ -1508,7 +1508,7 @@ procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 static int
-procfs_stopped_by_watchpoint (void)
+procfs_stopped_by_watchpoint (struct target_ops *ops)
 {
   return 0;
 }
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 8d57b9d..b38b33e 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2283,10 +2283,10 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
 }
 
 static int
-ppc_linux_stopped_by_watchpoint (void)
+ppc_linux_stopped_by_watchpoint (struct target_ops *ops)
 {
   CORE_ADDR addr;
-  return ppc_linux_stopped_data_address (&current_target, &addr);
+  return ppc_linux_stopped_data_address (ops, &addr);
 }
 
 static int
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 2383366..bd0829d 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -4856,7 +4856,7 @@ procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
    fault, else returns zero.  */
 
 static int
-procfs_stopped_by_watchpoint (void)
+procfs_stopped_by_watchpoint (struct target_ops *ops)
 {
   procinfo *pi;
 
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 9a2b5e6..41a93eb 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -252,11 +252,12 @@ static int
 					       struct gdbarch *,
 					       struct bp_target_info *);
 static struct target_ops *record_full_beneath_to_remove_breakpoint_ops;
-static int (*record_full_beneath_to_stopped_by_watchpoint) (void);
+static int (*record_full_beneath_to_stopped_by_watchpoint) (struct target_ops *);
 static int (*record_full_beneath_to_stopped_data_address) (struct target_ops *,
 							   CORE_ADDR *);
 static void
-  (*record_full_beneath_to_async) (void (*) (enum inferior_event_type, void *),
+  (*record_full_beneath_to_async) (struct target_ops *,
+				   void (*) (enum inferior_event_type, void *),
 				   void *);
 
 static void record_full_goto_insn (struct record_full_entry *entry,
@@ -824,10 +825,10 @@ static struct target_ops *tmp_to_insert_breakpoint_ops;
 static int (*tmp_to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
 					struct bp_target_info *);
 static struct target_ops *tmp_to_remove_breakpoint_ops;
-static int (*tmp_to_stopped_by_watchpoint) (void);
+static int (*tmp_to_stopped_by_watchpoint) (struct target_ops *);
 static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
-static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
-static void (*tmp_to_async) (void (*) (enum inferior_event_type, void *), void *);
+static void (*tmp_to_async) (struct target_ops *,
+			     void (*) (enum inferior_event_type, void *), void *);
 
 static void record_full_restore (void);
 
@@ -1523,12 +1524,16 @@ record_full_wait (struct target_ops *ops,
 }
 
 static int
-record_full_stopped_by_watchpoint (void)
+record_full_stopped_by_watchpoint (struct target_ops *ops)
 {
   if (RECORD_FULL_IS_REPLAY)
     return record_full_hw_watchpoint;
   else
-    return record_full_beneath_to_stopped_by_watchpoint ();
+    {
+      struct target_ops *beneath = find_target_beneath (ops);
+
+      return record_full_beneath_to_stopped_by_watchpoint (beneath);
+    }
 }
 
 static int
@@ -1909,25 +1914,26 @@ record_full_goto_bookmark (gdb_byte *raw_bookmark, int from_tty)
 }
 
 static void
-record_full_async (void (*callback) (enum inferior_event_type event_type,
+record_full_async (struct target_ops *ops,
+		   void (*callback) (enum inferior_event_type event_type,
 				     void *context), void *context)
 {
   /* If we're on top of a line target (e.g., linux-nat, remote), then
      set it to async mode as well.  Will be NULL if we're sitting on
      top of the core target, for "record restore".  */
   if (record_full_beneath_to_async != NULL)
-    record_full_beneath_to_async (callback, context);
+    record_full_beneath_to_async (find_target_beneath (ops), callback, context);
 }
 
 static int
-record_full_can_async_p (void)
+record_full_can_async_p (struct target_ops *ops)
 {
   /* We only enable async when the user specifically asks for it.  */
   return target_async_permitted;
 }
 
 static int
-record_full_is_async_p (void)
+record_full_is_async_p (struct target_ops *ops)
 {
   /* We only enable async when the user specifically asks for it.  */
   return target_async_permitted;
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index d722876..48c4b4b 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1477,7 +1477,7 @@ m32r_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
 }
 
 static int
-m32r_stopped_by_watchpoint (void)
+m32r_stopped_by_watchpoint (struct target_ops *ops)
 {
   CORE_ADDR addr;
 
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 6e7d956..6109e64 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -2450,7 +2450,7 @@ mips_remove_watchpoint (CORE_ADDR addr, int len, int type,
    if not.  */
 
 static int
-mips_stopped_by_watchpoint (void)
+mips_stopped_by_watchpoint (struct target_ops *ops)
 {
   return hit_watchpoint;
 }
diff --git a/gdb/remote.c b/gdb/remote.c
index e1d0a64..c6767d4 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -126,12 +126,14 @@ static void remote_kill (struct target_ops *ops);
 
 static int tohex (int nib);
 
-static int remote_can_async_p (void);
+static int remote_can_async_p (struct target_ops *);
 
-static int remote_is_async_p (void);
+static int remote_is_async_p (struct target_ops *);
 
-static void remote_async (void (*callback) (enum inferior_event_type event_type,
-					    void *context), void *context);
+static void remote_async (struct target_ops *ops,
+			  void (*callback) (enum inferior_event_type event_type,
+					    void *context),
+			  void *context);
 
 static void sync_remote_interrupt_twice (int signo);
 
@@ -8499,7 +8501,7 @@ remote_check_watch_resources (int type, int cnt, int ot)
 }
 
 static int
-remote_stopped_by_watchpoint (void)
+remote_stopped_by_watchpoint (struct target_ops *ops)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -8512,7 +8514,7 @@ remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
   struct remote_state *rs = get_remote_state ();
   int rc = 0;
 
-  if (remote_stopped_by_watchpoint ())
+  if (remote_stopped_by_watchpoint (target))
     {
       *addr_p = rs->remote_watch_data_address;
       rc = 1;
@@ -11683,7 +11685,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
 }
 
 static int
-remote_can_async_p (void)
+remote_can_async_p (struct target_ops *ops)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -11696,7 +11698,7 @@ remote_can_async_p (void)
 }
 
 static int
-remote_is_async_p (void)
+remote_is_async_p (struct target_ops *ops)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -11731,8 +11733,10 @@ remote_async_inferior_event_handler (gdb_client_data data)
 }
 
 static void
-remote_async (void (*callback) (enum inferior_event_type event_type,
-				void *context), void *context)
+remote_async (struct target_ops *ops,
+	      void (*callback) (enum inferior_event_type event_type,
+				void *context),
+	      void *context)
 {
   struct remote_state *rs = get_remote_state ();
 
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index ee9b617..8cc9060 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -433,7 +433,7 @@ struct watch_area
 static struct watch_area *watch_base = NULL;
 
 static int
-s390_stopped_by_watchpoint (void)
+s390_stopped_by_watchpoint (struct target_ops *ops)
 {
   per_lowcore_bits per_lowcore;
   ptrace_area parea;
diff --git a/gdb/target.c b/gdb/target.c
index 3d63ada..6723562 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -110,8 +110,6 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int,
 static int debug_to_remove_watchpoint (CORE_ADDR, int, int,
 				       struct expression *);
 
-static int debug_to_stopped_by_watchpoint (void);
-
 static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
 
 static int debug_to_watchpoint_addr_within_range (struct target_ops *,
@@ -742,7 +740,7 @@ update_current_target (void)
 	    (int (*) (CORE_ADDR, int, int, struct expression *))
 	    return_minus_one);
   de_fault (to_stopped_by_watchpoint,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_stopped_data_address,
 	    (int (*) (struct target_ops *, CORE_ADDR *))
@@ -820,7 +818,9 @@ update_current_target (void)
 	    (char *(*) (int))
 	    return_null);
   de_fault (to_async,
-	    (void (*) (void (*) (enum inferior_event_type, void*), void*))
+	    (void (*) (struct target_ops *,
+		       void (*) (enum inferior_event_type, void*),
+		       void*))
 	    tcomplain);
   de_fault (to_thread_architecture,
 	    default_thread_architecture);
@@ -3168,7 +3168,7 @@ find_default_create_inferior (struct target_ops *ops,
 }
 
 static int
-find_default_can_async_p (void)
+find_default_can_async_p (struct target_ops *ignore)
 {
   struct target_ops *t;
 
@@ -3178,12 +3178,12 @@ find_default_can_async_p (void)
      connected yet.  */
   t = find_default_run_target (NULL);
   if (t && t->to_can_async_p)
-    return (t->to_can_async_p) ();
+    return (t->to_can_async_p) (t);
   return 0;
 }
 
 static int
-find_default_is_async_p (void)
+find_default_is_async_p (struct target_ops *ignore)
 {
   struct target_ops *t;
 
@@ -3193,7 +3193,7 @@ find_default_is_async_p (void)
      connected yet.  */
   t = find_default_run_target (NULL);
   if (t && t->to_is_async_p)
-    return (t->to_is_async_p) ();
+    return (t->to_is_async_p) (t);
   return 0;
 }
 
@@ -3801,7 +3801,8 @@ init_dummy_target (void)
   dummy_target.to_has_registers = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_execution
     = (int (*) (struct target_ops *, ptid_t)) return_zero;
-  dummy_target.to_stopped_by_watchpoint = return_zero;
+  dummy_target.to_stopped_by_watchpoint
+    = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_stopped_data_address =
     (int (*) (struct target_ops *, CORE_ADDR *)) return_zero;
   dummy_target.to_magic = OPS_MAGIC;
@@ -4680,11 +4681,11 @@ debug_to_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int rw,
 }
 
 static int
-debug_to_stopped_by_watchpoint (void)
+debug_to_stopped_by_watchpoint (struct target_ops *ops)
 {
   int retval;
 
-  retval = debug_target.to_stopped_by_watchpoint ();
+  retval = debug_target.to_stopped_by_watchpoint (&debug_target);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_stopped_by_watchpoint () = %ld\n",
diff --git a/gdb/target.h b/gdb/target.h
index dee8d3e..e3479e2 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -426,7 +426,7 @@ struct target_ops
 				      CORE_ADDR, CORE_ADDR, int);
     int (*to_remove_mask_watchpoint) (struct target_ops *,
 				      CORE_ADDR, CORE_ADDR, int);
-    int (*to_stopped_by_watchpoint) (void);
+    int (*to_stopped_by_watchpoint) (struct target_ops *);
     int to_have_steppable_watchpoint;
     int to_have_continuable_watchpoint;
     int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
@@ -491,9 +491,10 @@ struct target_ops
     int to_has_thread_control;	/* control thread execution */
     int to_attach_no_wait;
     /* ASYNC target controls */
-    int (*to_can_async_p) (void);
-    int (*to_is_async_p) (void);
-    void (*to_async) (async_callback_ftype *, void *);
+    int (*to_can_async_p) (struct target_ops *);
+    int (*to_is_async_p) (struct target_ops *);
+    void (*to_async) (struct target_ops *,
+		      async_callback_ftype *, void *);
     int (*to_supports_non_stop) (void);
     /* find_memory_regions support method for gcore */
     int (*to_find_memory_regions) (find_memory_region_ftype func, void *data);
@@ -1456,16 +1457,16 @@ extern int default_child_has_execution (struct target_ops *ops,
 extern int target_async_permitted;
 
 /* Can the target support asynchronous execution?  */
-#define target_can_async_p() (current_target.to_can_async_p ())
+#define target_can_async_p() (current_target.to_can_async_p (&current_target))
 
 /* Is the target in asynchronous execution mode?  */
-#define target_is_async_p() (current_target.to_is_async_p ())
+#define target_is_async_p() (current_target.to_is_async_p (&current_target))
 
 int target_supports_non_stop (void);
 
 /* Put the target in async mode with the specified callback function.  */
 #define target_async(CALLBACK,CONTEXT) \
-     (current_target.to_async ((CALLBACK), (CONTEXT)))
+     (current_target.to_async (&current_target, (CALLBACK), (CONTEXT)))
 
 #define target_execution_direction() \
   (current_target.to_execution_direction ())
@@ -1539,8 +1540,8 @@ extern char *target_thread_name (struct thread_info *);
 /* Returns non-zero if we were stopped by a hardware watchpoint (memory read or
    write).  Only the INFERIOR_PTID task is being queried.  */
 
-#define target_stopped_by_watchpoint \
-   (*current_target.to_stopped_by_watchpoint)
+#define target_stopped_by_watchpoint()		\
+  ((*current_target.to_stopped_by_watchpoint) (&current_target))
 
 /* Non-zero if we have steppable watchpoints  */
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 21/38] convert to_extra_thread_info
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (19 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 29/38] convert to_search_memory Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:58 ` [RFC v2 17/38] Add target_ops argument to to_save_record Tom Tromey
                   ` (18 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_extra_thread_info.
	* target.h (struct target_ops) <to_extra_thread_info>: Use
	TARGET_DEFAULT_RETURN.

convert to_thread_name

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_thread_name.
	(target_thread_name): Unconditionally delegate.
	* target.h (struct target_ops) <to_thread_name>: Use
	TARGET_DEFAULT_RETURN.

convert to_pid_to_exec_file

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_pid_to_exec_file.
	* target.h (struct target_ops) <to_pid_to_exec_file>: Use
	TARGET_DEFAULT_RETURN.

convert to_log_command

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_log_command.
	* target.h (struct target_ops) <to_log_command>: Use
	TARGET_DEFAULT_IGNORE.
	(target_log_command): Unconditionally delegate.

convert to_find_memory_regions

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_find_memory_regions.
	(init_dummy_target): Don't initialize to_find_memory_regions.
	* target.h (struct target_ops) <to_find_memory_regions>: Use
	TARGET_DEFAULT_FUNC.

convert to_make_corefile_notes

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_make_corefile_notes.
	(init_dummy_target): Don't initialize to_make_corefile_notes.
	* target.h (struct target_ops) <to_make_corefile_notes>: Use
	TARGET_DEFAULT_FUNC.

convert to_get_bookmark

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_get_bookmark.
	(dummy_get_bookmark): Remove.
	(init_dummy_target): Don't inherit or default to_get_bookmark.
	* target.h (struct target_ops) <to_get_bookmark>: Use
	TARGET_DEFAULT_NORETURN

convert to_goto_bookmark

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_goto_bookmark.
	(dummy_goto_bookmark): Remove.
	(init_dummy_target): Don't inherit or default to_goto_bookmark.
	* target.h (struct target_ops) <to_goto_bookmark>: Use
	TARGET_DEFAULT_NORETURN.

convert to_can_execute_reverse

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_can_execute_reverse.
	* target.h (struct target_ops) <to_can_execute_reverse>: Use
	TARGET_DEFAULT_RETURN.
	(target_can_execute_reverse): Unconditionally delegate.

convert to_execution_direction

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_execution_direction.
	* target.h (struct target_ops) <to_execution_direction>: Use
	TARGET_DEFAULT_FUNC.
---
 gdb/ChangeLog          |  89 +++++++++++++++++++++++++++++++
 gdb/target-delegates.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  69 ++++++++----------------
 gdb/target.h           |  41 +++++++-------
 4 files changed, 274 insertions(+), 66 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 1ac0fc2..13e547d 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -426,6 +426,32 @@ tdefault_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3)
   return 0;
 }
 
+static char *
+delegate_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
+{
+  self = self->beneath;
+  return self->to_extra_thread_info (self, arg1);
+}
+
+static char *
+tdefault_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
+{
+  return 0;
+}
+
+static char *
+delegate_thread_name (struct target_ops *self, struct thread_info *arg1)
+{
+  self = self->beneath;
+  return self->to_thread_name (self, arg1);
+}
+
+static char *
+tdefault_thread_name (struct target_ops *self, struct thread_info *arg1)
+{
+  return 0;
+}
+
 static void
 delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2)
 {
@@ -433,6 +459,31 @@ delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2)
   self->to_rcmd (self, arg1, arg2);
 }
 
+static char *
+delegate_pid_to_exec_file (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_pid_to_exec_file (self, arg1);
+}
+
+static char *
+tdefault_pid_to_exec_file (struct target_ops *self, int arg1)
+{
+  return 0;
+}
+
+static void
+delegate_log_command (struct target_ops *self, const char *arg1)
+{
+  self = self->beneath;
+  self->to_log_command (self, arg1);
+}
+
+static void
+tdefault_log_command (struct target_ops *self, const char *arg1)
+{
+}
+
 static int
 delegate_can_async_p (struct target_ops *self)
 {
@@ -460,6 +511,46 @@ tdefault_async (struct target_ops *self, async_callback_ftype *arg1, void *arg2)
   tcomplain ();
 }
 
+static int
+delegate_find_memory_regions (struct target_ops *self, find_memory_region_ftype arg1, void *arg2)
+{
+  self = self->beneath;
+  return self->to_find_memory_regions (self, arg1, arg2);
+}
+
+static char * 
+delegate_make_corefile_notes (struct target_ops *self, bfd *arg1, int *arg2)
+{
+  self = self->beneath;
+  return self->to_make_corefile_notes (self, arg1, arg2);
+}
+
+static gdb_byte * 
+delegate_get_bookmark (struct target_ops *self, char *arg1, int arg2)
+{
+  self = self->beneath;
+  return self->to_get_bookmark (self, arg1, arg2);
+}
+
+static gdb_byte * 
+tdefault_get_bookmark (struct target_ops *self, char *arg1, int arg2)
+{
+  tcomplain ();
+}
+
+static void
+delegate_goto_bookmark (struct target_ops *self, gdb_byte *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_goto_bookmark (self, arg1, arg2);
+}
+
+static void
+tdefault_goto_bookmark (struct target_ops *self, gdb_byte *arg1, int arg2)
+{
+  tcomplain ();
+}
+
 static LONGEST
 delegate_xfer_partial (struct target_ops *self, enum target_object  arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6)
 {
@@ -474,6 +565,26 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object  arg1, const
 }
 
 static int
+delegate_can_execute_reverse (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_can_execute_reverse (self);
+}
+
+static int
+tdefault_can_execute_reverse (struct target_ops *self)
+{
+  return 0;
+}
+
+static enum exec_direction_kind 
+delegate_execution_direction (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_execution_direction (self);
+}
+
+static int
 delegate_supports_btrace (struct target_ops *self)
 {
   self = self->beneath;
@@ -561,16 +672,36 @@ install_delegators (struct target_ops *ops)
     ops->to_set_syscall_catchpoint = delegate_set_syscall_catchpoint;
   if (ops->to_has_exited == NULL)
     ops->to_has_exited = delegate_has_exited;
+  if (ops->to_extra_thread_info == NULL)
+    ops->to_extra_thread_info = delegate_extra_thread_info;
+  if (ops->to_thread_name == NULL)
+    ops->to_thread_name = delegate_thread_name;
   if (ops->to_rcmd == NULL)
     ops->to_rcmd = delegate_rcmd;
+  if (ops->to_pid_to_exec_file == NULL)
+    ops->to_pid_to_exec_file = delegate_pid_to_exec_file;
+  if (ops->to_log_command == NULL)
+    ops->to_log_command = delegate_log_command;
   if (ops->to_can_async_p == NULL)
     ops->to_can_async_p = delegate_can_async_p;
   if (ops->to_is_async_p == NULL)
     ops->to_is_async_p = delegate_is_async_p;
   if (ops->to_async == NULL)
     ops->to_async = delegate_async;
+  if (ops->to_find_memory_regions == NULL)
+    ops->to_find_memory_regions = delegate_find_memory_regions;
+  if (ops->to_make_corefile_notes == NULL)
+    ops->to_make_corefile_notes = delegate_make_corefile_notes;
+  if (ops->to_get_bookmark == NULL)
+    ops->to_get_bookmark = delegate_get_bookmark;
+  if (ops->to_goto_bookmark == NULL)
+    ops->to_goto_bookmark = delegate_goto_bookmark;
   if (ops->to_xfer_partial == NULL)
     ops->to_xfer_partial = delegate_xfer_partial;
+  if (ops->to_can_execute_reverse == NULL)
+    ops->to_can_execute_reverse = delegate_can_execute_reverse;
+  if (ops->to_execution_direction == NULL)
+    ops->to_execution_direction = delegate_execution_direction;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
 }
@@ -614,10 +745,20 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_remove_exec_catchpoint = tdefault_remove_exec_catchpoint;
   ops->to_set_syscall_catchpoint = tdefault_set_syscall_catchpoint;
   ops->to_has_exited = tdefault_has_exited;
+  ops->to_extra_thread_info = tdefault_extra_thread_info;
+  ops->to_thread_name = tdefault_thread_name;
   ops->to_rcmd = default_rcmd;
+  ops->to_pid_to_exec_file = tdefault_pid_to_exec_file;
+  ops->to_log_command = tdefault_log_command;
   ops->to_can_async_p = find_default_can_async_p;
   ops->to_is_async_p = find_default_is_async_p;
   ops->to_async = tdefault_async;
+  ops->to_find_memory_regions = dummy_find_memory_regions;
+  ops->to_make_corefile_notes = dummy_make_corefile_notes;
+  ops->to_get_bookmark = tdefault_get_bookmark;
+  ops->to_goto_bookmark = tdefault_goto_bookmark;
   ops->to_xfer_partial = tdefault_xfer_partial;
+  ops->to_can_execute_reverse = tdefault_can_execute_reverse;
+  ops->to_execution_direction = default_execution_direction;
   ops->to_supports_btrace = tdefault_supports_btrace;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 9def149..b657900 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -78,10 +78,20 @@ static target_xfer_partial_ftype default_xfer_partial;
 static struct gdbarch *default_thread_architecture (struct target_ops *ops,
 						    ptid_t ptid);
 
+static int dummy_find_memory_regions (struct target_ops *self,
+				      find_memory_region_ftype ignore1,
+				      void *ignore2);
+
+static char *dummy_make_corefile_notes (struct target_ops *self,
+					bfd *ignore1, int *ignore2);
+
 static int find_default_can_async_p (struct target_ops *ignore);
 
 static int find_default_is_async_p (struct target_ops *ignore);
 
+static enum exec_direction_kind default_execution_direction
+    (struct target_ops *self);
+
 #include "target-delegates.c"
 
 static void init_dummy_target (void);
@@ -644,13 +654,13 @@ update_current_target (void)
       /* Do not inherit to_thread_alive.  */
       /* Do not inherit to_find_new_threads.  */
       /* Do not inherit to_pid_to_str.  */
-      INHERIT (to_extra_thread_info, t);
-      INHERIT (to_thread_name, t);
+      /* Do not inherit to_extra_thread_info.  */
+      /* Do not inherit to_thread_name.  */
       INHERIT (to_stop, t);
       /* Do not inherit to_xfer_partial.  */
       /* Do not inherit to_rcmd.  */
-      INHERIT (to_pid_to_exec_file, t);
-      INHERIT (to_log_command, t);
+      /* Do not inherit to_pid_to_exec_file.  */
+      /* Do not inherit to_log_command.  */
       INHERIT (to_stratum, t);
       /* Do not inherit to_has_all_memory.  */
       /* Do not inherit to_has_memory.  */
@@ -661,13 +671,13 @@ update_current_target (void)
       /* Do not inherit to_can_async_p.  */
       /* Do not inherit to_is_async_p.  */
       /* Do not inherit to_async.  */
-      INHERIT (to_find_memory_regions, t);
-      INHERIT (to_make_corefile_notes, t);
-      INHERIT (to_get_bookmark, t);
-      INHERIT (to_goto_bookmark, t);
+      /* Do not inherit to_find_memory_regions.  */
+      /* Do not inherit to_make_corefile_notes.  */
+      /* Do not inherit to_get_bookmark.  */
+      /* Do not inherit to_goto_bookmark.  */
       /* Do not inherit to_get_thread_local_address.  */
-      INHERIT (to_can_execute_reverse, t);
-      INHERIT (to_execution_direction, t);
+      /* Do not inherit to_can_execute_reverse.  */
+      /* Do not inherit to_execution_direction.  */
       INHERIT (to_thread_architecture, t);
       /* Do not inherit to_read_description.  */
       INHERIT (to_get_ada_task_ptid, t);
@@ -735,18 +745,9 @@ update_current_target (void)
   de_fault (to_can_run,
 	    (int (*) (struct target_ops *))
 	    return_zero);
-  de_fault (to_extra_thread_info,
-	    (char *(*) (struct target_ops *, struct thread_info *))
-	    return_null);
-  de_fault (to_thread_name,
-	    (char *(*) (struct target_ops *, struct thread_info *))
-	    return_null);
   de_fault (to_stop,
 	    (void (*) (struct target_ops *, ptid_t))
 	    target_ignore);
-  de_fault (to_pid_to_exec_file,
-	    (char *(*) (struct target_ops *, int))
-	    return_null);
   de_fault (to_thread_architecture,
 	    default_thread_architecture);
   current_target.to_read_description = NULL;
@@ -863,7 +864,6 @@ update_current_target (void)
   de_fault (to_augmented_libraries_svr4_read,
 	    (int (*) (struct target_ops *))
 	    return_zero);
-  de_fault (to_execution_direction, default_execution_direction);
 
 #undef de_fault
 
@@ -2615,15 +2615,7 @@ target_pid_to_str (ptid_t ptid)
 char *
 target_thread_name (struct thread_info *info)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_thread_name != NULL)
-	return (*t->to_thread_name) (t, info);
-    }
-
-  return NULL;
+  return current_target.to_thread_name (&current_target, info);
 }
 
 void
@@ -3629,21 +3621,6 @@ dummy_make_corefile_notes (struct target_ops *self,
   return NULL;
 }
 
-/* Error-catcher for target_get_bookmark.  */
-static gdb_byte *
-dummy_get_bookmark (struct target_ops *self, char *ignore1, int ignore2)
-{
-  tcomplain ();
-  return NULL;
-}
-
-/* Error-catcher for target_goto_bookmark.  */
-static void
-dummy_goto_bookmark (struct target_ops *self, gdb_byte *ignore, int from_tty)
-{
-  tcomplain ();
-}
-
 /* Set up the handful of non-empty slots needed by the dummy target
    vector.  */
 
@@ -3659,10 +3636,6 @@ init_dummy_target (void)
     = find_default_supports_disable_randomization;
   dummy_target.to_pid_to_str = dummy_pid_to_str;
   dummy_target.to_stratum = dummy_stratum;
-  dummy_target.to_find_memory_regions = dummy_find_memory_regions;
-  dummy_target.to_make_corefile_notes = dummy_make_corefile_notes;
-  dummy_target.to_get_bookmark = dummy_get_bookmark;
-  dummy_target.to_goto_bookmark = dummy_goto_bookmark;
   dummy_target.to_has_all_memory = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_memory = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_stack = (int (*) (struct target_ops *)) return_zero;
diff --git a/gdb/target.h b/gdb/target.h
index 98f8687..625968c 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -542,14 +542,18 @@ struct target_ops
     int (*to_thread_alive) (struct target_ops *, ptid_t ptid);
     void (*to_find_new_threads) (struct target_ops *);
     char *(*to_pid_to_str) (struct target_ops *, ptid_t);
-    char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *);
-    char *(*to_thread_name) (struct target_ops *, struct thread_info *);
+    char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *)
+      TARGET_DEFAULT_RETURN (0);
+    char *(*to_thread_name) (struct target_ops *, struct thread_info *)
+      TARGET_DEFAULT_RETURN (0);
     void (*to_stop) (struct target_ops *, ptid_t);
     void (*to_rcmd) (struct target_ops *,
 		     char *command, struct ui_file *output)
       TARGET_DEFAULT_FUNC (default_rcmd);
-    char *(*to_pid_to_exec_file) (struct target_ops *, int pid);
-    void (*to_log_command) (struct target_ops *, const char *);
+    char *(*to_pid_to_exec_file) (struct target_ops *, int pid)
+      TARGET_DEFAULT_RETURN (0);
+    void (*to_log_command) (struct target_ops *, const char *)
+      TARGET_DEFAULT_IGNORE ();
     struct target_section_table *(*to_get_section_table) (struct target_ops *);
     enum strata to_stratum;
     int (*to_has_all_memory) (struct target_ops *);
@@ -569,13 +573,17 @@ struct target_ops
     int (*to_supports_non_stop) (struct target_ops *);
     /* find_memory_regions support method for gcore */
     int (*to_find_memory_regions) (struct target_ops *,
-				   find_memory_region_ftype func, void *data);
+				   find_memory_region_ftype func, void *data)
+      TARGET_DEFAULT_FUNC (dummy_find_memory_regions);
     /* make_corefile_notes support method for gcore */
-    char * (*to_make_corefile_notes) (struct target_ops *, bfd *, int *);
+    char * (*to_make_corefile_notes) (struct target_ops *, bfd *, int *)
+      TARGET_DEFAULT_FUNC (dummy_make_corefile_notes);
     /* get_bookmark support method for bookmarks */
-    gdb_byte * (*to_get_bookmark) (struct target_ops *, char *, int);
+    gdb_byte * (*to_get_bookmark) (struct target_ops *, char *, int)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
     /* goto_bookmark support method for bookmarks */
-    void (*to_goto_bookmark) (struct target_ops *, gdb_byte *, int);
+    void (*to_goto_bookmark) (struct target_ops *, gdb_byte *, int)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
     /* Return the thread-local address at OFFSET in the
        thread-local storage for the thread PTID and the shared library
        or executable file given by OBJFILE.  If that block of
@@ -680,12 +688,14 @@ struct target_ops
 			     CORE_ADDR *found_addrp);
 
     /* Can target execute in reverse?  */
-    int (*to_can_execute_reverse) (struct target_ops *);
+    int (*to_can_execute_reverse) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* The direction the target is currently executing.  Must be
        implemented on targets that support reverse execution and async
        mode.  The default simply returns forward execution.  */
-    enum exec_direction_kind (*to_execution_direction) (struct target_ops *);
+    enum exec_direction_kind (*to_execution_direction) (struct target_ops *)
+      TARGET_DEFAULT_FUNC (default_execution_direction);
 
     /* Does this target support debugging multiple processes
        simultaneously?  */
@@ -1738,8 +1748,7 @@ extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
 
 /* Target can execute in reverse?  */
 #define target_can_execute_reverse \
-     (current_target.to_can_execute_reverse ? \
-      current_target.to_can_execute_reverse (&current_target) : 0)
+      current_target.to_can_execute_reverse (&current_target)
 
 extern const struct target_desc *target_read_description (struct target_ops *);
 
@@ -1914,12 +1923,8 @@ extern char *target_fileio_read_stralloc (const char *filename);
 
 /* Command logging facility.  */
 
-#define target_log_command(p)						\
-  do									\
-    if (current_target.to_log_command)					\
-      (*current_target.to_log_command) (&current_target,		\
-					p);				\
-  while (0)
+#define target_log_command(p)					\
+  (*current_target.to_log_command) (&current_target, p)
 
 
 extern int target_core_of_thread (ptid_t ptid);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 35/38] remove some calls to INHERIT and de_fault
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (15 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 07/38] Add target_ops argument to to_close Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 27/38] convert to_get_section_table Tom Tromey
                   ` (22 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes a few unnecessary calls to INHERIT and de_fault:

* to_doc is only used when a target is registered
* to_magic is only used when a target is pushed and not useful for
  current_target.
* to_open and to_close are only ever called using a specific
  target_ops object; there is no need to de_fault them.

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

	* target.c (update_current_target): Do not INHERIT to_doc or
	to_magic.  Do not de_fault to_open or to_close.
---
 gdb/ChangeLog | 5 +++++
 gdb/target.c  | 8 --------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/gdb/target.c b/gdb/target.c
index 8de7487..bded196 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -606,13 +606,11 @@ update_current_target (void)
     {
       INHERIT (to_shortname, t);
       INHERIT (to_longname, t);
-      INHERIT (to_doc, t);
       INHERIT (to_attach_no_wait, t);
       INHERIT (deprecated_xfer_memory, t);
       INHERIT (to_have_steppable_watchpoint, t);
       INHERIT (to_have_continuable_watchpoint, t);
       INHERIT (to_has_thread_control, t);
-      INHERIT (to_magic, t);
     }
 #undef INHERIT
 
@@ -624,12 +622,6 @@ update_current_target (void)
   if (!current_target.field)               \
     current_target.field = value
 
-  de_fault (to_open,
-	    (void (*) (char *, int))
-	    tcomplain);
-  de_fault (to_close,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
   de_fault (deprecated_xfer_memory,
 	    (int (*) (CORE_ADDR, gdb_byte *, int, int,
 		      struct mem_attrib *, struct target_ops *))
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 27/38] convert to_get_section_table
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (16 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 35/38] remove some calls to INHERIT and de_fault Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 32/38] remove function casts from target.c Tom Tromey
                   ` (21 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (target_get_section_table): Unconditionally delegate.
	* target.h (struct target_ops) <to_get_section_table>: Use
	TARGET_DEFAULT_RETURN.

convert to_flash_erase

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

	* target-delegates.c: Rebuild.
	* target.c (target_flash_erase): Unconditionally delegate.
	* target.h (struct target_ops) <to_flash_erase>: Use
	TARGET_DEFAULT_NORETURN.

convert to_flash_done

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

	* target-delegates.c: Rebuild.
	* target.c (target_flash_done): Unconditionally delegate.
	* target.h (struct target_ops) <to_flash_done>: Use
	TARGET_DEFAULT_NORETURN.

convert to_core_of_thread

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

	* target-delegates.c: Rebuild.
	* target.c (target_core_of_thread): Unconditionally delegate.
	* target.h (struct target_ops) <to_core_of_thread>: Use
	TARGET_DEFAULT_RETURN.

convert to_verify_memory

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

	* target-delegates.c: Rebuild.
	* target.c (target_verify_memory): Unconditionally delegate.
	* target.h (struct target_ops) <to_verify_memory>: Use
	TARGET_DEFAULT_NORETURN.

convert to_call_history_range

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

	* target-delegates.c: Rebuild.
	* target.c (target_call_history_range): Unconditionally delegate.
	* target.h (struct target_ops) <to_call_history_range>: Use
	TARGET_DEFAULT_NORETURN.

convert to_call_history_from

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

	* target-delegates.c: Rebuild.
	* target.c (target_call_history_from): Unconditionally delegate.
	* target.h (struct target_ops) <to_call_history_from>: Use
	TARGET_DEFAULT_NORETURN.

convert to_call_history

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

	* target-delegates.c: Rebuild.
	* target.c (target_call_history): Unconditionally delegate.
	* target.h (struct target_ops) <to_call_history>: Use
	TARGET_DEFAULT_NORETURN.

convert to_insn_history_range

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

	* target-delegates.c: Rebuild.
	* target.c (target_insn_history_range): Unconditionally delegate.
	* target.h (struct target_ops) <to_insn_history_range>: Use
	TARGET_DEFAULT_NORETURN.

convert to_insn_history_from

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

	* target-delegates.c: Rebuild.
	* target.c (target_insn_history_from): Unconditionally delegate.
	* target.h (struct target_ops) <to_insn_history_from>: Use
	TARGET_DEFAULT_NORETURN.
---
 gdb/ChangeLog          |  70 ++++++++++++++++++++++
 gdb/target-delegates.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           | 144 +++++++++-----------------------------------
 gdb/target.h           |  30 ++++++----
 4 files changed, 278 insertions(+), 126 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index b59f199..e6c0cf3 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -630,6 +630,19 @@ tdefault_log_command (struct target_ops *self, const char *arg1)
 {
 }
 
+static struct target_section_table *
+delegate_get_section_table (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_get_section_table (self);
+}
+
+static struct target_section_table *
+tdefault_get_section_table (struct target_ops *self)
+{
+  return 0;
+}
+
 static int
 delegate_can_async_p (struct target_ops *self)
 {
@@ -710,6 +723,32 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object  arg1, const
   return -1;
 }
 
+static void
+delegate_flash_erase (struct target_ops *self, ULONGEST arg1, LONGEST arg2)
+{
+  self = self->beneath;
+  self->to_flash_erase (self, arg1, arg2);
+}
+
+static void
+tdefault_flash_erase (struct target_ops *self, ULONGEST arg1, LONGEST arg2)
+{
+  tcomplain ();
+}
+
+static void
+delegate_flash_done (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_flash_done (self);
+}
+
+static void
+tdefault_flash_done (struct target_ops *self)
+{
+  tcomplain ();
+}
+
 static ptid_t
 delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
 {
@@ -1093,6 +1132,32 @@ tdefault_set_trace_notes (struct target_ops *self, const char *arg1, const char
 }
 
 static int
+delegate_core_of_thread (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  return self->to_core_of_thread (self, arg1);
+}
+
+static int
+tdefault_core_of_thread (struct target_ops *self, ptid_t arg1)
+{
+  return -1;
+}
+
+static int
+delegate_verify_memory (struct target_ops *self, const gdb_byte *arg1, CORE_ADDR arg2, ULONGEST arg3)
+{
+  self = self->beneath;
+  return self->to_verify_memory (self, arg1, arg2, arg3);
+}
+
+static int
+tdefault_verify_memory (struct target_ops *self, const gdb_byte *arg1, CORE_ADDR arg2, ULONGEST arg3)
+{
+  tcomplain ();
+}
+
+static int
 delegate_get_tib_address (struct target_ops *self, ptid_t arg1, CORE_ADDR *arg2)
 {
   self = self->beneath;
@@ -1195,6 +1260,71 @@ tdefault_supports_btrace (struct target_ops *self)
   return 0;
 }
 
+static void
+delegate_insn_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+  self = self->beneath;
+  self->to_insn_history_from (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_insn_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+  tcomplain ();
+}
+
+static void
+delegate_insn_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+  self = self->beneath;
+  self->to_insn_history_range (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_insn_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+  tcomplain ();
+}
+
+static void
+delegate_call_history (struct target_ops *self, int arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_call_history (self, arg1, arg2);
+}
+
+static void
+tdefault_call_history (struct target_ops *self, int arg1, int arg2)
+{
+  tcomplain ();
+}
+
+static void
+delegate_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+  self = self->beneath;
+  self->to_call_history_from (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+{
+  tcomplain ();
+}
+
+static void
+delegate_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+  self = self->beneath;
+  self->to_call_history_range (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+{
+  tcomplain ();
+}
+
 static int
 delegate_augmented_libraries_svr4_read (struct target_ops *self)
 {
@@ -1319,6 +1449,8 @@ install_delegators (struct target_ops *ops)
     ops->to_pid_to_exec_file = delegate_pid_to_exec_file;
   if (ops->to_log_command == NULL)
     ops->to_log_command = delegate_log_command;
+  if (ops->to_get_section_table == NULL)
+    ops->to_get_section_table = delegate_get_section_table;
   if (ops->to_can_async_p == NULL)
     ops->to_can_async_p = delegate_can_async_p;
   if (ops->to_is_async_p == NULL)
@@ -1335,6 +1467,10 @@ install_delegators (struct target_ops *ops)
     ops->to_goto_bookmark = delegate_goto_bookmark;
   if (ops->to_xfer_partial == NULL)
     ops->to_xfer_partial = delegate_xfer_partial;
+  if (ops->to_flash_erase == NULL)
+    ops->to_flash_erase = delegate_flash_erase;
+  if (ops->to_flash_done == NULL)
+    ops->to_flash_done = delegate_flash_done;
   if (ops->to_get_ada_task_ptid == NULL)
     ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
   if (ops->to_can_execute_reverse == NULL)
@@ -1397,6 +1533,10 @@ install_delegators (struct target_ops *ops)
     ops->to_set_trace_buffer_size = delegate_set_trace_buffer_size;
   if (ops->to_set_trace_notes == NULL)
     ops->to_set_trace_notes = delegate_set_trace_notes;
+  if (ops->to_core_of_thread == NULL)
+    ops->to_core_of_thread = delegate_core_of_thread;
+  if (ops->to_verify_memory == NULL)
+    ops->to_verify_memory = delegate_verify_memory;
   if (ops->to_get_tib_address == NULL)
     ops->to_get_tib_address = delegate_get_tib_address;
   if (ops->to_set_permissions == NULL)
@@ -1413,6 +1553,16 @@ install_delegators (struct target_ops *ops)
     ops->to_can_use_agent = delegate_can_use_agent;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
+  if (ops->to_insn_history_from == NULL)
+    ops->to_insn_history_from = delegate_insn_history_from;
+  if (ops->to_insn_history_range == NULL)
+    ops->to_insn_history_range = delegate_insn_history_range;
+  if (ops->to_call_history == NULL)
+    ops->to_call_history = delegate_call_history;
+  if (ops->to_call_history_from == NULL)
+    ops->to_call_history_from = delegate_call_history_from;
+  if (ops->to_call_history_range == NULL)
+    ops->to_call_history_range = delegate_call_history_range;
   if (ops->to_augmented_libraries_svr4_read == NULL)
     ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
 }
@@ -1474,6 +1624,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_rcmd = default_rcmd;
   ops->to_pid_to_exec_file = tdefault_pid_to_exec_file;
   ops->to_log_command = tdefault_log_command;
+  ops->to_get_section_table = tdefault_get_section_table;
   ops->to_can_async_p = find_default_can_async_p;
   ops->to_is_async_p = find_default_is_async_p;
   ops->to_async = tdefault_async;
@@ -1482,6 +1633,8 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_get_bookmark = tdefault_get_bookmark;
   ops->to_goto_bookmark = tdefault_goto_bookmark;
   ops->to_xfer_partial = tdefault_xfer_partial;
+  ops->to_flash_erase = tdefault_flash_erase;
+  ops->to_flash_done = tdefault_flash_done;
   ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
   ops->to_can_execute_reverse = tdefault_can_execute_reverse;
   ops->to_execution_direction = default_execution_direction;
@@ -1513,6 +1666,8 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_set_circular_trace_buffer = tdefault_set_circular_trace_buffer;
   ops->to_set_trace_buffer_size = tdefault_set_trace_buffer_size;
   ops->to_set_trace_notes = tdefault_set_trace_notes;
+  ops->to_core_of_thread = tdefault_core_of_thread;
+  ops->to_verify_memory = tdefault_verify_memory;
   ops->to_get_tib_address = tdefault_get_tib_address;
   ops->to_set_permissions = tdefault_set_permissions;
   ops->to_static_tracepoint_marker_at = tdefault_static_tracepoint_marker_at;
@@ -1521,5 +1676,10 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_use_agent = tdefault_use_agent;
   ops->to_can_use_agent = tdefault_can_use_agent;
   ops->to_supports_btrace = tdefault_supports_btrace;
+  ops->to_insn_history_from = tdefault_insn_history_from;
+  ops->to_insn_history_range = tdefault_insn_history_range;
+  ops->to_call_history = tdefault_call_history;
+  ops->to_call_history_from = tdefault_call_history_from;
+  ops->to_call_history_range = tdefault_call_history_range;
   ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 9fbe19f..0ef82b3 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1088,16 +1088,10 @@ done:
 struct target_section_table *
 target_get_section_table (struct target_ops *target)
 {
-  struct target_ops *t;
-
   if (targetdebug)
     fprintf_unfiltered (gdb_stdlog, "target_get_section_table ()\n");
 
-  for (t = target; t != NULL; t = t->beneath)
-    if (t->to_get_section_table != NULL)
-      return (*t->to_get_section_table) (t);
-
-  return NULL;
+  return (*target->to_get_section_table) (target);
 }
 
 /* Find a section containing ADDR.  */
@@ -1729,36 +1723,18 @@ target_memory_map (void)
 void
 target_flash_erase (ULONGEST address, LONGEST length)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_flash_erase != NULL)
-      {
-	if (targetdebug)
-	  fprintf_unfiltered (gdb_stdlog, "target_flash_erase (%s, %s)\n",
-			      hex_string (address), phex (length, 0));
-	t->to_flash_erase (t, address, length);
-	return;
-      }
-
-  tcomplain ();
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_flash_erase (%s, %s)\n",
+			hex_string (address), phex (length, 0));
+  current_target.to_flash_erase (&current_target, address, length);
 }
 
 void
 target_flash_done (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_flash_done != NULL)
-      {
-	if (targetdebug)
-	  fprintf_unfiltered (gdb_stdlog, "target_flash_done\n");
-	t->to_flash_done (t);
-	return;
-      }
-
-  tcomplain ();
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_flash_done\n");
+  current_target.to_flash_done (&current_target);
 }
 
 static void
@@ -3674,47 +3650,28 @@ target_store_registers (struct regcache *regcache, int regno)
 int
 target_core_of_thread (ptid_t ptid)
 {
-  struct target_ops *t;
+  int retval = current_target.to_core_of_thread (&current_target, ptid);
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_core_of_thread != NULL)
-	{
-	  int retval = t->to_core_of_thread (t, ptid);
-
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog,
-				"target_core_of_thread (%d) = %d\n",
-				ptid_get_pid (ptid), retval);
-	  return retval;
-	}
-    }
-
-  return -1;
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog,
+			"target_core_of_thread (%d) = %d\n",
+			ptid_get_pid (ptid), retval);
+  return retval;
 }
 
 int
 target_verify_memory (const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_verify_memory != NULL)
-	{
-	  int retval = t->to_verify_memory (t, data, memaddr, size);
-
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog,
-				"target_verify_memory (%s, %s) = %d\n",
-				paddress (target_gdbarch (), memaddr),
-				pulongest (size),
-				retval);
-	  return retval;
-	}
-    }
+  int retval = current_target.to_verify_memory (&current_target,
+						data, memaddr, size);
 
-  tcomplain ();
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog,
+			"target_verify_memory (%s, %s) = %d\n",
+			paddress (target_gdbarch (), memaddr),
+			pulongest (size),
+			retval);
+  return retval;
 }
 
 /* The documentation for this function is in its prototype declaration in
@@ -4011,16 +3968,7 @@ target_insn_history (int size, int flags)
 void
 target_insn_history_from (ULONGEST from, int size, int flags)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_insn_history_from != NULL)
-      {
-	t->to_insn_history_from (t, from, size, flags);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_insn_history_from (&current_target, from, size, flags);
 }
 
 /* See target.h.  */
@@ -4028,16 +3976,7 @@ target_insn_history_from (ULONGEST from, int size, int flags)
 void
 target_insn_history_range (ULONGEST begin, ULONGEST end, int flags)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_insn_history_range != NULL)
-      {
-	t->to_insn_history_range (t, begin, end, flags);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_insn_history_range (&current_target, begin, end, flags);
 }
 
 /* See target.h.  */
@@ -4045,16 +3984,7 @@ target_insn_history_range (ULONGEST begin, ULONGEST end, int flags)
 void
 target_call_history (int size, int flags)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_call_history != NULL)
-      {
-	t->to_call_history (t, size, flags);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_call_history (&current_target, size, flags);
 }
 
 /* See target.h.  */
@@ -4062,16 +3992,7 @@ target_call_history (int size, int flags)
 void
 target_call_history_from (ULONGEST begin, int size, int flags)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_call_history_from != NULL)
-      {
-	t->to_call_history_from (t, begin, size, flags);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_call_history_from (&current_target, begin, size, flags);
 }
 
 /* See target.h.  */
@@ -4079,16 +4000,7 @@ target_call_history_from (ULONGEST begin, int size, int flags)
 void
 target_call_history_range (ULONGEST begin, ULONGEST end, int flags)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_call_history_range != NULL)
-      {
-	t->to_call_history_range (t, begin, end, flags);
-	return;
-      }
-
-  tcomplain ();
+  current_target.to_call_history_range (&current_target, begin, end, flags);
 }
 
 static void
diff --git a/gdb/target.h b/gdb/target.h
index 0e3ce22..45bc361 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -567,7 +567,8 @@ struct target_ops
       TARGET_DEFAULT_RETURN (0);
     void (*to_log_command) (struct target_ops *, const char *)
       TARGET_DEFAULT_IGNORE ();
-    struct target_section_table *(*to_get_section_table) (struct target_ops *);
+    struct target_section_table *(*to_get_section_table) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
     enum strata to_stratum;
     int (*to_has_all_memory) (struct target_ops *);
     int (*to_has_memory) (struct target_ops *);
@@ -662,13 +663,15 @@ struct target_ops
        Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
        on flash block boundaries, as reported by 'to_memory_map'.  */
     void (*to_flash_erase) (struct target_ops *,
-                           ULONGEST address, LONGEST length);
+                           ULONGEST address, LONGEST length)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Finishes a flash memory write sequence.  After this operation
        all flash memory should be available for writing and the result
        of reading from areas written by 'to_flash_write' should be
        equal to what was written.  */
-    void (*to_flash_done) (struct target_ops *);
+    void (*to_flash_done) (struct target_ops *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Describe the architecture-specific features of this target.
        Returns the description found, or NULL if no description
@@ -917,14 +920,16 @@ struct target_ops
        If the core cannot be determined -- either for the specified
        thread, or right now, or in this debug session, or for this
        target -- return -1.  */
-    int (*to_core_of_thread) (struct target_ops *, ptid_t ptid);
+    int (*to_core_of_thread) (struct target_ops *, ptid_t ptid)
+      TARGET_DEFAULT_RETURN (-1);
 
     /* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range
        matches the contents of [DATA,DATA+SIZE).  Returns 1 if there's
        a match, 0 if there's a mismatch, and -1 if an error is
        encountered while reading memory.  */
     int (*to_verify_memory) (struct target_ops *, const gdb_byte *data,
-			     CORE_ADDR memaddr, ULONGEST size);
+			     CORE_ADDR memaddr, ULONGEST size)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Return the address of the start of the Thread Information Block
        a Windows OS specific feature.  */
@@ -1036,29 +1041,34 @@ struct target_ops
        If SIZE < 0, disassemble abs (SIZE) instructions before FROM; otherwise,
        disassemble SIZE instructions after FROM.  */
     void (*to_insn_history_from) (struct target_ops *,
-				  ULONGEST from, int size, int flags);
+				  ULONGEST from, int size, int flags)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Disassemble a section of the recorded execution trace from instruction
        BEGIN (inclusive) to instruction END (inclusive).  */
     void (*to_insn_history_range) (struct target_ops *,
-				   ULONGEST begin, ULONGEST end, int flags);
+				   ULONGEST begin, ULONGEST end, int flags)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Print a function trace of the recorded execution trace.
        If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
        succeeding functions.  */
-    void (*to_call_history) (struct target_ops *, int size, int flags);
+    void (*to_call_history) (struct target_ops *, int size, int flags)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Print a function trace of the recorded execution trace starting
        at function FROM.
        If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
        SIZE functions after FROM.  */
     void (*to_call_history_from) (struct target_ops *,
-				  ULONGEST begin, int size, int flags);
+				  ULONGEST begin, int size, int flags)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Print a function trace of an execution trace section from function BEGIN
        (inclusive) to function END (inclusive).  */
     void (*to_call_history_range) (struct target_ops *,
-				   ULONGEST begin, ULONGEST end, int flags);
+				   ULONGEST begin, ULONGEST end, int flags)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
        non-empty annex.  */
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 36/38] convert to_decr_pc_after_break
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (5 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 22/38] convert to_thread_architecture Tom Tromey
@ 2014-02-06 20:56 ` Tom Tromey
  2014-02-06 20:56 ` [RFC v2 34/38] remove exec_set_find_memory_regions Tom Tromey
                   ` (32 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:56 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This converts to_decr_pc_after_break to the new style of delegation,
removing forward_target_decr_pc_after_break.

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

	* record-btrace.c (record_btrace_decr_pc_after_break): Delegate
	directly.
	* target-delegates.c: Rebuild.
	* target.h (struct target_ops) <to_decr_pc_after_break>: Use
	TARGET_DEFAULT_FUNC.
	* target.c (default_target_decr_pc_after_break): Rename from
	forward_target_decr_pc_after_break.  Simplify.
	(target_decr_pc_after_break): Rely on delegation.
---
 gdb/ChangeLog          | 11 +++++++++++
 gdb/record-btrace.c    |  2 +-
 gdb/target-delegates.c | 10 ++++++++++
 gdb/target.c           | 15 +++++++--------
 gdb/target.h           |  3 ++-
 5 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 44882ad..c4872eb 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1732,7 +1732,7 @@ record_btrace_decr_pc_after_break (struct target_ops *ops,
   if (record_btrace_is_replaying (ops))
     return 0;
 
-  return forward_target_decr_pc_after_break (ops->beneath, gdbarch);
+  return ops->beneath->to_decr_pc_after_break (ops->beneath, gdbarch);
 }
 
 /* The to_find_new_threads method of target record-btrace.  */
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 78e3c0d..d9c68cd 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -1572,6 +1572,13 @@ tdefault_augmented_libraries_svr4_read (struct target_ops *self)
   return 0;
 }
 
+static CORE_ADDR
+delegate_decr_pc_after_break (struct target_ops *self, struct gdbarch *arg1)
+{
+  self = self->beneath;
+  return self->to_decr_pc_after_break (self, arg1);
+}
+
 static void
 install_delegators (struct target_ops *ops)
 {
@@ -1837,6 +1844,8 @@ install_delegators (struct target_ops *ops)
     ops->to_call_history_range = delegate_call_history_range;
   if (ops->to_augmented_libraries_svr4_read == NULL)
     ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
+  if (ops->to_decr_pc_after_break == NULL)
+    ops->to_decr_pc_after_break = delegate_decr_pc_after_break;
 }
 
 static void
@@ -1973,4 +1982,5 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_call_history_from = tdefault_call_history_from;
   ops->to_call_history_range = tdefault_call_history_range;
   ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
+  ops->to_decr_pc_after_break = default_target_decr_pc_after_break;
 }
diff --git a/gdb/target.c b/gdb/target.c
index bded196..72d5a09 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -108,6 +108,9 @@ static int find_default_is_async_p (struct target_ops *ignore);
 static enum exec_direction_kind default_execution_direction
     (struct target_ops *self);
 
+static CORE_ADDR default_target_decr_pc_after_break (struct target_ops *ops,
+						     struct gdbarch *gdbarch);
+
 #include "target-delegates.c"
 
 static void init_dummy_target (void);
@@ -3781,16 +3784,12 @@ target_get_tailcall_unwinder (void)
   return NULL;
 }
 
-/* See target.h.  */
+/* Default implementation of to_decr_pc_after_break.  */
 
-CORE_ADDR
-forward_target_decr_pc_after_break (struct target_ops *ops,
+static CORE_ADDR
+default_target_decr_pc_after_break (struct target_ops *ops,
 				    struct gdbarch *gdbarch)
 {
-  for (; ops != NULL; ops = ops->beneath)
-    if (ops->to_decr_pc_after_break != NULL)
-      return ops->to_decr_pc_after_break (ops, gdbarch);
-
   return gdbarch_decr_pc_after_break (gdbarch);
 }
 
@@ -3799,7 +3798,7 @@ forward_target_decr_pc_after_break (struct target_ops *ops,
 CORE_ADDR
 target_decr_pc_after_break (struct gdbarch *gdbarch)
 {
-  return forward_target_decr_pc_after_break (current_target.beneath, gdbarch);
+  return current_target.to_decr_pc_after_break (&current_target, gdbarch);
 }
 
 static int
diff --git a/gdb/target.h b/gdb/target.h
index 09fe10e..c988a01 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1104,7 +1104,8 @@ struct target_ops
        after executing a breakpoint instruction.
        Defaults to gdbarch_decr_pc_after_break (GDBARCH).  */
     CORE_ADDR (*to_decr_pc_after_break) (struct target_ops *ops,
-					 struct gdbarch *gdbarch);
+					 struct gdbarch *gdbarch)
+      TARGET_DEFAULT_FUNC (default_target_decr_pc_after_break);
 
     int to_magic;
     /* Need sub-structure for target machine related rather than comm related?
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 04/38] add target method delegation
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (21 preceding siblings ...)
  2014-02-06 20:58 ` [RFC v2 17/38] Add target_ops argument to to_save_record Tom Tromey
@ 2014-02-06 20:58 ` Tom Tromey
  2014-02-07 15:53   ` Pedro Alves
  2014-02-06 20:58 ` [RFC v2 20/38] convert to_load Tom Tromey
                   ` (16 subsequent siblings)
  39 siblings, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch replaces some code in the record targets with target method
delegation.

record-full.c stores pointers to many target methods when the record
target is pushed.  Then it later delegates some calls via these.  This
is wrong because it violates the target stack contract.  In particular
it is ok to unpush a target at any stratum, but record-full does not
keep track of this, so it could potentially call into an unpushed
target.

This patch fixes the problem by using the newly-introduced generic
approach to target delegation for the methods in question.

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

	* record-full.c (record_full_beneath_to_resume_ops)
	(record_full_beneath_to_resume, record_full_beneath_to_wait_ops)
	(record_full_beneath_to_wait)
	(record_full_beneath_to_store_registers_ops)
	(record_full_beneath_to_store_registers)
	(record_full_beneath_to_xfer_partial_ops)
	(record_full_beneath_to_xfer_partial)
	(record_full_beneath_to_insert_breakpoint_ops)
	(record_full_beneath_to_insert_breakpoint)
	(record_full_beneath_to_remove_breakpoint_ops)
	(record_full_beneath_to_remove_breakpoint)
	(record_full_beneath_to_stopped_by_watchpoint)
	(record_full_beneath_to_stopped_data_address)
	(record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume)
	(tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops)
	(tmp_to_store_registers, tmp_to_xfer_partial_ops)
	(tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops)
	(tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops)
	(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
	(tmp_to_stopped_data_address, tmp_to_async): Remove.
	(record_full_open_1, record_full_open): Update.  Use RECORD_IS_USED.
	(record_full_resume, record_full_wait_1)
	(record_full_stopped_by_watchpoint, record_full_stopped_data_address)
	(record_full_store_registers, record_full_xfer_partial)
	(record_full_insert_breakpoint, record_full_remove_breakpoint)
	(record_full_async, record_full_core_xfer_partial): Use target
	delegation.
	* target-delegates.c: Rebuild.
	* target.c (current_xfer_partial): Remove.
	(update_current_target): Do not INHERIT or de_fault
	to_insert_breakpoint, to_remove_breakpoint,
	to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p,
	to_is_async_p, to_async.  Do not set to_xfer_partial field.
	(default_xfer_partial): Simplify.
	(current_xfer_partial): Remove.
	(target_wait, target_resume): Simplify.
	(find_default_can_async_p, find_default_is_async_p): Update.
	(init_dummy_target): Don't set to_can_async_p, to_is_async_p,
	to_xfer_partial, to_stopped_by_watchpoint,
	to_stopped_data_address.
	(target_store_registers): Simplify.
	(forward_target_remove_breakpoint)
	(forward_target_insert_breakpoint): Remove.
	(target_remove_breakpoint, target_insert_breakpoint)
	(debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update.
	* target.h (struct target_ops) <to_resume, to_wait,
	to_store_registers, to_insert_breakpoint, to_remove_breakpoint,
	to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p,
	to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT
	markup.
	(forward_target_remove_breakpoint)
	(forward_target_insert_breakpoint): Remove.
	* record-btrace.c (record_btrace_remove_breakpoint): Delegate
	directly.
	(record_btrace_insert_breakpoint): Delegate directly.
---
 gdb/ChangeLog          |  58 +++++++++++++
 gdb/record-btrace.c    |   4 +-
 gdb/record-full.c      | 222 +++++--------------------------------------------
 gdb/target-delegates.c | 152 +++++++++++++++++++++++++++++++++
 gdb/target.c           | 188 ++++++++++++-----------------------------
 gdb/target.h           |  51 +++++-------
 6 files changed, 306 insertions(+), 369 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 365b6be..e1125b5 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -869,7 +869,7 @@ record_btrace_insert_breakpoint (struct target_ops *ops,
 
   ret = 0;
   TRY_CATCH (except, RETURN_MASK_ALL)
-    ret = forward_target_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
+    ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
 
   record_btrace_allow_memory_access = old;
 
@@ -896,7 +896,7 @@ record_btrace_remove_breakpoint (struct target_ops *ops,
 
   ret = 0;
   TRY_CATCH (except, RETURN_MASK_ALL)
-    ret = forward_target_remove_breakpoint (ops->beneath, gdbarch, bp_tgt);
+    ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt);
 
   record_btrace_allow_memory_access = old;
 
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 41a93eb..d330892 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -228,38 +228,6 @@ static struct cmd_list_element *show_record_full_cmdlist;
 /* Command list for "record full".  */
 static struct cmd_list_element *record_full_cmdlist;
 
-/* The beneath function pointers.  */
-static struct target_ops *record_full_beneath_to_resume_ops;
-static void (*record_full_beneath_to_resume) (struct target_ops *, ptid_t, int,
-					      enum gdb_signal);
-static struct target_ops *record_full_beneath_to_wait_ops;
-static ptid_t (*record_full_beneath_to_wait) (struct target_ops *, ptid_t,
-					      struct target_waitstatus *,
-					      int);
-static struct target_ops *record_full_beneath_to_store_registers_ops;
-static void (*record_full_beneath_to_store_registers) (struct target_ops *,
-						       struct regcache *,
-						       int regno);
-static struct target_ops *record_full_beneath_to_xfer_partial_ops;
-static target_xfer_partial_ftype *record_full_beneath_to_xfer_partial;
-static int
-  (*record_full_beneath_to_insert_breakpoint) (struct target_ops *,
-					       struct gdbarch *,
-					       struct bp_target_info *);
-static struct target_ops *record_full_beneath_to_insert_breakpoint_ops;
-static int
-  (*record_full_beneath_to_remove_breakpoint) (struct target_ops *,
-					       struct gdbarch *,
-					       struct bp_target_info *);
-static struct target_ops *record_full_beneath_to_remove_breakpoint_ops;
-static int (*record_full_beneath_to_stopped_by_watchpoint) (struct target_ops *);
-static int (*record_full_beneath_to_stopped_data_address) (struct target_ops *,
-							   CORE_ADDR *);
-static void
-  (*record_full_beneath_to_async) (struct target_ops *,
-				   void (*) (enum inferior_event_type, void *),
-				   void *);
-
 static void record_full_goto_insn (struct record_full_entry *entry,
 				   enum exec_direction_kind dir);
 static void record_full_save (const char *recfilename);
@@ -806,30 +774,6 @@ record_full_exec_insn (struct regcache *regcache,
     }
 }
 
-static struct target_ops *tmp_to_resume_ops;
-static void (*tmp_to_resume) (struct target_ops *, ptid_t, int,
-			      enum gdb_signal);
-static struct target_ops *tmp_to_wait_ops;
-static ptid_t (*tmp_to_wait) (struct target_ops *, ptid_t,
-			      struct target_waitstatus *,
-			      int);
-static struct target_ops *tmp_to_store_registers_ops;
-static void (*tmp_to_store_registers) (struct target_ops *,
-				       struct regcache *,
-				       int regno);
-static struct target_ops *tmp_to_xfer_partial_ops;
-static target_xfer_partial_ftype *tmp_to_xfer_partial;
-static int (*tmp_to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
-					struct bp_target_info *);
-static struct target_ops *tmp_to_insert_breakpoint_ops;
-static int (*tmp_to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
-					struct bp_target_info *);
-static struct target_ops *tmp_to_remove_breakpoint_ops;
-static int (*tmp_to_stopped_by_watchpoint) (struct target_ops *);
-static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
-static void (*tmp_to_async) (struct target_ops *,
-			     void (*) (enum inferior_event_type, void *), void *);
-
 static void record_full_restore (void);
 
 /* Asynchronous signal handle registered as event loop source for when
@@ -892,26 +836,6 @@ record_full_open_1 (char *name, int from_tty)
     error (_("Process record: the current architecture doesn't support "
 	     "record function."));
 
-  if (!tmp_to_resume)
-    error (_("Could not find 'to_resume' method on the target stack."));
-  if (!tmp_to_wait)
-    error (_("Could not find 'to_wait' method on the target stack."));
-  if (!tmp_to_store_registers)
-    error (_("Could not find 'to_store_registers' "
-	     "method on the target stack."));
-  if (!tmp_to_insert_breakpoint)
-    error (_("Could not find 'to_insert_breakpoint' "
-	     "method on the target stack."));
-  if (!tmp_to_remove_breakpoint)
-    error (_("Could not find 'to_remove_breakpoint' "
-	     "method on the target stack."));
-  if (!tmp_to_stopped_by_watchpoint)
-    error (_("Could not find 'to_stopped_by_watchpoint' "
-	     "method on the target stack."));
-  if (!tmp_to_stopped_data_address)
-    error (_("Could not find 'to_stopped_data_address' "
-	     "method on the target stack."));
-
   push_target (&record_full_ops);
 }
 
@@ -929,89 +853,12 @@ record_full_open (char *name, int from_tty)
 
   record_preopen ();
 
-  /* Reset the tmp beneath pointers.  */
-  tmp_to_resume_ops = NULL;
-  tmp_to_resume = NULL;
-  tmp_to_wait_ops = NULL;
-  tmp_to_wait = NULL;
-  tmp_to_store_registers_ops = NULL;
-  tmp_to_store_registers = NULL;
-  tmp_to_xfer_partial_ops = NULL;
-  tmp_to_xfer_partial = NULL;
-  tmp_to_insert_breakpoint = NULL;
-  tmp_to_remove_breakpoint = NULL;
-  tmp_to_stopped_by_watchpoint = NULL;
-  tmp_to_stopped_data_address = NULL;
-  tmp_to_async = NULL;
-  tmp_to_insert_breakpoint_ops = NULL;
-  tmp_to_remove_breakpoint_ops = NULL;
-
-  /* Set the beneath function pointers.  */
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (!tmp_to_resume)
-        {
-	  tmp_to_resume = t->to_resume;
-	  tmp_to_resume_ops = t;
-        }
-      if (!tmp_to_wait)
-        {
-	  tmp_to_wait = t->to_wait;
-	  tmp_to_wait_ops = t;
-        }
-      if (!tmp_to_store_registers)
-        {
-	  tmp_to_store_registers = t->to_store_registers;
-	  tmp_to_store_registers_ops = t;
-        }
-      if (!tmp_to_xfer_partial)
-        {
-	  tmp_to_xfer_partial = t->to_xfer_partial;
-	  tmp_to_xfer_partial_ops = t;
-        }
-      if (!tmp_to_insert_breakpoint)
-	{
-	  tmp_to_insert_breakpoint = t->to_insert_breakpoint;
-	  tmp_to_insert_breakpoint_ops = t;
-	}
-      if (!tmp_to_remove_breakpoint)
-	{
-	  tmp_to_remove_breakpoint = t->to_remove_breakpoint;
-	  tmp_to_remove_breakpoint_ops = t;
-	}
-      if (!tmp_to_stopped_by_watchpoint)
-	tmp_to_stopped_by_watchpoint = t->to_stopped_by_watchpoint;
-      if (!tmp_to_stopped_data_address)
-	tmp_to_stopped_data_address = t->to_stopped_data_address;
-      if (!tmp_to_async)
-	tmp_to_async = t->to_async;
-    }
-  if (!tmp_to_xfer_partial)
-    error (_("Could not find 'to_xfer_partial' method on the target stack."));
-
   /* Reset */
   record_full_insn_num = 0;
   record_full_insn_count = 0;
   record_full_list = &record_full_first;
   record_full_list->next = NULL;
 
-  /* Set the tmp beneath pointers to beneath pointers.  */
-  record_full_beneath_to_resume_ops = tmp_to_resume_ops;
-  record_full_beneath_to_resume = tmp_to_resume;
-  record_full_beneath_to_wait_ops = tmp_to_wait_ops;
-  record_full_beneath_to_wait = tmp_to_wait;
-  record_full_beneath_to_store_registers_ops = tmp_to_store_registers_ops;
-  record_full_beneath_to_store_registers = tmp_to_store_registers;
-  record_full_beneath_to_xfer_partial_ops = tmp_to_xfer_partial_ops;
-  record_full_beneath_to_xfer_partial = tmp_to_xfer_partial;
-  record_full_beneath_to_insert_breakpoint = tmp_to_insert_breakpoint;
-  record_full_beneath_to_insert_breakpoint_ops = tmp_to_insert_breakpoint_ops;
-  record_full_beneath_to_remove_breakpoint = tmp_to_remove_breakpoint;
-  record_full_beneath_to_remove_breakpoint_ops = tmp_to_remove_breakpoint_ops;
-  record_full_beneath_to_stopped_by_watchpoint = tmp_to_stopped_by_watchpoint;
-  record_full_beneath_to_stopped_data_address = tmp_to_stopped_data_address;
-  record_full_beneath_to_async = tmp_to_async;
-
   if (core_bfd)
     record_full_core_open_1 (name, from_tty);
   else
@@ -1135,8 +982,7 @@ record_full_resume (struct target_ops *ops, ptid_t ptid, int step,
       /* Make sure the target beneath reports all signals.  */
       target_pass_signals (0, NULL);
 
-      record_full_beneath_to_resume (record_full_beneath_to_resume_ops,
-				     ptid, step, signal);
+      ops->beneath->to_resume (ops->beneath, ptid, step, signal);
     }
 
   /* We are about to start executing the inferior (or simulate it),
@@ -1226,8 +1072,7 @@ record_full_wait_1 (struct target_ops *ops,
       if (record_full_resume_step)
 	{
 	  /* This is a single step.  */
-	  return record_full_beneath_to_wait (record_full_beneath_to_wait_ops,
-					      ptid, status, options);
+	  return ops->beneath->to_wait (ops->beneath, ptid, status, options);
 	}
       else
 	{
@@ -1238,8 +1083,7 @@ record_full_wait_1 (struct target_ops *ops,
 
 	  while (1)
 	    {
-	      ret = record_full_beneath_to_wait
-		(record_full_beneath_to_wait_ops, ptid, status, options);
+	      ret = ops->beneath->to_wait (ops->beneath, ptid, status, options);
 	      if (status->kind == TARGET_WAITKIND_IGNORE)
 		{
 		  if (record_debug)
@@ -1323,9 +1167,8 @@ record_full_wait_1 (struct target_ops *ops,
 					    "Process record: record_full_wait "
 					    "issuing one more step in the "
 					    "target beneath\n");
-		      record_full_beneath_to_resume
-			(record_full_beneath_to_resume_ops, ptid, step,
-			 GDB_SIGNAL_0);
+		      ops->beneath->to_resume (ops->beneath, ptid, step,
+					       GDB_SIGNAL_0);
 		      continue;
 		    }
 		}
@@ -1529,11 +1372,7 @@ record_full_stopped_by_watchpoint (struct target_ops *ops)
   if (RECORD_FULL_IS_REPLAY)
     return record_full_hw_watchpoint;
   else
-    {
-      struct target_ops *beneath = find_target_beneath (ops);
-
-      return record_full_beneath_to_stopped_by_watchpoint (beneath);
-    }
+    return ops->beneath->to_stopped_by_watchpoint (ops->beneath);
 }
 
 static int
@@ -1542,7 +1381,7 @@ record_full_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
   if (RECORD_FULL_IS_REPLAY)
     return 0;
   else
-    return record_full_beneath_to_stopped_data_address (ops, addr_p);
+    return ops->beneath->to_stopped_data_address (ops->beneath, addr_p);
 }
 
 /* Record registers change (by user or by GDB) to list as an instruction.  */
@@ -1645,8 +1484,7 @@ record_full_store_registers (struct target_ops *ops,
 
       record_full_registers_change (regcache, regno);
     }
-  record_full_beneath_to_store_registers
-    (record_full_beneath_to_store_registers_ops, regcache, regno);
+  ops->beneath->to_store_registers (ops->beneath, regcache, regno);
 }
 
 /* "to_xfer_partial" method.  Behavior is conditional on
@@ -1711,9 +1549,9 @@ record_full_xfer_partial (struct target_ops *ops, enum target_object object,
 	record_full_insn_num++;
     }
 
-  return record_full_beneath_to_xfer_partial
-    (record_full_beneath_to_xfer_partial_ops, object, annex,
-     readbuf, writebuf, offset, len);
+  return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+					readbuf, writebuf, offset,
+					len);
 }
 
 /* This structure represents a breakpoint inserted while the record
@@ -1794,9 +1632,7 @@ record_full_insert_breakpoint (struct target_ops *ops,
       int ret;
 
       old_cleanups = record_full_gdb_operation_disable_set ();
-      ops = record_full_beneath_to_insert_breakpoint_ops;
-      ret = record_full_beneath_to_insert_breakpoint (ops, gdbarch,
-						      bp_tgt);
+      ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
       do_cleanups (old_cleanups);
 
       if (ret != 0)
@@ -1837,9 +1673,8 @@ record_full_remove_breakpoint (struct target_ops *ops,
 	      int ret;
 
 	      old_cleanups = record_full_gdb_operation_disable_set ();
-	      ops = record_full_beneath_to_remove_breakpoint_ops;
-	      ret = record_full_beneath_to_remove_breakpoint (ops, gdbarch,
-							      bp_tgt);
+	      ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch,
+							bp_tgt);
 	      do_cleanups (old_cleanups);
 
 	      if (ret != 0)
@@ -1913,18 +1748,6 @@ record_full_goto_bookmark (gdb_byte *raw_bookmark, int from_tty)
   return;
 }
 
-static void
-record_full_async (struct target_ops *ops,
-		   void (*callback) (enum inferior_event_type event_type,
-				     void *context), void *context)
-{
-  /* If we're on top of a line target (e.g., linux-nat, remote), then
-     set it to async mode as well.  Will be NULL if we're sitting on
-     top of the core target, for "record restore".  */
-  if (record_full_beneath_to_async != NULL)
-    record_full_beneath_to_async (find_target_beneath (ops), callback, context);
-}
-
 static int
 record_full_can_async_p (struct target_ops *ops)
 {
@@ -2103,7 +1926,6 @@ init_record_full_ops (void)
   /* Add bookmark target methods.  */
   record_full_ops.to_get_bookmark = record_full_get_bookmark;
   record_full_ops.to_goto_bookmark = record_full_goto_bookmark;
-  record_full_ops.to_async = record_full_async;
   record_full_ops.to_can_async_p = record_full_can_async_p;
   record_full_ops.to_is_async_p = record_full_is_async_p;
   record_full_ops.to_execution_direction = record_full_execution_direction;
@@ -2263,10 +2085,10 @@ record_full_core_xfer_partial (struct target_ops *ops,
 		  else
 		    {
 		      if (!entry)
-			return record_full_beneath_to_xfer_partial
-			  (record_full_beneath_to_xfer_partial_ops,
-			   object, annex, readbuf, writebuf,
-			   offset, len);
+			return ops->beneath->to_xfer_partial (ops->beneath,
+							      object, annex,
+							      readbuf, writebuf,
+							      offset, len);
 
 		      memcpy (readbuf, entry->buf + sec_offset,
 			      (size_t) len);
@@ -2282,9 +2104,8 @@ record_full_core_xfer_partial (struct target_ops *ops,
 	error (_("You can't do that without a process to debug."));
     }
 
-  return record_full_beneath_to_xfer_partial
-    (record_full_beneath_to_xfer_partial_ops, object, annex,
-     readbuf, writebuf, offset, len);
+  return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+					readbuf, writebuf, offset, len);
 }
 
 /* "to_insert_breakpoint" method for prec over corefile.  */
@@ -2346,9 +2167,6 @@ init_record_full_core_ops (void)
   /* Add bookmark target methods.  */
   record_full_core_ops.to_get_bookmark = record_full_get_bookmark;
   record_full_core_ops.to_goto_bookmark = record_full_goto_bookmark;
-  record_full_core_ops.to_async = record_full_async;
-  record_full_core_ops.to_can_async_p = record_full_can_async_p;
-  record_full_core_ops.to_is_async_p = record_full_is_async_p;
   record_full_core_ops.to_execution_direction
     = record_full_execution_direction;
   record_full_core_ops.to_info_record = record_full_info;
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index cf6364d..8f28321 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -4,11 +4,163 @@
 /* To regenerate this file, run:*/
 /*      make-target-delegates target.h > target-delegates.c */
 static void
+delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
+{
+  self = self->beneath;
+  self->to_resume (self, arg1, arg2, arg3);
+}
+
+static void
+tdefault_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
+{
+  noprocess ();
+}
+
+static ptid_t
+delegate_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *arg2, int arg3)
+{
+  self = self->beneath;
+  return self->to_wait (self, arg1, arg2, arg3);
+}
+
+static ptid_t
+tdefault_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *arg2, int arg3)
+{
+  noprocess ();
+}
+
+static void
+delegate_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_store_registers (self, arg1, arg2);
+}
+
+static void
+tdefault_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+{
+  noprocess ();
+}
+
+static int
+delegate_insert_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
+{
+  self = self->beneath;
+  return self->to_insert_breakpoint (self, arg1, arg2);
+}
+
+static int
+delegate_remove_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
+{
+  self = self->beneath;
+  return self->to_remove_breakpoint (self, arg1, arg2);
+}
+
+static int
+delegate_stopped_by_watchpoint (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_stopped_by_watchpoint (self);
+}
+
+static int
+tdefault_stopped_by_watchpoint (struct target_ops *self)
+{
+  return 0;
+}
+
+static int
+delegate_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
+{
+  self = self->beneath;
+  return self->to_stopped_data_address (self, arg1);
+}
+
+static int
+tdefault_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
+{
+  return 0;
+}
+
+static int
+delegate_can_async_p (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_can_async_p (self);
+}
+
+static int
+delegate_is_async_p (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_is_async_p (self);
+}
+
+static void
+delegate_async (struct target_ops *self, async_callback_ftype *arg1, void *arg2)
+{
+  self = self->beneath;
+  self->to_async (self, arg1, arg2);
+}
+
+static void
+tdefault_async (struct target_ops *self, async_callback_ftype *arg1, void *arg2)
+{
+  tcomplain ();
+}
+
+static LONGEST
+delegate_xfer_partial (struct target_ops *self, enum target_object  arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6)
+{
+  self = self->beneath;
+  return self->to_xfer_partial (self, arg1, arg2, arg3, arg4, arg5, arg6);
+}
+
+static LONGEST
+tdefault_xfer_partial (struct target_ops *self, enum target_object  arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6)
+{
+  return -1;
+}
+
+static void
 install_delegators (struct target_ops *ops)
 {
+  if (ops->to_resume == NULL)
+    ops->to_resume = delegate_resume;
+  if (ops->to_wait == NULL)
+    ops->to_wait = delegate_wait;
+  if (ops->to_store_registers == NULL)
+    ops->to_store_registers = delegate_store_registers;
+  if (ops->to_insert_breakpoint == NULL)
+    ops->to_insert_breakpoint = delegate_insert_breakpoint;
+  if (ops->to_remove_breakpoint == NULL)
+    ops->to_remove_breakpoint = delegate_remove_breakpoint;
+  if (ops->to_stopped_by_watchpoint == NULL)
+    ops->to_stopped_by_watchpoint = delegate_stopped_by_watchpoint;
+  if (ops->to_stopped_data_address == NULL)
+    ops->to_stopped_data_address = delegate_stopped_data_address;
+  if (ops->to_can_async_p == NULL)
+    ops->to_can_async_p = delegate_can_async_p;
+  if (ops->to_is_async_p == NULL)
+    ops->to_is_async_p = delegate_is_async_p;
+  if (ops->to_async == NULL)
+    ops->to_async = delegate_async;
+  if (ops->to_xfer_partial == NULL)
+    ops->to_xfer_partial = delegate_xfer_partial;
 }
 
 static void
 install_dummy_methods (struct target_ops *ops)
 {
+  ops->to_resume = tdefault_resume;
+  ops->to_wait = tdefault_wait;
+  ops->to_store_registers = tdefault_store_registers;
+  ops->to_insert_breakpoint = memory_insert_breakpoint;
+  ops->to_remove_breakpoint = memory_remove_breakpoint;
+  ops->to_stopped_by_watchpoint = tdefault_stopped_by_watchpoint;
+  ops->to_stopped_data_address = tdefault_stopped_data_address;
+  ops->to_can_async_p = find_default_can_async_p;
+  ops->to_is_async_p = find_default_is_async_p;
+  ops->to_async = tdefault_async;
+  ops->to_xfer_partial = tdefault_xfer_partial;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 3109559..bde91ab 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -74,11 +74,13 @@ static struct target_ops *find_default_run_target (char *);
 
 static target_xfer_partial_ftype default_xfer_partial;
 
-static target_xfer_partial_ftype current_xfer_partial;
-
 static struct gdbarch *default_thread_architecture (struct target_ops *ops,
 						    ptid_t ptid);
 
+static int find_default_can_async_p (struct target_ops *ignore);
+
+static int find_default_is_async_p (struct target_ops *ignore);
+
 #include "target-delegates.c"
 
 static void init_dummy_target (void);
@@ -600,10 +602,10 @@ update_current_target (void)
       INHERIT (to_remove_watchpoint, t);
       /* Do not inherit to_insert_mask_watchpoint.  */
       /* Do not inherit to_remove_mask_watchpoint.  */
-      INHERIT (to_stopped_data_address, t);
+      /* Do not inherit to_stopped_data_address.  */
       INHERIT (to_have_steppable_watchpoint, t);
       INHERIT (to_have_continuable_watchpoint, t);
-      INHERIT (to_stopped_by_watchpoint, t);
+      /* Do not inherit to_stopped_by_watchpoint.  */
       INHERIT (to_watchpoint_addr_within_range, t);
       INHERIT (to_region_ok_for_hw_watchpoint, t);
       INHERIT (to_can_accel_watchpoint_condition, t);
@@ -648,9 +650,9 @@ update_current_target (void)
       /* Do not inherit to_has_registers.  */
       /* Do not inherit to_has_execution.  */
       INHERIT (to_has_thread_control, t);
-      INHERIT (to_can_async_p, t);
-      INHERIT (to_is_async_p, t);
-      INHERIT (to_async, t);
+      /* Do not inherit to_can_async_p.  */
+      /* Do not inherit to_is_async_p.  */
+      /* Do not inherit to_async.  */
       INHERIT (to_find_memory_regions, t);
       INHERIT (to_make_corefile_notes, t);
       INHERIT (to_get_bookmark, t);
@@ -746,12 +748,6 @@ update_current_target (void)
   de_fault (to_remove_watchpoint,
 	    (int (*) (CORE_ADDR, int, int, struct expression *))
 	    return_minus_one);
-  de_fault (to_stopped_by_watchpoint,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_stopped_data_address,
-	    (int (*) (struct target_ops *, CORE_ADDR *))
-	    return_zero);
   de_fault (to_watchpoint_addr_within_range,
 	    default_watchpoint_addr_within_range);
   de_fault (to_region_ok_for_hw_watchpoint,
@@ -817,18 +813,12 @@ update_current_target (void)
   de_fault (to_stop,
 	    (void (*) (ptid_t))
 	    target_ignore);
-  current_target.to_xfer_partial = current_xfer_partial;
   de_fault (to_rcmd,
 	    (void (*) (char *, struct ui_file *))
 	    tcomplain);
   de_fault (to_pid_to_exec_file,
 	    (char *(*) (int))
 	    return_null);
-  de_fault (to_async,
-	    (void (*) (struct target_ops *,
-		       void (*) (enum inferior_event_type, void*),
-		       void*))
-	    tcomplain);
   de_fault (to_thread_architecture,
 	    default_thread_architecture);
   current_target.to_read_description = NULL;
@@ -2004,27 +1994,12 @@ default_xfer_partial (struct target_ops *ops, enum target_object object,
       else
 	return -1;
     }
-  else if (ops->beneath != NULL)
-    return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
-					  readbuf, writebuf, offset, len);
-  else
-    return -1;
-}
-
-/* The xfer_partial handler for the topmost target.  Unlike the default,
-   it does not need to handle memory specially; it just passes all
-   requests down the stack.  */
-
-static LONGEST
-current_xfer_partial (struct target_ops *ops, enum target_object object,
-		      const char *annex, gdb_byte *readbuf,
-		      const gdb_byte *writebuf, ULONGEST offset, ULONGEST len)
-{
-  if (ops->beneath != NULL)
-    return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
-					  readbuf, writebuf, offset, len);
   else
-    return -1;
+    {
+      gdb_assert (ops->beneath != NULL);
+      return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+					    readbuf, writebuf, offset, len);
+    }
 }
 
 /* Target vector read/write partial wrapper functions.  */
@@ -2467,20 +2442,6 @@ get_target_memory_unsigned (struct target_ops *ops, CORE_ADDR addr,
 /* See target.h.  */
 
 int
-forward_target_insert_breakpoint (struct target_ops *ops,
-				  struct gdbarch *gdbarch,
-				  struct bp_target_info *bp_tgt)
-{
-  for (; ops != NULL; ops = ops->beneath)
-    if (ops->to_insert_breakpoint != NULL)
-      return ops->to_insert_breakpoint (ops, gdbarch, bp_tgt);
-
-  return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
-}
-
-/* See target.h.  */
-
-int
 target_insert_breakpoint (struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
@@ -2490,15 +2451,15 @@ target_insert_breakpoint (struct gdbarch *gdbarch,
       return 1;
     }
 
-  return forward_target_insert_breakpoint (&current_target, gdbarch, bp_tgt);
+  return current_target.to_insert_breakpoint (&current_target,
+					      gdbarch, bp_tgt);
 }
 
 /* See target.h.  */
 
 int
-forward_target_remove_breakpoint (struct target_ops *ops,
-				  struct gdbarch *gdbarch,
-				  struct bp_target_info *bp_tgt)
+target_remove_breakpoint (struct gdbarch *gdbarch,
+			  struct bp_target_info *bp_tgt)
 {
   /* This is kind of a weird case to handle, but the permission might
      have been changed after breakpoints were inserted - in which case
@@ -2510,20 +2471,8 @@ forward_target_remove_breakpoint (struct target_ops *ops,
       return 1;
     }
 
-  for (; ops != NULL; ops = ops->beneath)
-    if (ops->to_remove_breakpoint != NULL)
-      return ops->to_remove_breakpoint (ops, gdbarch, bp_tgt);
-
-  return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
-}
-
-/* See target.h.  */
-
-int
-target_remove_breakpoint (struct gdbarch *gdbarch,
-			  struct bp_target_info *bp_tgt)
-{
-  return forward_target_remove_breakpoint (&current_target, gdbarch, bp_tgt);
+  return current_target.to_remove_breakpoint (&current_target,
+					      gdbarch, bp_tgt);
 }
 
 static void
@@ -2703,34 +2652,26 @@ ptid_t
 target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 {
   struct target_ops *t;
+  ptid_t retval = (current_target.to_wait) (&current_target, ptid,
+					    status, options);
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
+  if (targetdebug)
     {
-      if (t->to_wait != NULL)
-	{
-	  ptid_t retval = (*t->to_wait) (t, ptid, status, options);
+      char *status_string;
+      char *options_string;
 
-	  if (targetdebug)
-	    {
-	      char *status_string;
-	      char *options_string;
-
-	      status_string = target_waitstatus_to_string (status);
-	      options_string = target_options_to_string (options);
-	      fprintf_unfiltered (gdb_stdlog,
-				  "target_wait (%d, status, options={%s})"
-				  " = %d,   %s\n",
-				  ptid_get_pid (ptid), options_string,
-				  ptid_get_pid (retval), status_string);
-	      xfree (status_string);
-	      xfree (options_string);
-	    }
-
-	  return retval;
-	}
+      status_string = target_waitstatus_to_string (status);
+      options_string = target_options_to_string (options);
+      fprintf_unfiltered (gdb_stdlog,
+			  "target_wait (%d, status, options={%s})"
+			  " = %d,   %s\n",
+			  ptid_get_pid (ptid), options_string,
+			  ptid_get_pid (retval), status_string);
+      xfree (status_string);
+      xfree (options_string);
     }
 
-  noprocess ();
+  return retval;
 }
 
 char *
@@ -2768,26 +2709,17 @@ target_resume (ptid_t ptid, int step, enum gdb_signal signal)
 
   target_dcache_invalidate ();
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_resume != NULL)
-	{
-	  t->to_resume (t, ptid, step, signal);
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n",
-				ptid_get_pid (ptid),
-				step ? "step" : "continue",
-				gdb_signal_to_name (signal));
-
-	  registers_changed_ptid (ptid);
-	  set_executing (ptid, 1);
-	  set_running (ptid, 1);
-	  clear_inline_frame_state (ptid);
-	  return;
-	}
-    }
+  current_target.to_resume (&current_target, ptid, step, signal);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n",
+			ptid_get_pid (ptid),
+			step ? "step" : "continue",
+			gdb_signal_to_name (signal));
 
-  noprocess ();
+  registers_changed_ptid (ptid);
+  set_executing (ptid, 1);
+  set_running (ptid, 1);
+  clear_inline_frame_state (ptid);
 }
 
 void
@@ -3184,7 +3116,7 @@ find_default_can_async_p (struct target_ops *ignore)
      configured with a native debugger, and target remote isn't
      connected yet.  */
   t = find_default_run_target (NULL);
-  if (t && t->to_can_async_p)
+  if (t && t->to_can_async_p != delegate_can_async_p)
     return (t->to_can_async_p) (t);
   return 0;
 }
@@ -3199,7 +3131,7 @@ find_default_is_async_p (struct target_ops *ignore)
      configured with a native debugger, and target remote isn't
      connected yet.  */
   t = find_default_run_target (NULL);
-  if (t && t->to_is_async_p)
+  if (t && t->to_is_async_p != delegate_is_async_p)
     return (t->to_is_async_p) (t);
   return 0;
 }
@@ -3804,8 +3736,6 @@ init_dummy_target (void)
   dummy_target.to_detach = 
     (void (*)(struct target_ops *, const char *, int))target_ignore;
   dummy_target.to_create_inferior = find_default_create_inferior;
-  dummy_target.to_can_async_p = find_default_can_async_p;
-  dummy_target.to_is_async_p = find_default_is_async_p;
   dummy_target.to_supports_non_stop = find_default_supports_non_stop;
   dummy_target.to_supports_disable_randomization
     = find_default_supports_disable_randomization;
@@ -3815,17 +3745,12 @@ init_dummy_target (void)
   dummy_target.to_make_corefile_notes = dummy_make_corefile_notes;
   dummy_target.to_get_bookmark = dummy_get_bookmark;
   dummy_target.to_goto_bookmark = dummy_goto_bookmark;
-  dummy_target.to_xfer_partial = default_xfer_partial;
   dummy_target.to_has_all_memory = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_memory = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_stack = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_registers = (int (*) (struct target_ops *)) return_zero;
   dummy_target.to_has_execution
     = (int (*) (struct target_ops *, ptid_t)) return_zero;
-  dummy_target.to_stopped_by_watchpoint
-    = (int (*) (struct target_ops *)) return_zero;
-  dummy_target.to_stopped_data_address =
-    (int (*) (struct target_ops *, CORE_ADDR *)) return_zero;
   dummy_target.to_magic = OPS_MAGIC;
 
   install_dummy_methods (&dummy_target);
@@ -4045,20 +3970,11 @@ target_store_registers (struct regcache *regcache, int regno)
   if (!may_write_registers)
     error (_("Writing to registers is not allowed (regno %d)"), regno);
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
+  current_target.to_store_registers (&current_target, regcache, regno);
+  if (targetdebug)
     {
-      if (t->to_store_registers != NULL)
-	{
-	  t->to_store_registers (t, regcache, regno);
-	  if (targetdebug)
-	    {
-	      debug_print_register ("target_store_registers", regcache, regno);
-	    }
-	  return;
-	}
+      debug_print_register ("target_store_registers", regcache, regno);
     }
-
-  noprocess ();
 }
 
 int
@@ -4632,7 +4548,7 @@ debug_to_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 {
   int retval;
 
-  retval = forward_target_insert_breakpoint (&debug_target, gdbarch, bp_tgt);
+  retval = debug_target.to_insert_breakpoint (&debug_target, gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_insert_breakpoint (%s, xxx) = %ld\n",
@@ -4647,7 +4563,7 @@ debug_to_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 {
   int retval;
 
-  retval = forward_target_remove_breakpoint (&debug_target, gdbarch, bp_tgt);
+  retval = debug_target.to_remove_breakpoint (&debug_target, gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
 		      "target_remove_breakpoint (%s, xxx) = %ld\n",
diff --git a/gdb/target.h b/gdb/target.h
index 19db907..8d00d3a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -398,11 +398,14 @@ struct target_ops
     void (*to_post_attach) (int);
     void (*to_detach) (struct target_ops *ops, const char *, int);
     void (*to_disconnect) (struct target_ops *, char *, int);
-    void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal);
+    void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal)
+      TARGET_DEFAULT_NORETURN (noprocess ());
     ptid_t (*to_wait) (struct target_ops *,
-		       ptid_t, struct target_waitstatus *, int);
+		       ptid_t, struct target_waitstatus *, int)
+      TARGET_DEFAULT_NORETURN (noprocess ());
     void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
-    void (*to_store_registers) (struct target_ops *, struct regcache *, int);
+    void (*to_store_registers) (struct target_ops *, struct regcache *, int)
+      TARGET_DEFAULT_NORETURN (noprocess ());
     void (*to_prepare_to_store) (struct target_ops *, struct regcache *);
 
     /* Transfer LEN bytes of memory between GDB address MYADDR and
@@ -433,9 +436,11 @@ struct target_ops
 
     void (*to_files_info) (struct target_ops *);
     int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
-				 struct bp_target_info *);
+				 struct bp_target_info *)
+      TARGET_DEFAULT_FUNC (memory_insert_breakpoint);
     int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
-				 struct bp_target_info *);
+				 struct bp_target_info *)
+      TARGET_DEFAULT_FUNC (memory_remove_breakpoint);
     int (*to_can_use_hw_breakpoint) (int, int, int);
     int (*to_ranged_break_num_registers) (struct target_ops *);
     int (*to_insert_hw_breakpoint) (struct gdbarch *, struct bp_target_info *);
@@ -450,10 +455,12 @@ struct target_ops
 				      CORE_ADDR, CORE_ADDR, int);
     int (*to_remove_mask_watchpoint) (struct target_ops *,
 				      CORE_ADDR, CORE_ADDR, int);
-    int (*to_stopped_by_watchpoint) (struct target_ops *);
+    int (*to_stopped_by_watchpoint) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
     int to_have_steppable_watchpoint;
     int to_have_continuable_watchpoint;
-    int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
+    int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *)
+      TARGET_DEFAULT_RETURN (0);
     int (*to_watchpoint_addr_within_range) (struct target_ops *,
 					    CORE_ADDR, CORE_ADDR, int);
 
@@ -515,10 +522,12 @@ struct target_ops
     int to_has_thread_control;	/* control thread execution */
     int to_attach_no_wait;
     /* ASYNC target controls */
-    int (*to_can_async_p) (struct target_ops *);
-    int (*to_is_async_p) (struct target_ops *);
-    void (*to_async) (struct target_ops *,
-		      async_callback_ftype *, void *);
+    int (*to_can_async_p) (struct target_ops *)
+      TARGET_DEFAULT_FUNC (find_default_can_async_p);
+    int (*to_is_async_p) (struct target_ops *)
+      TARGET_DEFAULT_FUNC (find_default_is_async_p);
+    void (*to_async) (struct target_ops *, async_callback_ftype *, void *)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
     int (*to_supports_non_stop) (void);
     /* find_memory_regions support method for gcore */
     int (*to_find_memory_regions) (find_memory_region_ftype func, void *data);
@@ -569,7 +578,8 @@ struct target_ops
     LONGEST (*to_xfer_partial) (struct target_ops *ops,
 				enum target_object object, const char *annex,
 				gdb_byte *readbuf, const gdb_byte *writebuf,
-				ULONGEST offset, ULONGEST len);
+				ULONGEST offset, ULONGEST len)
+      TARGET_DEFAULT_RETURN (-1);
 
     /* Returns the memory map for the target.  A return value of NULL
        means that no memory map is available.  If a memory address
@@ -1177,29 +1187,12 @@ int target_write_memory_blocks (VEC(memory_write_request_s) *requests,
 /* Insert a hardware breakpoint at address BP_TGT->placed_address in
    the target machine.  Returns 0 for success, and returns non-zero or
    throws an error (with a detailed failure reason error code and
-   message) otherwise.
-   Start the target search at OPS.  */
-
-extern int forward_target_insert_breakpoint (struct target_ops *ops,
-					     struct gdbarch *gdbarch,
-					     struct bp_target_info *bp_tgt);
-
-/* Insert a hardware breakpoint at address BP_TGT->placed_address in
-   the target machine.  Returns 0 for success, and returns non-zero or
-   throws an error (with a detailed failure reason error code and
    message) otherwise.  */
 
 extern int target_insert_breakpoint (struct gdbarch *gdbarch,
 				     struct bp_target_info *bp_tgt);
 
 /* Remove a breakpoint at address BP_TGT->placed_address in the target
-   machine.  Result is 0 for success, non-zero for error.
-   Start the target search at OPS.  */
-
-extern int forward_target_remove_breakpoint (struct target_ops *ops,
-					     struct gdbarch *gdbarch,
-					     struct bp_target_info *bp_tgt);
-/* Remove a breakpoint at address BP_TGT->placed_address in the target
    machine.  Result is 0 for success, non-zero for error.  */
 
 extern int target_remove_breakpoint (struct gdbarch *gdbarch,
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 11/38] Add target_ops argument to to_get_ada_task_ptid
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (24 preceding siblings ...)
  2014-02-06 20:58 ` [RFC v2 25/38] convert to_static_tracepoint_markers_by_strid Tom Tromey
@ 2014-02-06 20:58 ` Tom Tromey
  2014-02-06 21:23 ` [RFC v2 12/38] Add target_ops argument to to_can_execute_reverse Tom Tromey
                   ` (13 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* windows-nat.c (windows_get_ada_task_ptid): Add 'self' argument.
	* target.h (struct target_ops) <to_get_ada_task_ptid>: Add
	argument.
	(target_get_ada_task_ptid): Add argument.
	* target.c (update_current_target): Update.
	(default_get_ada_task_ptid): Add 'self' argument.
	* sol-thread.c (sol_get_ada_task_ptid): Add 'self' argument.
	* remote.c (remote_get_ada_task_ptid): Add 'self' argument.
	* ravenscar-thread.c (ravenscar_get_ada_task_ptid): Add 'self'
	argument.
	* linux-thread-db.c (thread_db_get_ada_task_ptid): Add 'self'
	argument.
	* inf-ttrace.c (inf_ttrace_get_ada_task_ptid): Add 'self'
	argument.
	* dec-thread.c (dec_thread_get_ada_task_ptid): Add 'self'
	argument.
	* darwin-nat.c (darwin_get_ada_task_ptid): Add 'self' argument.
	* aix-thread.c (aix_thread_get_ada_task_ptid): Add 'self'
	argument.
---
 gdb/ChangeLog          | 22 ++++++++++++++++++++++
 gdb/aix-thread.c       |  2 +-
 gdb/darwin-nat.c       |  2 +-
 gdb/dec-thread.c       |  5 +++--
 gdb/inf-ttrace.c       |  2 +-
 gdb/linux-thread-db.c  |  2 +-
 gdb/ravenscar-thread.c |  2 +-
 gdb/remote.c           |  2 +-
 gdb/sol-thread.c       |  2 +-
 gdb/target.c           |  4 ++--
 gdb/target.h           |  5 +++--
 gdb/windows-nat.c      |  2 +-
 12 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 3597d3c..087f7f8 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1808,7 +1808,7 @@ aix_thread_extra_thread_info (struct target_ops *self,
 }
 
 static ptid_t
-aix_thread_get_ada_task_ptid (long lwp, long thread)
+aix_thread_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   return ptid_build (ptid_get_pid (inferior_ptid), 0, thread);
 }
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 70b03a9..2a716bc 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1992,7 +1992,7 @@ darwin_pid_to_exec_file (struct target_ops *self, int pid)
 }
 
 static ptid_t
-darwin_get_ada_task_ptid (long lwp, long thread)
+darwin_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   int i;
   darwin_thread_t *t;
diff --git a/gdb/dec-thread.c b/gdb/dec-thread.c
index b9a1c68..e7cecc4 100644
--- a/gdb/dec-thread.c
+++ b/gdb/dec-thread.c
@@ -687,12 +687,13 @@ dec_thread_new_objfile_observer (struct objfile *objfile)
 /* The "to_get_ada_task_ptid" method of the dec_thread_ops.  */
 
 static ptid_t
-dec_thread_get_ada_task_ptid (long lwp, long thread)
+dec_thread_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   int i;
   struct dec_thread_info *info;
 
-  debug ("dec_thread_get_ada_task_ptid (lwp=0x%lx, thread=0x%lx)",
+  debug ("dec_thread_get_ada_task_ptid (struct target_ops *self,
+  lwp=0x%lx, thread=0x%lx)",
          lwp, thread);
 
   for (i = 0; VEC_iterate (dec_thread_info_s, dec_thread_list, i, info);
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index c7b2856..c91fc68 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -1304,7 +1304,7 @@ inf_ttrace_pid_to_str (struct target_ops *ops, ptid_t ptid)
 /* Implement the get_ada_task_ptid target_ops method.  */
 
 static ptid_t
-inf_ttrace_get_ada_task_ptid (long lwp, long thread)
+inf_ttrace_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   return ptid_build (ptid_get_pid (inferior_ptid), lwp, 0);
 }
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 9180464..cf7adc4 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1875,7 +1875,7 @@ thread_db_find_thread_from_tid (struct thread_info *thread, void *data)
 /* Implement the to_get_ada_task_ptid target method for this target.  */
 
 static ptid_t
-thread_db_get_ada_task_ptid (long lwp, long thread)
+thread_db_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   struct thread_info *thread_info;
 
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 12d0247..7002971 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -352,7 +352,7 @@ ravenscar_inferior_created (struct target_ops *target, int from_tty)
 }
 
 static ptid_t
-ravenscar_get_ada_task_ptid (long lwp, long thread)
+ravenscar_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   return ptid_build (ptid_get_pid (base_ptid), 0, thread);
 }
diff --git a/gdb/remote.c b/gdb/remote.c
index fde6942..0e24500 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3037,7 +3037,7 @@ remote_static_tracepoint_markers_by_strid (const char *strid)
 /* Implement the to_get_ada_task_ptid function for the remote targets.  */
 
 static ptid_t
-remote_get_ada_task_ptid (long lwp, long thread)
+remote_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   return ptid_build (ptid_get_pid (inferior_ptid), 0, lwp);
 }
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index f39f8bb..81f19fc 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -1190,7 +1190,7 @@ thread_db_find_thread_from_tid (struct thread_info *thread, void *data)
 }
 
 static ptid_t
-sol_get_ada_task_ptid (long lwp, long thread)
+sol_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   struct thread_info *thread_info =
     iterate_over_threads (thread_db_find_thread_from_tid, &thread);
diff --git a/gdb/target.c b/gdb/target.c
index ec48d40..1716c45 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -537,7 +537,7 @@ default_terminal_info (struct target_ops *self, const char *args, int from_tty)
    inferior_ptid.  */
 
 static ptid_t
-default_get_ada_task_ptid (long lwp, long tid)
+default_get_ada_task_ptid (struct target_ops *self, long lwp, long tid)
 {
   return ptid_build (ptid_get_pid (inferior_ptid), lwp, tid);
 }
@@ -837,7 +837,7 @@ update_current_target (void)
 	    default_thread_architecture);
   current_target.to_read_description = NULL;
   de_fault (to_get_ada_task_ptid,
-            (ptid_t (*) (long, long))
+            (ptid_t (*) (struct target_ops *, long, long))
             default_get_ada_task_ptid);
   de_fault (to_supports_multi_process,
 	    (int (*) (void))
diff --git a/gdb/target.h b/gdb/target.h
index c315bcb..419842f 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -628,7 +628,8 @@ struct target_ops
        based on LWP and THREAD.  These values are extracted from the
        task Private_Data section of the Ada Task Control Block, and
        their interpretation depends on the target.  */
-    ptid_t (*to_get_ada_task_ptid) (long lwp, long thread);
+    ptid_t (*to_get_ada_task_ptid) (struct target_ops *,
+				    long lwp, long thread);
 
     /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
        Return 0 if *READPTR is already at the end of the buffer.
@@ -1689,7 +1690,7 @@ extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
 extern const struct target_desc *target_read_description (struct target_ops *);
 
 #define target_get_ada_task_ptid(lwp, tid) \
-     (*current_target.to_get_ada_task_ptid) (lwp,tid)
+     (*current_target.to_get_ada_task_ptid) (&current_target, lwp,tid)
 
 /* Utility implementation of searching memory.  */
 extern int simple_search_memory (struct target_ops* ops,
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 91af87b..0af13df 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2580,7 +2580,7 @@ windows_get_tib_address (ptid_t ptid, CORE_ADDR *addr)
 }
 
 static ptid_t
-windows_get_ada_task_ptid (long lwp, long thread)
+windows_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 {
   return ptid_build (ptid_get_pid (inferior_ptid), 0, lwp);
 }
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 20/38] convert to_load
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (22 preceding siblings ...)
  2014-02-06 20:58 ` [RFC v2 04/38] add target method delegation Tom Tromey
@ 2014-02-06 20:58 ` Tom Tromey
  2014-02-06 20:58 ` [RFC v2 25/38] convert to_static_tracepoint_markers_by_strid Tom Tromey
                   ` (15 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_load.
	* target.h (struct target_ops) <to_load>: Use
	TARGET_DEFAULT_NORETURN.

convert to_post_startup_inferior

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_post_startup_inferior.
	* target.h (struct target_ops) <to_post_startup_inferior>: Use
	TARGET_DEFAULT_IGNORE.

convert to_insert_fork_catchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_insert_fork_catchpoint.
	* target.h (struct target_ops) <to_insert_fork_catchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_remove_fork_catchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_remove_fork_catchpoint.
	* target.h (struct target_ops) <to_remove_fork_catchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_insert_vfork_catchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_insert_vfork_catchpoint.
	* target.h (struct target_ops) <to_insert_vfork_catchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_remove_vfork_catchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_remove_vfork_catchpoint.
	* target.h (struct target_ops) <to_remove_vfork_catchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_insert_exec_catchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_insert_exec_catchpoint.
	* target.h (struct target_ops) <to_insert_exec_catchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_remove_exec_catchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_insert_exec_catchpoint.
	* target.h (struct target_ops) <to_insert_exec_catchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_set_syscall_catchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_set_syscall_catchpoint.
	(return_one): Remove.
	* target.h (struct target_ops) <to_set_syscall_catchpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_has_exited

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_has_exited.
	* target.h (struct target_ops) <to_has_exited>: Use
	TARGET_DEFAULT_RETURN..
---
 gdb/ChangeLog          |  81 +++++++++++++++++++++++++
 gdb/target-delegates.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  58 ++++--------------
 gdb/target.h           |  30 ++++++----
 4 files changed, 270 insertions(+), 58 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 7a673ee..1ac0fc2 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -298,6 +298,135 @@ delegate_terminal_info (struct target_ops *self, const char *arg1, int arg2)
 }
 
 static void
+delegate_load (struct target_ops *self, char *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_load (self, arg1, arg2);
+}
+
+static void
+tdefault_load (struct target_ops *self, char *arg1, int arg2)
+{
+  tcomplain ();
+}
+
+static void
+delegate_post_startup_inferior (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  self->to_post_startup_inferior (self, arg1);
+}
+
+static void
+tdefault_post_startup_inferior (struct target_ops *self, ptid_t arg1)
+{
+}
+
+static int
+delegate_insert_fork_catchpoint (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_insert_fork_catchpoint (self, arg1);
+}
+
+static int
+tdefault_insert_fork_catchpoint (struct target_ops *self, int arg1)
+{
+  return 1;
+}
+
+static int
+delegate_remove_fork_catchpoint (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_remove_fork_catchpoint (self, arg1);
+}
+
+static int
+tdefault_remove_fork_catchpoint (struct target_ops *self, int arg1)
+{
+  return 1;
+}
+
+static int
+delegate_insert_vfork_catchpoint (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_insert_vfork_catchpoint (self, arg1);
+}
+
+static int
+tdefault_insert_vfork_catchpoint (struct target_ops *self, int arg1)
+{
+  return 1;
+}
+
+static int
+delegate_remove_vfork_catchpoint (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_remove_vfork_catchpoint (self, arg1);
+}
+
+static int
+tdefault_remove_vfork_catchpoint (struct target_ops *self, int arg1)
+{
+  return 1;
+}
+
+static int
+delegate_insert_exec_catchpoint (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_insert_exec_catchpoint (self, arg1);
+}
+
+static int
+tdefault_insert_exec_catchpoint (struct target_ops *self, int arg1)
+{
+  return 1;
+}
+
+static int
+delegate_remove_exec_catchpoint (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_remove_exec_catchpoint (self, arg1);
+}
+
+static int
+tdefault_remove_exec_catchpoint (struct target_ops *self, int arg1)
+{
+  return 1;
+}
+
+static int
+delegate_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int arg3, int arg4, int *arg5)
+{
+  self = self->beneath;
+  return self->to_set_syscall_catchpoint (self, arg1, arg2, arg3, arg4, arg5);
+}
+
+static int
+tdefault_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int arg3, int arg4, int *arg5)
+{
+  return 1;
+}
+
+static int
+delegate_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3)
+{
+  self = self->beneath;
+  return self->to_has_exited (self, arg1, arg2, arg3);
+}
+
+static int
+tdefault_has_exited (struct target_ops *self, int arg1, int arg2, int *arg3)
+{
+  return 0;
+}
+
+static void
 delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2)
 {
   self = self->beneath;
@@ -412,6 +541,26 @@ install_delegators (struct target_ops *ops)
     ops->to_terminal_save_ours = delegate_terminal_save_ours;
   if (ops->to_terminal_info == NULL)
     ops->to_terminal_info = delegate_terminal_info;
+  if (ops->to_load == NULL)
+    ops->to_load = delegate_load;
+  if (ops->to_post_startup_inferior == NULL)
+    ops->to_post_startup_inferior = delegate_post_startup_inferior;
+  if (ops->to_insert_fork_catchpoint == NULL)
+    ops->to_insert_fork_catchpoint = delegate_insert_fork_catchpoint;
+  if (ops->to_remove_fork_catchpoint == NULL)
+    ops->to_remove_fork_catchpoint = delegate_remove_fork_catchpoint;
+  if (ops->to_insert_vfork_catchpoint == NULL)
+    ops->to_insert_vfork_catchpoint = delegate_insert_vfork_catchpoint;
+  if (ops->to_remove_vfork_catchpoint == NULL)
+    ops->to_remove_vfork_catchpoint = delegate_remove_vfork_catchpoint;
+  if (ops->to_insert_exec_catchpoint == NULL)
+    ops->to_insert_exec_catchpoint = delegate_insert_exec_catchpoint;
+  if (ops->to_remove_exec_catchpoint == NULL)
+    ops->to_remove_exec_catchpoint = delegate_remove_exec_catchpoint;
+  if (ops->to_set_syscall_catchpoint == NULL)
+    ops->to_set_syscall_catchpoint = delegate_set_syscall_catchpoint;
+  if (ops->to_has_exited == NULL)
+    ops->to_has_exited = delegate_has_exited;
   if (ops->to_rcmd == NULL)
     ops->to_rcmd = delegate_rcmd;
   if (ops->to_can_async_p == NULL)
@@ -455,6 +604,16 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_terminal_ours = tdefault_terminal_ours;
   ops->to_terminal_save_ours = tdefault_terminal_save_ours;
   ops->to_terminal_info = default_terminal_info;
+  ops->to_load = tdefault_load;
+  ops->to_post_startup_inferior = tdefault_post_startup_inferior;
+  ops->to_insert_fork_catchpoint = tdefault_insert_fork_catchpoint;
+  ops->to_remove_fork_catchpoint = tdefault_remove_fork_catchpoint;
+  ops->to_insert_vfork_catchpoint = tdefault_insert_vfork_catchpoint;
+  ops->to_remove_vfork_catchpoint = tdefault_remove_vfork_catchpoint;
+  ops->to_insert_exec_catchpoint = tdefault_insert_exec_catchpoint;
+  ops->to_remove_exec_catchpoint = tdefault_remove_exec_catchpoint;
+  ops->to_set_syscall_catchpoint = tdefault_set_syscall_catchpoint;
+  ops->to_has_exited = tdefault_has_exited;
   ops->to_rcmd = default_rcmd;
   ops->to_can_async_p = find_default_can_async_p;
   ops->to_is_async_p = find_default_is_async_p;
diff --git a/gdb/target.c b/gdb/target.c
index 0c31f47..9def149 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -63,8 +63,6 @@ static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
 
 static int return_zero (void);
 
-static int return_one (void);
-
 static int return_minus_one (void);
 
 static void *return_null (void);
@@ -627,18 +625,18 @@ update_current_target (void)
       /* Do not inherit to_terminal_save_ours.  */
       /* Do not inherit to_terminal_info.  */
       /* Do not inherit to_kill.  */
-      INHERIT (to_load, t);
+      /* Do not inherit to_load.  */
       /* Do no inherit to_create_inferior.  */
-      INHERIT (to_post_startup_inferior, t);
-      INHERIT (to_insert_fork_catchpoint, t);
-      INHERIT (to_remove_fork_catchpoint, t);
-      INHERIT (to_insert_vfork_catchpoint, t);
-      INHERIT (to_remove_vfork_catchpoint, t);
+      /* Do not inherit to_post_startup_inferior.  */
+      /* Do not inherit to_insert_fork_catchpoint.  */
+      /* Do not inherit to_remove_fork_catchpoint.  */
+      /* Do not inherit to_insert_vfork_catchpoint.  */
+      /* Do not inherit to_remove_vfork_catchpoint.  */
       /* Do not inherit to_follow_fork.  */
-      INHERIT (to_insert_exec_catchpoint, t);
-      INHERIT (to_remove_exec_catchpoint, t);
-      INHERIT (to_set_syscall_catchpoint, t);
-      INHERIT (to_has_exited, t);
+      /* Do not inherit to_insert_exec_catchpoint.  */
+      /* Do not inherit to_remove_exec_catchpoint.  */
+      /* Do not inherit to_set_syscall_catchpoint.  */
+      /* Do not inherit to_has_exited.  */
       /* Do not inherit to_mourn_inferior.  */
       INHERIT (to_can_run, t);
       /* Do not inherit to_pass_signals.  */
@@ -734,36 +732,6 @@ update_current_target (void)
 	    (int (*) (CORE_ADDR, gdb_byte *, int, int,
 		      struct mem_attrib *, struct target_ops *))
 	    nomemory);
-  de_fault (to_load,
-	    (void (*) (struct target_ops *, char *, int))
-	    tcomplain);
-  de_fault (to_post_startup_inferior,
-	    (void (*) (struct target_ops *, ptid_t))
-	    target_ignore);
-  de_fault (to_insert_fork_catchpoint,
-	    (int (*) (struct target_ops *, int))
-	    return_one);
-  de_fault (to_remove_fork_catchpoint,
-	    (int (*) (struct target_ops *, int))
-	    return_one);
-  de_fault (to_insert_vfork_catchpoint,
-	    (int (*) (struct target_ops *, int))
-	    return_one);
-  de_fault (to_remove_vfork_catchpoint,
-	    (int (*) (struct target_ops *, int))
-	    return_one);
-  de_fault (to_insert_exec_catchpoint,
-	    (int (*) (struct target_ops *, int))
-	    return_one);
-  de_fault (to_remove_exec_catchpoint,
-	    (int (*) (struct target_ops *, int))
-	    return_one);
-  de_fault (to_set_syscall_catchpoint,
-	    (int (*) (struct target_ops *, int, int, int, int, int *))
-	    return_one);
-  de_fault (to_has_exited,
-	    (int (*) (struct target_ops *, int, int, int *))
-	    return_zero);
   de_fault (to_can_run,
 	    (int (*) (struct target_ops *))
 	    return_zero);
@@ -3554,12 +3522,6 @@ return_zero (void)
 }
 
 static int
-return_one (void)
-{
-  return 1;
-}
-
-static int
 return_minus_one (void)
 {
   return -1;
diff --git a/gdb/target.h b/gdb/target.h
index 001b161..98f8687 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -504,20 +504,30 @@ struct target_ops
     void (*to_terminal_info) (struct target_ops *, const char *, int)
       TARGET_DEFAULT_FUNC (default_terminal_info);
     void (*to_kill) (struct target_ops *);
-    void (*to_load) (struct target_ops *, char *, int);
+    void (*to_load) (struct target_ops *, char *, int)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
     void (*to_create_inferior) (struct target_ops *, 
 				char *, char *, char **, int);
-    void (*to_post_startup_inferior) (struct target_ops *, ptid_t);
-    int (*to_insert_fork_catchpoint) (struct target_ops *, int);
-    int (*to_remove_fork_catchpoint) (struct target_ops *, int);
-    int (*to_insert_vfork_catchpoint) (struct target_ops *, int);
-    int (*to_remove_vfork_catchpoint) (struct target_ops *, int);
+    void (*to_post_startup_inferior) (struct target_ops *, ptid_t)
+      TARGET_DEFAULT_IGNORE ();
+    int (*to_insert_fork_catchpoint) (struct target_ops *, int)
+      TARGET_DEFAULT_RETURN (1);
+    int (*to_remove_fork_catchpoint) (struct target_ops *, int)
+      TARGET_DEFAULT_RETURN (1);
+    int (*to_insert_vfork_catchpoint) (struct target_ops *, int)
+      TARGET_DEFAULT_RETURN (1);
+    int (*to_remove_vfork_catchpoint) (struct target_ops *, int)
+      TARGET_DEFAULT_RETURN (1);
     int (*to_follow_fork) (struct target_ops *, int, int);
-    int (*to_insert_exec_catchpoint) (struct target_ops *, int);
-    int (*to_remove_exec_catchpoint) (struct target_ops *, int);
+    int (*to_insert_exec_catchpoint) (struct target_ops *, int)
+      TARGET_DEFAULT_RETURN (1);
+    int (*to_remove_exec_catchpoint) (struct target_ops *, int)
+      TARGET_DEFAULT_RETURN (1);
     int (*to_set_syscall_catchpoint) (struct target_ops *,
-				      int, int, int, int, int *);
-    int (*to_has_exited) (struct target_ops *, int, int, int *);
+				      int, int, int, int, int *)
+      TARGET_DEFAULT_RETURN (1);
+    int (*to_has_exited) (struct target_ops *, int, int, int *)
+      TARGET_DEFAULT_RETURN (0);
     void (*to_mourn_inferior) (struct target_ops *);
     int (*to_can_run) (struct target_ops *);
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 25/38] convert to_static_tracepoint_markers_by_strid
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (23 preceding siblings ...)
  2014-02-06 20:58 ` [RFC v2 20/38] convert to_load Tom Tromey
@ 2014-02-06 20:58 ` Tom Tromey
  2014-02-06 20:58 ` [RFC v2 11/38] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
                   ` (14 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Note that this patch reformats the
to_static_tracepoint_markers_by_strid field declaration in struct
target_ops.  This was needed because make-target-delegates requires
the opening paren for the parameters to be on the same line as the
method name, and I didn't see an easy way to fix this.

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_static_tracepoint_markers_by_strid.
	* target.h (struct target_ops)
	<to_static_tracepoint_markers_by_strid>: Use
	TARGET_DEFAULT_NORETURN.

convert to_traceframe_info

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_traceframe_info.
	(return_null): Remove.
	* target.h (struct target_ops) <to_traceframe_info>: Use
	TARGET_DEFAULT_RETURN.

convert to_use_agent

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_use_agent.
	* target.h (struct target_ops) <to_use_agent>: Use
	TARGET_DEFAULT_NORETURN.

convert to_can_use_agent

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_can_use_agent.
	* target.h (struct target_ops) <to_can_use_agent>: Use
	TARGET_DEFAULT_RETURN.

convert to_augmented_libraries_svr4_read

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_augmented_libraries_svr4_read.
	* target.h (struct target_ops) <to_augmented_libraries_svr4_read>:
	Use TARGET_DEFAULT_RETURN.

convert to_supports_evaluation_of_breakpoint_conditions

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_supports_evaluation_of_breakpoint_conditions.
	* target.h (struct target_ops)
	<to_supports_evaluation_of_breakpoint_conditions>: Use
	TARGET_DEFAULT_RETURN.

convert to_can_run_breakpoint_commands

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_can_run_breakpoint_commands.
	* target.h (struct target_ops) <to_can_run_breakpoint_commands>:
	Use TARGET_DEFAULT_RETURN.

convert to_stop

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_stop.
	* target.h (struct target_ops) <to_stop>: Use
	TARGET_DEFAULT_IGNORE.

convert to_fetch_registers

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

	* target-delegates.c: Rebuild.
	* target.c (target_fetch_registers): Unconditionally delegate.
	* target.h (struct target_ops) <to_fetch_registers>: Use
	TARGET_DEFAULT_NORETURN.

convert to_ranged_break_num_registers

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

	* target-delegates.c: Rebuild.
	* target.c (target_ranged_break_num_registers): Unconditionally
	delegate.
	* target.h (struct target_ops) <to_ranged_break_num_registers>:
	Use TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          |  82 +++++++++++++++++++++++++
 gdb/target-delegates.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  73 ++++-------------------
 gdb/target.h           |  31 ++++++----
 4 files changed, 273 insertions(+), 71 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 968d2fd..98d3f17 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -61,6 +61,18 @@ tdefault_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *a
 }
 
 static void
+delegate_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_fetch_registers (self, arg1, arg2);
+}
+
+static void
+tdefault_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+{
+}
+
+static void
 delegate_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
 {
   self = self->beneath;
@@ -126,6 +138,19 @@ tdefault_can_use_hw_breakpoint (struct target_ops *self, int arg1, int arg2, int
 }
 
 static int
+delegate_ranged_break_num_registers (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_ranged_break_num_registers (self);
+}
+
+static int
+tdefault_ranged_break_num_registers (struct target_ops *self)
+{
+  return -1;
+}
+
+static int
 delegate_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
 {
   self = self->beneath;
@@ -453,6 +478,18 @@ tdefault_thread_name (struct target_ops *self, struct thread_info *arg1)
 }
 
 static void
+delegate_stop (struct target_ops *self, ptid_t arg1)
+{
+  self = self->beneath;
+  self->to_stop (self, arg1);
+}
+
+static void
+tdefault_stop (struct target_ops *self, ptid_t arg1)
+{
+}
+
+static void
 delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2)
 {
   self = self->beneath;
@@ -630,6 +667,32 @@ tdefault_supports_string_tracing (struct target_ops *self)
   return 0;
 }
 
+static int
+delegate_supports_evaluation_of_breakpoint_conditions (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_supports_evaluation_of_breakpoint_conditions (self);
+}
+
+static int
+tdefault_supports_evaluation_of_breakpoint_conditions (struct target_ops *self)
+{
+  return 0;
+}
+
+static int
+delegate_can_run_breakpoint_commands (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_can_run_breakpoint_commands (self);
+}
+
+static int
+tdefault_can_run_breakpoint_commands (struct target_ops *self)
+{
+  return 0;
+}
+
 static struct gdbarch *
 delegate_thread_architecture (struct target_ops *self, ptid_t arg1)
 {
@@ -958,6 +1021,58 @@ tdefault_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, s
   return 0;
 }
 
+static VEC(static_tracepoint_marker_p) *
+delegate_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
+{
+  self = self->beneath;
+  return self->to_static_tracepoint_markers_by_strid (self, arg1);
+}
+
+static VEC(static_tracepoint_marker_p) *
+tdefault_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
+{
+  tcomplain ();
+}
+
+static struct traceframe_info *
+delegate_traceframe_info (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_traceframe_info (self);
+}
+
+static struct traceframe_info *
+tdefault_traceframe_info (struct target_ops *self)
+{
+  return 0;
+}
+
+static int
+delegate_use_agent (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  return self->to_use_agent (self, arg1);
+}
+
+static int
+tdefault_use_agent (struct target_ops *self, int arg1)
+{
+  tcomplain ();
+}
+
+static int
+delegate_can_use_agent (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_can_use_agent (self);
+}
+
+static int
+tdefault_can_use_agent (struct target_ops *self)
+{
+  return 0;
+}
+
 static int
 delegate_supports_btrace (struct target_ops *self)
 {
@@ -971,6 +1086,19 @@ tdefault_supports_btrace (struct target_ops *self)
   return 0;
 }
 
+static int
+delegate_augmented_libraries_svr4_read (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_augmented_libraries_svr4_read (self);
+}
+
+static int
+tdefault_augmented_libraries_svr4_read (struct target_ops *self)
+{
+  return 0;
+}
+
 static void
 install_delegators (struct target_ops *ops)
 {
@@ -984,6 +1112,8 @@ install_delegators (struct target_ops *ops)
     ops->to_resume = delegate_resume;
   if (ops->to_wait == NULL)
     ops->to_wait = delegate_wait;
+  if (ops->to_fetch_registers == NULL)
+    ops->to_fetch_registers = delegate_fetch_registers;
   if (ops->to_store_registers == NULL)
     ops->to_store_registers = delegate_store_registers;
   if (ops->to_prepare_to_store == NULL)
@@ -996,6 +1126,8 @@ install_delegators (struct target_ops *ops)
     ops->to_remove_breakpoint = delegate_remove_breakpoint;
   if (ops->to_can_use_hw_breakpoint == NULL)
     ops->to_can_use_hw_breakpoint = delegate_can_use_hw_breakpoint;
+  if (ops->to_ranged_break_num_registers == NULL)
+    ops->to_ranged_break_num_registers = delegate_ranged_break_num_registers;
   if (ops->to_insert_hw_breakpoint == NULL)
     ops->to_insert_hw_breakpoint = delegate_insert_hw_breakpoint;
   if (ops->to_remove_hw_breakpoint == NULL)
@@ -1050,6 +1182,8 @@ install_delegators (struct target_ops *ops)
     ops->to_extra_thread_info = delegate_extra_thread_info;
   if (ops->to_thread_name == NULL)
     ops->to_thread_name = delegate_thread_name;
+  if (ops->to_stop == NULL)
+    ops->to_stop = delegate_stop;
   if (ops->to_rcmd == NULL)
     ops->to_rcmd = delegate_rcmd;
   if (ops->to_pid_to_exec_file == NULL)
@@ -1084,6 +1218,10 @@ install_delegators (struct target_ops *ops)
     ops->to_supports_enable_disable_tracepoint = delegate_supports_enable_disable_tracepoint;
   if (ops->to_supports_string_tracing == NULL)
     ops->to_supports_string_tracing = delegate_supports_string_tracing;
+  if (ops->to_supports_evaluation_of_breakpoint_conditions == NULL)
+    ops->to_supports_evaluation_of_breakpoint_conditions = delegate_supports_evaluation_of_breakpoint_conditions;
+  if (ops->to_can_run_breakpoint_commands == NULL)
+    ops->to_can_run_breakpoint_commands = delegate_can_run_breakpoint_commands;
   if (ops->to_thread_architecture == NULL)
     ops->to_thread_architecture = delegate_thread_architecture;
   if (ops->to_trace_init == NULL)
@@ -1136,8 +1274,18 @@ install_delegators (struct target_ops *ops)
     ops->to_set_permissions = delegate_set_permissions;
   if (ops->to_static_tracepoint_marker_at == NULL)
     ops->to_static_tracepoint_marker_at = delegate_static_tracepoint_marker_at;
+  if (ops->to_static_tracepoint_markers_by_strid == NULL)
+    ops->to_static_tracepoint_markers_by_strid = delegate_static_tracepoint_markers_by_strid;
+  if (ops->to_traceframe_info == NULL)
+    ops->to_traceframe_info = delegate_traceframe_info;
+  if (ops->to_use_agent == NULL)
+    ops->to_use_agent = delegate_use_agent;
+  if (ops->to_can_use_agent == NULL)
+    ops->to_can_use_agent = delegate_can_use_agent;
   if (ops->to_supports_btrace == NULL)
     ops->to_supports_btrace = delegate_supports_btrace;
+  if (ops->to_augmented_libraries_svr4_read == NULL)
+    ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
 }
 
 static void
@@ -1148,12 +1296,14 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_detach = tdefault_detach;
   ops->to_resume = tdefault_resume;
   ops->to_wait = tdefault_wait;
+  ops->to_fetch_registers = tdefault_fetch_registers;
   ops->to_store_registers = tdefault_store_registers;
   ops->to_prepare_to_store = tdefault_prepare_to_store;
   ops->to_files_info = tdefault_files_info;
   ops->to_insert_breakpoint = memory_insert_breakpoint;
   ops->to_remove_breakpoint = memory_remove_breakpoint;
   ops->to_can_use_hw_breakpoint = tdefault_can_use_hw_breakpoint;
+  ops->to_ranged_break_num_registers = tdefault_ranged_break_num_registers;
   ops->to_insert_hw_breakpoint = tdefault_insert_hw_breakpoint;
   ops->to_remove_hw_breakpoint = tdefault_remove_hw_breakpoint;
   ops->to_remove_watchpoint = tdefault_remove_watchpoint;
@@ -1181,6 +1331,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_has_exited = tdefault_has_exited;
   ops->to_extra_thread_info = tdefault_extra_thread_info;
   ops->to_thread_name = tdefault_thread_name;
+  ops->to_stop = tdefault_stop;
   ops->to_rcmd = default_rcmd;
   ops->to_pid_to_exec_file = tdefault_pid_to_exec_file;
   ops->to_log_command = tdefault_log_command;
@@ -1198,6 +1349,8 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_supports_multi_process = tdefault_supports_multi_process;
   ops->to_supports_enable_disable_tracepoint = tdefault_supports_enable_disable_tracepoint;
   ops->to_supports_string_tracing = tdefault_supports_string_tracing;
+  ops->to_supports_evaluation_of_breakpoint_conditions = tdefault_supports_evaluation_of_breakpoint_conditions;
+  ops->to_can_run_breakpoint_commands = tdefault_can_run_breakpoint_commands;
   ops->to_thread_architecture = default_thread_architecture;
   ops->to_trace_init = tdefault_trace_init;
   ops->to_download_tracepoint = tdefault_download_tracepoint;
@@ -1224,5 +1377,10 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_get_tib_address = tdefault_get_tib_address;
   ops->to_set_permissions = tdefault_set_permissions;
   ops->to_static_tracepoint_marker_at = tdefault_static_tracepoint_marker_at;
+  ops->to_static_tracepoint_markers_by_strid = tdefault_static_tracepoint_markers_by_strid;
+  ops->to_traceframe_info = tdefault_traceframe_info;
+  ops->to_use_agent = tdefault_use_agent;
+  ops->to_can_use_agent = tdefault_can_use_agent;
   ops->to_supports_btrace = tdefault_supports_btrace;
+  ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 31be211..8d041b7 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -66,8 +66,6 @@ static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
 
 static int return_zero (void);
 
-static void *return_null (void);
-
 void target_ignore (void);
 
 static void target_command (char *, int);
@@ -657,7 +655,7 @@ update_current_target (void)
       /* Do not inherit to_pid_to_str.  */
       /* Do not inherit to_extra_thread_info.  */
       /* Do not inherit to_thread_name.  */
-      INHERIT (to_stop, t);
+      /* Do not inherit to_stop.  */
       /* Do not inherit to_xfer_partial.  */
       /* Do not inherit to_rcmd.  */
       /* Do not inherit to_pid_to_exec_file.  */
@@ -711,14 +709,15 @@ update_current_target (void)
       /* Do not inherit to_get_tib_address.  */
       /* Do not inherit to_set_permissions.  */
       /* Do not inherit to_static_tracepoint_marker_at.  */
-      INHERIT (to_static_tracepoint_markers_by_strid, t);
-      INHERIT (to_traceframe_info, t);
-      INHERIT (to_use_agent, t);
-      INHERIT (to_can_use_agent, t);
-      INHERIT (to_augmented_libraries_svr4_read, t);
+      /* Do not inherit to_static_tracepoint_markers_by_strid.  */
+      /* Do not inherit to_traceframe_info.  */
+      /* Do not inherit to_use_agent.  */
+      /* Do not inherit to_can_use_agent.  */
+      /* Do not inherit to_augmented_libraries_svr4_read.  */
       INHERIT (to_magic, t);
-      INHERIT (to_supports_evaluation_of_breakpoint_conditions, t);
-      INHERIT (to_can_run_breakpoint_commands, t);
+      /* Do not inherit
+	 to_supports_evaluation_of_breakpoint_conditions.  */
+      /* Do not inherit to_can_run_breakpoint_commands.  */
       /* Do not inherit to_memory_map.  */
       /* Do not inherit to_flash_erase.  */
       /* Do not inherit to_flash_done.  */
@@ -746,32 +745,7 @@ update_current_target (void)
   de_fault (to_can_run,
 	    (int (*) (struct target_ops *))
 	    return_zero);
-  de_fault (to_stop,
-	    (void (*) (struct target_ops *, ptid_t))
-	    target_ignore);
   current_target.to_read_description = NULL;
-  de_fault (to_static_tracepoint_markers_by_strid,
-	    (VEC(static_tracepoint_marker_p) * (*) (struct target_ops *,
-						    const char *))
-	    tcomplain);
-  de_fault (to_traceframe_info,
-	    (struct traceframe_info * (*) (struct target_ops *))
-	    return_null);
-  de_fault (to_supports_evaluation_of_breakpoint_conditions,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_can_run_breakpoint_commands,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_use_agent,
-	    (int (*) (struct target_ops *, int))
-	    tcomplain);
-  de_fault (to_can_use_agent,
-	    (int (*) (struct target_ops *))
-	    return_zero);
-  de_fault (to_augmented_libraries_svr4_read,
-	    (int (*) (struct target_ops *))
-	    return_zero);
 
 #undef de_fault
 
@@ -3421,12 +3395,6 @@ return_zero (void)
   return 0;
 }
 
-static void *
-return_null (void)
-{
-  return 0;
-}
-
 /*
  * Find the next target down the stack from the specified target.
  */
@@ -3729,18 +3697,9 @@ debug_print_register (const char * func,
 void
 target_fetch_registers (struct regcache *regcache, int regno)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_fetch_registers != NULL)
-	{
-	  t->to_fetch_registers (t, regcache, regno);
-	  if (targetdebug)
-	    debug_print_register ("target_fetch_registers", regcache, regno);
-	  return;
-	}
-    }
+  current_target.to_fetch_registers (&current_target, regcache, regno);
+  if (targetdebug)
+    debug_print_register ("target_fetch_registers", regcache, regno);
 }
 
 void
@@ -3879,13 +3838,7 @@ target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask)
 int
 target_ranged_break_num_registers (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_ranged_break_num_registers != NULL)
-      return t->to_ranged_break_num_registers (t);
-
-  return -1;
+  return current_target.to_ranged_break_num_registers (&current_target);
 }
 
 /* See target.h.  */
diff --git a/gdb/target.h b/gdb/target.h
index 40b3e57..29b3b96 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -406,7 +406,8 @@ struct target_ops
     ptid_t (*to_wait) (struct target_ops *,
 		       ptid_t, struct target_waitstatus *, int)
       TARGET_DEFAULT_NORETURN (noprocess ());
-    void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
+    void (*to_fetch_registers) (struct target_ops *, struct regcache *, int)
+      TARGET_DEFAULT_IGNORE ();
     void (*to_store_registers) (struct target_ops *, struct regcache *, int)
       TARGET_DEFAULT_NORETURN (noprocess ());
     void (*to_prepare_to_store) (struct target_ops *, struct regcache *)
@@ -448,7 +449,8 @@ struct target_ops
       TARGET_DEFAULT_FUNC (memory_remove_breakpoint);
     int (*to_can_use_hw_breakpoint) (struct target_ops *, int, int, int)
       TARGET_DEFAULT_RETURN (0);
-    int (*to_ranged_break_num_registers) (struct target_ops *);
+    int (*to_ranged_break_num_registers) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (-1);
     int (*to_insert_hw_breakpoint) (struct target_ops *,
 				    struct gdbarch *, struct bp_target_info *)
       TARGET_DEFAULT_RETURN (-1);
@@ -546,7 +548,8 @@ struct target_ops
       TARGET_DEFAULT_RETURN (0);
     char *(*to_thread_name) (struct target_ops *, struct thread_info *)
       TARGET_DEFAULT_RETURN (0);
-    void (*to_stop) (struct target_ops *, ptid_t);
+    void (*to_stop) (struct target_ops *, ptid_t)
+      TARGET_DEFAULT_IGNORE ();
     void (*to_rcmd) (struct target_ops *,
 		     char *command, struct ui_file *output)
       TARGET_DEFAULT_FUNC (default_rcmd);
@@ -717,11 +720,13 @@ struct target_ops
 
     /* Does this target support evaluation of breakpoint conditions on its
        end?  */
-    int (*to_supports_evaluation_of_breakpoint_conditions) (struct target_ops *);
+    int (*to_supports_evaluation_of_breakpoint_conditions) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Does this target support evaluation of breakpoint commands on its
        end?  */
-    int (*to_can_run_breakpoint_commands) (struct target_ops *);
+    int (*to_can_run_breakpoint_commands) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Determine current architecture of thread PTID.
 
@@ -929,8 +934,8 @@ struct target_ops
 
     /* Return a vector of all tracepoints markers string id ID, or all
        markers if ID is NULL.  */
-    VEC(static_tracepoint_marker_p) *(*to_static_tracepoint_markers_by_strid)
-      (struct target_ops *, const char *id);
+    VEC(static_tracepoint_marker_p) *(*to_static_tracepoint_markers_by_strid) (struct target_ops *, const char *id)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Return a traceframe info object describing the current
        traceframe's contents.  If the target doesn't support
@@ -945,14 +950,17 @@ struct target_ops
        is available in the read-only sections.  This method should not
        cache data; higher layers take care of caching, invalidating,
        and re-fetching when necessary.  */
-    struct traceframe_info *(*to_traceframe_info) (struct target_ops *);
+    struct traceframe_info *(*to_traceframe_info) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Ask the target to use or not to use agent according to USE.  Return 1
        successful, 0 otherwise.  */
-    int (*to_use_agent) (struct target_ops *, int use);
+    int (*to_use_agent) (struct target_ops *, int use)
+      TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Is the target able to use agent in current state?  */
-    int (*to_can_use_agent) (struct target_ops *);
+    int (*to_can_use_agent) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Check whether the target supports branch tracing.  */
     int (*to_supports_btrace) (struct target_ops *)
@@ -1044,7 +1052,8 @@ struct target_ops
 
     /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
        non-empty annex.  */
-    int (*to_augmented_libraries_svr4_read) (struct target_ops *);
+    int (*to_augmented_libraries_svr4_read) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Those unwinders are tried before any other arch unwinders.  Use NULL if
        it is not used.  */
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 17/38] Add target_ops argument to to_save_record
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (20 preceding siblings ...)
  2014-02-06 20:56 ` [RFC v2 21/38] convert to_extra_thread_info Tom Tromey
@ 2014-02-06 20:58 ` Tom Tromey
  2014-02-06 20:58 ` [RFC v2 04/38] add target method delegation Tom Tromey
                   ` (17 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 20:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_save_record>: Add argument.
	* target.c (target_save_record): Add argument.
	* record-full.c (record_full_save): Add 'self' argument.
	(record_full_save): Add 'self' argument.

Add target_ops argument to to_delete_record

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

	* target.h (struct target_ops) <to_delete_record>: Add argument.
	* target.c (target_delete_record): Add argument.
	* record-full.c (record_full_delete): Add 'self' argument.

Add target_ops argument to to_record_is_replaying

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

	* target.h (struct target_ops) <to_record_is_replaying>: Add
	argument.
	* target.c (target_record_is_replaying): Add argument.
	* record-full.c (record_full_is_replaying): Add 'self' argument.
	* record-btrace.c (record_btrace_is_replaying): Add 'self'
	argument.
	(record_btrace_xfer_partial, record_btrace_store_registers)
	(record_btrace_prepare_to_store, record_btrace_resume)
	(record_btrace_wait, record_btrace_decr_pc_after_break)
	(record_btrace_find_new_threads, record_btrace_thread_alive):
	Update.

Add target_ops argument to to_goto_record_begin

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

	* target.h (struct target_ops) <to_goto_record_begin>: Add
	argument.
	* target.c (target_goto_record_begin): Add argument.
	* record-full.c (record_full_goto_begin): Add 'self' argument.
	* record-btrace.c (record_btrace_goto_begin): Add 'self'
	argument.

Add target_ops argument to to_goto_record_end

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

	* target.h (struct target_ops) <to_goto_record_end>: Add argument.
	* target.c (target_goto_record_end): Add argument.
	* record-full.c (record_full_goto_end): Add 'self' argument.
	* record-btrace.c (record_btrace_goto_end): Add 'self' argument.

Add target_ops argument to to_goto_record

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

	* target.h (struct target_ops) <to_goto_record>: Add argument.
	* target.c (target_goto_record): Add argument.
	* record-full.c (record_full_goto): Add 'self' argument.
	* record-btrace.c (record_btrace_goto): Add 'self' argument.

Add target_ops argument to to_insn_history

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

	* target.h (struct target_ops) <to_insn_history>: Add argument.
	* target.c (target_insn_history): Add argument.
	* record-btrace.c (record_btrace_insn_history): Add 'self'
	argument.

Add target_ops argument to to_insn_history_from

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

	* target.h (struct target_ops) <to_insn_history_from>: Add
	argument.
	* target.c (target_insn_history_from): Add argument.
	* record-btrace.c (record_btrace_insn_history_from): Add 'self'
	argument.

Add target_ops argument to to_insn_history_range

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

	* target.h (struct target_ops) <to_insn_history_range>: Add
	argument.
	* target.c (target_insn_history_range): Add argument.
	* record-btrace.c (record_btrace_insn_history_range): Add 'self'
	argument.
	(record_btrace_insn_history_from): Update.

Add target_ops argument to to_call_history

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

	* target.h (struct target_ops) <to_call_history>: Add argument.
	* target.c (target_call_history): Add argument.
	* record-btrace.c (record_btrace_call_history): Add 'self'
	argument.

Add target_ops argument to to_call_history_from

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

	* target.h (struct target_ops) <to_call_history_from>: Add
	argument.
	* target.c (target_call_history_from): Add argument.
	* record-btrace.c (record_btrace_call_history_from): Add 'self'
	argument.

Add target_ops argument to to_call_history_range

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

	* target.h (struct target_ops) <to_call_history_range>: Add
	argument.
	* target.c (target_call_history_range): Add argument.
	* record-btrace.c (record_btrace_call_history_range): Add 'self'
	argument.
	(record_btrace_call_history_from): Update.

Add target_ops argument to to_augmented_libraries_svr4_read

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

	* target.h (struct target_ops) <to_augmented_libraries_svr4_read>:
	Add argument.
	(target_augmented_libraries_svr4_read): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_augmented_libraries_svr4_read): Add 'self'
	argument.
---
 gdb/ChangeLog       | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/record-btrace.c |  44 +++++++++++----------
 gdb/record-full.c   |  15 ++++----
 gdb/remote.c        |   2 +-
 gdb/target.c        |  26 ++++++-------
 gdb/target.h        |  32 +++++++++-------
 6 files changed, 171 insertions(+), 55 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 9f7951d..44882ad 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -312,7 +312,7 @@ btrace_insn_history (struct ui_out *uiout,
 /* The to_insn_history method of target record-btrace.  */
 
 static void
-record_btrace_insn_history (int size, int flags)
+record_btrace_insn_history (struct target_ops *self, int size, int flags)
 {
   struct btrace_thread_info *btinfo;
   struct btrace_insn_history *history;
@@ -398,7 +398,8 @@ record_btrace_insn_history (int size, int flags)
 /* The to_insn_history_range method of target record-btrace.  */
 
 static void
-record_btrace_insn_history_range (ULONGEST from, ULONGEST to, int flags)
+record_btrace_insn_history_range (struct target_ops *self,
+				  ULONGEST from, ULONGEST to, int flags)
 {
   struct btrace_thread_info *btinfo;
   struct btrace_insn_history *history;
@@ -450,7 +451,8 @@ record_btrace_insn_history_range (ULONGEST from, ULONGEST to, int flags)
 /* The to_insn_history_from method of target record-btrace.  */
 
 static void
-record_btrace_insn_history_from (ULONGEST from, int size, int flags)
+record_btrace_insn_history_from (struct target_ops *self,
+				 ULONGEST from, int size, int flags)
 {
   ULONGEST begin, end, context;
 
@@ -477,7 +479,7 @@ record_btrace_insn_history_from (ULONGEST from, int size, int flags)
 	end = ULONGEST_MAX;
     }
 
-  record_btrace_insn_history_range (begin, end, flags);
+  record_btrace_insn_history_range (self, begin, end, flags);
 }
 
 /* Print the instruction number range for a function call history line.  */
@@ -615,7 +617,7 @@ btrace_call_history (struct ui_out *uiout,
 /* The to_call_history method of target record-btrace.  */
 
 static void
-record_btrace_call_history (int size, int flags)
+record_btrace_call_history (struct target_ops *self, int size, int flags)
 {
   struct btrace_thread_info *btinfo;
   struct btrace_call_history *history;
@@ -704,7 +706,8 @@ record_btrace_call_history (int size, int flags)
 /* The to_call_history_range method of target record-btrace.  */
 
 static void
-record_btrace_call_history_range (ULONGEST from, ULONGEST to, int flags)
+record_btrace_call_history_range (struct target_ops *self,
+				  ULONGEST from, ULONGEST to, int flags)
 {
   struct btrace_thread_info *btinfo;
   struct btrace_call_history *history;
@@ -756,7 +759,8 @@ record_btrace_call_history_range (ULONGEST from, ULONGEST to, int flags)
 /* The to_call_history_from method of target record-btrace.  */
 
 static void
-record_btrace_call_history_from (ULONGEST from, int size, int flags)
+record_btrace_call_history_from (struct target_ops *self,
+				 ULONGEST from, int size, int flags)
 {
   ULONGEST begin, end, context;
 
@@ -783,13 +787,13 @@ record_btrace_call_history_from (ULONGEST from, int size, int flags)
 	end = ULONGEST_MAX;
     }
 
-  record_btrace_call_history_range (begin, end, flags);
+  record_btrace_call_history_range (self, begin, end, flags);
 }
 
 /* The to_record_is_replaying method of target record-btrace.  */
 
 static int
-record_btrace_is_replaying (void)
+record_btrace_is_replaying (struct target_ops *self)
 {
   struct thread_info *tp;
 
@@ -811,7 +815,7 @@ record_btrace_xfer_partial (struct target_ops *ops, enum target_object object,
   struct target_ops *t;
 
   /* Filter out requests that don't make sense during replay.  */
-  if (!record_btrace_allow_memory_access && record_btrace_is_replaying ())
+  if (!record_btrace_allow_memory_access && record_btrace_is_replaying (ops))
     {
       switch (object)
 	{
@@ -960,7 +964,7 @@ record_btrace_store_registers (struct target_ops *ops,
 {
   struct target_ops *t;
 
-  if (record_btrace_is_replaying ())
+  if (record_btrace_is_replaying (ops))
     error (_("This record target does not allow writing registers."));
 
   gdb_assert (may_write_registers != 0);
@@ -983,7 +987,7 @@ record_btrace_prepare_to_store (struct target_ops *ops,
 {
   struct target_ops *t;
 
-  if (record_btrace_is_replaying ())
+  if (record_btrace_is_replaying (ops))
     return;
 
   for (t = ops->beneath; t != NULL; t = t->beneath)
@@ -1457,7 +1461,7 @@ record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step,
       record_btrace_stop_replaying (other);
 
   /* As long as we're not replaying, just forward the request.  */
-  if (!record_btrace_is_replaying () && execution_direction != EXEC_REVERSE)
+  if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
     {
       for (ops = ops->beneath; ops != NULL; ops = ops->beneath)
 	if (ops->to_resume != NULL)
@@ -1673,7 +1677,7 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid,
   DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid), options);
 
   /* As long as we're not replaying, just forward the request.  */
-  if (!record_btrace_is_replaying () && execution_direction != EXEC_REVERSE)
+  if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
     {
       for (ops = ops->beneath; ops != NULL; ops = ops->beneath)
 	if (ops->to_wait != NULL)
@@ -1725,7 +1729,7 @@ record_btrace_decr_pc_after_break (struct target_ops *ops,
 {
   /* When replaying, we do not actually execute the breakpoint instruction
      so there is no need to adjust the PC after hitting a breakpoint.  */
-  if (record_btrace_is_replaying ())
+  if (record_btrace_is_replaying (ops))
     return 0;
 
   return forward_target_decr_pc_after_break (ops->beneath, gdbarch);
@@ -1737,7 +1741,7 @@ static void
 record_btrace_find_new_threads (struct target_ops *ops)
 {
   /* Don't expect new threads if we're replaying.  */
-  if (record_btrace_is_replaying ())
+  if (record_btrace_is_replaying (ops))
     return;
 
   /* Forward the request.  */
@@ -1755,7 +1759,7 @@ static int
 record_btrace_thread_alive (struct target_ops *ops, ptid_t ptid)
 {
   /* We don't add or remove threads during replay.  */
-  if (record_btrace_is_replaying ())
+  if (record_btrace_is_replaying (ops))
     return find_thread_ptid (ptid) != NULL;
 
   /* Forward the request.  */
@@ -1797,7 +1801,7 @@ record_btrace_set_replay (struct thread_info *tp,
 /* The to_goto_record_begin method of target record-btrace.  */
 
 static void
-record_btrace_goto_begin (void)
+record_btrace_goto_begin (struct target_ops *self)
 {
   struct thread_info *tp;
   struct btrace_insn_iterator begin;
@@ -1813,7 +1817,7 @@ record_btrace_goto_begin (void)
 /* The to_goto_record_end method of target record-btrace.  */
 
 static void
-record_btrace_goto_end (void)
+record_btrace_goto_end (struct target_ops *ops)
 {
   struct thread_info *tp;
 
@@ -1827,7 +1831,7 @@ record_btrace_goto_end (void)
 /* The to_goto_record method of target record-btrace.  */
 
 static void
-record_btrace_goto (ULONGEST insn)
+record_btrace_goto (struct target_ops *self, ULONGEST insn)
 {
   struct thread_info *tp;
   struct btrace_insn_iterator it;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 2b62f3e..d3f7279 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -230,7 +230,8 @@ static struct cmd_list_element *record_full_cmdlist;
 
 static void record_full_goto_insn (struct record_full_entry *entry,
 				   enum exec_direction_kind dir);
-static void record_full_save (const char *recfilename);
+static void record_full_save (struct target_ops *self,
+			      const char *recfilename);
 
 /* Alloc and free functions for record_full_reg, record_full_mem, and
    record_full_end entries.  */
@@ -1816,7 +1817,7 @@ record_full_info (struct target_ops *self)
 /* The "to_record_delete" target method.  */
 
 static void
-record_full_delete (void)
+record_full_delete (struct target_ops *self)
 {
   record_full_list_release_following (record_full_list);
 }
@@ -1824,7 +1825,7 @@ record_full_delete (void)
 /* The "to_record_is_replaying" target method.  */
 
 static int
-record_full_is_replaying (void)
+record_full_is_replaying (struct target_ops *self)
 {
   return RECORD_FULL_IS_REPLAY;
 }
@@ -1859,7 +1860,7 @@ record_full_goto_entry (struct record_full_entry *p)
 /* The "to_goto_record_begin" target method.  */
 
 static void
-record_full_goto_begin (void)
+record_full_goto_begin (struct target_ops *self)
 {
   struct record_full_entry *p = NULL;
 
@@ -1873,7 +1874,7 @@ record_full_goto_begin (void)
 /* The "to_goto_record_end" target method.  */
 
 static void
-record_full_goto_end (void)
+record_full_goto_end (struct target_ops *self)
 {
   struct record_full_entry *p = NULL;
 
@@ -1889,7 +1890,7 @@ record_full_goto_end (void)
 /* The "to_goto_record" target method.  */
 
 static void
-record_full_goto (ULONGEST target_insn)
+record_full_goto (struct target_ops *self, ULONGEST target_insn)
 {
   struct record_full_entry *p = NULL;
 
@@ -2480,7 +2481,7 @@ record_full_save_cleanups (void *data)
    format, with an extra section for our data.  */
 
 static void
-record_full_save (const char *recfilename)
+record_full_save (struct target_ops *self, const char *recfilename)
 {
   struct record_full_entry *cur_record_full_list;
   uint32_t magic;
diff --git a/gdb/remote.c b/gdb/remote.c
index e2cefe0..be36234 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11560,7 +11560,7 @@ remote_read_btrace (struct target_ops *self,
 }
 
 static int
-remote_augmented_libraries_svr4_read (void)
+remote_augmented_libraries_svr4_read (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
diff --git a/gdb/target.c b/gdb/target.c
index ab4f1ff..6bfaa58 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -947,7 +947,7 @@ update_current_target (void)
 	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_augmented_libraries_svr4_read,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_execution_direction, default_execution_direction);
 
@@ -4239,7 +4239,7 @@ target_save_record (const char *filename)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_save_record != NULL)
       {
-	t->to_save_record (filename);
+	t->to_save_record (t, filename);
 	return;
       }
 
@@ -4270,7 +4270,7 @@ target_delete_record (void)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_delete_record != NULL)
       {
-	t->to_delete_record ();
+	t->to_delete_record (t);
 	return;
       }
 
@@ -4286,7 +4286,7 @@ target_record_is_replaying (void)
 
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_record_is_replaying != NULL)
-	return t->to_record_is_replaying ();
+	return t->to_record_is_replaying (t);
 
   return 0;
 }
@@ -4301,7 +4301,7 @@ target_goto_record_begin (void)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_goto_record_begin != NULL)
       {
-	t->to_goto_record_begin ();
+	t->to_goto_record_begin (t);
 	return;
       }
 
@@ -4318,7 +4318,7 @@ target_goto_record_end (void)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_goto_record_end != NULL)
       {
-	t->to_goto_record_end ();
+	t->to_goto_record_end (t);
 	return;
       }
 
@@ -4335,7 +4335,7 @@ target_goto_record (ULONGEST insn)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_goto_record != NULL)
       {
-	t->to_goto_record (insn);
+	t->to_goto_record (t, insn);
 	return;
       }
 
@@ -4352,7 +4352,7 @@ target_insn_history (int size, int flags)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_insn_history != NULL)
       {
-	t->to_insn_history (size, flags);
+	t->to_insn_history (t, size, flags);
 	return;
       }
 
@@ -4369,7 +4369,7 @@ target_insn_history_from (ULONGEST from, int size, int flags)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_insn_history_from != NULL)
       {
-	t->to_insn_history_from (from, size, flags);
+	t->to_insn_history_from (t, from, size, flags);
 	return;
       }
 
@@ -4386,7 +4386,7 @@ target_insn_history_range (ULONGEST begin, ULONGEST end, int flags)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_insn_history_range != NULL)
       {
-	t->to_insn_history_range (begin, end, flags);
+	t->to_insn_history_range (t, begin, end, flags);
 	return;
       }
 
@@ -4403,7 +4403,7 @@ target_call_history (int size, int flags)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_call_history != NULL)
       {
-	t->to_call_history (size, flags);
+	t->to_call_history (t, size, flags);
 	return;
       }
 
@@ -4420,7 +4420,7 @@ target_call_history_from (ULONGEST begin, int size, int flags)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_call_history_from != NULL)
       {
-	t->to_call_history_from (begin, size, flags);
+	t->to_call_history_from (t, begin, size, flags);
 	return;
       }
 
@@ -4437,7 +4437,7 @@ target_call_history_range (ULONGEST begin, ULONGEST end, int flags)
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_call_history_range != NULL)
       {
-	t->to_call_history_range (begin, end, flags);
+	t->to_call_history_range (t, begin, end, flags);
 	return;
       }
 
diff --git a/gdb/target.h b/gdb/target.h
index 572671c..9fdd506 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -920,57 +920,61 @@ struct target_ops
     void (*to_info_record) (struct target_ops *);
 
     /* Save the recorded execution trace into a file.  */
-    void (*to_save_record) (const char *filename);
+    void (*to_save_record) (struct target_ops *, const char *filename);
 
     /* Delete the recorded execution trace from the current position onwards.  */
-    void (*to_delete_record) (void);
+    void (*to_delete_record) (struct target_ops *);
 
     /* Query if the record target is currently replaying.  */
-    int (*to_record_is_replaying) (void);
+    int (*to_record_is_replaying) (struct target_ops *);
 
     /* Go to the begin of the execution trace.  */
-    void (*to_goto_record_begin) (void);
+    void (*to_goto_record_begin) (struct target_ops *);
 
     /* Go to the end of the execution trace.  */
-    void (*to_goto_record_end) (void);
+    void (*to_goto_record_end) (struct target_ops *);
 
     /* Go to a specific location in the recorded execution trace.  */
-    void (*to_goto_record) (ULONGEST insn);
+    void (*to_goto_record) (struct target_ops *, ULONGEST insn);
 
     /* Disassemble SIZE instructions in the recorded execution trace from
        the current position.
        If SIZE < 0, disassemble abs (SIZE) preceding instructions; otherwise,
        disassemble SIZE succeeding instructions.  */
-    void (*to_insn_history) (int size, int flags);
+    void (*to_insn_history) (struct target_ops *, int size, int flags);
 
     /* Disassemble SIZE instructions in the recorded execution trace around
        FROM.
        If SIZE < 0, disassemble abs (SIZE) instructions before FROM; otherwise,
        disassemble SIZE instructions after FROM.  */
-    void (*to_insn_history_from) (ULONGEST from, int size, int flags);
+    void (*to_insn_history_from) (struct target_ops *,
+				  ULONGEST from, int size, int flags);
 
     /* Disassemble a section of the recorded execution trace from instruction
        BEGIN (inclusive) to instruction END (inclusive).  */
-    void (*to_insn_history_range) (ULONGEST begin, ULONGEST end, int flags);
+    void (*to_insn_history_range) (struct target_ops *,
+				   ULONGEST begin, ULONGEST end, int flags);
 
     /* Print a function trace of the recorded execution trace.
        If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
        succeeding functions.  */
-    void (*to_call_history) (int size, int flags);
+    void (*to_call_history) (struct target_ops *, int size, int flags);
 
     /* Print a function trace of the recorded execution trace starting
        at function FROM.
        If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
        SIZE functions after FROM.  */
-    void (*to_call_history_from) (ULONGEST begin, int size, int flags);
+    void (*to_call_history_from) (struct target_ops *,
+				  ULONGEST begin, int size, int flags);
 
     /* Print a function trace of an execution trace section from function BEGIN
        (inclusive) to function END (inclusive).  */
-    void (*to_call_history_range) (ULONGEST begin, ULONGEST end, int flags);
+    void (*to_call_history_range) (struct target_ops *,
+				   ULONGEST begin, ULONGEST end, int flags);
 
     /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
        non-empty annex.  */
-    int (*to_augmented_libraries_svr4_read) (void);
+    int (*to_augmented_libraries_svr4_read) (struct target_ops *);
 
     /* Those unwinders are tried before any other arch unwinders.  Use NULL if
        it is not used.  */
@@ -1876,7 +1880,7 @@ extern char *target_fileio_read_stralloc (const char *filename);
   (*current_target.to_can_use_agent) (&current_target)
 
 #define target_augmented_libraries_svr4_read() \
-  (*current_target.to_augmented_libraries_svr4_read) ()
+  (*current_target.to_augmented_libraries_svr4_read) (&current_target)
 
 /* Command logging facility.  */
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 15/38] Add target_ops argument to to_upload_trace_state_variables
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (28 preceding siblings ...)
  2014-02-06 21:23 ` [RFC v2 06/38] introduce remote_load Tom Tromey
@ 2014-02-06 21:23 ` Tom Tromey
  2014-02-06 21:24 ` [RFC v2 05/38] convert to_supports_btrace Tom Tromey
                   ` (9 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_upload_trace_state_variables>:
	Add argument.
	(target_upload_trace_state_variables): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_upload_trace_state_variables): Add 'self'
	argument.
	(remote_start_remote): Update.

Add target_ops argument to to_get_raw_trace_data

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

	* target.h (struct target_ops) <to_get_raw_trace_data>: Add
	argument.
	(target_get_raw_trace_data): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_get_raw_trace_data): Add 'self' argument.

Add target_ops argument to to_get_min_fast_tracepoint_insn_len

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

	* target.h (struct target_ops)
	<to_get_min_fast_tracepoint_insn_len>: Add argument.
	(target_get_min_fast_tracepoint_insn_len): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_get_min_fast_tracepoint_insn_len): Add 'self'
	argument.

Add target_ops argument to to_set_disconnected_tracing

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

	* target.h (struct target_ops) <to_set_disconnected_tracing>: Add
	argument.
	(target_set_disconnected_tracing): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_set_disconnected_tracing): Add 'self' argument.

Add target_ops argument to to_set_circular_trace_buffer

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

	* target.h (struct target_ops) <to_set_circular_trace_buffer>: Add
	argument.
	(target_set_circular_trace_buffer): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_set_circular_trace_buffer): Add 'self'
	argument.

Add target_ops argument to to_set_trace_buffer_size

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

	* target.h (struct target_ops) <to_set_trace_buffer_size>: Add
	argument.
	(target_set_trace_buffer_size): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_set_trace_buffer_size): Add 'self' argument.

Add target_ops argument to to_set_trace_notes

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

	* target.h (struct target_ops) <to_set_trace_notes>: Add argument.
	(target_set_trace_notes): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_set_trace_notes): Add 'self' argument.

Add target_ops argument to to_get_tib_address

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

	* windows-nat.c (windows_get_tib_address): Add 'self' argument.
	* target.h (struct target_ops) <to_get_tib_address>: Add argument.
	(target_get_tib_address): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_get_tib_address): Add 'self' argument.

Add target_ops argument to to_set_permissions

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

	* target.h (struct target_ops) <to_set_permissions>: Add argument.
	(target_set_permissions): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_set_permissions): Add 'self' argument.
	(remote_start_remote): Update.

Add target_ops argument to to_static_tracepoint_marker_at

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

	* target.h (struct target_ops) <to_static_tracepoint_marker_at>:
	Add argument.
	(target_static_tracepoint_marker_at): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_static_tracepoint_marker_at): Add 'self'
	argument.
---
 gdb/ChangeLog     | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/remote.c      | 32 +++++++++++----------
 gdb/target.c      | 22 ++++++++-------
 gdb/target.h      | 46 +++++++++++++++++-------------
 gdb/windows-nat.c |  3 +-
 5 files changed, 142 insertions(+), 45 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index b7ad654..ce9bfd4 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -201,7 +201,7 @@ static void show_remote_protocol_packet_cmd (struct ui_file *file,
 static char *write_ptid (char *buf, const char *endbuf, ptid_t ptid);
 static ptid_t read_ptid (char *buf, char **obuf);
 
-static void remote_set_permissions (void);
+static void remote_set_permissions (struct target_ops *self);
 
 struct remote_state;
 static int remote_get_trace_status (struct target_ops *self,
@@ -210,7 +210,8 @@ static int remote_get_trace_status (struct target_ops *self,
 static int remote_upload_tracepoints (struct target_ops *self,
 				      struct uploaded_tp **utpp);
 
-static int remote_upload_trace_state_variables (struct uploaded_tsv **utsvp);
+static int remote_upload_trace_state_variables (struct target_ops *self,
+						struct uploaded_tsv **utsvp);
   
 static void remote_query_supported (void);
 
@@ -2959,7 +2960,7 @@ remote_threads_extra_info (struct target_ops *self, struct thread_info *tp)
 \f
 
 static int
-remote_static_tracepoint_marker_at (CORE_ADDR addr,
+remote_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR addr,
 				    struct static_tracepoint_marker *marker)
 {
   struct remote_state *rs = get_remote_state ();
@@ -3424,7 +3425,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
 
   /* If the stub wants to get a QAllow, compose one and send it.  */
   if (remote_protocol_packets[PACKET_QAllow].support != PACKET_DISABLE)
-    remote_set_permissions ();
+    remote_set_permissions (target);
 
   /* Next, we possibly activate noack mode.
 
@@ -3511,7 +3512,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
     {
       struct uploaded_tsv *uploaded_tsvs = NULL;
 
-      remote_upload_trace_state_variables (&uploaded_tsvs);
+      remote_upload_trace_state_variables (target, &uploaded_tsvs);
       merge_uploaded_trace_state_variables (&uploaded_tsvs);
     }
 
@@ -3824,7 +3825,7 @@ remote_serial_open (char *name)
    permissions.  */
 
 void
-remote_set_permissions (void)
+remote_set_permissions (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -9509,7 +9510,7 @@ remote_get_thread_local_address (struct target_ops *ops,
    Returns 1 if ptid is found and thread_local_base is non zero.  */
 
 static int
-remote_get_tib_address (ptid_t ptid, CORE_ADDR *addr)
+remote_get_tib_address (struct target_ops *self, ptid_t ptid, CORE_ADDR *addr)
 {
   if (remote_protocol_packets[PACKET_qGetTIBAddr].support != PACKET_DISABLE)
     {
@@ -11157,7 +11158,8 @@ remote_save_trace_data (struct target_ops *self, const char *filename)
    not be unhappy if we don't get as much as we ask for.  */
 
 static LONGEST
-remote_get_raw_trace_data (gdb_byte *buf, ULONGEST offset, LONGEST len)
+remote_get_raw_trace_data (struct target_ops *self,
+			   gdb_byte *buf, ULONGEST offset, LONGEST len)
 {
   struct remote_state *rs = get_remote_state ();
   char *reply;
@@ -11195,7 +11197,7 @@ remote_get_raw_trace_data (gdb_byte *buf, ULONGEST offset, LONGEST len)
 }
 
 static void
-remote_set_disconnected_tracing (int val)
+remote_set_disconnected_tracing (struct target_ops *self, int val)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -11226,7 +11228,7 @@ remote_core_of_thread (struct target_ops *ops, ptid_t ptid)
 }
 
 static void
-remote_set_circular_trace_buffer (int val)
+remote_set_circular_trace_buffer (struct target_ops *self, int val)
 {
   struct remote_state *rs = get_remote_state ();
   char *reply;
@@ -11271,7 +11273,7 @@ remote_traceframe_info (void)
    length is unknown.  */
 
 static int
-remote_get_min_fast_tracepoint_insn_len (void)
+remote_get_min_fast_tracepoint_insn_len (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
   char *reply;
@@ -11300,7 +11302,7 @@ remote_get_min_fast_tracepoint_insn_len (void)
 }
 
 static void
-remote_set_trace_buffer_size (LONGEST val)
+remote_set_trace_buffer_size (struct target_ops *self, LONGEST val)
 {
   if (remote_protocol_packets[PACKET_QTBuffer_size].support
       != PACKET_DISABLE)
@@ -11332,7 +11334,8 @@ remote_set_trace_buffer_size (LONGEST val)
 }
 
 static int
-remote_set_trace_notes (const char *user, const char *notes,
+remote_set_trace_notes (struct target_ops *self,
+			const char *user, const char *notes,
 			const char *stop_notes)
 {
   struct remote_state *rs = get_remote_state ();
@@ -11863,7 +11866,8 @@ remote_upload_tracepoints (struct target_ops *self, struct uploaded_tp **utpp)
 }
 
 static int
-remote_upload_trace_state_variables (struct uploaded_tsv **utsvp)
+remote_upload_trace_state_variables (struct target_ops *self,
+				     struct uploaded_tsv **utsvp)
 {
   struct remote_state *rs = get_remote_state ();
   char *p;
diff --git a/gdb/target.c b/gdb/target.c
index 71dff46..379c4d2 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -896,34 +896,36 @@ update_current_target (void)
 	    (int (*) (struct target_ops *, struct uploaded_tp **))
 	    return_zero);
   de_fault (to_upload_trace_state_variables,
-	    (int (*) (struct uploaded_tsv **))
+	    (int (*) (struct target_ops *, struct uploaded_tsv **))
 	    return_zero);
   de_fault (to_get_raw_trace_data,
-	    (LONGEST (*) (gdb_byte *, ULONGEST, LONGEST))
+	    (LONGEST (*) (struct target_ops *, gdb_byte *, ULONGEST, LONGEST))
 	    tcomplain);
   de_fault (to_get_min_fast_tracepoint_insn_len,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_minus_one);
   de_fault (to_set_disconnected_tracing,
-	    (void (*) (int))
+	    (void (*) (struct target_ops *, int))
 	    target_ignore);
   de_fault (to_set_circular_trace_buffer,
-	    (void (*) (int))
+	    (void (*) (struct target_ops *, int))
 	    target_ignore);
   de_fault (to_set_trace_buffer_size,
-	    (void (*) (LONGEST))
+	    (void (*) (struct target_ops *, LONGEST))
 	    target_ignore);
   de_fault (to_set_trace_notes,
-	    (int (*) (const char *, const char *, const char *))
+	    (int (*) (struct target_ops *,
+		      const char *, const char *, const char *))
 	    return_zero);
   de_fault (to_get_tib_address,
-	    (int (*) (ptid_t, CORE_ADDR *))
+	    (int (*) (struct target_ops *, ptid_t, CORE_ADDR *))
 	    tcomplain);
   de_fault (to_set_permissions,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    target_ignore);
   de_fault (to_static_tracepoint_marker_at,
-	    (int (*) (CORE_ADDR, struct static_tracepoint_marker *))
+	    (int (*) (struct target_ops *,
+		      CORE_ADDR, struct static_tracepoint_marker *))
 	    return_zero);
   de_fault (to_static_tracepoint_markers_by_strid,
 	    (VEC(static_tracepoint_marker_p) * (*) (const char *))
diff --git a/gdb/target.h b/gdb/target.h
index e53c041..56fbd96 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -803,27 +803,29 @@ struct target_ops
     int (*to_upload_tracepoints) (struct target_ops *,
 				  struct uploaded_tp **utpp);
 
-    int (*to_upload_trace_state_variables) (struct uploaded_tsv **utsvp);
+    int (*to_upload_trace_state_variables) (struct target_ops *,
+					    struct uploaded_tsv **utsvp);
 
-    LONGEST (*to_get_raw_trace_data) (gdb_byte *buf,
+    LONGEST (*to_get_raw_trace_data) (struct target_ops *, gdb_byte *buf,
 				      ULONGEST offset, LONGEST len);
 
     /* Get the minimum length of instruction on which a fast tracepoint
        may be set on the target.  If this operation is unsupported,
        return -1.  If for some reason the minimum length cannot be
        determined, return 0.  */
-    int (*to_get_min_fast_tracepoint_insn_len) (void);
+    int (*to_get_min_fast_tracepoint_insn_len) (struct target_ops *);
 
     /* Set the target's tracing behavior in response to unexpected
        disconnection - set VAL to 1 to keep tracing, 0 to stop.  */
-    void (*to_set_disconnected_tracing) (int val);
-    void (*to_set_circular_trace_buffer) (int val);
+    void (*to_set_disconnected_tracing) (struct target_ops *, int val);
+    void (*to_set_circular_trace_buffer) (struct target_ops *, int val);
     /* Set the size of trace buffer in the target.  */
-    void (*to_set_trace_buffer_size) (LONGEST val);
+    void (*to_set_trace_buffer_size) (struct target_ops *, LONGEST val);
 
     /* Add/change textual notes about the trace run, returning 1 if
        successful, 0 otherwise.  */
-    int (*to_set_trace_notes) (const char *user, const char *notes,
+    int (*to_set_trace_notes) (struct target_ops *,
+			       const char *user, const char *notes,
 			       const char *stopnotes);
 
     /* Return the processor core that thread PTID was last seen on.
@@ -844,14 +846,15 @@ struct target_ops
 
     /* Return the address of the start of the Thread Information Block
        a Windows OS specific feature.  */
-    int (*to_get_tib_address) (ptid_t ptid, CORE_ADDR *addr);
+    int (*to_get_tib_address) (struct target_ops *,
+			       ptid_t ptid, CORE_ADDR *addr);
 
     /* Send the new settings of write permission variables.  */
-    void (*to_set_permissions) (void);
+    void (*to_set_permissions) (struct target_ops *);
 
     /* Look for a static tracepoint marker at ADDR, and fill in MARKER
        with its details.  Return 1 on success, 0 on failure.  */
-    int (*to_static_tracepoint_marker_at) (CORE_ADDR,
+    int (*to_static_tracepoint_marker_at) (struct target_ops *, CORE_ADDR,
 					   struct static_tracepoint_marker *marker);
 
     /* Return a vector of all tracepoints markers string id ID, or all
@@ -1823,34 +1826,37 @@ extern char *target_fileio_read_stralloc (const char *filename);
   (*current_target.to_upload_tracepoints) (&current_target, utpp)
 
 #define target_upload_trace_state_variables(utsvp) \
-  (*current_target.to_upload_trace_state_variables) (utsvp)
+  (*current_target.to_upload_trace_state_variables) (&current_target, utsvp)
 
 #define target_get_raw_trace_data(buf,offset,len) \
-  (*current_target.to_get_raw_trace_data) ((buf), (offset), (len))
+  (*current_target.to_get_raw_trace_data) (&current_target,	\
+					   (buf), (offset), (len))
 
 #define target_get_min_fast_tracepoint_insn_len() \
-  (*current_target.to_get_min_fast_tracepoint_insn_len) ()
+  (*current_target.to_get_min_fast_tracepoint_insn_len) (&current_target)
 
 #define target_set_disconnected_tracing(val) \
-  (*current_target.to_set_disconnected_tracing) (val)
+  (*current_target.to_set_disconnected_tracing) (&current_target, val)
 
 #define	target_set_circular_trace_buffer(val)	\
-  (*current_target.to_set_circular_trace_buffer) (val)
+  (*current_target.to_set_circular_trace_buffer) (&current_target, val)
 
 #define	target_set_trace_buffer_size(val)	\
-  (*current_target.to_set_trace_buffer_size) (val)
+  (*current_target.to_set_trace_buffer_size) (&current_target, val)
 
 #define	target_set_trace_notes(user,notes,stopnotes)		\
-  (*current_target.to_set_trace_notes) ((user), (notes), (stopnotes))
+  (*current_target.to_set_trace_notes) (&current_target,	\
+					(user), (notes), (stopnotes))
 
 #define target_get_tib_address(ptid, addr) \
-  (*current_target.to_get_tib_address) ((ptid), (addr))
+  (*current_target.to_get_tib_address) (&current_target, (ptid), (addr))
 
 #define target_set_permissions() \
-  (*current_target.to_set_permissions) ()
+  (*current_target.to_set_permissions) (&current_target)
 
 #define target_static_tracepoint_marker_at(addr, marker) \
-  (*current_target.to_static_tracepoint_marker_at) (addr, marker)
+  (*current_target.to_static_tracepoint_marker_at) (&current_target,	\
+						    addr, marker)
 
 #define target_static_tracepoint_markers_by_strid(marker_id) \
   (*current_target.to_static_tracepoint_markers_by_strid) (marker_id)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 0af13df..c417861 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2565,7 +2565,8 @@ windows_xfer_partial (struct target_ops *ops, enum target_object object,
    Returns 1 if ptid is found and sets *ADDR to thread_local_base.  */
 
 static int
-windows_get_tib_address (ptid_t ptid, CORE_ADDR *addr)
+windows_get_tib_address (struct target_ops *self,
+			 ptid_t ptid, CORE_ADDR *addr)
 {
   thread_info *th;
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 06/38] introduce remote_load
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (27 preceding siblings ...)
  2014-02-06 21:23 ` [RFC v2 19/38] convert to_remove_watchpoint Tom Tromey
@ 2014-02-06 21:23 ` Tom Tromey
  2014-02-06 21:23 ` [RFC v2 15/38] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
                   ` (10 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I used a refactoring script to add target_ops arguments to all the
target methods.  In order to make this script work a little better,
this patch adds a new "remote_load" function; this eliminates the need
to later change the signature of generic_load.

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

	* remote.c (remote_load): New function.
	(init_remote_ops): Use it.
---
 gdb/ChangeLog |  5 +++++
 gdb/remote.c  | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 1996571..88feab0 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11535,6 +11535,14 @@ remote_augmented_libraries_svr4_read (void)
   return rs->augmented_libraries_svr4_read;
 }
 
+/* Implementation of to_load.  */
+
+static void
+remote_load (char *name, int from_tty)
+{
+  generic_load (name, from_tty);
+}
+
 static void
 init_remote_ops (void)
 {
@@ -11568,7 +11576,7 @@ Specify the serial device it is connected to\n\
   remote_ops.to_insert_watchpoint = remote_insert_watchpoint;
   remote_ops.to_remove_watchpoint = remote_remove_watchpoint;
   remote_ops.to_kill = remote_kill;
-  remote_ops.to_load = generic_load;
+  remote_ops.to_load = remote_load;
   remote_ops.to_mourn_inferior = remote_mourn;
   remote_ops.to_pass_signals = remote_pass_signals;
   remote_ops.to_program_signals = remote_program_signals;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 12/38] Add target_ops argument to to_can_execute_reverse
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (25 preceding siblings ...)
  2014-02-06 20:58 ` [RFC v2 11/38] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
@ 2014-02-06 21:23 ` Tom Tromey
  2014-02-06 21:23 ` [RFC v2 19/38] convert to_remove_watchpoint Tom Tromey
                   ` (12 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_can_execute_reverse>: Add
	argument.
	(target_can_execute_reverse): Add argument.
	* remote.c (remote_can_execute_reverse): Add 'self' argument.
	* record-full.c (record_full_can_execute_reverse): Add 'self'
	argument.
	* record-btrace.c (record_btrace_can_execute_reverse): Add 'self'
	argument.

Add target_ops argument to to_execution_direction

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

	* target.h (struct target_ops) <to_execution_direction>: Add
	argument.
	(target_execution_direction): Add argument.
	* target.c (default_execution_direction): Add 'self' argument.
	* record-full.c (record_full_execution_direction): Add 'self'
	argument.

Add target_ops argument to to_supports_multi_process

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

	* target.h (struct target_ops) <to_supports_multi_process>: Add
	argument.
	(target_supports_multi_process): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_supports_multi_process): Add 'self' argument.
	* linux-nat.c (linux_nat_supports_multi_process): Add 'self'
	argument.
	* darwin-nat.c (darwin_supports_multi_process): Add 'self'
	argument.

Add target_ops argument to to_supports_enable_disable_tracepoint

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

	* target.h (struct target_ops)
	<to_supports_enable_disable_tracepoint>: Add argument.
	(target_supports_enable_disable_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_supports_enable_disable_tracepoint): Add 'self'
	argument.

Add target_ops argument to to_supports_disable_randomization

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

	* target.h (struct target_ops)
	<to_supports_disable_randomization>: Add argument.
	* target.c (find_default_supports_disable_randomization): Add
	argument.
	(target_supports_disable_randomization): Add argument.
	(find_default_supports_disable_randomization): Add 'self'
	argument.
	* remote.c (extended_remote_supports_disable_randomization): Add
	'self' argument.
	(remote_supports_disable_randomization): Add 'self' argument.
	(extended_remote_create_inferior): Update.
	* linux-nat.c (linux_nat_supports_disable_randomization): Add
	'self' argument.

Add target_ops argument to to_supports_string_tracing

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

	* target.h (struct target_ops) <to_supports_string_tracing>: Add
	argument.
	(target_supports_string_tracing): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_supports_string_tracing): Add 'self' argument.

Add target_ops argument to to_supports_evaluation_of_breakpoint_conditions

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

	* target.h (struct target_ops)
	<to_supports_evaluation_of_breakpoint_conditions>: Add argument.
	(target_supports_evaluation_of_breakpoint_conditions): Add
	argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_supports_cond_breakpoints): Add 'self'
	argument.
	(remote_insert_breakpoint): Add 'self' argument.
	(remote_insert_hw_breakpoint): Add 'self' argument.
	(remote_supports_cond_breakpoints): Add 'self' argument.

Add target_ops argument to to_can_run_breakpoint_commands

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

	* target.h (struct target_ops) <to_can_run_breakpoint_commands>:
	Add argument.
	(target_can_run_breakpoint_commands): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_can_run_breakpoint_commands): Add 'self'
	argument.
	(remote_insert_breakpoint): Add 'self' argument.
	(remote_insert_hw_breakpoint): Add 'self' argument.
	(remote_can_run_breakpoint_commands): Add 'self' argument.

Add target_ops argument to to_fileio_open

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

	* target.h (struct target_ops) <to_fileio_open>: Add argument.
	* target.c (target_fileio_open): Add argument.
	* remote.c (remote_hostio_open): Add 'self' argument.
	(remote_bfd_iovec_open): Add 'self' argument.
	(remote_file_put): Add 'self' argument.
	(remote_file_get): Add 'self' argument.
	* inf-child.c (inf_child_fileio_open): Add 'self' argument.
---
 gdb/ChangeLog       | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/darwin-nat.c    |   2 +-
 gdb/inf-child.c     |   3 +-
 gdb/linux-nat.c     |   4 +--
 gdb/record-btrace.c |   2 +-
 gdb/record-full.c   |   4 +--
 gdb/remote.c        |  42 ++++++++++++----------
 gdb/target.c        |  20 +++++------
 gdb/target.h        |  33 ++++++++---------
 9 files changed, 158 insertions(+), 52 deletions(-)

diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 2a716bc..e1bfe88 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -2059,7 +2059,7 @@ darwin_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
 }
 
 static int
-darwin_supports_multi_process (void)
+darwin_supports_multi_process (struct target_ops *self)
 {
   return 1;
 }
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index e047636..cd2aee6 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -231,7 +231,8 @@ inf_child_errno_to_fileio_error (int errnum)
    target file descriptor, or -1 if an error occurs (and set
    *TARGET_ERRNO).  */
 static int
-inf_child_fileio_open (const char *filename, int flags, int mode,
+inf_child_fileio_open (struct target_ops *self,
+		       const char *filename, int flags, int mode,
 		       int *target_errno)
 {
   int nat_flags;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 2181648..a1dc8fa 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4529,13 +4529,13 @@ linux_nat_supports_non_stop (struct target_ops *self)
 int linux_multi_process = 1;
 
 static int
-linux_nat_supports_multi_process (void)
+linux_nat_supports_multi_process (struct target_ops *self)
 {
   return linux_multi_process;
 }
 
 static int
-linux_nat_supports_disable_randomization (void)
+linux_nat_supports_disable_randomization (struct target_ops *self)
 {
 #ifdef HAVE_PERSONALITY
   return 1;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 7d43330..94ff83d 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1712,7 +1712,7 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid,
 /* The to_can_execute_reverse method of target record-btrace.  */
 
 static int
-record_btrace_can_execute_reverse (void)
+record_btrace_can_execute_reverse (struct target_ops *self)
 {
   return 1;
 }
diff --git a/gdb/record-full.c b/gdb/record-full.c
index a825f5a..755c815 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1693,7 +1693,7 @@ record_full_remove_breakpoint (struct target_ops *ops,
 /* "to_can_execute_reverse" method for process record target.  */
 
 static int
-record_full_can_execute_reverse (void)
+record_full_can_execute_reverse (struct target_ops *self)
 {
   return 1;
 }
@@ -1764,7 +1764,7 @@ record_full_is_async_p (struct target_ops *ops)
 }
 
 static enum exec_direction_kind
-record_full_execution_direction (void)
+record_full_execution_direction (struct target_ops *self)
 {
   return record_full_execution_dir;
 }
diff --git a/gdb/remote.c b/gdb/remote.c
index 0e24500..d5054c8 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -231,9 +231,9 @@ static int remote_read_description_p (struct target_ops *target);
 
 static void remote_console_output (char *msg);
 
-static int remote_supports_cond_breakpoints (void);
+static int remote_supports_cond_breakpoints (struct target_ops *self);
 
-static int remote_can_run_breakpoint_commands (void);
+static int remote_can_run_breakpoint_commands (struct target_ops *self);
 
 /* For "remote".  */
 
@@ -8041,7 +8041,7 @@ extended_remote_mourn (struct target_ops *ops)
 }
 
 static int
-extended_remote_supports_disable_randomization (void)
+extended_remote_supports_disable_randomization (struct target_ops *self)
 {
   return (remote_protocol_packets[PACKET_QDisableRandomization].support
 	  == PACKET_ENABLE);
@@ -8145,7 +8145,7 @@ extended_remote_create_inferior (struct target_ops *ops,
     target_async (inferior_event_handler, 0);
 
   /* Disable address space randomization if requested (and supported).  */
-  if (extended_remote_supports_disable_randomization ())
+  if (extended_remote_supports_disable_randomization (ops))
     extended_remote_disable_randomization (disable_randomization);
 
   /* Now restart the remote server.  */
@@ -8286,10 +8286,10 @@ remote_insert_breakpoint (struct target_ops *ops,
       p += hexnumstr (p, addr);
       xsnprintf (p, endbuf - p, ",%d", bpsize);
 
-      if (remote_supports_cond_breakpoints ())
+      if (remote_supports_cond_breakpoints (ops))
 	remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
 
-      if (remote_can_run_breakpoint_commands ())
+      if (remote_can_run_breakpoint_commands (ops))
 	remote_add_target_side_commands (gdbarch, bp_tgt, p);
 
       putpkt (rs->buf);
@@ -8565,10 +8565,10 @@ remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
   p += hexnumstr (p, (ULONGEST) addr);
   xsnprintf (p, endbuf - p, ",%x", bp_tgt->placed_size);
 
-  if (remote_supports_cond_breakpoints ())
+  if (remote_supports_cond_breakpoints (self))
     remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
 
-  if (remote_can_run_breakpoint_commands ())
+  if (remote_can_run_breakpoint_commands (self))
     remote_add_target_side_commands (gdbarch, bp_tgt, p);
 
   putpkt (rs->buf);
@@ -9845,7 +9845,8 @@ remote_hostio_send_command (int command_bytes, int which_packet,
    *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_open (const char *filename, int flags, int mode,
+remote_hostio_open (struct target_ops *self,
+		    const char *filename, int flags, int mode,
 		    int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
@@ -10091,7 +10092,8 @@ remote_bfd_iovec_open (struct bfd *abfd, void *open_closure)
 
   gdb_assert (remote_filename_p (filename));
 
-  fd = remote_hostio_open (filename + 7, FILEIO_O_RDONLY, 0, &remote_errno);
+  fd = remote_hostio_open (find_target_at (process_stratum),
+			   filename + 7, FILEIO_O_RDONLY, 0, &remote_errno);
   if (fd == -1)
     {
       errno = remote_fileio_errno_to_host (remote_errno);
@@ -10197,7 +10199,8 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty)
     perror_with_name (local_file);
   back_to = make_cleanup_fclose (file);
 
-  fd = remote_hostio_open (remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
+  fd = remote_hostio_open (find_target_at (process_stratum),
+			   remote_file, (FILEIO_O_WRONLY | FILEIO_O_CREAT
 					 | FILEIO_O_TRUNC),
 			   0700, &remote_errno);
   if (fd == -1)
@@ -10281,7 +10284,8 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty)
   if (!rs->remote_desc)
     error (_("command can only be used with remote target"));
 
-  fd = remote_hostio_open (remote_file, FILEIO_O_RDONLY, 0, &remote_errno);
+  fd = remote_hostio_open (find_target_at (process_stratum),
+			   remote_file, FILEIO_O_RDONLY, 0, &remote_errno);
   if (fd == -1)
     remote_hostio_error (remote_errno);
 
@@ -10405,7 +10409,7 @@ remote_command (char *args, int from_tty)
 }
 
 static int
-remote_can_execute_reverse (void)
+remote_can_execute_reverse (struct target_ops *self)
 {
   if (remote_protocol_packets[PACKET_bs].support == PACKET_ENABLE
       || remote_protocol_packets[PACKET_bc].support == PACKET_ENABLE)
@@ -10421,14 +10425,14 @@ remote_supports_non_stop (struct target_ops *self)
 }
 
 static int
-remote_supports_disable_randomization (void)
+remote_supports_disable_randomization (struct target_ops *self)
 {
   /* Only supported in extended mode.  */
   return 0;
 }
 
 static int
-remote_supports_multi_process (void)
+remote_supports_multi_process (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -10448,7 +10452,7 @@ remote_supports_cond_tracepoints (void)
 }
 
 static int
-remote_supports_cond_breakpoints (void)
+remote_supports_cond_breakpoints (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -10480,7 +10484,7 @@ remote_supports_install_in_trace (void)
 }
 
 static int
-remote_supports_enable_disable_tracepoint (void)
+remote_supports_enable_disable_tracepoint (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -10488,7 +10492,7 @@ remote_supports_enable_disable_tracepoint (void)
 }
 
 static int
-remote_supports_string_tracing (void)
+remote_supports_string_tracing (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -10496,7 +10500,7 @@ remote_supports_string_tracing (void)
 }
 
 static int
-remote_can_run_breakpoint_commands (void)
+remote_can_run_breakpoint_commands (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
 
diff --git a/gdb/target.c b/gdb/target.c
index 1716c45..37d44e8 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -543,7 +543,7 @@ default_get_ada_task_ptid (struct target_ops *self, long lwp, long tid)
 }
 
 static enum exec_direction_kind
-default_execution_direction (void)
+default_execution_direction (struct target_ops *self)
 {
   if (!target_can_execute_reverse)
     return EXEC_FORWARD;
@@ -840,13 +840,13 @@ update_current_target (void)
             (ptid_t (*) (struct target_ops *, long, long))
             default_get_ada_task_ptid);
   de_fault (to_supports_multi_process,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_supports_enable_disable_tracepoint,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_supports_string_tracing,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_trace_init,
 	    (void (*) (void))
@@ -930,10 +930,10 @@ update_current_target (void)
 	    (struct traceframe_info * (*) (void))
 	    return_null);
   de_fault (to_supports_evaluation_of_breakpoint_conditions,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_can_run_breakpoint_commands,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_use_agent,
 	    (int (*) (int))
@@ -3206,13 +3206,13 @@ target_info_proc (char *args, enum info_proc_what what)
 }
 
 static int
-find_default_supports_disable_randomization (void)
+find_default_supports_disable_randomization (struct target_ops *self)
 {
   struct target_ops *t;
 
   t = find_default_run_target (NULL);
   if (t && t->to_supports_disable_randomization)
-    return (t->to_supports_disable_randomization) ();
+    return (t->to_supports_disable_randomization) (t);
   return 0;
 }
 
@@ -3223,7 +3223,7 @@ target_supports_disable_randomization (void)
 
   for (t = &current_target; t != NULL; t = t->beneath)
     if (t->to_supports_disable_randomization)
-      return t->to_supports_disable_randomization ();
+      return t->to_supports_disable_randomization (t);
 
   return 0;
 }
@@ -3311,7 +3311,7 @@ target_fileio_open (const char *filename, int flags, int mode,
     {
       if (t->to_fileio_open != NULL)
 	{
-	  int fd = t->to_fileio_open (filename, flags, mode, target_errno);
+	  int fd = t->to_fileio_open (t, filename, flags, mode, target_errno);
 
 	  if (targetdebug)
 	    fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/target.h b/gdb/target.h
index 419842f..72a811b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -650,34 +650,34 @@ struct target_ops
 			     CORE_ADDR *found_addrp);
 
     /* Can target execute in reverse?  */
-    int (*to_can_execute_reverse) (void);
+    int (*to_can_execute_reverse) (struct target_ops *);
 
     /* The direction the target is currently executing.  Must be
        implemented on targets that support reverse execution and async
        mode.  The default simply returns forward execution.  */
-    enum exec_direction_kind (*to_execution_direction) (void);
+    enum exec_direction_kind (*to_execution_direction) (struct target_ops *);
 
     /* Does this target support debugging multiple processes
        simultaneously?  */
-    int (*to_supports_multi_process) (void);
+    int (*to_supports_multi_process) (struct target_ops *);
 
     /* Does this target support enabling and disabling tracepoints while a trace
        experiment is running?  */
-    int (*to_supports_enable_disable_tracepoint) (void);
+    int (*to_supports_enable_disable_tracepoint) (struct target_ops *);
 
     /* Does this target support disabling address space randomization?  */
-    int (*to_supports_disable_randomization) (void);
+    int (*to_supports_disable_randomization) (struct target_ops *);
 
     /* Does this target support the tracenz bytecode for string collection?  */
-    int (*to_supports_string_tracing) (void);
+    int (*to_supports_string_tracing) (struct target_ops *);
 
     /* Does this target support evaluation of breakpoint conditions on its
        end?  */
-    int (*to_supports_evaluation_of_breakpoint_conditions) (void);
+    int (*to_supports_evaluation_of_breakpoint_conditions) (struct target_ops *);
 
     /* Does this target support evaluation of breakpoint commands on its
        end?  */
-    int (*to_can_run_breakpoint_commands) (void);
+    int (*to_can_run_breakpoint_commands) (struct target_ops *);
 
     /* Determine current architecture of thread PTID.
 
@@ -703,7 +703,8 @@ struct target_ops
     /* Open FILENAME on the target, using FLAGS and MODE.  Return a
        target file descriptor, or -1 if an error occurs (and set
        *TARGET_ERRNO).  */
-    int (*to_fileio_open) (const char *filename, int flags, int mode,
+    int (*to_fileio_open) (struct target_ops *,
+			   const char *filename, int flags, int mode,
 			   int *target_errno);
 
     /* Write up to LEN bytes from WRITE_BUF to FD on the target.
@@ -1091,7 +1092,7 @@ int target_info_proc (char *, enum info_proc_what);
    simultaneously.  */
 
 #define	target_supports_multi_process()	\
-     (*current_target.to_supports_multi_process) ()
+     (*current_target.to_supports_multi_process) (&current_target)
 
 /* Returns true if this target can disable address space randomization.  */
 
@@ -1101,22 +1102,22 @@ int target_supports_disable_randomization (void);
    while a trace experiment is running.  */
 
 #define target_supports_enable_disable_tracepoint() \
-  (*current_target.to_supports_enable_disable_tracepoint) ()
+  (*current_target.to_supports_enable_disable_tracepoint) (&current_target)
 
 #define target_supports_string_tracing() \
-  (*current_target.to_supports_string_tracing) ()
+  (*current_target.to_supports_string_tracing) (&current_target)
 
 /* Returns true if this target can handle breakpoint conditions
    on its end.  */
 
 #define target_supports_evaluation_of_breakpoint_conditions() \
-  (*current_target.to_supports_evaluation_of_breakpoint_conditions) ()
+  (*current_target.to_supports_evaluation_of_breakpoint_conditions) (&current_target)
 
 /* Returns true if this target can handle breakpoint commands
    on its end.  */
 
 #define target_can_run_breakpoint_commands() \
-  (*current_target.to_can_run_breakpoint_commands) ()
+  (*current_target.to_can_run_breakpoint_commands) (&current_target)
 
 extern int target_read_string (CORE_ADDR, char **, int, int *);
 
@@ -1499,7 +1500,7 @@ int target_supports_non_stop (void);
      (current_target.to_async (&current_target, (CALLBACK), (CONTEXT)))
 
 #define target_execution_direction() \
-  (current_target.to_execution_direction ())
+  (current_target.to_execution_direction (&current_target))
 
 /* Converts a process id to a string.  Usually, the string just contains
    `process xyz', but on some systems it may contain
@@ -1685,7 +1686,7 @@ extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask);
 /* Target can execute in reverse?  */
 #define target_can_execute_reverse \
      (current_target.to_can_execute_reverse ? \
-      current_target.to_can_execute_reverse () : 0)
+      current_target.to_can_execute_reverse (&current_target) : 0)
 
 extern const struct target_desc *target_read_description (struct target_ops *);
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 19/38] convert to_remove_watchpoint
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (26 preceding siblings ...)
  2014-02-06 21:23 ` [RFC v2 12/38] Add target_ops argument to to_can_execute_reverse Tom Tromey
@ 2014-02-06 21:23 ` Tom Tromey
  2014-02-06 21:23 ` [RFC v2 06/38] introduce remote_load Tom Tromey
                   ` (11 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_remove_watchpoint.
	* target.h (struct target_ops) <to_remove_watchpoint>: Use
	TARGET_DEFAULT_NORETURN.

convert to_watchpoint_addr_within_range

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_watchpoint_addr_within_range.
	* target.h (struct target_ops) <to_watchpoint_addr_within_range>:
	Use TARGET_DEFAULT_FUNC.

convert to_region_ok_for_hw_watchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_region_ok_for_hw_watchpoint.
	* target.h (struct target_ops) <to_region_ok_for_hw_watchpoint>:
	Use TARGET_DEFAULT_FUNC.

convert to_can_accel_watchpoint_condition

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_can_accel_watchpoint_condition.
	* target.h (struct target_ops)
	<to_can_accel_watchpoint_condition>: Use TARGET_DEFAULT_RETURN.

convert to_terminal_init

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_terminal_init.
	* target.h (struct target_ops) <to_terminal_init>: Use
	TARGET_DEFAULT_IGNORE.

convert to_terminal_inferior

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_terminal_inferior.
	* target.h (struct target_ops) <to_terminal_inferior>: Use
	TARGET_DEFAULT_IGNORE.

convert to_terminal_ours_for_output

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_terminal_ours_for_output.
	* target.h (struct target_ops) <to_terminal_ours_for_output>: Use
	TARGET_DEFAULT_IGNORE.

convert to_terminal_ours

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_terminal_ours.
	* target.h (struct target_ops) <to_terminal_ours>: Use
	TARGET_DEFAULT_IGNORE.

convert to_terminal_save_ours

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_terminal_save_ours.
	* target.h (struct target_ops) <to_terminal_save_ours>: Use
	TARGET_DEFAULT_IGNORE.

convert to_terminal_info

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_terminal_info.
	* target.h (struct target_ops) <to_terminal_info>: Use
	TARGET_DEFAULT_FUNC.
---
 gdb/ChangeLog          |  80 +++++++++++++++++++++++++++++
 gdb/target-delegates.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  49 ++++--------------
 gdb/target.h           |  30 +++++++----
 4 files changed, 247 insertions(+), 49 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 6e26824..7a673ee 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -152,6 +152,19 @@ tdefault_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, st
 }
 
 static int
+delegate_remove_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
+{
+  self = self->beneath;
+  return self->to_remove_watchpoint (self, arg1, arg2, arg3, arg4);
+}
+
+static int
+tdefault_remove_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
+{
+  return -1;
+}
+
+static int
 delegate_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
 {
   self = self->beneath;
@@ -190,6 +203,100 @@ tdefault_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
   return 0;
 }
 
+static int
+delegate_watchpoint_addr_within_range (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3)
+{
+  self = self->beneath;
+  return self->to_watchpoint_addr_within_range (self, arg1, arg2, arg3);
+}
+
+static int
+delegate_region_ok_for_hw_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2)
+{
+  self = self->beneath;
+  return self->to_region_ok_for_hw_watchpoint (self, arg1, arg2);
+}
+
+static int
+delegate_can_accel_watchpoint_condition (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
+{
+  self = self->beneath;
+  return self->to_can_accel_watchpoint_condition (self, arg1, arg2, arg3, arg4);
+}
+
+static int
+tdefault_can_accel_watchpoint_condition (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
+{
+  return 0;
+}
+
+static void
+delegate_terminal_init (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_terminal_init (self);
+}
+
+static void
+tdefault_terminal_init (struct target_ops *self)
+{
+}
+
+static void
+delegate_terminal_inferior (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_terminal_inferior (self);
+}
+
+static void
+tdefault_terminal_inferior (struct target_ops *self)
+{
+}
+
+static void
+delegate_terminal_ours_for_output (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_terminal_ours_for_output (self);
+}
+
+static void
+tdefault_terminal_ours_for_output (struct target_ops *self)
+{
+}
+
+static void
+delegate_terminal_ours (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_terminal_ours (self);
+}
+
+static void
+tdefault_terminal_ours (struct target_ops *self)
+{
+}
+
+static void
+delegate_terminal_save_ours (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_terminal_save_ours (self);
+}
+
+static void
+tdefault_terminal_save_ours (struct target_ops *self)
+{
+}
+
+static void
+delegate_terminal_info (struct target_ops *self, const char *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_terminal_info (self, arg1, arg2);
+}
+
 static void
 delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2)
 {
@@ -279,12 +386,32 @@ install_delegators (struct target_ops *ops)
     ops->to_insert_hw_breakpoint = delegate_insert_hw_breakpoint;
   if (ops->to_remove_hw_breakpoint == NULL)
     ops->to_remove_hw_breakpoint = delegate_remove_hw_breakpoint;
+  if (ops->to_remove_watchpoint == NULL)
+    ops->to_remove_watchpoint = delegate_remove_watchpoint;
   if (ops->to_insert_watchpoint == NULL)
     ops->to_insert_watchpoint = delegate_insert_watchpoint;
   if (ops->to_stopped_by_watchpoint == NULL)
     ops->to_stopped_by_watchpoint = delegate_stopped_by_watchpoint;
   if (ops->to_stopped_data_address == NULL)
     ops->to_stopped_data_address = delegate_stopped_data_address;
+  if (ops->to_watchpoint_addr_within_range == NULL)
+    ops->to_watchpoint_addr_within_range = delegate_watchpoint_addr_within_range;
+  if (ops->to_region_ok_for_hw_watchpoint == NULL)
+    ops->to_region_ok_for_hw_watchpoint = delegate_region_ok_for_hw_watchpoint;
+  if (ops->to_can_accel_watchpoint_condition == NULL)
+    ops->to_can_accel_watchpoint_condition = delegate_can_accel_watchpoint_condition;
+  if (ops->to_terminal_init == NULL)
+    ops->to_terminal_init = delegate_terminal_init;
+  if (ops->to_terminal_inferior == NULL)
+    ops->to_terminal_inferior = delegate_terminal_inferior;
+  if (ops->to_terminal_ours_for_output == NULL)
+    ops->to_terminal_ours_for_output = delegate_terminal_ours_for_output;
+  if (ops->to_terminal_ours == NULL)
+    ops->to_terminal_ours = delegate_terminal_ours;
+  if (ops->to_terminal_save_ours == NULL)
+    ops->to_terminal_save_ours = delegate_terminal_save_ours;
+  if (ops->to_terminal_info == NULL)
+    ops->to_terminal_info = delegate_terminal_info;
   if (ops->to_rcmd == NULL)
     ops->to_rcmd = delegate_rcmd;
   if (ops->to_can_async_p == NULL)
@@ -315,9 +442,19 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_can_use_hw_breakpoint = tdefault_can_use_hw_breakpoint;
   ops->to_insert_hw_breakpoint = tdefault_insert_hw_breakpoint;
   ops->to_remove_hw_breakpoint = tdefault_remove_hw_breakpoint;
+  ops->to_remove_watchpoint = tdefault_remove_watchpoint;
   ops->to_insert_watchpoint = tdefault_insert_watchpoint;
   ops->to_stopped_by_watchpoint = tdefault_stopped_by_watchpoint;
   ops->to_stopped_data_address = tdefault_stopped_data_address;
+  ops->to_watchpoint_addr_within_range = default_watchpoint_addr_within_range;
+  ops->to_region_ok_for_hw_watchpoint = default_region_ok_for_hw_watchpoint;
+  ops->to_can_accel_watchpoint_condition = tdefault_can_accel_watchpoint_condition;
+  ops->to_terminal_init = tdefault_terminal_init;
+  ops->to_terminal_inferior = tdefault_terminal_inferior;
+  ops->to_terminal_ours_for_output = tdefault_terminal_ours_for_output;
+  ops->to_terminal_ours = tdefault_terminal_ours;
+  ops->to_terminal_save_ours = tdefault_terminal_save_ours;
+  ops->to_terminal_info = default_terminal_info;
   ops->to_rcmd = default_rcmd;
   ops->to_can_async_p = find_default_can_async_p;
   ops->to_is_async_p = find_default_is_async_p;
diff --git a/gdb/target.c b/gdb/target.c
index 559ae5f..0c31f47 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -609,23 +609,23 @@ update_current_target (void)
       /* Do not inherit to_remove_hw_breakpoint.  */
       /* Do not inherit to_ranged_break_num_registers.  */
       /* Do not inherit to_insert_watchpoint.  */
-      INHERIT (to_remove_watchpoint, t);
+      /* Do not inherit to_remove_watchpoint.  */
       /* Do not inherit to_insert_mask_watchpoint.  */
       /* Do not inherit to_remove_mask_watchpoint.  */
       /* Do not inherit to_stopped_data_address.  */
       INHERIT (to_have_steppable_watchpoint, t);
       INHERIT (to_have_continuable_watchpoint, t);
       /* Do not inherit to_stopped_by_watchpoint.  */
-      INHERIT (to_watchpoint_addr_within_range, t);
-      INHERIT (to_region_ok_for_hw_watchpoint, t);
-      INHERIT (to_can_accel_watchpoint_condition, t);
+      /* Do not inherit to_watchpoint_addr_within_range.  */
+      /* Do not inherit to_region_ok_for_hw_watchpoint.  */
+      /* Do not inherit to_can_accel_watchpoint_condition.  */
       /* Do not inherit to_masked_watch_num_registers.  */
-      INHERIT (to_terminal_init, t);
-      INHERIT (to_terminal_inferior, t);
-      INHERIT (to_terminal_ours_for_output, t);
-      INHERIT (to_terminal_ours, t);
-      INHERIT (to_terminal_save_ours, t);
-      INHERIT (to_terminal_info, t);
+      /* Do not inherit to_terminal_init.  */
+      /* Do not inherit to_terminal_inferior.  */
+      /* Do not inherit to_terminal_ours_for_output.  */
+      /* Do not inherit to_terminal_ours.  */
+      /* Do not inherit to_terminal_save_ours.  */
+      /* Do not inherit to_terminal_info.  */
       /* Do not inherit to_kill.  */
       INHERIT (to_load, t);
       /* Do no inherit to_create_inferior.  */
@@ -734,35 +734,6 @@ update_current_target (void)
 	    (int (*) (CORE_ADDR, gdb_byte *, int, int,
 		      struct mem_attrib *, struct target_ops *))
 	    nomemory);
-  de_fault (to_remove_watchpoint,
-	    (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);
-  de_fault (to_region_ok_for_hw_watchpoint,
-	    default_region_ok_for_hw_watchpoint);
-  de_fault (to_can_accel_watchpoint_condition,
-            (int (*) (struct target_ops *, CORE_ADDR, int, int,
-		      struct expression *))
-            return_zero);
-  de_fault (to_terminal_init,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
-  de_fault (to_terminal_inferior,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
-  de_fault (to_terminal_ours_for_output,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
-  de_fault (to_terminal_ours,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
-  de_fault (to_terminal_save_ours,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
-  de_fault (to_terminal_info,
-	    default_terminal_info);
   de_fault (to_load,
 	    (void (*) (struct target_ops *, char *, int))
 	    tcomplain);
diff --git a/gdb/target.h b/gdb/target.h
index ad552a9..001b161 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) (struct target_ops *,
-				 CORE_ADDR, int, int, struct expression *);
+				 CORE_ADDR, int, int, struct expression *)
+      TARGET_DEFAULT_RETURN (-1);
     int (*to_insert_watchpoint) (struct target_ops *,
 				 CORE_ADDR, int, int, struct expression *)
       TARGET_DEFAULT_RETURN (-1);
@@ -475,24 +476,33 @@ struct target_ops
     int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *)
       TARGET_DEFAULT_RETURN (0);
     int (*to_watchpoint_addr_within_range) (struct target_ops *,
-					    CORE_ADDR, CORE_ADDR, int);
+					    CORE_ADDR, CORE_ADDR, int)
+      TARGET_DEFAULT_FUNC (default_watchpoint_addr_within_range);
 
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
     int (*to_region_ok_for_hw_watchpoint) (struct target_ops *,
-					   CORE_ADDR, int);
+					   CORE_ADDR, int)
+      TARGET_DEFAULT_FUNC (default_region_ok_for_hw_watchpoint);
 
     int (*to_can_accel_watchpoint_condition) (struct target_ops *,
 					      CORE_ADDR, int, int,
-					      struct expression *);
+					      struct expression *)
+      TARGET_DEFAULT_RETURN (0);
     int (*to_masked_watch_num_registers) (struct target_ops *,
 					  CORE_ADDR, CORE_ADDR);
-    void (*to_terminal_init) (struct target_ops *);
-    void (*to_terminal_inferior) (struct target_ops *);
-    void (*to_terminal_ours_for_output) (struct target_ops *);
-    void (*to_terminal_ours) (struct target_ops *);
-    void (*to_terminal_save_ours) (struct target_ops *);
-    void (*to_terminal_info) (struct target_ops *, const char *, int);
+    void (*to_terminal_init) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
+    void (*to_terminal_inferior) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
+    void (*to_terminal_ours_for_output) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
+    void (*to_terminal_ours) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
+    void (*to_terminal_save_ours) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
+    void (*to_terminal_info) (struct target_ops *, const char *, int)
+      TARGET_DEFAULT_FUNC (default_terminal_info);
     void (*to_kill) (struct target_ops *);
     void (*to_load) (struct target_ops *, char *, int);
     void (*to_create_inferior) (struct target_ops *, 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 14/38] Add target_ops argument to to_disable_tracepoint
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (32 preceding siblings ...)
  2014-02-06 21:24 ` [RFC v2 31/38] minor cleanups to update_current_target Tom Tromey
@ 2014-02-06 21:24 ` Tom Tromey
  2014-02-06 21:38 ` [RFC v2 30/38] change delegation for to_read_description Tom Tromey
                   ` (5 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_disable_tracepoint>: Add
	argument.
	(target_disable_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_disable_tracepoint): Add 'self' argument.

Add target_ops argument to to_trace_set_readonly_regions

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

	* target.h (struct target_ops) <to_trace_set_readonly_regions>:
	Add argument.
	(target_trace_set_readonly_regions): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_trace_set_readonly_regions): Add 'self'
	argument.

Add target_ops argument to to_trace_start

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

	* target.h (struct target_ops) <to_trace_start>: Add argument.
	(target_trace_start): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_trace_start): Add 'self' argument.

Add target_ops argument to to_get_trace_status

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

	* tracepoint.c (tfile_get_trace_status): Add 'self' argument.
	* target.h (struct target_ops) <to_get_trace_status>: Add
	argument.
	(target_get_trace_status): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_get_trace_status): Add 'self' argument.
	(remote_start_remote, remote_can_download_tracepoint): Update.
	* ctf.c (ctf_get_trace_status): Add 'self' argument.

Add target_ops argument to to_get_tracepoint_status

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

	* tracepoint.c (tfile_get_tracepoint_status): Add 'self' argument.
	* target.h (struct target_ops) <to_get_tracepoint_status>: Add
	argument.
	(target_get_tracepoint_status): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_get_tracepoint_status): Add 'self' argument.

Add target_ops argument to to_trace_stop

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

	* target.h (struct target_ops) <to_trace_stop>: Add argument.
	(target_trace_stop): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_trace_stop): Add 'self' argument.

Add target_ops argument to to_trace_find

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

	* tracepoint.c (tfile_trace_find): Add 'self' argument.
	* target.h (struct target_ops) <to_trace_find>: Add argument.
	(target_trace_find): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_trace_find): Add 'self' argument.
	* ctf.c (ctf_trace_find): Add 'self' argument.

Add target_ops argument to to_get_trace_state_variable_value

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

	* tracepoint.c (tfile_get_trace_state_variable_value): Add 'self'
	argument.
	* target.h (struct target_ops)
	<to_get_trace_state_variable_value>: Add argument.
	(target_get_trace_state_variable_value): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_get_trace_state_variable_value): Add 'self'
	argument.
	* ctf.c (ctf_get_trace_state_variable_value): Add 'self' argument.

Add target_ops argument to to_save_trace_data

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

	* target.h (struct target_ops) <to_save_trace_data>: Add argument.
	(target_save_trace_data): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_save_trace_data): Add 'self' argument.

Add target_ops argument to to_upload_tracepoints

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

	* target.h (struct target_ops) <to_upload_tracepoints>: Add
	argument.
	(target_upload_tracepoints): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_upload_tracepoints): Add 'self' argument.
	(remote_start_remote): Update.
---
 gdb/ChangeLog    | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/ctf.c        |  7 +++--
 gdb/remote.c     | 37 +++++++++++++-----------
 gdb/target.c     | 22 +++++++-------
 gdb/target.h     | 47 +++++++++++++++++-------------
 gdb/tracepoint.c | 10 ++++---
 6 files changed, 158 insertions(+), 53 deletions(-)

diff --git a/gdb/ctf.c b/gdb/ctf.c
index 6caca5f..67cc1c7 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1503,7 +1503,8 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object,
    true, otherwise return false.  */
 
 static int
-ctf_get_trace_state_variable_value (int tsvnum, LONGEST *val)
+ctf_get_trace_state_variable_value (struct target_ops *self,
+				    int tsvnum, LONGEST *val)
 {
   struct bt_iter_pos *pos;
   int found = 0;
@@ -1620,7 +1621,7 @@ ctf_get_traceframe_address (void)
    number in it.  Return traceframe number when matched.  */
 
 static int
-ctf_trace_find (enum trace_find_type type, int num,
+ctf_trace_find (struct target_ops *self, enum trace_find_type type, int num,
 		CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
 {
   int ret = -1;
@@ -1824,7 +1825,7 @@ ctf_traceframe_info (void)
    The trace status for a file is that tracing can never be run.  */
 
 static int
-ctf_get_trace_status (struct trace_status *ts)
+ctf_get_trace_status (struct target_ops *self, struct trace_status *ts)
 {
   /* Other bits of trace status were collected as part of opening the
      trace files, so nothing to do here.  */
diff --git a/gdb/remote.c b/gdb/remote.c
index 107fd5b..b7ad654 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -204,9 +204,11 @@ static ptid_t read_ptid (char *buf, char **obuf);
 static void remote_set_permissions (void);
 
 struct remote_state;
-static int remote_get_trace_status (struct trace_status *ts);
+static int remote_get_trace_status (struct target_ops *self,
+				    struct trace_status *ts);
 
-static int remote_upload_tracepoints (struct uploaded_tp **utpp);
+static int remote_upload_tracepoints (struct target_ops *self,
+				      struct uploaded_tp **utpp);
 
 static int remote_upload_trace_state_variables (struct uploaded_tsv **utsvp);
   
@@ -3505,7 +3507,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
   /* Upload TSVs regardless of whether the target is running or not.  The
      remote stub, such as GDBserver, may have some predefined or builtin
      TSVs, even if the target is not running.  */
-  if (remote_get_trace_status (current_trace_status ()) != -1)
+  if (remote_get_trace_status (target, current_trace_status ()) != -1)
     {
       struct uploaded_tsv *uploaded_tsvs = NULL;
 
@@ -3674,14 +3676,14 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
 
   /* Possibly the target has been engaged in a trace run started
      previously; find out where things are at.  */
-  if (remote_get_trace_status (current_trace_status ()) != -1)
+  if (remote_get_trace_status (target, current_trace_status ()) != -1)
     {
       struct uploaded_tp *uploaded_tps = NULL;
 
       if (current_trace_status ()->running)
 	printf_filtered (_("Trace is already running on the target.\n"));
 
-      remote_upload_tracepoints (&uploaded_tps);
+      remote_upload_tracepoints (target, &uploaded_tps);
 
       merge_uploaded_tracepoints (&uploaded_tps);
     }
@@ -10777,7 +10779,7 @@ remote_can_download_tracepoint (struct target_ops *self)
     return 0;
 
   ts = current_trace_status ();
-  status = remote_get_trace_status (ts);
+  status = remote_get_trace_status (self, ts);
 
   if (status == -1 || !ts->running_known || !ts->running)
     return 0;
@@ -10833,7 +10835,8 @@ remote_enable_tracepoint (struct target_ops *self,
 }
 
 static void
-remote_disable_tracepoint (struct bp_location *location)
+remote_disable_tracepoint (struct target_ops *self,
+			   struct bp_location *location)
 {
   struct remote_state *rs = get_remote_state ();
   char addr_buf[40];
@@ -10850,7 +10853,7 @@ remote_disable_tracepoint (struct bp_location *location)
 }
 
 static void
-remote_trace_set_readonly_regions (void)
+remote_trace_set_readonly_regions (struct target_ops *self)
 {
   asection *s;
   bfd *abfd = NULL;
@@ -10900,7 +10903,7 @@ Too many sections for read-only sections definition packet."));
 }
 
 static void
-remote_trace_start (void)
+remote_trace_start (struct target_ops *self)
 {
   putpkt ("QTStart");
   remote_get_noisy_reply (&target_buf, &target_buf_size);
@@ -10911,7 +10914,7 @@ remote_trace_start (void)
 }
 
 static int
-remote_get_trace_status (struct trace_status *ts)
+remote_get_trace_status (struct target_ops *self, struct trace_status *ts)
 {
   /* Initialize it just to avoid a GCC false warning.  */
   char *p = NULL;
@@ -10961,7 +10964,7 @@ remote_get_trace_status (struct trace_status *ts)
 }
 
 static void
-remote_get_tracepoint_status (struct breakpoint *bp,
+remote_get_tracepoint_status (struct target_ops *self, struct breakpoint *bp,
 			      struct uploaded_tp *utp)
 {
   struct remote_state *rs = get_remote_state ();
@@ -11008,7 +11011,7 @@ remote_get_tracepoint_status (struct breakpoint *bp,
 }
 
 static void
-remote_trace_stop (void)
+remote_trace_stop (struct target_ops *self)
 {
   putpkt ("QTStop");
   remote_get_noisy_reply (&target_buf, &target_buf_size);
@@ -11019,7 +11022,8 @@ remote_trace_stop (void)
 }
 
 static int
-remote_trace_find (enum trace_find_type type, int num,
+remote_trace_find (struct target_ops *self,
+		   enum trace_find_type type, int num,
 		   CORE_ADDR addr1, CORE_ADDR addr2,
 		   int *tpp)
 {
@@ -11101,7 +11105,8 @@ remote_trace_find (enum trace_find_type type, int num,
 }
 
 static int
-remote_get_trace_state_variable_value (int tsvnum, LONGEST *val)
+remote_get_trace_state_variable_value (struct target_ops *self,
+				       int tsvnum, LONGEST *val)
 {
   struct remote_state *rs = get_remote_state ();
   char *reply;
@@ -11125,7 +11130,7 @@ remote_get_trace_state_variable_value (int tsvnum, LONGEST *val)
 }
 
 static int
-remote_save_trace_data (const char *filename)
+remote_save_trace_data (struct target_ops *self, const char *filename)
 {
   struct remote_state *rs = get_remote_state ();
   char *p, *reply;
@@ -11837,7 +11842,7 @@ remote_new_objfile (struct objfile *objfile)
    collection.  */
   
 static int
-remote_upload_tracepoints (struct uploaded_tp **utpp)
+remote_upload_tracepoints (struct target_ops *self, struct uploaded_tp **utpp)
 {
   struct remote_state *rs = get_remote_state ();
   char *p;
diff --git a/gdb/target.c b/gdb/target.c
index b7f25ee..71dff46 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -864,34 +864,36 @@ update_current_target (void)
 	    (void (*) (struct target_ops *, struct bp_location *))
 	    tcomplain);
   de_fault (to_disable_tracepoint,
-	    (void (*) (struct bp_location *))
+	    (void (*) (struct target_ops *, struct bp_location *))
 	    tcomplain);
   de_fault (to_trace_set_readonly_regions,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    tcomplain);
   de_fault (to_trace_start,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    tcomplain);
   de_fault (to_get_trace_status,
-	    (int (*) (struct trace_status *))
+	    (int (*) (struct target_ops *, struct trace_status *))
 	    return_minus_one);
   de_fault (to_get_tracepoint_status,
-	    (void (*) (struct breakpoint *, struct uploaded_tp *))
+	    (void (*) (struct target_ops *, struct breakpoint *,
+		       struct uploaded_tp *))
 	    tcomplain);
   de_fault (to_trace_stop,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    tcomplain);
   de_fault (to_trace_find,
-	    (int (*) (enum trace_find_type, int, CORE_ADDR, CORE_ADDR, int *))
+	    (int (*) (struct target_ops *,
+		      enum trace_find_type, int, CORE_ADDR, CORE_ADDR, int *))
 	    return_minus_one);
   de_fault (to_get_trace_state_variable_value,
-	    (int (*) (int, LONGEST *))
+	    (int (*) (struct target_ops *, int, LONGEST *))
 	    return_zero);
   de_fault (to_save_trace_data,
-	    (int (*) (const char *))
+	    (int (*) (struct target_ops *, const char *))
 	    tcomplain);
   de_fault (to_upload_tracepoints,
-	    (int (*) (struct uploaded_tp **))
+	    (int (*) (struct target_ops *, struct uploaded_tp **))
 	    return_zero);
   de_fault (to_upload_trace_state_variables,
 	    (int (*) (struct uploaded_tsv **))
diff --git a/gdb/target.h b/gdb/target.h
index 71454dc..e53c041 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -762,41 +762,46 @@ struct target_ops
 				  struct bp_location *location);
 
     /* Disable a tracepoint on the target.  */
-    void (*to_disable_tracepoint) (struct bp_location *location);
+    void (*to_disable_tracepoint) (struct target_ops *,
+				   struct bp_location *location);
 
     /* Inform the target info of memory regions that are readonly
        (such as text sections), and so it should return data from
        those rather than look in the trace buffer.  */
-    void (*to_trace_set_readonly_regions) (void);
+    void (*to_trace_set_readonly_regions) (struct target_ops *);
 
     /* Start a trace run.  */
-    void (*to_trace_start) (void);
+    void (*to_trace_start) (struct target_ops *);
 
     /* Get the current status of a tracing run.  */
-    int (*to_get_trace_status) (struct trace_status *ts);
+    int (*to_get_trace_status) (struct target_ops *, struct trace_status *ts);
 
-    void (*to_get_tracepoint_status) (struct breakpoint *tp,
+    void (*to_get_tracepoint_status) (struct target_ops *,
+				      struct breakpoint *tp,
 				      struct uploaded_tp *utp);
 
     /* Stop a trace run.  */
-    void (*to_trace_stop) (void);
+    void (*to_trace_stop) (struct target_ops *);
 
    /* Ask the target to find a trace frame of the given type TYPE,
       using NUM, ADDR1, and ADDR2 as search parameters.  Returns the
       number of the trace frame, and also the tracepoint number at
       TPP.  If no trace frame matches, return -1.  May throw if the
       operation fails.  */
-    int (*to_trace_find) (enum trace_find_type type, int num,
+    int (*to_trace_find) (struct target_ops *,
+			  enum trace_find_type type, int num,
 			  CORE_ADDR addr1, CORE_ADDR addr2, int *tpp);
 
     /* Get the value of the trace state variable number TSV, returning
        1 if the value is known and writing the value itself into the
        location pointed to by VAL, else returning 0.  */
-    int (*to_get_trace_state_variable_value) (int tsv, LONGEST *val);
+    int (*to_get_trace_state_variable_value) (struct target_ops *,
+					      int tsv, LONGEST *val);
 
-    int (*to_save_trace_data) (const char *filename);
+    int (*to_save_trace_data) (struct target_ops *, const char *filename);
 
-    int (*to_upload_tracepoints) (struct uploaded_tp **utpp);
+    int (*to_upload_tracepoints) (struct target_ops *,
+				  struct uploaded_tp **utpp);
 
     int (*to_upload_trace_state_variables) (struct uploaded_tsv **utsvp);
 
@@ -1786,34 +1791,36 @@ extern char *target_fileio_read_stralloc (const char *filename);
   (*current_target.to_enable_tracepoint) (&current_target, loc)
 
 #define target_disable_tracepoint(loc) \
-  (*current_target.to_disable_tracepoint) (loc)
+  (*current_target.to_disable_tracepoint) (&current_target, loc)
 
 #define target_trace_start() \
-  (*current_target.to_trace_start) ()
+  (*current_target.to_trace_start) (&current_target)
 
 #define target_trace_set_readonly_regions() \
-  (*current_target.to_trace_set_readonly_regions) ()
+  (*current_target.to_trace_set_readonly_regions) (&current_target)
 
 #define target_get_trace_status(ts) \
-  (*current_target.to_get_trace_status) (ts)
+  (*current_target.to_get_trace_status) (&current_target, ts)
 
 #define target_get_tracepoint_status(tp,utp)		\
-  (*current_target.to_get_tracepoint_status) (tp, utp)
+  (*current_target.to_get_tracepoint_status) (&current_target, tp, utp)
 
 #define target_trace_stop() \
-  (*current_target.to_trace_stop) ()
+  (*current_target.to_trace_stop) (&current_target)
 
 #define target_trace_find(type,num,addr1,addr2,tpp) \
-  (*current_target.to_trace_find) ((type), (num), (addr1), (addr2), (tpp))
+  (*current_target.to_trace_find) (&current_target, \
+				   (type), (num), (addr1), (addr2), (tpp))
 
 #define target_get_trace_state_variable_value(tsv,val) \
-  (*current_target.to_get_trace_state_variable_value) ((tsv), (val))
+  (*current_target.to_get_trace_state_variable_value) (&current_target,	\
+						       (tsv), (val))
 
 #define target_save_trace_data(filename) \
-  (*current_target.to_save_trace_data) (filename)
+  (*current_target.to_save_trace_data) (&current_target, filename)
 
 #define target_upload_tracepoints(utpp) \
-  (*current_target.to_upload_tracepoints) (utpp)
+  (*current_target.to_upload_tracepoints) (&current_target, utpp)
 
 #define target_upload_trace_state_variables(utsvp) \
   (*current_target.to_upload_trace_state_variables) (utsvp)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index d4937be..a3d5405 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4783,7 +4783,7 @@ tfile_files_info (struct target_ops *t)
 /* The trace status for a file is that tracing can never be run.  */
 
 static int
-tfile_get_trace_status (struct trace_status *ts)
+tfile_get_trace_status (struct target_ops *self, struct trace_status *ts)
 {
   /* Other bits of trace status were collected as part of opening the
      trace files, so nothing to do here.  */
@@ -4792,7 +4792,8 @@ tfile_get_trace_status (struct trace_status *ts)
 }
 
 static void
-tfile_get_tracepoint_status (struct breakpoint *tp, struct uploaded_tp *utp)
+tfile_get_tracepoint_status (struct target_ops *self,
+			     struct breakpoint *tp, struct uploaded_tp *utp)
 {
   /* Other bits of trace status were collected as part of opening the
      trace files, so nothing to do here.  */
@@ -4837,7 +4838,7 @@ tfile_get_traceframe_address (off_t tframe_offset)
    each.  */
 
 static int
-tfile_trace_find (enum trace_find_type type, int num,
+tfile_trace_find (struct target_ops *self, enum trace_find_type type, int num,
 		  CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
 {
   short tpnum;
@@ -5206,7 +5207,8 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
    block with a matching tsv number.  */
 
 static int
-tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val)
+tfile_get_trace_state_variable_value (struct target_ops *self,
+				      int tsvnum, LONGEST *val)
 {
   int pos;
   int found = 0;
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 31/38] minor cleanups to update_current_target
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (31 preceding siblings ...)
  2014-02-06 21:24 ` [RFC v2 13/38] Add target_ops argument to to_fileio_pwrite Tom Tromey
@ 2014-02-06 21:24 ` Tom Tromey
  2014-02-06 21:24 ` [RFC v2 14/38] Add target_ops argument to to_disable_tracepoint Tom Tromey
                   ` (6 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

During the conversion I kept all the "do not inherit" comments in
update_current_target.  However, now they are not needed.  This patch
updates the comments for INHERIT and de_fault, and removes the
somewhat odd INHERIT of to_stratum.

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

	* target.c (update_current_target): Update comments.  Do not
	INHERIT to_stratum.
---
 gdb/ChangeLog |   5 +++
 gdb/target.c  | 128 +++-------------------------------------------------------
 2 files changed, 11 insertions(+), 122 deletions(-)

diff --git a/gdb/target.c b/gdb/target.c
index 6f87671..eded617 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -592,147 +592,31 @@ update_current_target (void)
   /* Install the delegators.  */
   install_delegators (&current_target);
 
+  current_target.to_stratum = target_stack->to_stratum;
+
 #define INHERIT(FIELD, TARGET) \
       if (!current_target.FIELD) \
 	current_target.FIELD = (TARGET)->FIELD
 
+  /* Do not add any new INHERITs here.  Instead, use the delegation
+     mechanism provided by make-target-delegates.  */
   for (t = target_stack; t; t = t->beneath)
     {
       INHERIT (to_shortname, t);
       INHERIT (to_longname, t);
       INHERIT (to_doc, t);
-      /* Do not inherit to_open.  */
-      /* Do not inherit to_close.  */
-      /* Do not inherit to_attach.  */
-      /* Do not inherit to_post_attach.  */
       INHERIT (to_attach_no_wait, t);
-      /* Do not inherit to_detach.  */
-      /* Do not inherit to_disconnect.  */
-      /* Do not inherit to_resume.  */
-      /* Do not inherit to_wait.  */
-      /* Do not inherit to_fetch_registers.  */
-      /* Do not inherit to_store_registers.  */
-      /* Do not inherit to_prepare_to_store.  */
       INHERIT (deprecated_xfer_memory, t);
-      /* Do not inherit to_files_info.  */
-      /* Do not inherit to_insert_breakpoint.  */
-      /* Do not inherit to_remove_breakpoint.  */
-      /* Do not inherit to_can_use_hw_breakpoint.  */
-      /* Do not inherit to_insert_hw_breakpoint.  */
-      /* Do not inherit to_remove_hw_breakpoint.  */
-      /* Do not inherit to_ranged_break_num_registers.  */
-      /* Do not inherit to_insert_watchpoint.  */
-      /* Do not inherit to_remove_watchpoint.  */
-      /* Do not inherit to_insert_mask_watchpoint.  */
-      /* Do not inherit to_remove_mask_watchpoint.  */
-      /* Do not inherit to_stopped_data_address.  */
       INHERIT (to_have_steppable_watchpoint, t);
       INHERIT (to_have_continuable_watchpoint, t);
-      /* Do not inherit to_stopped_by_watchpoint.  */
-      /* Do not inherit to_watchpoint_addr_within_range.  */
-      /* Do not inherit to_region_ok_for_hw_watchpoint.  */
-      /* Do not inherit to_can_accel_watchpoint_condition.  */
-      /* Do not inherit to_masked_watch_num_registers.  */
-      /* Do not inherit to_terminal_init.  */
-      /* Do not inherit to_terminal_inferior.  */
-      /* Do not inherit to_terminal_ours_for_output.  */
-      /* Do not inherit to_terminal_ours.  */
-      /* Do not inherit to_terminal_save_ours.  */
-      /* Do not inherit to_terminal_info.  */
-      /* Do not inherit to_kill.  */
-      /* Do not inherit to_load.  */
-      /* Do no inherit to_create_inferior.  */
-      /* Do not inherit to_post_startup_inferior.  */
-      /* Do not inherit to_insert_fork_catchpoint.  */
-      /* Do not inherit to_remove_fork_catchpoint.  */
-      /* Do not inherit to_insert_vfork_catchpoint.  */
-      /* Do not inherit to_remove_vfork_catchpoint.  */
-      /* Do not inherit to_follow_fork.  */
-      /* Do not inherit to_insert_exec_catchpoint.  */
-      /* Do not inherit to_remove_exec_catchpoint.  */
-      /* Do not inherit to_set_syscall_catchpoint.  */
-      /* Do not inherit to_has_exited.  */
-      /* Do not inherit to_mourn_inferior.  */
-      /* Do not inherit to_can_run.  */
-      /* Do not inherit to_pass_signals.  */
-      /* Do not inherit to_program_signals.  */
-      /* Do not inherit to_thread_alive.  */
-      /* Do not inherit to_find_new_threads.  */
-      /* Do not inherit to_pid_to_str.  */
-      /* Do not inherit to_extra_thread_info.  */
-      /* Do not inherit to_thread_name.  */
-      /* Do not inherit to_stop.  */
-      /* Do not inherit to_xfer_partial.  */
-      /* Do not inherit to_rcmd.  */
-      /* Do not inherit to_pid_to_exec_file.  */
-      /* Do not inherit to_log_command.  */
-      INHERIT (to_stratum, t);
-      /* Do not inherit to_has_all_memory.  */
-      /* Do not inherit to_has_memory.  */
-      /* Do not inherit to_has_stack.  */
-      /* Do not inherit to_has_registers.  */
-      /* Do not inherit to_has_execution.  */
       INHERIT (to_has_thread_control, t);
-      /* Do not inherit to_can_async_p.  */
-      /* Do not inherit to_is_async_p.  */
-      /* Do not inherit to_async.  */
-      /* Do not inherit to_find_memory_regions.  */
-      /* Do not inherit to_make_corefile_notes.  */
-      /* Do not inherit to_get_bookmark.  */
-      /* Do not inherit to_goto_bookmark.  */
-      /* Do not inherit to_get_thread_local_address.  */
-      /* Do not inherit to_can_execute_reverse.  */
-      /* Do not inherit to_execution_direction.  */
-      /* Do not inherit to_thread_architecture.  */
-      /* Do not inherit to_read_description.  */
-      /* Do not inherit to_get_ada_task_ptid.  */
-      /* Do not inherit to_search_memory.  */
-      /* Do not inherit to_supports_multi_process.  */
-      /* Do not inherit to_supports_enable_disable_tracepoint.  */
-      /* Do not inherit to_supports_string_tracing.  */
-      /* Do not inherit to_trace_init.  */
-      /* Do not inherit to_download_tracepoint.  */
-      /* Do not inherit to_can_download_tracepoint.  */
-      /* Do not inherit to_download_trace_state_variable.  */
-      /* Do not inherit to_enable_tracepoint.  */
-      /* Do not inherit to_disable_tracepoint.  */
-      /* Do not inherit to_trace_set_readonly_regions.  */
-      /* Do not inherit to_trace_start.  */
-      /* Do not inherit to_get_trace_status.  */
-      /* Do not inherit to_get_tracepoint_status.  */
-      /* Do not inherit to_trace_stop.  */
-      /* Do not inherit to_trace_find.  */
-      /* Do not inherit to_get_trace_state_variable_value.  */
-      /* Do not inherit to_save_trace_data.  */
-      /* Do not inherit to_upload_tracepoints.  */
-      /* Do not inherit to_upload_trace_state_variables.  */
-      /* Do not inherit to_get_raw_trace_data.  */
-      /* Do not inherit to_get_min_fast_tracepoint_insn_len.  */
-      /* Do not inherit to_set_disconnected_tracing.  */
-      /* Do not inherit to_set_circular_trace_buffer.  */
-      /* Do not inherit to_set_trace_buffer_size.  */
-      /* Do not inherit to_set_trace_notes.  */
-      /* Do not inherit to_get_tib_address.  */
-      /* Do not inherit to_set_permissions.  */
-      /* Do not inherit to_static_tracepoint_marker_at.  */
-      /* Do not inherit to_static_tracepoint_markers_by_strid.  */
-      /* Do not inherit to_traceframe_info.  */
-      /* Do not inherit to_use_agent.  */
-      /* Do not inherit to_can_use_agent.  */
-      /* Do not inherit to_augmented_libraries_svr4_read.  */
       INHERIT (to_magic, t);
-      /* Do not inherit
-	 to_supports_evaluation_of_breakpoint_conditions.  */
-      /* Do not inherit to_can_run_breakpoint_commands.  */
-      /* Do not inherit to_memory_map.  */
-      /* Do not inherit to_flash_erase.  */
-      /* Do not inherit to_flash_done.  */
     }
 #undef INHERIT
 
   /* Clean up a target struct so it no longer has any zero pointers in
-     it.  Some entries are defaulted to a method that print an error,
-     others are hard-wired to a standard recursive default.  */
+     it.  Do not add any new de_faults here.  Instead, use the
+     delegation mechanism provided by make-target-delegates.  */
 
 #define de_fault(field, value) \
   if (!current_target.field)               \
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 13/38] Add target_ops argument to to_fileio_pwrite
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (30 preceding siblings ...)
  2014-02-06 21:24 ` [RFC v2 05/38] convert to_supports_btrace Tom Tromey
@ 2014-02-06 21:24 ` Tom Tromey
  2014-02-06 21:24 ` [RFC v2 31/38] minor cleanups to update_current_target Tom Tromey
                   ` (7 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target.h (struct target_ops) <to_fileio_pwrite>: Add argument.
	* target.c (target_fileio_pwrite): Add argument.
	* remote.c (remote_hostio_pwrite): Add 'self' argument.
	(remote_file_put): Update.
	* inf-child.c (inf_child_fileio_pwrite): Add 'self' argument.

Add target_ops argument to to_fileio_pread

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

	* target.h (struct target_ops) <to_fileio_pread>: Add argument.
	* target.c (target_fileio_pread): Add argument.
	* remote.c (remote_hostio_pread): Add 'self' argument.
	(remote_bfd_iovec_pread, remote_file_get): Update.
	* inf-child.c (inf_child_fileio_pread): Add 'self' argument.

Add target_ops argument to to_fileio_close

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

	* target.h (struct target_ops) <to_fileio_close>: Add argument.
	* target.c (target_fileio_close): Add argument.
	* remote.c (remote_hostio_close): Add 'self' argument.
	(remote_hostio_close_cleanup): Update.
	(remote_bfd_iovec_close, remote_file_put, remote_file_get):
	Update.
	* inf-child.c (inf_child_fileio_close): Add 'self' argument.

Add target_ops argument to to_fileio_unlink

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

	* target.h (struct target_ops) <to_fileio_unlink>: Add argument.
	* target.c (target_fileio_unlink): Add argument.
	* remote.c (remote_hostio_unlink): Add 'self' argument.
	(remote_file_delete): Update.
	* inf-child.c (inf_child_fileio_unlink): Add 'self' argument.

Add target_ops argument to to_fileio_readlink

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

	* target.h (struct target_ops) <to_fileio_readlink>: Add argument.
	* target.c (target_fileio_readlink): Add argument.
	* remote.c (remote_hostio_readlink): Add 'self' argument.
	* inf-child.c (inf_child_fileio_readlink): Add 'self' argument.

Add target_ops argument to to_trace_init

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

	* target.h (struct target_ops) <to_trace_init>: Add argument.
	(target_trace_init): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_trace_init): Add 'self' argument.

Add target_ops argument to to_download_tracepoint

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

	* target.h (struct target_ops) <to_download_tracepoint>: Add
	argument.
	(target_download_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_download_tracepoint): Add 'self' argument.

Add target_ops argument to to_can_download_tracepoint

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

	* target.h (struct target_ops) <to_can_download_tracepoint>: Add
	argument.
	(target_can_download_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_can_download_tracepoint): Add 'self' argument.

Add target_ops argument to to_download_trace_state_variable

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

	* target.h (struct target_ops) <to_download_trace_state_variable>:
	Add argument.
	(target_download_trace_state_variable): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_download_trace_state_variable): Add 'self'
	argument.

Add target_ops argument to to_enable_tracepoint

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

	* target.h (struct target_ops) <to_enable_tracepoint>: Add
	argument.
	(target_enable_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_enable_tracepoint): Add 'self' argument.
---
 gdb/ChangeLog   | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/inf-child.c | 14 ++++++----
 gdb/remote.c    | 46 +++++++++++++++++++-------------
 gdb/target.c    | 20 +++++++-------
 gdb/target.h    | 37 +++++++++++++++-----------
 5 files changed, 150 insertions(+), 48 deletions(-)

diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index cd2aee6..054e279 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -257,7 +257,8 @@ inf_child_fileio_open (struct target_ops *self,
    Return the number of bytes written, or -1 if an error occurs
    (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
+inf_child_fileio_pwrite (struct target_ops *self,
+			 int fd, const gdb_byte *write_buf, int len,
 			 ULONGEST offset, int *target_errno)
 {
   int ret;
@@ -285,7 +286,8 @@ inf_child_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
    Return the number of bytes read, or -1 if an error occurs
    (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_pread (int fd, gdb_byte *read_buf, int len,
+inf_child_fileio_pread (struct target_ops *self,
+			int fd, gdb_byte *read_buf, int len,
 			ULONGEST offset, int *target_errno)
 {
   int ret;
@@ -312,7 +314,7 @@ inf_child_fileio_pread (int fd, gdb_byte *read_buf, int len,
 /* Close FD on the target.  Return 0, or -1 if an error occurs
    (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_close (int fd, int *target_errno)
+inf_child_fileio_close (struct target_ops *self, int fd, int *target_errno)
 {
   int ret;
 
@@ -326,7 +328,8 @@ inf_child_fileio_close (int fd, int *target_errno)
 /* Unlink FILENAME on the target.  Return 0, or -1 if an error
    occurs (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_unlink (const char *filename, int *target_errno)
+inf_child_fileio_unlink (struct target_ops *self,
+			 const char *filename, int *target_errno)
 {
   int ret;
 
@@ -341,7 +344,8 @@ inf_child_fileio_unlink (const char *filename, int *target_errno)
    null-terminated string allocated via xmalloc, or NULL if an error
    occurs (and set *TARGET_ERRNO).  */
 static char *
-inf_child_fileio_readlink (const char *filename, int *target_errno)
+inf_child_fileio_readlink (struct target_ops *self,
+			   const char *filename, int *target_errno)
 {
   /* We support readlink only on systems that also provide a compile-time
      maximum path length (PATH_MAX), at least for now.  */
diff --git a/gdb/remote.c b/gdb/remote.c
index d5054c8..107fd5b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9873,7 +9873,8 @@ remote_hostio_open (struct target_ops *self,
    set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_pwrite (int fd, const gdb_byte *write_buf, int len,
+remote_hostio_pwrite (struct target_ops *self,
+		      int fd, const gdb_byte *write_buf, int len,
 		      ULONGEST offset, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
@@ -9901,7 +9902,8 @@ remote_hostio_pwrite (int fd, const gdb_byte *write_buf, int len,
    set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_pread (int fd, gdb_byte *read_buf, int len,
+remote_hostio_pread (struct target_ops *self,
+		     int fd, gdb_byte *read_buf, int len,
 		     ULONGEST offset, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
@@ -9940,7 +9942,7 @@ remote_hostio_pread (int fd, gdb_byte *read_buf, int len,
    (and set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_close (int fd, int *remote_errno)
+remote_hostio_close (struct target_ops *self, int fd, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
   char *p = rs->buf;
@@ -9958,7 +9960,8 @@ remote_hostio_close (int fd, int *remote_errno)
    occurs (and set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_unlink (const char *filename, int *remote_errno)
+remote_hostio_unlink (struct target_ops *self,
+		      const char *filename, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
   char *p = rs->buf;
@@ -9978,7 +9981,8 @@ remote_hostio_unlink (const char *filename, int *remote_errno)
    occurs (and set *REMOTE_ERRNO).  */
 
 static char *
-remote_hostio_readlink (const char *filename, int *remote_errno)
+remote_hostio_readlink (struct target_ops *self,
+			const char *filename, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
   char *p = rs->buf;
@@ -10079,7 +10083,7 @@ remote_hostio_close_cleanup (void *opaque)
   int fd = *(int *) opaque;
   int remote_errno;
 
-  remote_hostio_close (fd, &remote_errno);
+  remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno);
 }
 
 
@@ -10116,7 +10120,7 @@ remote_bfd_iovec_close (struct bfd *abfd, void *stream)
 
   /* Ignore errors on close; these may happen if the remote
      connection was already torn down.  */
-  remote_hostio_close (fd, &remote_errno);
+  remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno);
 
   /* Zero means success.  */
   return 0;
@@ -10133,7 +10137,8 @@ remote_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf,
   pos = 0;
   while (nbytes > pos)
     {
-      bytes = remote_hostio_pread (fd, (gdb_byte *) buf + pos, nbytes - pos,
+      bytes = remote_hostio_pread (find_target_at (process_stratum),
+				   fd, (gdb_byte *) buf + pos, nbytes - pos,
 				   offset + pos, &remote_errno);
       if (bytes == 0)
         /* Success, but no bytes, means end-of-file.  */
@@ -10244,7 +10249,8 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty)
       bytes += bytes_in_buffer;
       bytes_in_buffer = 0;
 
-      retcode = remote_hostio_pwrite (fd, buffer, bytes,
+      retcode = remote_hostio_pwrite (find_target_at (process_stratum),
+				      fd, buffer, bytes,
 				      offset, &remote_errno);
 
       if (retcode < 0)
@@ -10263,7 +10269,7 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty)
     }
 
   discard_cleanups (close_cleanup);
-  if (remote_hostio_close (fd, &remote_errno))
+  if (remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno))
     remote_hostio_error (remote_errno);
 
   if (from_tty)
@@ -10305,7 +10311,8 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty)
   offset = 0;
   while (1)
     {
-      bytes = remote_hostio_pread (fd, buffer, io_size, offset, &remote_errno);
+      bytes = remote_hostio_pread (find_target_at (process_stratum),
+				   fd, buffer, io_size, offset, &remote_errno);
       if (bytes == 0)
 	/* Success, but no bytes, means end-of-file.  */
 	break;
@@ -10320,7 +10327,7 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty)
     }
 
   discard_cleanups (close_cleanup);
-  if (remote_hostio_close (fd, &remote_errno))
+  if (remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno))
     remote_hostio_error (remote_errno);
 
   if (from_tty)
@@ -10337,7 +10344,8 @@ remote_file_delete (const char *remote_file, int from_tty)
   if (!rs->remote_desc)
     error (_("command can only be used with remote target"));
 
-  retcode = remote_hostio_unlink (remote_file, &remote_errno);
+  retcode = remote_hostio_unlink (find_target_at (process_stratum),
+				  remote_file, &remote_errno);
   if (retcode == -1)
     remote_hostio_error (remote_errno);
 
@@ -10508,7 +10516,7 @@ remote_can_run_breakpoint_commands (struct target_ops *self)
 }
 
 static void
-remote_trace_init (void)
+remote_trace_init (struct target_ops *self)
 {
   putpkt ("QTinit");
   remote_get_noisy_reply (&target_buf, &target_buf_size);
@@ -10579,7 +10587,7 @@ remote_download_command_source (int num, ULONGEST addr,
 }
 
 static void
-remote_download_tracepoint (struct bp_location *loc)
+remote_download_tracepoint (struct target_ops *self, struct bp_location *loc)
 {
 #define BUF_SIZE 2048
 
@@ -10756,7 +10764,7 @@ remote_download_tracepoint (struct bp_location *loc)
 }
 
 static int
-remote_can_download_tracepoint (void)
+remote_can_download_tracepoint (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
   struct trace_status *ts;
@@ -10784,7 +10792,8 @@ remote_can_download_tracepoint (void)
 
 
 static void
-remote_download_trace_state_variable (struct trace_state_variable *tsv)
+remote_download_trace_state_variable (struct target_ops *self,
+				      struct trace_state_variable *tsv)
 {
   struct remote_state *rs = get_remote_state ();
   char *p;
@@ -10806,7 +10815,8 @@ remote_download_trace_state_variable (struct trace_state_variable *tsv)
 }
 
 static void
-remote_enable_tracepoint (struct bp_location *location)
+remote_enable_tracepoint (struct target_ops *self,
+			  struct bp_location *location)
 {
   struct remote_state *rs = get_remote_state ();
   char addr_buf[40];
diff --git a/gdb/target.c b/gdb/target.c
index 37d44e8..b7f25ee 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -849,19 +849,19 @@ update_current_target (void)
 	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_trace_init,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    tcomplain);
   de_fault (to_download_tracepoint,
-	    (void (*) (struct bp_location *))
+	    (void (*) (struct target_ops *, struct bp_location *))
 	    tcomplain);
   de_fault (to_can_download_tracepoint,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_download_trace_state_variable,
-	    (void (*) (struct trace_state_variable *))
+	    (void (*) (struct target_ops *, struct trace_state_variable *))
 	    tcomplain);
   de_fault (to_enable_tracepoint,
-	    (void (*) (struct bp_location *))
+	    (void (*) (struct target_ops *, struct bp_location *))
 	    tcomplain);
   de_fault (to_disable_tracepoint,
 	    (void (*) (struct bp_location *))
@@ -3339,7 +3339,7 @@ target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
     {
       if (t->to_fileio_pwrite != NULL)
 	{
-	  int ret = t->to_fileio_pwrite (fd, write_buf, len, offset,
+	  int ret = t->to_fileio_pwrite (t, fd, write_buf, len, offset,
 					 target_errno);
 
 	  if (targetdebug)
@@ -3369,7 +3369,7 @@ target_fileio_pread (int fd, gdb_byte *read_buf, int len,
     {
       if (t->to_fileio_pread != NULL)
 	{
-	  int ret = t->to_fileio_pread (fd, read_buf, len, offset,
+	  int ret = t->to_fileio_pread (t, fd, read_buf, len, offset,
 					target_errno);
 
 	  if (targetdebug)
@@ -3397,7 +3397,7 @@ target_fileio_close (int fd, int *target_errno)
     {
       if (t->to_fileio_close != NULL)
 	{
-	  int ret = t->to_fileio_close (fd, target_errno);
+	  int ret = t->to_fileio_close (t, fd, target_errno);
 
 	  if (targetdebug)
 	    fprintf_unfiltered (gdb_stdlog,
@@ -3422,7 +3422,7 @@ target_fileio_unlink (const char *filename, int *target_errno)
     {
       if (t->to_fileio_unlink != NULL)
 	{
-	  int ret = t->to_fileio_unlink (filename, target_errno);
+	  int ret = t->to_fileio_unlink (t, filename, target_errno);
 
 	  if (targetdebug)
 	    fprintf_unfiltered (gdb_stdlog,
@@ -3448,7 +3448,7 @@ target_fileio_readlink (const char *filename, int *target_errno)
     {
       if (t->to_fileio_readlink != NULL)
 	{
-	  char *ret = t->to_fileio_readlink (filename, target_errno);
+	  char *ret = t->to_fileio_readlink (t, filename, target_errno);
 
 	  if (targetdebug)
 	    fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/target.h b/gdb/target.h
index 72a811b..71454dc 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -710,27 +710,31 @@ struct target_ops
     /* Write up to LEN bytes from WRITE_BUF to FD on the target.
        Return the number of bytes written, or -1 if an error occurs
        (and set *TARGET_ERRNO).  */
-    int (*to_fileio_pwrite) (int fd, const gdb_byte *write_buf, int len,
+    int (*to_fileio_pwrite) (struct target_ops *,
+			     int fd, const gdb_byte *write_buf, int len,
 			     ULONGEST offset, int *target_errno);
 
     /* Read up to LEN bytes FD on the target into READ_BUF.
        Return the number of bytes read, or -1 if an error occurs
        (and set *TARGET_ERRNO).  */
-    int (*to_fileio_pread) (int fd, gdb_byte *read_buf, int len,
+    int (*to_fileio_pread) (struct target_ops *,
+			    int fd, gdb_byte *read_buf, int len,
 			    ULONGEST offset, int *target_errno);
 
     /* Close FD on the target.  Return 0, or -1 if an error occurs
        (and set *TARGET_ERRNO).  */
-    int (*to_fileio_close) (int fd, int *target_errno);
+    int (*to_fileio_close) (struct target_ops *, int fd, int *target_errno);
 
     /* Unlink FILENAME on the target.  Return 0, or -1 if an error
        occurs (and set *TARGET_ERRNO).  */
-    int (*to_fileio_unlink) (const char *filename, int *target_errno);
+    int (*to_fileio_unlink) (struct target_ops *,
+			     const char *filename, int *target_errno);
 
     /* Read value of symbolic link FILENAME on the target.  Return a
        null-terminated string allocated via xmalloc, or NULL if an error
        occurs (and set *TARGET_ERRNO).  */
-    char *(*to_fileio_readlink) (const char *filename, int *target_errno);
+    char *(*to_fileio_readlink) (struct target_ops *,
+				 const char *filename, int *target_errno);
 
 
     /* Implement the "info proc" command.  */
@@ -739,20 +743,23 @@ struct target_ops
     /* Tracepoint-related operations.  */
 
     /* Prepare the target for a tracing run.  */
-    void (*to_trace_init) (void);
+    void (*to_trace_init) (struct target_ops *);
 
     /* Send full details of a tracepoint location to the target.  */
-    void (*to_download_tracepoint) (struct bp_location *location);
+    void (*to_download_tracepoint) (struct target_ops *,
+				    struct bp_location *location);
 
     /* Is the target able to download tracepoint locations in current
        state?  */
-    int (*to_can_download_tracepoint) (void);
+    int (*to_can_download_tracepoint) (struct target_ops *);
 
     /* Send full details of a trace state variable to the target.  */
-    void (*to_download_trace_state_variable) (struct trace_state_variable *tsv);
+    void (*to_download_trace_state_variable) (struct target_ops *,
+					      struct trace_state_variable *tsv);
 
     /* Enable a tracepoint on the target.  */
-    void (*to_enable_tracepoint) (struct bp_location *location);
+    void (*to_enable_tracepoint) (struct target_ops *,
+				  struct bp_location *location);
 
     /* Disable a tracepoint on the target.  */
     void (*to_disable_tracepoint) (struct bp_location *location);
@@ -1764,19 +1771,19 @@ extern char *target_fileio_read_stralloc (const char *filename);
 /* Tracepoint-related operations.  */
 
 #define target_trace_init() \
-  (*current_target.to_trace_init) ()
+  (*current_target.to_trace_init) (&current_target)
 
 #define target_download_tracepoint(t) \
-  (*current_target.to_download_tracepoint) (t)
+  (*current_target.to_download_tracepoint) (&current_target, t)
 
 #define target_can_download_tracepoint() \
-  (*current_target.to_can_download_tracepoint) ()
+  (*current_target.to_can_download_tracepoint) (&current_target)
 
 #define target_download_trace_state_variable(tsv) \
-  (*current_target.to_download_trace_state_variable) (tsv)
+  (*current_target.to_download_trace_state_variable) (&current_target, tsv)
 
 #define target_enable_tracepoint(loc) \
-  (*current_target.to_enable_tracepoint) (loc)
+  (*current_target.to_enable_tracepoint) (&current_target, loc)
 
 #define target_disable_tracepoint(loc) \
   (*current_target.to_disable_tracepoint) (loc)
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 05/38] convert to_supports_btrace
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (29 preceding siblings ...)
  2014-02-06 21:23 ` [RFC v2 15/38] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
@ 2014-02-06 21:24 ` Tom Tromey
  2014-02-06 21:24 ` [RFC v2 13/38] Add target_ops argument to to_fileio_pwrite Tom Tromey
                   ` (8 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a "self" argument to to_supports_btrace.  Due to how one
implementation of this method is shared with gdbserver this required a
small change to gdbserver as well.

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

	* common/linux-btrace.c (linux_supports_btrace): Add "ops"
	argument.
	* common/linux-btrace.h (linux_supports_btrace): Update.
	* remote.c (remote_supports_btrace): Add "self" argument.
	* target-delegates.c: Rebuild.
	* target.c (target_supports_btrace): Remove.
	* target.h (struct target_ops) <to_supports_btrace>: Add
	target_ops argument.
	(target_supports_btrace): New define.

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

	* target.h (struct target_ops) <supports_btrace>: Add target_ops
	argument.
	(target_supports_btrace): Update.
---
 gdb/ChangeLog             | 12 ++++++++++++
 gdb/common/linux-btrace.c |  4 ++--
 gdb/common/linux-btrace.h |  2 +-
 gdb/gdbserver/ChangeLog   |  6 ++++++
 gdb/gdbserver/target.h    |  7 ++++---
 gdb/remote.c              |  2 +-
 gdb/target-delegates.c    | 16 ++++++++++++++++
 gdb/target.c              | 14 --------------
 gdb/target.h              |  6 ++++--
 9 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c
index 218e0ce..188220b 100644
--- a/gdb/common/linux-btrace.c
+++ b/gdb/common/linux-btrace.c
@@ -407,7 +407,7 @@ cpu_supports_btrace (void)
 /* See linux-btrace.h.  */
 
 int
-linux_supports_btrace (void)
+linux_supports_btrace (struct target_ops *ops)
 {
   static int cached;
 
@@ -600,7 +600,7 @@ linux_read_btrace (VEC (btrace_block_s) **btrace,
 /* See linux-btrace.h.  */
 
 int
-linux_supports_btrace (void)
+linux_supports_btrace (struct target_ops *ops)
 {
   return 0;
 }
diff --git a/gdb/common/linux-btrace.h b/gdb/common/linux-btrace.h
index a97b697..12e9b60 100644
--- a/gdb/common/linux-btrace.h
+++ b/gdb/common/linux-btrace.h
@@ -62,7 +62,7 @@ struct btrace_target_info
 };
 
 /* See to_supports_btrace in target.h.  */
-extern int linux_supports_btrace (void);
+extern int linux_supports_btrace (struct target_ops *);
 
 /* See to_enable_btrace in target.h.  */
 extern struct btrace_target_info *linux_enable_btrace (ptid_t ptid);
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index ae48cd7..7374d58 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -350,7 +350,7 @@ struct target_ops
   int (*supports_agent) (void);
 
   /* Check whether the target supports branch tracing.  */
-  int (*supports_btrace) (void);
+  int (*supports_btrace) (struct target_ops *);
 
   /* Enable branch tracing for @ptid and allocate a branch trace target
      information struct for reading and for disabling branch trace.  */
@@ -491,8 +491,9 @@ int kill_inferior (int);
   (the_target->supports_agent ? \
    (*the_target->supports_agent) () : 0)
 
-#define target_supports_btrace() \
-  (the_target->supports_btrace ? (*the_target->supports_btrace) () : 0)
+#define target_supports_btrace()			\
+  (the_target->supports_btrace				\
+   ? (*the_target->supports_btrace) (the_target) : 0)
 
 #define target_enable_btrace(ptid) \
   (*the_target->enable_btrace) (ptid)
diff --git a/gdb/remote.c b/gdb/remote.c
index c6767d4..1996571 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11389,7 +11389,7 @@ struct btrace_target_info
 /* Check whether the target supports branch tracing.  */
 
 static int
-remote_supports_btrace (void)
+remote_supports_btrace (struct target_ops *self)
 {
   if (remote_protocol_packets[PACKET_Qbtrace_off].support != PACKET_ENABLE)
     return 0;
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 8f28321..a7877cc 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -122,6 +122,19 @@ tdefault_xfer_partial (struct target_ops *self, enum target_object  arg1, const
   return -1;
 }
 
+static int
+delegate_supports_btrace (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_supports_btrace (self);
+}
+
+static int
+tdefault_supports_btrace (struct target_ops *self)
+{
+  return 0;
+}
+
 static void
 install_delegators (struct target_ops *ops)
 {
@@ -147,6 +160,8 @@ install_delegators (struct target_ops *ops)
     ops->to_async = delegate_async;
   if (ops->to_xfer_partial == NULL)
     ops->to_xfer_partial = delegate_xfer_partial;
+  if (ops->to_supports_btrace == NULL)
+    ops->to_supports_btrace = delegate_supports_btrace;
 }
 
 static void
@@ -163,4 +178,5 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_is_async_p = find_default_is_async_p;
   ops->to_async = tdefault_async;
   ops->to_xfer_partial = tdefault_xfer_partial;
+  ops->to_supports_btrace = tdefault_supports_btrace;
 }
diff --git a/gdb/target.c b/gdb/target.c
index bde91ab..8ab9cbf 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -4109,20 +4109,6 @@ target_ranged_break_num_registers (void)
 
 /* See target.h.  */
 
-int
-target_supports_btrace (void)
-{
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_supports_btrace != NULL)
-      return t->to_supports_btrace ();
-
-  return 0;
-}
-
-/* See target.h.  */
-
 struct btrace_target_info *
 target_enable_btrace (ptid_t ptid)
 {
diff --git a/gdb/target.h b/gdb/target.h
index 8d00d3a..76a2d1b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -859,7 +859,8 @@ struct target_ops
     int (*to_can_use_agent) (void);
 
     /* Check whether the target supports branch tracing.  */
-    int (*to_supports_btrace) (void);
+    int (*to_supports_btrace) (struct target_ops *)
+      TARGET_DEFAULT_RETURN (0);
 
     /* Enable branch tracing for PTID and allocate a branch trace target
        information struct for reading and for disabling branch trace.  */
@@ -2019,7 +2020,8 @@ extern void update_target_permissions (void);
 void target_ignore (void);
 
 /* See to_supports_btrace in struct target_ops.  */
-extern int target_supports_btrace (void);
+#define target_supports_btrace() \
+  (current_target.to_supports_btrace (&current_target))
 
 /* See to_enable_btrace in struct target_ops.  */
 extern struct btrace_target_info *target_enable_btrace (ptid_t ptid);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 30/38] change delegation for to_read_description
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (33 preceding siblings ...)
  2014-02-06 21:24 ` [RFC v2 14/38] Add target_ops argument to to_disable_tracepoint Tom Tromey
@ 2014-02-06 21:38 ` Tom Tromey
  2014-02-06 21:38 ` [RFC v2 33/38] pass NULL to TARGET_DEFAULT_RETURN when appropriate Tom Tromey
                   ` (4 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This switches to_read_description to the "new normal" delegation
scheme.  This one was a bit trickier than the other changes due to the
way that target_read_description handled delegation.  I examined all
the target implementations of to_read_description and changed the ones
returning NULL to instead delegate.

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

	* arm-linux-nat.c (arm_linux_read_description): Delegate when
	needed.
	* corelow.c (core_read_description): Delegate when needed.
	* remote.c (remote_read_description): Delegate when needed.
	* target-delegates.c: Rebuild.
	* target.c (target_read_description): Rewrite.
	* target.h (struct target_ops) <to_read_description>: Update
	comment.  Use TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          | 11 +++++++++++
 gdb/arm-linux-nat.c    |  4 ++--
 gdb/corelow.c          | 12 +++++++++---
 gdb/remote.c           |  4 ++--
 gdb/target-delegates.c | 16 ++++++++++++++++
 gdb/target.c           | 15 +--------------
 gdb/target.h           | 10 ++++++----
 7 files changed, 47 insertions(+), 25 deletions(-)

diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 75f58ca..a92642d 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -636,7 +636,7 @@ arm_linux_read_description (struct target_ops *ops)
 
   if (target_auxv_search (ops, AT_HWCAP, &arm_hwcap) != 1)
     {
-      return NULL;
+      return ops->beneath->to_read_description (ops->beneath);
     }
 
   if (arm_hwcap & HWCAP_IWMMXT)
@@ -681,7 +681,7 @@ arm_linux_read_description (struct target_ops *ops)
       return result;
     }
 
-  return NULL;
+  return ops->beneath->to_read_description (ops->beneath);
 }
 
 /* Information describing the hardware breakpoint capabilities.  */
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 1198a51..944c1c9 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -870,10 +870,16 @@ static const struct target_desc *
 core_read_description (struct target_ops *target)
 {
   if (core_gdbarch && gdbarch_core_read_description_p (core_gdbarch))
-    return gdbarch_core_read_description (core_gdbarch, 
-					  target, core_bfd);
+    {
+      const struct target_desc *result;
+
+      result = gdbarch_core_read_description (core_gdbarch, 
+					      target, core_bfd);
+      if (result != NULL)
+	return result;
+    }
 
-  return NULL;
+  return target->beneath->to_read_description (target->beneath);
 }
 
 static char *
diff --git a/gdb/remote.c b/gdb/remote.c
index be36234..fef22cf 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9624,7 +9624,7 @@ remote_read_description (struct target_ops *target)
   /* Do not try this during initial connection, when we do not know
      whether there is a running but stopped thread.  */
   if (!target_has_execution || ptid_equal (inferior_ptid, null_ptid))
-    return NULL;
+    return target->beneath->to_read_description (target->beneath);
 
   if (!VEC_empty (remote_g_packet_guess_s, data->guesses))
     {
@@ -9643,7 +9643,7 @@ remote_read_description (struct target_ops *target)
 	 an architecture, but it's too tricky to do safely.  */
     }
 
-  return NULL;
+  return target->beneath->to_read_description (target->beneath);
 }
 
 /* Remote file transfer support.  This is host-initiated I/O, not
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 6174685..ae5a796 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -801,6 +801,19 @@ tdefault_flash_done (struct target_ops *self)
   tcomplain ();
 }
 
+static const struct target_desc *
+delegate_read_description (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_read_description (self);
+}
+
+static const struct target_desc *
+tdefault_read_description (struct target_ops *self)
+{
+  return 0;
+}
+
 static ptid_t
 delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
 {
@@ -1700,6 +1713,8 @@ install_delegators (struct target_ops *ops)
     ops->to_flash_erase = delegate_flash_erase;
   if (ops->to_flash_done == NULL)
     ops->to_flash_done = delegate_flash_done;
+  if (ops->to_read_description == NULL)
+    ops->to_read_description = delegate_read_description;
   if (ops->to_get_ada_task_ptid == NULL)
     ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
   if (ops->to_auxv_parse == NULL)
@@ -1896,6 +1911,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_memory_map = tdefault_memory_map;
   ops->to_flash_erase = tdefault_flash_erase;
   ops->to_flash_done = tdefault_flash_done;
+  ops->to_read_description = tdefault_read_description;
   ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
   ops->to_auxv_parse = default_auxv_parse;
   ops->to_search_memory = default_search_memory;
diff --git a/gdb/target.c b/gdb/target.c
index 4016128..6f87671 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -748,7 +748,6 @@ update_current_target (void)
 	    (int (*) (CORE_ADDR, gdb_byte *, int, int,
 		      struct mem_attrib *, struct target_ops *))
 	    nomemory);
-  current_target.to_read_description = NULL;
 
 #undef de_fault
 
@@ -2569,19 +2568,7 @@ target_mourn_inferior (void)
 const struct target_desc *
 target_read_description (struct target_ops *target)
 {
-  struct target_ops *t;
-
-  for (t = target; t != NULL; t = t->beneath)
-    if (t->to_read_description != NULL)
-      {
-	const struct target_desc *tdesc;
-
-	tdesc = t->to_read_description (t);
-	if (tdesc)
-	  return tdesc;
-      }
-
-  return NULL;
+  return target->to_read_description (target);
 }
 
 /* This implements a basic search of memory, reading target memory and
diff --git a/gdb/target.h b/gdb/target.h
index 47a92d0..853db76 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -677,10 +677,12 @@ struct target_ops
     void (*to_flash_done) (struct target_ops *)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
-    /* Describe the architecture-specific features of this target.
-       Returns the description found, or NULL if no description
-       was available.  */
-    const struct target_desc *(*to_read_description) (struct target_ops *ops);
+    /* Describe the architecture-specific features of this target.  If
+       OPS doesn't have a description, this should delegate to the
+       "beneath" target.  Returns the description found, or NULL if no
+       description was available.  */
+    const struct target_desc *(*to_read_description) (struct target_ops *ops)
+	 TARGET_DEFAULT_RETURN (0);
 
     /* Build the PTID of the thread on which a given task is running,
        based on LWP and THREAD.  These values are extracted from the
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 33/38] pass NULL to TARGET_DEFAULT_RETURN when appropriate
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (34 preceding siblings ...)
  2014-02-06 21:38 ` [RFC v2 30/38] change delegation for to_read_description Tom Tromey
@ 2014-02-06 21:38 ` Tom Tromey
  2014-02-06 21:42 ` [RFC v2 18/38] convert to_detach Tom Tromey
                   ` (3 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes instances of TARGET_DEFAULT_RETURN(0) to
TARGET_DEFAULT_RETURN(NULL) when appropriate.  The use of "0" was a
relic from an earlier implementation of make-target-delegates; and I
didn't want to go back through the long patch series, fixing up
conflicts, just to change this small detail.

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

	* target-delegates.c: Rebuild.
	* target.h (struct target_ops) <to_extra_thread_info,
	to_thread_name, to_pid_to_exec_file, to_get_section_table,
	to_memory_map, to_read_description, to_traceframe_info>: Use NULL,
	not 0, in TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          |  8 ++++++++
 gdb/target-delegates.c | 14 +++++++-------
 gdb/target.h           | 14 +++++++-------
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index ae5a796..78e3c0d 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -609,7 +609,7 @@ delegate_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
 static char *
 tdefault_extra_thread_info (struct target_ops *self, struct thread_info *arg1)
 {
-  return 0;
+  return NULL;
 }
 
 static char *
@@ -622,7 +622,7 @@ delegate_thread_name (struct target_ops *self, struct thread_info *arg1)
 static char *
 tdefault_thread_name (struct target_ops *self, struct thread_info *arg1)
 {
-  return 0;
+  return NULL;
 }
 
 static void
@@ -654,7 +654,7 @@ delegate_pid_to_exec_file (struct target_ops *self, int arg1)
 static char *
 tdefault_pid_to_exec_file (struct target_ops *self, int arg1)
 {
-  return 0;
+  return NULL;
 }
 
 static void
@@ -679,7 +679,7 @@ delegate_get_section_table (struct target_ops *self)
 static struct target_section_table *
 tdefault_get_section_table (struct target_ops *self)
 {
-  return 0;
+  return NULL;
 }
 
 static int
@@ -772,7 +772,7 @@ delegate_memory_map (struct target_ops *self)
 static VEC(mem_region_s) *
 tdefault_memory_map (struct target_ops *self)
 {
-  return 0;
+  return NULL;
 }
 
 static void
@@ -811,7 +811,7 @@ delegate_read_description (struct target_ops *self)
 static const struct target_desc *
 tdefault_read_description (struct target_ops *self)
 {
-  return 0;
+  return NULL;
 }
 
 static ptid_t
@@ -1297,7 +1297,7 @@ delegate_traceframe_info (struct target_ops *self)
 static struct traceframe_info *
 tdefault_traceframe_info (struct target_ops *self)
 {
-  return 0;
+  return NULL;
 }
 
 static int
diff --git a/gdb/target.h b/gdb/target.h
index 853db76..09fe10e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -558,20 +558,20 @@ struct target_ops
     char *(*to_pid_to_str) (struct target_ops *, ptid_t)
       TARGET_DEFAULT_FUNC (default_pid_to_str);
     char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *)
-      TARGET_DEFAULT_RETURN (0);
+      TARGET_DEFAULT_RETURN (NULL);
     char *(*to_thread_name) (struct target_ops *, struct thread_info *)
-      TARGET_DEFAULT_RETURN (0);
+      TARGET_DEFAULT_RETURN (NULL);
     void (*to_stop) (struct target_ops *, ptid_t)
       TARGET_DEFAULT_IGNORE ();
     void (*to_rcmd) (struct target_ops *,
 		     char *command, struct ui_file *output)
       TARGET_DEFAULT_FUNC (default_rcmd);
     char *(*to_pid_to_exec_file) (struct target_ops *, int pid)
-      TARGET_DEFAULT_RETURN (0);
+      TARGET_DEFAULT_RETURN (NULL);
     void (*to_log_command) (struct target_ops *, const char *)
       TARGET_DEFAULT_IGNORE ();
     struct target_section_table *(*to_get_section_table) (struct target_ops *)
-      TARGET_DEFAULT_RETURN (0);
+      TARGET_DEFAULT_RETURN (NULL);
     enum strata to_stratum;
     int (*to_has_all_memory) (struct target_ops *);
     int (*to_has_memory) (struct target_ops *);
@@ -659,7 +659,7 @@ struct target_ops
        change unexpectedly, it should be invalidated, and higher
        layers will re-fetch it.  */
     VEC(mem_region_s) *(*to_memory_map) (struct target_ops *)
-      TARGET_DEFAULT_RETURN (0);
+      TARGET_DEFAULT_RETURN (NULL);
 
     /* Erases the region of flash memory starting at ADDRESS, of
        length LENGTH.
@@ -682,7 +682,7 @@ struct target_ops
        "beneath" target.  Returns the description found, or NULL if no
        description was available.  */
     const struct target_desc *(*to_read_description) (struct target_ops *ops)
-	 TARGET_DEFAULT_RETURN (0);
+	 TARGET_DEFAULT_RETURN (NULL);
 
     /* Build the PTID of the thread on which a given task is running,
        based on LWP and THREAD.  These values are extracted from the
@@ -974,7 +974,7 @@ struct target_ops
        cache data; higher layers take care of caching, invalidating,
        and re-fetching when necessary.  */
     struct traceframe_info *(*to_traceframe_info) (struct target_ops *)
-      TARGET_DEFAULT_RETURN (0);
+      TARGET_DEFAULT_RETURN (NULL);
 
     /* Ask the target to use or not to use agent according to USE.  Return 1
        successful, 0 otherwise.  */
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 18/38] convert to_detach
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (35 preceding siblings ...)
  2014-02-06 21:38 ` [RFC v2 33/38] pass NULL to TARGET_DEFAULT_RETURN when appropriate Tom Tromey
@ 2014-02-06 21:42 ` Tom Tromey
  2014-02-06 21:47 ` [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods Tom Tromey
                   ` (2 subsequent siblings)
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

	* target-delegates.c: Rebuild.
	* target.c (target_detach): Unconditionally delegate.
	(init_dummy_target): Don't initialize to_detach.
	* target.h (struct target_ops) <to_detach>: Use
	TARGET_DEFAULT_IGNORE.

convert to_attach

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

	* target-delegates.c: Rebuild.
	* target.c (init_dummy_target): Don't initialize to_attach.
	(target_attach): Unconditionally delegate.
	* target.h (struct target_ops) <to_attach>: Use
	TARGET_DEFAULT_FUNC.

convert to_rcmd

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_rcmd.
	(default_rcmd): New function.
	(do_monitor_command): Unconditionally delegate.
	* target.h (struct target_ops) <to_rmcd>: Use
	TARGET_DEFAULT_FUNC.

convert to_post_attach

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_post_attach.
	* target.h (struct target_ops) <to_post_attach>: Use
	TARGET_DEFAULT_IGNORE.

convert to_prepare_to_store

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_store.
	* target.h (struct target_ops) <to_store>: Use
	TARGET_DEFAULT_NORETURN.

convert to_files_info

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_files_info.
	* target.h (struct target_ops) <to_files_info>: Use
	TARGET_DEFAULT_IGNORE.

convert to_can_use_hw_breakpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_can_use_hw_breakpoint.
	* target.h (struct target_ops) <to_can_use_hw_breakpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_insert_hw_breakpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_insert_hw_breakpoint.
	* target.h (struct target_ops) <to_insert_hw_breakpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_remove_hw_breakpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_remove_hw_breakpoint.
	* target.h (struct target_ops) <to_remove_hw_breakpoint>: Use
	TARGET_DEFAULT_RETURN.

convert to_insert_watchpoint

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

	* target-delegates.c: Rebuild.
	* target.c (update_current_target): Don't inherit or default
	to_insert_watchpoint.
	* target.h (struct target_ops) <to_insert_watchpoint>: Use
	TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          |  82 ++++++++++++++++++++++++++++
 gdb/target-delegates.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  98 ++++++++-------------------------
 gdb/target.h           |  30 ++++++----
 4 files changed, 271 insertions(+), 84 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index a7877cc..6e26824 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -4,6 +4,37 @@
 /* To regenerate this file, run:*/
 /*      make-target-delegates target.h > target-delegates.c */
 static void
+delegate_attach (struct target_ops *self, char *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_attach (self, arg1, arg2);
+}
+
+static void
+delegate_post_attach (struct target_ops *self, int arg1)
+{
+  self = self->beneath;
+  self->to_post_attach (self, arg1);
+}
+
+static void
+tdefault_post_attach (struct target_ops *self, int arg1)
+{
+}
+
+static void
+delegate_detach (struct target_ops *self, const char *arg1, int arg2)
+{
+  self = self->beneath;
+  self->to_detach (self, arg1, arg2);
+}
+
+static void
+tdefault_detach (struct target_ops *self, const char *arg1, int arg2)
+{
+}
+
+static void
 delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
 {
   self = self->beneath;
@@ -42,6 +73,31 @@ tdefault_store_registers (struct target_ops *self, struct regcache *arg1, int ar
   noprocess ();
 }
 
+static void
+delegate_prepare_to_store (struct target_ops *self, struct regcache *arg1)
+{
+  self = self->beneath;
+  self->to_prepare_to_store (self, arg1);
+}
+
+static void
+tdefault_prepare_to_store (struct target_ops *self, struct regcache *arg1)
+{
+  noprocess ();
+}
+
+static void
+delegate_files_info (struct target_ops *self)
+{
+  self = self->beneath;
+  self->to_files_info (self);
+}
+
+static void
+tdefault_files_info (struct target_ops *self)
+{
+}
+
 static int
 delegate_insert_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
 {
@@ -57,6 +113,58 @@ delegate_remove_breakpoint (struct target_ops *self, struct gdbarch *arg1, struc
 }
 
 static int
+delegate_can_use_hw_breakpoint (struct target_ops *self, int arg1, int arg2, int arg3)
+{
+  self = self->beneath;
+  return self->to_can_use_hw_breakpoint (self, arg1, arg2, arg3);
+}
+
+static int
+tdefault_can_use_hw_breakpoint (struct target_ops *self, int arg1, int arg2, int arg3)
+{
+  return 0;
+}
+
+static int
+delegate_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
+{
+  self = self->beneath;
+  return self->to_insert_hw_breakpoint (self, arg1, arg2);
+}
+
+static int
+tdefault_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
+{
+  return -1;
+}
+
+static int
+delegate_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
+{
+  self = self->beneath;
+  return self->to_remove_hw_breakpoint (self, arg1, arg2);
+}
+
+static int
+tdefault_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
+{
+  return -1;
+}
+
+static int
+delegate_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
+{
+  self = self->beneath;
+  return self->to_insert_watchpoint (self, arg1, arg2, arg3, arg4);
+}
+
+static int
+tdefault_insert_watchpoint (struct target_ops *self, CORE_ADDR arg1, int arg2, int arg3, struct expression *arg4)
+{
+  return -1;
+}
+
+static int
 delegate_stopped_by_watchpoint (struct target_ops *self)
 {
   self = self->beneath;
@@ -82,6 +190,13 @@ tdefault_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
   return 0;
 }
 
+static void
+delegate_rcmd (struct target_ops *self, char *arg1, struct ui_file *arg2)
+{
+  self = self->beneath;
+  self->to_rcmd (self, arg1, arg2);
+}
+
 static int
 delegate_can_async_p (struct target_ops *self)
 {
@@ -138,20 +253,40 @@ tdefault_supports_btrace (struct target_ops *self)
 static void
 install_delegators (struct target_ops *ops)
 {
+  if (ops->to_attach == NULL)
+    ops->to_attach = delegate_attach;
+  if (ops->to_post_attach == NULL)
+    ops->to_post_attach = delegate_post_attach;
+  if (ops->to_detach == NULL)
+    ops->to_detach = delegate_detach;
   if (ops->to_resume == NULL)
     ops->to_resume = delegate_resume;
   if (ops->to_wait == NULL)
     ops->to_wait = delegate_wait;
   if (ops->to_store_registers == NULL)
     ops->to_store_registers = delegate_store_registers;
+  if (ops->to_prepare_to_store == NULL)
+    ops->to_prepare_to_store = delegate_prepare_to_store;
+  if (ops->to_files_info == NULL)
+    ops->to_files_info = delegate_files_info;
   if (ops->to_insert_breakpoint == NULL)
     ops->to_insert_breakpoint = delegate_insert_breakpoint;
   if (ops->to_remove_breakpoint == NULL)
     ops->to_remove_breakpoint = delegate_remove_breakpoint;
+  if (ops->to_can_use_hw_breakpoint == NULL)
+    ops->to_can_use_hw_breakpoint = delegate_can_use_hw_breakpoint;
+  if (ops->to_insert_hw_breakpoint == NULL)
+    ops->to_insert_hw_breakpoint = delegate_insert_hw_breakpoint;
+  if (ops->to_remove_hw_breakpoint == NULL)
+    ops->to_remove_hw_breakpoint = delegate_remove_hw_breakpoint;
+  if (ops->to_insert_watchpoint == NULL)
+    ops->to_insert_watchpoint = delegate_insert_watchpoint;
   if (ops->to_stopped_by_watchpoint == NULL)
     ops->to_stopped_by_watchpoint = delegate_stopped_by_watchpoint;
   if (ops->to_stopped_data_address == NULL)
     ops->to_stopped_data_address = delegate_stopped_data_address;
+  if (ops->to_rcmd == NULL)
+    ops->to_rcmd = delegate_rcmd;
   if (ops->to_can_async_p == NULL)
     ops->to_can_async_p = delegate_can_async_p;
   if (ops->to_is_async_p == NULL)
@@ -167,13 +302,23 @@ install_delegators (struct target_ops *ops)
 static void
 install_dummy_methods (struct target_ops *ops)
 {
+  ops->to_attach = find_default_attach;
+  ops->to_post_attach = tdefault_post_attach;
+  ops->to_detach = tdefault_detach;
   ops->to_resume = tdefault_resume;
   ops->to_wait = tdefault_wait;
   ops->to_store_registers = tdefault_store_registers;
+  ops->to_prepare_to_store = tdefault_prepare_to_store;
+  ops->to_files_info = tdefault_files_info;
   ops->to_insert_breakpoint = memory_insert_breakpoint;
   ops->to_remove_breakpoint = memory_remove_breakpoint;
+  ops->to_can_use_hw_breakpoint = tdefault_can_use_hw_breakpoint;
+  ops->to_insert_hw_breakpoint = tdefault_insert_hw_breakpoint;
+  ops->to_remove_hw_breakpoint = tdefault_remove_hw_breakpoint;
+  ops->to_insert_watchpoint = tdefault_insert_watchpoint;
   ops->to_stopped_by_watchpoint = tdefault_stopped_by_watchpoint;
   ops->to_stopped_data_address = tdefault_stopped_data_address;
+  ops->to_rcmd = default_rcmd;
   ops->to_can_async_p = find_default_can_async_p;
   ops->to_is_async_p = find_default_is_async_p;
   ops->to_async = tdefault_async;
diff --git a/gdb/target.c b/gdb/target.c
index 6bfaa58..559ae5f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -55,6 +55,8 @@ static int default_watchpoint_addr_within_range (struct target_ops *,
 static int default_region_ok_for_hw_watchpoint (struct target_ops *,
 						CORE_ADDR, int);
 
+static void default_rcmd (struct target_ops *, char *, struct ui_file *);
+
 static void tcomplain (void) ATTRIBUTE_NORETURN;
 
 static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
@@ -589,7 +591,7 @@ update_current_target (void)
       /* Do not inherit to_open.  */
       /* Do not inherit to_close.  */
       /* Do not inherit to_attach.  */
-      INHERIT (to_post_attach, t);
+      /* Do not inherit to_post_attach.  */
       INHERIT (to_attach_no_wait, t);
       /* Do not inherit to_detach.  */
       /* Do not inherit to_disconnect.  */
@@ -597,16 +599,16 @@ update_current_target (void)
       /* Do not inherit to_wait.  */
       /* Do not inherit to_fetch_registers.  */
       /* Do not inherit to_store_registers.  */
-      INHERIT (to_prepare_to_store, t);
+      /* Do not inherit to_prepare_to_store.  */
       INHERIT (deprecated_xfer_memory, t);
-      INHERIT (to_files_info, t);
+      /* Do not inherit to_files_info.  */
       /* Do not inherit to_insert_breakpoint.  */
       /* Do not inherit to_remove_breakpoint.  */
-      INHERIT (to_can_use_hw_breakpoint, t);
-      INHERIT (to_insert_hw_breakpoint, t);
-      INHERIT (to_remove_hw_breakpoint, t);
+      /* Do not inherit to_can_use_hw_breakpoint.  */
+      /* Do not inherit to_insert_hw_breakpoint.  */
+      /* Do not inherit to_remove_hw_breakpoint.  */
       /* Do not inherit to_ranged_break_num_registers.  */
-      INHERIT (to_insert_watchpoint, t);
+      /* Do not inherit to_insert_watchpoint.  */
       INHERIT (to_remove_watchpoint, t);
       /* Do not inherit to_insert_mask_watchpoint.  */
       /* Do not inherit to_remove_mask_watchpoint.  */
@@ -648,7 +650,7 @@ update_current_target (void)
       INHERIT (to_thread_name, t);
       INHERIT (to_stop, t);
       /* Do not inherit to_xfer_partial.  */
-      INHERIT (to_rcmd, t);
+      /* Do not inherit to_rcmd.  */
       INHERIT (to_pid_to_exec_file, t);
       INHERIT (to_log_command, t);
       INHERIT (to_stratum, t);
@@ -728,34 +730,10 @@ update_current_target (void)
   de_fault (to_close,
 	    (void (*) (struct target_ops *))
 	    target_ignore);
-  de_fault (to_post_attach,
-	    (void (*) (struct target_ops *, int))
-	    target_ignore);
-  de_fault (to_prepare_to_store,
-	    (void (*) (struct target_ops *, struct regcache *))
-	    noprocess);
   de_fault (deprecated_xfer_memory,
 	    (int (*) (CORE_ADDR, gdb_byte *, int, int,
 		      struct mem_attrib *, struct target_ops *))
 	    nomemory);
-  de_fault (to_files_info,
-	    (void (*) (struct target_ops *))
-	    target_ignore);
-  de_fault (to_can_use_hw_breakpoint,
-	    (int (*) (struct target_ops *, int, int, int))
-	    return_zero);
-  de_fault (to_insert_hw_breakpoint,
-	    (int (*) (struct target_ops *, struct gdbarch *,
-		      struct bp_target_info *))
-	    return_minus_one);
-  de_fault (to_remove_hw_breakpoint,
-	    (int (*) (struct target_ops *, struct gdbarch *,
-		      struct bp_target_info *))
-	    return_minus_one);
-  de_fault (to_insert_watchpoint,
-	    (int (*) (struct target_ops *, CORE_ADDR, int, int,
-		      struct expression *))
-	    return_minus_one);
   de_fault (to_remove_watchpoint,
 	    (int (*) (struct target_ops *, CORE_ADDR, int, int,
 		      struct expression *))
@@ -827,9 +805,6 @@ update_current_target (void)
   de_fault (to_stop,
 	    (void (*) (struct target_ops *, ptid_t))
 	    target_ignore);
-  de_fault (to_rcmd,
-	    (void (*) (struct target_ops *, char *, struct ui_file *))
-	    tcomplain);
   de_fault (to_pid_to_exec_file,
 	    (char *(*) (struct target_ops *, int))
 	    return_null);
@@ -2629,19 +2604,10 @@ target_detach (const char *args, int from_tty)
 
   prepare_for_detach ();
 
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_detach != NULL)
-	{
-	  t->to_detach (t, args, from_tty);
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n",
-				args, from_tty);
-	  return;
-	}
-    }
-
-  internal_error (__FILE__, __LINE__, _("could not find a target to detach"));
+  current_target.to_detach (&current_target, args, from_tty);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n",
+			args, from_tty);
 }
 
 void
@@ -3754,9 +3720,6 @@ init_dummy_target (void)
   dummy_target.to_shortname = "None";
   dummy_target.to_longname = "None";
   dummy_target.to_doc = "";
-  dummy_target.to_attach = find_default_attach;
-  dummy_target.to_detach = 
-    (void (*)(struct target_ops *, const char *, int))target_ignore;
   dummy_target.to_create_inferior = find_default_create_inferior;
   dummy_target.to_supports_non_stop = find_default_supports_non_stop;
   dummy_target.to_supports_disable_randomization
@@ -3803,22 +3766,10 @@ target_close (struct target_ops *targ)
 void
 target_attach (char *args, int from_tty)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    {
-      if (t->to_attach != NULL)	
-	{
-	  t->to_attach (t, args, from_tty);
-	  if (targetdebug)
-	    fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n",
-				args, from_tty);
-	  return;
-	}
-    }
-
-  internal_error (__FILE__, __LINE__,
-		  _("could not find a target to attach"));
+  current_target.to_attach (&current_target, args, from_tty);
+  if (targetdebug)
+    fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n",
+			args, from_tty);
 }
 
 int
@@ -5017,16 +4968,15 @@ stack of targets currently in use (including the exec-file,\n\
 core-file, and process, if any), as well as the symbol file name.";
 
 static void
+default_rcmd (struct target_ops *self, char *command, struct ui_file *output)
+{
+  error (_("\"monitor\" command not supported by this target."));
+}
+
+static void
 do_monitor_command (char *cmd,
 		 int from_tty)
 {
-  if ((current_target.to_rcmd
-       == (void (*) (struct target_ops *, char *, struct ui_file *)) tcomplain)
-      || (current_target.to_rcmd == debug_to_rcmd
-	  && (debug_target.to_rcmd
-	      == (void (*) (struct target_ops *,
-			    char *, struct ui_file *)) tcomplain)))
-    error (_("\"monitor\" command not supported by this target."));
   target_rcmd (cmd, gdb_stdtarg);
 }
 
diff --git a/gdb/target.h b/gdb/target.h
index 9fdd506..ad552a9 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -394,9 +394,12 @@ struct target_ops
        to xfree everything (including the "struct target_ops").  */
     void (*to_xclose) (struct target_ops *targ);
     void (*to_close) (struct target_ops *);
-    void (*to_attach) (struct target_ops *ops, char *, int);
-    void (*to_post_attach) (struct target_ops *, int);
-    void (*to_detach) (struct target_ops *ops, const char *, int);
+    void (*to_attach) (struct target_ops *ops, char *, int)
+      TARGET_DEFAULT_FUNC (find_default_attach);
+    void (*to_post_attach) (struct target_ops *, int)
+      TARGET_DEFAULT_IGNORE ();
+    void (*to_detach) (struct target_ops *ops, const char *, int)
+      TARGET_DEFAULT_IGNORE ();
     void (*to_disconnect) (struct target_ops *, char *, int);
     void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal)
       TARGET_DEFAULT_NORETURN (noprocess ());
@@ -406,7 +409,8 @@ struct target_ops
     void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
     void (*to_store_registers) (struct target_ops *, struct regcache *, int)
       TARGET_DEFAULT_NORETURN (noprocess ());
-    void (*to_prepare_to_store) (struct target_ops *, struct regcache *);
+    void (*to_prepare_to_store) (struct target_ops *, struct regcache *)
+      TARGET_DEFAULT_NORETURN (noprocess ());
 
     /* Transfer LEN bytes of memory between GDB address MYADDR and
        target address MEMADDR.  If WRITE, transfer them to the target, else
@@ -434,26 +438,31 @@ struct target_ops
 				   struct mem_attrib *attrib,
 				   struct target_ops *target);
 
-    void (*to_files_info) (struct target_ops *);
+    void (*to_files_info) (struct target_ops *)
+      TARGET_DEFAULT_IGNORE ();
     int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
 				 struct bp_target_info *)
       TARGET_DEFAULT_FUNC (memory_insert_breakpoint);
     int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
 				 struct bp_target_info *)
       TARGET_DEFAULT_FUNC (memory_remove_breakpoint);
-    int (*to_can_use_hw_breakpoint) (struct target_ops *, int, int, int);
+    int (*to_can_use_hw_breakpoint) (struct target_ops *, int, int, int)
+      TARGET_DEFAULT_RETURN (0);
     int (*to_ranged_break_num_registers) (struct target_ops *);
     int (*to_insert_hw_breakpoint) (struct target_ops *,
-				    struct gdbarch *, struct bp_target_info *);
+				    struct gdbarch *, struct bp_target_info *)
+      TARGET_DEFAULT_RETURN (-1);
     int (*to_remove_hw_breakpoint) (struct target_ops *,
-				    struct gdbarch *, struct bp_target_info *);
+				    struct gdbarch *, struct bp_target_info *)
+      TARGET_DEFAULT_RETURN (-1);
 
     /* Documentation of what the two routines below are expected to do is
        provided with the corresponding target_* macros.  */
     int (*to_remove_watchpoint) (struct target_ops *,
 				 CORE_ADDR, int, int, struct expression *);
     int (*to_insert_watchpoint) (struct target_ops *,
-				 CORE_ADDR, int, int, struct expression *);
+				 CORE_ADDR, int, int, struct expression *)
+      TARGET_DEFAULT_RETURN (-1);
 
     int (*to_insert_mask_watchpoint) (struct target_ops *,
 				      CORE_ADDR, CORE_ADDR, int);
@@ -517,7 +526,8 @@ struct target_ops
     char *(*to_thread_name) (struct target_ops *, struct thread_info *);
     void (*to_stop) (struct target_ops *, ptid_t);
     void (*to_rcmd) (struct target_ops *,
-		     char *command, struct ui_file *output);
+		     char *command, struct ui_file *output)
+      TARGET_DEFAULT_FUNC (default_rcmd);
     char *(*to_pid_to_exec_file) (struct target_ops *, int pid);
     void (*to_log_command) (struct target_ops *, const char *);
     struct target_section_table *(*to_get_section_table) (struct target_ops *);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (36 preceding siblings ...)
  2014-02-06 21:42 ` [RFC v2 18/38] convert to_detach Tom Tromey
@ 2014-02-06 21:47 ` Tom Tromey
  2014-02-07 16:02   ` Pedro Alves
  2014-02-07 16:47 ` [RFC v2 00/38] clean up target delegation Pedro Alves
  2014-02-19 16:35 ` Tom Tromey
  39 siblings, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-06 21:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This converts to_get_unwinder and to_get_tailcall_unwinder to methods
and arranges for them to use the new delegation scheme.

This just lets us avoid having a differing style (neither new-style
nor INHERIT) of delegation in the tree.

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

	* target.c (target_get_unwinder): Rewrite.
	(target_get_tailcall_unwinder): Rewrite.
	* record-btrace.c (record_btrace_to_get_unwinder): New function.
	(record_btrace_to_get_tailcall_unwinder): New function.
	(init_record_btrace_ops): Update.
	* target.h (struct target_ops) <to_get_unwinder,
	to_get_tailcall_unwinder>: Now function pointers.  Use
	TARGET_DEFAULT_RETURN.
---
 gdb/ChangeLog          | 11 +++++++++++
 gdb/record-btrace.c    | 20 ++++++++++++++++++--
 gdb/target-delegates.c | 32 ++++++++++++++++++++++++++++++++
 gdb/target.c           | 16 ++--------------
 gdb/target.h           | 12 ++++++++----
 5 files changed, 71 insertions(+), 20 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index c4872eb..ab288ef 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1302,6 +1302,22 @@ const struct frame_unwind record_btrace_tailcall_frame_unwind =
   record_btrace_frame_dealloc_cache
 };
 
+/* Implement the to_get_unwinder method.  */
+
+static const struct frame_unwind *
+record_btrace_to_get_unwinder (struct target_ops *self)
+{
+  return &record_btrace_frame_unwind;
+}
+
+/* Implement the to_get_tailcall_unwinder method.  */
+
+static const struct frame_unwind *
+record_btrace_to_get_tailcall_unwinder (struct target_ops *self)
+{
+  return &record_btrace_tailcall_frame_unwind;
+}
+
 /* Indicate that TP should be resumed according to FLAG.  */
 
 static void
@@ -1888,8 +1904,8 @@ init_record_btrace_ops (void)
   ops->to_fetch_registers = record_btrace_fetch_registers;
   ops->to_store_registers = record_btrace_store_registers;
   ops->to_prepare_to_store = record_btrace_prepare_to_store;
-  ops->to_get_unwinder = &record_btrace_frame_unwind;
-  ops->to_get_tailcall_unwinder = &record_btrace_tailcall_frame_unwind;
+  ops->to_get_unwinder = &record_btrace_to_get_unwinder;
+  ops->to_get_tailcall_unwinder = &record_btrace_to_get_tailcall_unwinder;
   ops->to_resume = record_btrace_resume;
   ops->to_wait = record_btrace_wait;
   ops->to_find_new_threads = record_btrace_find_new_threads;
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index d9c68cd..03b0d2a 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -1572,6 +1572,32 @@ tdefault_augmented_libraries_svr4_read (struct target_ops *self)
   return 0;
 }
 
+static const struct frame_unwind *
+delegate_get_unwinder (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_get_unwinder (self);
+}
+
+static const struct frame_unwind *
+tdefault_get_unwinder (struct target_ops *self)
+{
+  return NULL;
+}
+
+static const struct frame_unwind *
+delegate_get_tailcall_unwinder (struct target_ops *self)
+{
+  self = self->beneath;
+  return self->to_get_tailcall_unwinder (self);
+}
+
+static const struct frame_unwind *
+tdefault_get_tailcall_unwinder (struct target_ops *self)
+{
+  return NULL;
+}
+
 static CORE_ADDR
 delegate_decr_pc_after_break (struct target_ops *self, struct gdbarch *arg1)
 {
@@ -1844,6 +1870,10 @@ install_delegators (struct target_ops *ops)
     ops->to_call_history_range = delegate_call_history_range;
   if (ops->to_augmented_libraries_svr4_read == NULL)
     ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
+  if (ops->to_get_unwinder == NULL)
+    ops->to_get_unwinder = delegate_get_unwinder;
+  if (ops->to_get_tailcall_unwinder == NULL)
+    ops->to_get_tailcall_unwinder = delegate_get_tailcall_unwinder;
   if (ops->to_decr_pc_after_break == NULL)
     ops->to_decr_pc_after_break = delegate_decr_pc_after_break;
 }
@@ -1982,5 +2012,7 @@ install_dummy_methods (struct target_ops *ops)
   ops->to_call_history_from = tdefault_call_history_from;
   ops->to_call_history_range = tdefault_call_history_range;
   ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
+  ops->to_get_unwinder = tdefault_get_unwinder;
+  ops->to_get_tailcall_unwinder = tdefault_get_tailcall_unwinder;
   ops->to_decr_pc_after_break = default_target_decr_pc_after_break;
 }
diff --git a/gdb/target.c b/gdb/target.c
index 72d5a09..d03c4fb 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3761,13 +3761,7 @@ debug_to_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 const struct frame_unwind *
 target_get_unwinder (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_get_unwinder != NULL)
-      return t->to_get_unwinder;
-
-  return NULL;
+  return current_target.to_get_unwinder (&current_target);
 }
 
 /* See target.h.  */
@@ -3775,13 +3769,7 @@ target_get_unwinder (void)
 const struct frame_unwind *
 target_get_tailcall_unwinder (void)
 {
-  struct target_ops *t;
-
-  for (t = current_target.beneath; t != NULL; t = t->beneath)
-    if (t->to_get_tailcall_unwinder != NULL)
-      return t->to_get_tailcall_unwinder;
-
-  return NULL;
+  return current_target.to_get_tailcall_unwinder (&current_target);
 }
 
 /* Default implementation of to_decr_pc_after_break.  */
diff --git a/gdb/target.h b/gdb/target.h
index c988a01..58519b0 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1095,10 +1095,14 @@ struct target_ops
     int (*to_augmented_libraries_svr4_read) (struct target_ops *)
       TARGET_DEFAULT_RETURN (0);
 
-    /* Those unwinders are tried before any other arch unwinders.  Use NULL if
-       it is not used.  */
-    const struct frame_unwind *to_get_unwinder;
-    const struct frame_unwind *to_get_tailcall_unwinder;
+    /* Those unwinders are tried before any other arch unwinders.  If
+       SELF doesn't have unwinders, it should delegate to the
+       "beneath" target.  */
+    const struct frame_unwind *(*to_get_unwinder) (struct target_ops *self)
+      TARGET_DEFAULT_RETURN (NULL);
+
+    const struct frame_unwind *(*to_get_tailcall_unwinder) (struct target_ops *self)
+      TARGET_DEFAULT_RETURN (NULL);
 
     /* Return the number of bytes by which the PC needs to be decremented
        after executing a breakpoint instruction.
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 02/38] introduce and use find_target_at
  2014-02-06 20:55 ` [RFC v2 02/38] introduce and use find_target_at Tom Tromey
@ 2014-02-07 15:43   ` Pedro Alves
  2014-02-07 21:54     ` Tom Tromey
  0 siblings, 1 reply; 55+ messages in thread
From: Pedro Alves @ 2014-02-07 15:43 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 02/06/2014 08:55 PM, Tom Tromey wrote:
> RECORD_IS_USED looks at current_target.to_stratum to determine whether
> a record target is in use.  This is bad because arch_stratum is
> greater than record_stratum.
> 
> To fix this, this patch adds find_target_at to determine whether a
> target appears at a given stratum.  This may seem like overkill
> somehow, but I have a subsequent patch series that uses it more
> heavily.
> 
> This new function lets us clean up find_record_target a bit as well.

This log entry is now stale.  The to_stratum issue was fixed
meanwhile.  (also, this own series makes use of this later on,
no need to mention a subsequent series).

> 
> 2014-02-06  Tom Tromey  <tromey@redhat.com>
> 
> 	* record.c (find_record_target): Use find_target_at.
> 	* record.h (RECORD_IS_REPLAY): Use find_target_at.
> 	* target.c (find_target_at): New function.
> 	* target.h (find_target_at): Declare.
> ---
>  gdb/ChangeLog |  7 +++++++
>  gdb/record.c  |  8 +-------
>  gdb/target.c  | 14 ++++++++++++++
>  gdb/target.h  |  5 +++++
>  4 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/gdb/record.c b/gdb/record.c
> index 4c67192..41e167f 100644
> --- a/gdb/record.c
> +++ b/gdb/record.c
> @@ -62,13 +62,7 @@ struct cmd_list_element *info_record_cmdlist = NULL;
>  struct target_ops *
>  find_record_target (void)
>  {
> -  struct target_ops *t;
> -
> -  for (t = current_target.beneath; t != NULL; t = t->beneath)
> -    if (t->to_stratum == record_stratum)
> -      return t;
> -
> -  return NULL;
> +  return find_target_at (record_stratum);
>  }
>  
>  /* Check that recording is active.  Throw an error, if it isn't.  */
> diff --git a/gdb/target.c b/gdb/target.c
> index 6723562..c9f004a 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -3685,6 +3685,20 @@ find_target_beneath (struct target_ops *t)
>    return t->beneath;
>  }
>  
> +/* See target.h.  */
> +
> +struct target_ops *
> +find_target_at (enum strata stratum)
> +{
> +  struct target_ops *t;
> +
> +  for (t = current_target.beneath; t != NULL; t = t->beneath)
> +    if (t->to_stratum == stratum)
> +      return t;
> +
> +  return NULL;
> +}
> +
>  \f
>  /* The inferior process has died.  Long live the inferior!  */
>  
> diff --git a/gdb/target.h b/gdb/target.h
> index e3479e2..07d0afd 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -1955,6 +1955,11 @@ extern void find_default_create_inferior (struct target_ops *,
>  
>  extern struct target_ops *find_target_beneath (struct target_ops *);
>  
> +/* Find the target at STRATUM.  If no target is at that stratum,
> +   return NULL.  */
> +
> +struct target_ops *find_target_at (enum strata stratum);
> +
>  /* Read OS data object of type TYPE from the target, and return it in
>     XML format.  The result is NUL-terminated and returned as a string,
>     allocated using xmalloc.  If an error occurs or the transfer is
> 


-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 04/38] add target method delegation
  2014-02-06 20:58 ` [RFC v2 04/38] add target method delegation Tom Tromey
@ 2014-02-07 15:53   ` Pedro Alves
  2014-02-07 21:37     ` Tom Tromey
  0 siblings, 1 reply; 55+ messages in thread
From: Pedro Alves @ 2014-02-07 15:53 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 02/06/2014 08:55 PM, Tom Tromey wrote:
> -  record_full_core_ops.to_can_async_p = record_full_can_async_p;
> -  record_full_core_ops.to_is_async_p = record_full_is_async_p;

I think you forgot to update this hunk.  I think these
should still be installed?

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 37/38] fix buglet in nto-procfs.c
  2014-02-06 20:56 ` [RFC v2 37/38] fix buglet in nto-procfs.c Tom Tromey
@ 2014-02-07 16:01   ` Pedro Alves
  0 siblings, 0 replies; 55+ messages in thread
From: Pedro Alves @ 2014-02-07 16:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 02/06/2014 08:55 PM, Tom Tromey wrote:
> I happened to notice that nto-procfs.c defines
> procfs_remove_hw_breakpoint but never uses it.  This caused it not to
> be updated by my target-method-updating script.  This patch fixes the
> function and installs it properly.  I have no way to test this,
> however.
> 
> 2014-02-06  Tom Tromey  <tromey@redhat.com>
> 
> 	* nto-procfs.c (procfs_remove_hw_breakpoint): Add 'self'
> 	argument.
> 	(init_procfs_ops): Correctly set to_remove_hw_breakpoint.

OK, just go ahead without testing.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods
  2014-02-06 21:47 ` [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods Tom Tromey
@ 2014-02-07 16:02   ` Pedro Alves
  0 siblings, 0 replies; 55+ messages in thread
From: Pedro Alves @ 2014-02-07 16:02 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 02/06/2014 08:55 PM, Tom Tromey wrote:
> This converts to_get_unwinder and to_get_tailcall_unwinder to methods
> and arranges for them to use the new delegation scheme.
> 
> This just lets us avoid having a differing style (neither new-style
> nor INHERIT) of delegation in the tree.
> 
> 2014-02-06  Tom Tromey  <tromey@redhat.com>
> 
> 	* target.c (target_get_unwinder): Rewrite.
> 	(target_get_tailcall_unwinder): Rewrite.
> 	* record-btrace.c (record_btrace_to_get_unwinder): New function.
> 	(record_btrace_to_get_tailcall_unwinder): New function.
> 	(init_record_btrace_ops): Update.
> 	* target.h (struct target_ops) <to_get_unwinder,
> 	to_get_tailcall_unwinder>: Now function pointers.  Use
> 	TARGET_DEFAULT_RETURN.
> ---
>  gdb/ChangeLog          | 11 +++++++++++
>  gdb/record-btrace.c    | 20 ++++++++++++++++++--
>  gdb/target-delegates.c | 32 ++++++++++++++++++++++++++++++++
>  gdb/target.c           | 16 ++--------------
>  gdb/target.h           | 12 ++++++++----
>  5 files changed, 71 insertions(+), 20 deletions(-)
> 
> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
> index c4872eb..ab288ef 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -1302,6 +1302,22 @@ const struct frame_unwind record_btrace_tailcall_frame_unwind =
>    record_btrace_frame_dealloc_cache
>  };
>  
> +/* Implement the to_get_unwinder method.  */
> +
> +static const struct frame_unwind *
> +record_btrace_to_get_unwinder (struct target_ops *self)
> +{
> +  return &record_btrace_frame_unwind;
> +}
> +
> +/* Implement the to_get_tailcall_unwinder method.  */
> +
> +static const struct frame_unwind *
> +record_btrace_to_get_tailcall_unwinder (struct target_ops *self)
> +{
> +  return &record_btrace_tailcall_frame_unwind;
> +}
> +
>  /* Indicate that TP should be resumed according to FLAG.  */
>  
>  static void
> @@ -1888,8 +1904,8 @@ init_record_btrace_ops (void)
>    ops->to_fetch_registers = record_btrace_fetch_registers;
>    ops->to_store_registers = record_btrace_store_registers;
>    ops->to_prepare_to_store = record_btrace_prepare_to_store;
> -  ops->to_get_unwinder = &record_btrace_frame_unwind;
> -  ops->to_get_tailcall_unwinder = &record_btrace_tailcall_frame_unwind;
> +  ops->to_get_unwinder = &record_btrace_to_get_unwinder;
> +  ops->to_get_tailcall_unwinder = &record_btrace_to_get_tailcall_unwinder;
>    ops->to_resume = record_btrace_resume;
>    ops->to_wait = record_btrace_wait;
>    ops->to_find_new_threads = record_btrace_find_new_threads;
> diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
> index d9c68cd..03b0d2a 100644
> --- a/gdb/target-delegates.c
> +++ b/gdb/target-delegates.c
> @@ -1572,6 +1572,32 @@ tdefault_augmented_libraries_svr4_read (struct target_ops *self)
>    return 0;
>  }
>  
> +static const struct frame_unwind *
> +delegate_get_unwinder (struct target_ops *self)
> +{
> +  self = self->beneath;
> +  return self->to_get_unwinder (self);
> +}
> +
> +static const struct frame_unwind *
> +tdefault_get_unwinder (struct target_ops *self)
> +{
> +  return NULL;
> +}
> +
> +static const struct frame_unwind *
> +delegate_get_tailcall_unwinder (struct target_ops *self)
> +{
> +  self = self->beneath;
> +  return self->to_get_tailcall_unwinder (self);
> +}
> +
> +static const struct frame_unwind *
> +tdefault_get_tailcall_unwinder (struct target_ops *self)
> +{
> +  return NULL;
> +}
> +
>  static CORE_ADDR
>  delegate_decr_pc_after_break (struct target_ops *self, struct gdbarch *arg1)
>  {
> @@ -1844,6 +1870,10 @@ install_delegators (struct target_ops *ops)
>      ops->to_call_history_range = delegate_call_history_range;
>    if (ops->to_augmented_libraries_svr4_read == NULL)
>      ops->to_augmented_libraries_svr4_read = delegate_augmented_libraries_svr4_read;
> +  if (ops->to_get_unwinder == NULL)
> +    ops->to_get_unwinder = delegate_get_unwinder;
> +  if (ops->to_get_tailcall_unwinder == NULL)
> +    ops->to_get_tailcall_unwinder = delegate_get_tailcall_unwinder;
>    if (ops->to_decr_pc_after_break == NULL)
>      ops->to_decr_pc_after_break = delegate_decr_pc_after_break;
>  }
> @@ -1982,5 +2012,7 @@ install_dummy_methods (struct target_ops *ops)
>    ops->to_call_history_from = tdefault_call_history_from;
>    ops->to_call_history_range = tdefault_call_history_range;
>    ops->to_augmented_libraries_svr4_read = tdefault_augmented_libraries_svr4_read;
> +  ops->to_get_unwinder = tdefault_get_unwinder;
> +  ops->to_get_tailcall_unwinder = tdefault_get_tailcall_unwinder;
>    ops->to_decr_pc_after_break = default_target_decr_pc_after_break;
>  }
> diff --git a/gdb/target.c b/gdb/target.c
> index 72d5a09..d03c4fb 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -3761,13 +3761,7 @@ debug_to_prepare_to_store (struct target_ops *self, struct regcache *regcache)
>  const struct frame_unwind *
>  target_get_unwinder (void)
>  {
> -  struct target_ops *t;
> -
> -  for (t = current_target.beneath; t != NULL; t = t->beneath)
> -    if (t->to_get_unwinder != NULL)
> -      return t->to_get_unwinder;
> -
> -  return NULL;
> +  return current_target.to_get_unwinder (&current_target);
>  }
>  
>  /* See target.h.  */
> @@ -3775,13 +3769,7 @@ target_get_unwinder (void)
>  const struct frame_unwind *
>  target_get_tailcall_unwinder (void)
>  {
> -  struct target_ops *t;
> -
> -  for (t = current_target.beneath; t != NULL; t = t->beneath)
> -    if (t->to_get_tailcall_unwinder != NULL)
> -      return t->to_get_tailcall_unwinder;
> -
> -  return NULL;
> +  return current_target.to_get_tailcall_unwinder (&current_target);
>  }
>  
>  /* Default implementation of to_decr_pc_after_break.  */
> diff --git a/gdb/target.h b/gdb/target.h
> index c988a01..58519b0 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -1095,10 +1095,14 @@ struct target_ops
>      int (*to_augmented_libraries_svr4_read) (struct target_ops *)
>        TARGET_DEFAULT_RETURN (0);
>  
> -    /* Those unwinders are tried before any other arch unwinders.  Use NULL if
> -       it is not used.  */
> -    const struct frame_unwind *to_get_unwinder;
> -    const struct frame_unwind *to_get_tailcall_unwinder;
> +    /* Those unwinders are tried before any other arch unwinders.  If
> +       SELF doesn't have unwinders, it should delegate to the
> +       "beneath" target.  */
> +    const struct frame_unwind *(*to_get_unwinder) (struct target_ops *self)
> +      TARGET_DEFAULT_RETURN (NULL);
> +
> +    const struct frame_unwind *(*to_get_tailcall_unwinder) (struct target_ops *self)
> +      TARGET_DEFAULT_RETURN (NULL);
>  
>      /* Return the number of bytes by which the PC needs to be decremented
>         after executing a breakpoint instruction.
> 


-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 00/38] clean up target delegation
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (37 preceding siblings ...)
  2014-02-06 21:47 ` [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods Tom Tromey
@ 2014-02-07 16:47 ` Pedro Alves
  2014-02-19 16:35 ` Tom Tromey
  39 siblings, 0 replies; 55+ messages in thread
From: Pedro Alves @ 2014-02-07 16:47 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 02/06/2014 08:54 PM, Tom Tromey wrote:
> This is revision 2 of the target delegation cleanup series.  The
> original series is here:
> 
>     https://sourceware.org/ml/gdb-patches/2014-01/msg00331.html
> 
> This submission is, again, a squashed version of the series I actually
> developed.  I've redone the squashing using the same patch bundlings
> as before.
> 
> When the time comes, I plan to merge the atomized series rather than
> this one; the squashing having been done to avoid an email flood and
> to bundle the more mechanical patches in an attempt to make reviews
> less strenuous.
> 
> This series differs from the original in several ways, though I
> believe none of the changes are truly major.
> 
> I believe this version addresses all the reviews.
> 
> It required minor changes here and there when I rebased.  I didn't
> generally make a record of these fixes, but they were all simply
> adaptations either to patches that went in earlier, or to other
> patches touching target methods.
> 
> A couple of patches from the old series have already been pushed.
> 
> Patches 33-38 in this series are new to this revision.  They all arose
> from reviews of the first series.  I believe they were all reviewed
> already by Pedro.

There were a couple that we only discussed on internal IRC, I
believe.  FAOD, I've replied to those.

> Built and regtested on x86-64 Fedora 18.  Due to the relatively minor
> nature of the changes from revision 1, I did not redo the more
> comprehensive testing I did of that revision.

I cross checked my previous comments against the new series,
only noticed only a couple small details.  I didn't look again at
patches where in v1 they already looked fine to me.  So to me,
with patches #2 and #4 addressed, this is good to me.  Am I looking
forward to it.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 04/38] add target method delegation
  2014-02-07 15:53   ` Pedro Alves
@ 2014-02-07 21:37     ` Tom Tromey
  0 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-07 21:37 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 02/06/2014 08:55 PM, Tom Tromey wrote:
>> -  record_full_core_ops.to_can_async_p = record_full_can_async_p;
>> -  record_full_core_ops.to_is_async_p = record_full_is_async_p;

Pedro> I think you forgot to update this hunk.  I think these
Pedro> should still be installed?

Thanks, I've fixed this on my branch.

Tom

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 02/38] introduce and use find_target_at
  2014-02-07 15:43   ` Pedro Alves
@ 2014-02-07 21:54     ` Tom Tromey
  2014-02-10 14:28       ` Pedro Alves
  0 siblings, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-07 21:54 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro> This log entry is now stale.  The to_stratum issue was fixed
Pedro> meanwhile.  (also, this own series makes use of this later on,
Pedro> no need to mention a subsequent series).

Thanks.  The ChangeLog was also a little out of date:

>> * record.h (RECORD_IS_REPLAY): Use find_target_at.

... this no longer appears in the patch.

I've changed the log message to read:

    This patch adds find_target_at to determine whether a target appears
    at a given stratum.  This new function lets us clean up
    find_record_target a bit, and is generally useful.

Let me know what you think.

Tom

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 07/38] Add target_ops argument to to_close
  2014-02-06 20:56 ` [RFC v2 07/38] Add target_ops argument to to_close Tom Tromey
@ 2014-02-08  3:00   ` Yao Qi
  2014-02-10 17:50     ` Tom Tromey
  0 siblings, 1 reply; 55+ messages in thread
From: Yao Qi @ 2014-02-08  3:00 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 02/07/2014 04:55 AM, Tom Tromey wrote:
>  static int
> -ppc_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
> +ppc_linux_region_ok_for_hw_watchpoint (struct target_ops *self,
> +				       CORE_ADDR addr, int len)
>  {
>    /* Handle sub-8-byte quantities.  */
>    if (len <= 0)
> @@ -1672,7 +1674,8 @@ ppc_linux_ranged_break_num_registers (struct target_ops *target)
>     success, 1 if hardware breakpoints are not supported or -1 for failure.  */

ppc_linux_region_ok_for_hw_watchpoint calls ppc_linux_get_hwcap, which
uses current_target,

/* Fetch the AT_HWCAP entry from the aux vector.  */
static unsigned long
ppc_linux_get_hwcap (void)
{
  CORE_ADDR field;

  if (target_auxv_search (&current_target, AT_HWCAP, &field))
    return (unsigned long) field;

  return 0;
}

Do we need to add argument 'ops' to ppc_linux_get_hwcap and stop
using current_target in ppc_linux_get_hwcap?

You may have done that in the following patches, and it is not
surprise I miss it.

Likewise, we need to add argument 'ops' to s390_get_hwcap too,
and pass ops from its caller.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 01/38] add "this" pointers to more target APIs
  2014-02-06 20:56 ` [RFC v2 01/38] add "this" pointers to more target APIs Tom Tromey
@ 2014-02-08  5:19   ` Doug Evans
  2014-02-10 22:36     ` Doug Evans
  0 siblings, 1 reply; 55+ messages in thread
From: Doug Evans @ 2014-02-08  5:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, Feb 6, 2014 at 12:54 PM, Tom Tromey <tromey@redhat.com> wrote:
> A subsequent pass introduces delegation helper functions to the target
> API.  This delegation is much cleaner if the target_ops pointer is
> directly available at delegation time.
>
> This patch adds the "this" pointer to various to_* methods for this
> purpose.
>
> This updates a number of ports which I am unable to test.  Please give
> them a look-over.  Any possible problem here is trivial, though, as
> all that is required is adding an argument to a function.

Hi.
I'm *not* suggesting wholesale changes (babysteps is totally fine with
me), but there's something I'm not sure about.

I think it was on IRC where there was a discussion of passing the
(pseudo-)vtable pointer as the self/this parameter being less
preferable to passing a more canonical self/this which in turn has the
(pseudo-)vtable pointer.  In this case we might not need such a change
until such time as we've already converted to C++ (and thus taking the
next step now could be time best spent elsewhere).  My question is to
ask for clarity on where you see the target API headed.  Will we need
a more canonical self/this pointer soon(-ish)?

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 02/38] introduce and use find_target_at
  2014-02-07 21:54     ` Tom Tromey
@ 2014-02-10 14:28       ` Pedro Alves
  0 siblings, 0 replies; 55+ messages in thread
From: Pedro Alves @ 2014-02-10 14:28 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 02/07/2014 09:54 PM, Tom Tromey wrote:
> Pedro> This log entry is now stale.  The to_stratum issue was fixed
> Pedro> meanwhile.  (also, this own series makes use of this later on,
> Pedro> no need to mention a subsequent series).
> 
> Thanks.  The ChangeLog was also a little out of date:
> 
>>> * record.h (RECORD_IS_REPLAY): Use find_target_at.
> 
> ... this no longer appears in the patch.
> 
> I've changed the log message to read:
> 
>     This patch adds find_target_at to determine whether a target appears
>     at a given stratum.  This new function lets us clean up
>     find_record_target a bit, and is generally useful.
> 
> Let me know what you think.

That's fine with me.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 07/38] Add target_ops argument to to_close
  2014-02-08  3:00   ` Yao Qi
@ 2014-02-10 17:50     ` Tom Tromey
  0 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-10 17:50 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> /* Fetch the AT_HWCAP entry from the aux vector.  */
Yao> static unsigned long
Yao> ppc_linux_get_hwcap (void)
Yao> {
Yao>   CORE_ADDR field;

Yao>   if (target_auxv_search (&current_target, AT_HWCAP, &field))
Yao>     return (unsigned long) field;

Yao>   return 0;
Yao> }

Yao> Do we need to add argument 'ops' to ppc_linux_get_hwcap and stop
Yao> using current_target in ppc_linux_get_hwcap?

It depends on whether the call should act at the current stratum or
below, or whether the call should restart from the top of the target
stack.

In most cases I think the latter is intended.

Yao> You may have done that in the following patches, and it is not
Yao> surprise I miss it.

Nope.

Tom

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 01/38] add "this" pointers to more target APIs
  2014-02-08  5:19   ` Doug Evans
@ 2014-02-10 22:36     ` Doug Evans
  2014-02-10 23:01       ` Doug Evans
  2014-02-12 19:56       ` Tom Tromey
  0 siblings, 2 replies; 55+ messages in thread
From: Doug Evans @ 2014-02-10 22:36 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, Feb 7, 2014 at 9:19 PM, Doug Evans <dje@google.com> wrote:
> On Thu, Feb 6, 2014 at 12:54 PM, Tom Tromey <tromey@redhat.com> wrote:
>> A subsequent pass introduces delegation helper functions to the target
>> API.  This delegation is much cleaner if the target_ops pointer is
>> directly available at delegation time.
>>
>> This patch adds the "this" pointer to various to_* methods for this
>> purpose.
>>
>> This updates a number of ports which I am unable to test.  Please give
>> them a look-over.  Any possible problem here is trivial, though, as
>> all that is required is adding an argument to a function.
>
> Hi.
> I'm *not* suggesting wholesale changes (babysteps is totally fine with
> me), but there's something I'm not sure about.
>
> I think it was on IRC where there was a discussion of passing the
> (pseudo-)vtable pointer as the self/this parameter being less
> preferable to passing a more canonical self/this which in turn has the
> (pseudo-)vtable pointer.  In this case we might not need such a change
> until such time as we've already converted to C++ (and thus taking the
> next step now could be time best spent elsewhere).  My question is to
> ask for clarity on where you see the target API headed.  Will we need
> a more canonical self/this pointer soon(-ish)?

As an example (just in case there's some confusion),
one thing I'm thinking about is global state used by targets.
If, for example, we support multiple remote connections then we're
going to have multiple open sockets/descriptors and IWBN if the
target_ops methods fetched such things from "self" instead of global
variables (*1).

I could be missing something of course.

---
(*1): I can imagine a temp hack of keeping such global variables
around and saving/restoring them when we switch targets (so that we
didn't have to update each target_ops function), but that's a bit of
work in itself, and I think(!) it would be preferable to skip that
step.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 01/38] add "this" pointers to more target APIs
  2014-02-10 22:36     ` Doug Evans
@ 2014-02-10 23:01       ` Doug Evans
  2014-02-12 19:56       ` Tom Tromey
  1 sibling, 0 replies; 55+ messages in thread
From: Doug Evans @ 2014-02-10 23:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, Feb 10, 2014 at 2:36 PM, Doug Evans <dje@google.com> wrote:
> On Fri, Feb 7, 2014 at 9:19 PM, Doug Evans <dje@google.com> wrote:
>> On Thu, Feb 6, 2014 at 12:54 PM, Tom Tromey <tromey@redhat.com> wrote:
>>> A subsequent pass introduces delegation helper functions to the target
>>> API.  This delegation is much cleaner if the target_ops pointer is
>>> directly available at delegation time.
>>>
>>> This patch adds the "this" pointer to various to_* methods for this
>>> purpose.
>>>
>>> This updates a number of ports which I am unable to test.  Please give
>>> them a look-over.  Any possible problem here is trivial, though, as
>>> all that is required is adding an argument to a function.
>>
>> Hi.
>> I'm *not* suggesting wholesale changes (babysteps is totally fine with
>> me), but there's something I'm not sure about.
>>
>> I think it was on IRC where there was a discussion of passing the
>> (pseudo-)vtable pointer as the self/this parameter being less
>> preferable to passing a more canonical self/this which in turn has the
>> (pseudo-)vtable pointer.  In this case we might not need such a change
>> until such time as we've already converted to C++ (and thus taking the
>> next step now could be time best spent elsewhere).  My question is to
>> ask for clarity on where you see the target API headed.  Will we need
>> a more canonical self/this pointer soon(-ish)?
>
> As an example (just in case there's some confusion),
> one thing I'm thinking about is global state used by targets.
> If, for example, we support multiple remote connections then we're
> going to have multiple open sockets/descriptors and IWBN if the
> target_ops methods fetched such things from "self" instead of global
> variables (*1).
>
> I could be missing something of course.
>
> ---
> (*1): I can imagine a temp hack of keeping such global variables
> around and saving/restoring them when we switch targets (so that we
> didn't have to update each target_ops function), but that's a bit of
> work in itself, and I think(!) it would be preferable to skip that
> step.

Gotta love hitting Send one moment too soon.
Apologies for the follow-up.

Another interim solution could be to either use the to_data field of
struct target_ops (I'm not sure if bfd-target.c would need changes) or
add a new field, and have one copy of target_ops per active target.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 01/38] add "this" pointers to more target APIs
  2014-02-10 22:36     ` Doug Evans
  2014-02-10 23:01       ` Doug Evans
@ 2014-02-12 19:56       ` Tom Tromey
  2014-02-12 20:22         ` Doug Evans
  1 sibling, 1 reply; 55+ messages in thread
From: Tom Tromey @ 2014-02-12 19:56 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

Doug> As an example (just in case there's some confusion),
Doug> one thing I'm thinking about is global state used by targets.
Doug> If, for example, we support multiple remote connections then we're
Doug> going to have multiple open sockets/descriptors and IWBN if the
Doug> target_ops methods fetched such things from "self" instead of global
Doug> variables (*1).

Doug> I could be missing something of course.

Doug> ---
Doug> (*1): I can imagine a temp hack of keeping such global variables
Doug> around and saving/restoring them when we switch targets (so that we
Doug> didn't have to update each target_ops function), but that's a bit of
Doug> work in itself, and I think(!) it would be preferable to skip that
Doug> step.

My plan is outlined on the multi-target wiki page and on the patches on
the corresponding branch.  The wiki page is here:

https://sourceware.org/gdb/wiki/MultiTarget

Basically the question is whether it is better to turn target_ops into a
real vtable and separate the vtable bits from the state bits.  I think
this is undeniably cleaner.

One concrete benefit of the cleanliness aspect is that it exposes the
API difficulties around to_open; namely that we need to properly
instantiate target objects in spots like find_default_run_target.  This
is not properly handled on the branch.

But, as I said, it is more typing to do this conversion, especially as
I'll now have to redo it, which is somewhat demotivating.  Not to
mention that this would be another sub-series requiring unusual amounts
of testing, as it touches code everywhere.  And, it isn't strictly
necessary, as to_data can be used.  And, if I were to do it again, I'd
probably do it a bit differently.  So I'm not sure.

There really aren't that many targets to convert, in the sense that
being target async capable is a prerequisite for multi-target; and if a
target's maintainer hasn't bothered to do this conversion, then it can
be ignored.  Also, *-nat targets do not require a state conversion, as
in the gdb design they are inherently singletons.  I believe this leaves
remote (largely done and merged; though see the wiki), corelow (done on
the branch), ctf, tfile, and record.  I have not yet converted the
latter three.

As far as the target stack goes, the branch makes the notion of a target
stack explicit, and attaches the target stack to the program space.
Switching progspaces also switches target stacks.  I'm happy with this
approach, though of course it is still too early to know whether it has
an undiscovered flaw.  An individual stratum in a given target stack has
access to its own data, on the branch by subclassing gdb_target, but see
above.

Tom

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 01/38] add "this" pointers to more target APIs
  2014-02-12 19:56       ` Tom Tromey
@ 2014-02-12 20:22         ` Doug Evans
  0 siblings, 0 replies; 55+ messages in thread
From: Doug Evans @ 2014-02-12 20:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Wed, Feb 12, 2014 at 11:56 AM, Tom Tromey <tromey@redhat.com> wrote:
> Doug> As an example (just in case there's some confusion),
> Doug> one thing I'm thinking about is global state used by targets.
> Doug> If, for example, we support multiple remote connections then we're
> Doug> going to have multiple open sockets/descriptors and IWBN if the
> Doug> target_ops methods fetched such things from "self" instead of global
> Doug> variables (*1).
>[...]
> My plan is outlined on the multi-target wiki page and on the patches on
> the corresponding branch.  The wiki page is here:
>
> https://sourceware.org/gdb/wiki/MultiTarget
>
> Basically the question is whether it is better to turn target_ops into a
> real vtable and separate the vtable bits from the state bits.  I think
> this is undeniably cleaner.
>
> One concrete benefit of the cleanliness aspect is that it exposes the
> API difficulties around to_open; namely that we need to properly
> instantiate target objects in spots like find_default_run_target.  This
> is not properly handled on the branch.
>
> But, as I said, it is more typing to do this conversion, especially as
> I'll now have to redo it, which is somewhat demotivating.  Not to
> mention that this would be another sub-series requiring unusual amounts
> of testing, as it touches code everywhere.  And, it isn't strictly
> necessary, as to_data can be used.  And, if I were to do it again, I'd
> probably do it a bit differently.  So I'm not sure.

Ah, so this series is just an interim step, and a follow-up will
replace "struct target_ops *self" with "struct foo *self" with foo
containing "struct target_ops *".

Thanks for the clarification.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [RFC v2 00/38] clean up target delegation
  2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
                   ` (38 preceding siblings ...)
  2014-02-07 16:47 ` [RFC v2 00/38] clean up target delegation Pedro Alves
@ 2014-02-19 16:35 ` Tom Tromey
  39 siblings, 0 replies; 55+ messages in thread
From: Tom Tromey @ 2014-02-19 16:35 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This is revision 2 of the target delegation cleanup series.  The
Tom> original series is here:
Tom>     https://sourceware.org/ml/gdb-patches/2014-01/msg00331.html

I'm checking this in now.
Due to the size of the series I am going to disable the irc commit bot
before pushing.

I've re-tested this on x86-64 Fedora 18.

Despite extensive testing, this series will probably break the build for
somebody.  Normally the fix is trivial.  I'm available to fix problems,
though; please send me the build log and I will send back a patch to try
out.

Tom

^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2014-02-19 16:35 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-06 20:55 [RFC v2 00/38] clean up target delegation Tom Tromey
2014-02-06 20:55 ` [RFC v2 16/38] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
2014-02-06 20:55 ` [RFC v2 09/38] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
2014-02-06 20:55 ` [RFC v2 03/38] add make-target-delegates Tom Tromey
2014-02-06 20:55 ` [RFC v2 08/38] Add target_ops argument to to_terminal_init Tom Tromey
2014-02-06 20:55 ` [RFC v2 02/38] introduce and use find_target_at Tom Tromey
2014-02-07 15:43   ` Pedro Alves
2014-02-07 21:54     ` Tom Tromey
2014-02-10 14:28       ` Pedro Alves
2014-02-06 20:56 ` [RFC v2 22/38] convert to_thread_architecture Tom Tromey
2014-02-06 20:56 ` [RFC v2 36/38] convert to_decr_pc_after_break Tom Tromey
2014-02-06 20:56 ` [RFC v2 34/38] remove exec_set_find_memory_regions Tom Tromey
2014-02-06 20:56 ` [RFC v2 23/38] convert to_disable_tracepoint Tom Tromey
2014-02-06 20:56 ` [RFC v2 10/38] Add target_ops argument to to_thread_name Tom Tromey
2014-02-06 20:56 ` [RFC v2 01/38] add "this" pointers to more target APIs Tom Tromey
2014-02-08  5:19   ` Doug Evans
2014-02-10 22:36     ` Doug Evans
2014-02-10 23:01       ` Doug Evans
2014-02-12 19:56       ` Tom Tromey
2014-02-12 20:22         ` Doug Evans
2014-02-06 20:56 ` [RFC v2 28/38] convert to_insn_history Tom Tromey
2014-02-06 20:56 ` [RFC v2 37/38] fix buglet in nto-procfs.c Tom Tromey
2014-02-07 16:01   ` Pedro Alves
2014-02-06 20:56 ` [RFC v2 24/38] convert to_upload_trace_state_variables Tom Tromey
2014-02-06 20:56 ` [RFC v2 26/38] convert to_insert_mask_watchpoint Tom Tromey
2014-02-06 20:56 ` [RFC v2 07/38] Add target_ops argument to to_close Tom Tromey
2014-02-08  3:00   ` Yao Qi
2014-02-10 17:50     ` Tom Tromey
2014-02-06 20:56 ` [RFC v2 35/38] remove some calls to INHERIT and de_fault Tom Tromey
2014-02-06 20:56 ` [RFC v2 27/38] convert to_get_section_table Tom Tromey
2014-02-06 20:56 ` [RFC v2 32/38] remove function casts from target.c Tom Tromey
2014-02-06 20:56 ` [RFC v2 29/38] convert to_search_memory Tom Tromey
2014-02-06 20:56 ` [RFC v2 21/38] convert to_extra_thread_info Tom Tromey
2014-02-06 20:58 ` [RFC v2 17/38] Add target_ops argument to to_save_record Tom Tromey
2014-02-06 20:58 ` [RFC v2 04/38] add target method delegation Tom Tromey
2014-02-07 15:53   ` Pedro Alves
2014-02-07 21:37     ` Tom Tromey
2014-02-06 20:58 ` [RFC v2 20/38] convert to_load Tom Tromey
2014-02-06 20:58 ` [RFC v2 25/38] convert to_static_tracepoint_markers_by_strid Tom Tromey
2014-02-06 20:58 ` [RFC v2 11/38] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
2014-02-06 21:23 ` [RFC v2 12/38] Add target_ops argument to to_can_execute_reverse Tom Tromey
2014-02-06 21:23 ` [RFC v2 19/38] convert to_remove_watchpoint Tom Tromey
2014-02-06 21:23 ` [RFC v2 06/38] introduce remote_load Tom Tromey
2014-02-06 21:23 ` [RFC v2 15/38] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
2014-02-06 21:24 ` [RFC v2 05/38] convert to_supports_btrace Tom Tromey
2014-02-06 21:24 ` [RFC v2 13/38] Add target_ops argument to to_fileio_pwrite Tom Tromey
2014-02-06 21:24 ` [RFC v2 31/38] minor cleanups to update_current_target Tom Tromey
2014-02-06 21:24 ` [RFC v2 14/38] Add target_ops argument to to_disable_tracepoint Tom Tromey
2014-02-06 21:38 ` [RFC v2 30/38] change delegation for to_read_description Tom Tromey
2014-02-06 21:38 ` [RFC v2 33/38] pass NULL to TARGET_DEFAULT_RETURN when appropriate Tom Tromey
2014-02-06 21:42 ` [RFC v2 18/38] convert to_detach Tom Tromey
2014-02-06 21:47 ` [RFC v2 38/38] convert to_get_unwinder and to_get_tailcall_unwinder to methods Tom Tromey
2014-02-07 16:02   ` Pedro Alves
2014-02-07 16:47 ` [RFC v2 00/38] clean up target delegation Pedro Alves
2014-02-19 16:35 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).