public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC 03/32] introduce async_callback_ftype
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
@ 2014-01-13 19:12 ` Tom Tromey
  2014-01-14 10:35   ` Pedro Alves
  2014-01-13 19:12 ` [RFC 02/32] introduce and use find_target_at Tom Tromey
                   ` (33 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces async_callback_ftype.  This is needed for
make-target-delegates to work properly, as it doesn't implement a real
parser.  I think it's also an ok cleanup in its own right.

2014-01-08  Tom Tromey  <tromey@redhat.com>

	* target.h (async_callback_ftype): New typedef.
	(struct target_ops) <to_async>: Use it.
---
 gdb/ChangeLog | 5 +++++
 gdb/target.h  | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gdb/target.h b/gdb/target.h
index b219cff..78c9d34 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -341,6 +341,10 @@ extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
 \f
 struct thread_info;		/* fwd decl for parameter list below: */
 
+/* The type of the callback to the to_async method.  */
+
+typedef void async_callback_ftype (enum inferior_event_type, void *);
+
 struct target_ops
   {
     struct target_ops *beneath;	/* To the target under this one.  */
@@ -484,8 +488,7 @@ struct target_ops
     /* 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 *,
-		      void (*) (enum inferior_event_type, void *), void *);
+    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);
-- 
1.8.1.4

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

* [RFC 00/32] clean up target delegation
@ 2014-01-13 19:12 Tom Tromey
  2014-01-13 19:12 ` [RFC 03/32] introduce async_callback_ftype Tom Tromey
                   ` (34 more replies)
  0 siblings, 35 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:12 UTC (permalink / raw)
  To: gdb-patches

This patch series cleans up most of the target API.

It changes nearly every target method to take a "self" argument.  This
was done in a mostly automated way.  This is PR 8626.

It introduces a new script, and some new annotation-like macros in
target.h, to change how delegation, and the base case, are handled for
nearly every method in target_ops.  This seems like it resolves PR
7701, at least from my point of view.

The justification for the "self" arguments comes primarily from
multi-target: eventually each layer of the target stack may be its own
object with its own state.  Adding the self arguments guarantees a
simple way for a given layer to access the relevant state; and a
simple way to handle delegation, should it be needed.

Regularizing the delegation is part of this series because the above
requires care when making a delegating call -- care not always taken,
I think, in the current tree.  In particular, it is important to call
a method in a given stratum's method with that stratum's target_ops
pointer.

I took the approach of using a new script that reads target.h and
extracts the method information.  I chose this approach because it is
quite easy to work with as a developer -- target.h is just plain C
code, generally following rules we already follow.  An alternate
approach might be something like gdbarch.sh, but I've long considered
that unreadable.

The original patch series consists of 231 patches -- I did each method
conversion as a separate patch, to make it simpler to fix problems
during development.  To make it less awful on the list, I've combined
groups of ~10 patches in each of the blocks of rote patches.  I merged
them in a completely automated way; so the log messages are a bit
"weird" -- just the concatenation of each patch's log.

If you want to see the atomized series in its full glory, it is all on
the "target-cleanup" branch in my gitorious repository.  If you think
it would be better if I sent the atomized patch series to the list,
I'm happy to do that as well.

Because this touches every target, I built this on many platforms.  I
mostly did build tests because most of the patches are obviously
semantically neutral.

   x86-64 Fedora 18 (native).  I built every revision (cumulatively of
   course).  Regression tested native and with the native-gdbserver
   target board.
   x86-64 Fedora 18, cross build with Mingw tools.  I cross built each
   revision.
   PPC64 Linux (gcc110 in the compile farm).  Built each revision both
   normally and with the SPU target enabled.
   AIX (gcc111 in the compile farm).
   NetBSD 5.1 (gcc70 in the compile farm).

Of course, this probably still introduces bugs.  On the plus side, any
compile time bug will be trivial to fix.


After this patch, nearly every remaining INHERIT is for a scalar
field.  I think it would be worth eliminating these as well; the
simplest would seem to be to convert each to a new target method.  I'm
happy to do this if others agree.

The remaining method using INHERIT is deprecated_xfer_memory.  This is
also a method not using delegation or getting the "target_ops"
treatment.  I didn't bother with this one because my understanding is
that Pedro is working on eliminating this method entirely.

There are also three remaining uses of de_fault: to_open, to_close,
and deprecated_xfer_memory.  to_open and to_close are just special.
They may need some work for the multi-target feature, but I didn't
want to attempt it now.  deprecated_xfer_memory, again, is hopefully
just going away.


There are also still a few methods not using the new delegation
scheme: 

    to_has_all_memory to_has_memory to_has_stack to_has_registers
    to_has_execution to_supports_non_stop to_get_thread_local_address
    to_thread_address_space to_fileio_* to_info_proc

I'll fix to_fileio_* soon.

In each of the other cases, the method in question is used in a way
that isn't readily convertible to the current delegation scheme.  I
left converting these for the future.


Please read through this as much as you are able.  I myself plan to
leave it for a little while, then come back and re-read each patch
(ugh) for sanity; then rebase (ugh).  Naturally I will fix up any
review requests.  When pushing I think I will push the atomized
series, not the one that is bundled for review.

Tom



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

* [RFC 01/32] add "this" pointers to more target APIs
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
  2014-01-13 19:12 ` [RFC 03/32] introduce async_callback_ftype Tom Tromey
  2014-01-13 19:12 ` [RFC 02/32] introduce and use find_target_at Tom Tromey
@ 2014-01-13 19:12 ` Tom Tromey
  2014-01-14 12:10   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 08/32] remove extended_remote_create_inferior_1 Tom Tromey
                   ` (31 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:12 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-01-08  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.
	* corelow.c (ignore): Add 'ops' argument.
	* exec.c (ignore): 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.
	* mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint):
	Add 'ops' argument.
	* mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops'
	argument.
	* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
	Add 'ops' argument.
	* nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint)
	(procfs_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_insert_breakpoint)
	(record_full_beneath_to_remove_breakpoint)
	(record_full_beneath_to_stopped_by_watchpoint)
	(record_full_beneath_to_async, tmp_to_insert_breakpoint)
	(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
	(tmp_to_async): Add 'ops' argument.
	(record_full_stopped_by_watchpoint, record_full_insert_breakpoint)
	(record_full_remove_breakpoint, record_full_async)
	(record_full_can_async_p, record_full_is_async_p)
	(record_full_core_insert_breakpoint)
	(record_full_core_remove_breakpoint): Add 'ops' argument.
	* remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint)
	(m32r_stopped_by_watchpoint): Add 'ops' argument.
	* remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint)
	(mips_stopped_by_watchpoint): Add 'ops' argument.
	* remote.c (remote_insert_breakpoint, remote_remove_breakpoint)
	(remote_stopped_by_watchpoint_p, remote_can_async_p)
	(remote_is_async_p, remote_async): Add 'ops' argument.
	* s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument.
	* target.c (update_current_target)
	(target_insert_breakpoint, target_remove_breakpoint)
	(find_default_can_async_p, find_default_is_async_p): Update.
	(init_dummy_target): Update.
	(debug_to_insert_breakpoint, debug_to_remove_breakpoint)
	(debug_to_stopped_by_watchpoint): Add 'ops' argument.
	* target.h (struct target_ops) <to_insert_breakpoint,
	to_remove_breakpoint, 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.
	(memory_remove_breakpoint, memory_insert_breakpoint): Add 'ops'
	argument.
---
 gdb/ChangeLog           | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/aarch64-linux-nat.c |  4 ++--
 gdb/arm-linux-nat.c     |  4 ++--
 gdb/corelow.c           |  3 ++-
 gdb/exec.c              |  3 ++-
 gdb/i386-nat.c          |  4 ++--
 gdb/ia64-linux-nat.c    |  4 ++--
 gdb/inf-ttrace.c        |  2 +-
 gdb/linux-nat.c         | 22 ++++++++----------
 gdb/mem-break.c         |  6 +++--
 gdb/mips-linux-nat.c    |  2 +-
 gdb/monitor.c           |  6 +++--
 gdb/nto-procfs.c        | 10 ++++----
 gdb/ppc-linux-nat.c     |  4 ++--
 gdb/procfs.c            |  2 +-
 gdb/record-full.c       | 58 +++++++++++++++++++++++++++++-----------------
 gdb/remote-m32r-sdi.c   |  8 ++++---
 gdb/remote-mips.c       | 12 ++++++----
 gdb/remote.c            | 34 +++++++++++++++------------
 gdb/s390-linux-nat.c    |  2 +-
 gdb/target.c            | 45 ++++++++++++++++++------------------
 gdb/target.h            | 31 ++++++++++++++-----------
 22 files changed, 212 insertions(+), 115 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 256725b..5f4baa5 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -1473,11 +1473,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 c43a7e4..0dc6e2a 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/corelow.c b/gdb/corelow.c
index 2869eea..50f89cf 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -842,7 +842,8 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
    breakpoint_init_inferior).  */
 
 static int
-ignore (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
+ignore (struct target_ops *ops, struct gdbarch *gdbarch,
+	struct bp_target_info *bp_tgt)
 {
   return 0;
 }
diff --git a/gdb/exec.c b/gdb/exec.c
index 38d2edb..70409d9 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -801,7 +801,8 @@ exec_set_section_address (const char *filename, int index, CORE_ADDR address)
    breakpoint_init_inferior).  */
 
 static int
-ignore (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
+ignore (struct target_ops *ops, struct gdbarch *gdbarch,
+	struct bp_target_info *bp_tgt)
 {
   return 0;
 }
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 0a5deb0..8d54ae0 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 edc1e23..51fbc81 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 eb0adcb..2193569 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 d2091ca..6d839e6 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -268,10 +268,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);
@@ -2490,7 +2486,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)
     {
@@ -2508,7 +2504,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);
 
@@ -4504,7 +4500,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.
@@ -4515,7 +4511,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.
@@ -4675,8 +4671,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)
     {
@@ -4761,8 +4759,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 (linux_ops))
+    linux_nat_async (linux_ops, NULL, 0);
 
   if (linux_ops->to_close)
     linux_ops->to_close ();
diff --git a/gdb/mem-break.c b/gdb/mem-break.c
index f06c4ae..7af39d1 100644
--- a/gdb/mem-break.c
+++ b/gdb/mem-break.c
@@ -77,14 +77,16 @@ default_memory_remove_breakpoint (struct gdbarch *gdbarch,
 
 
 int
-memory_insert_breakpoint (struct gdbarch *gdbarch,
+memory_insert_breakpoint (struct target_ops *ops,
+			  struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
   return gdbarch_memory_insert_breakpoint (gdbarch, bp_tgt);
 }
 
 int
-memory_remove_breakpoint (struct gdbarch *gdbarch,
+memory_remove_breakpoint (struct target_ops *ops,
+			  struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
   return gdbarch_memory_remove_breakpoint (gdbarch, bp_tgt);
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 9246741..2285b4b 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/monitor.c b/gdb/monitor.c
index 2d94d42..248109a 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -2095,7 +2095,8 @@ monitor_mourn_inferior (struct target_ops *ops)
 /* Tell the monitor to add a breakpoint.  */
 
 static int
-monitor_insert_breakpoint (struct gdbarch *gdbarch,
+monitor_insert_breakpoint (struct target_ops *ops,
+			   struct gdbarch *gdbarch,
 			   struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr = bp_tgt->placed_address;
@@ -2132,7 +2133,8 @@ monitor_insert_breakpoint (struct gdbarch *gdbarch,
 /* Tell the monitor to remove a breakpoint.  */
 
 static int
-monitor_remove_breakpoint (struct gdbarch *gdbarch,
+monitor_remove_breakpoint (struct target_ops *ops,
+			   struct gdbarch *gdbarch,
 			   struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr = bp_tgt->placed_address;
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 1c2f298..4e3d2d2 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
@@ -922,14 +922,16 @@ procfs_breakpoint (CORE_ADDR addr, int type, int size)
 }
 
 static int
-procfs_insert_breakpoint (struct gdbarch *gdbarch,
+procfs_insert_breakpoint (struct target_ops *ops,
+			  struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
   return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, 0);
 }
 
 static int
-procfs_remove_breakpoint (struct gdbarch *gdbarch,
+procfs_remove_breakpoint (struct target_ops *ops,
+			  struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
   return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, -1);
@@ -1508,7 +1510,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 d6820be..82ed2c6 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 ef9bb3d..40a5dd5 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -4861,7 +4861,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 f9af408..f4d760a 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -237,16 +237,19 @@ static LONGEST
 					  ULONGEST offset,
 					  LONGEST len);
 static int
-  (*record_full_beneath_to_insert_breakpoint) (struct gdbarch *,
+  (*record_full_beneath_to_insert_breakpoint) (struct target_ops *,
+					       struct gdbarch *,
 					       struct bp_target_info *);
 static int
-  (*record_full_beneath_to_remove_breakpoint) (struct gdbarch *,
+  (*record_full_beneath_to_remove_breakpoint) (struct target_ops *,
+					       struct gdbarch *,
 					       struct bp_target_info *);
-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,
@@ -814,14 +817,16 @@ static LONGEST (*tmp_to_xfer_partial) (struct target_ops *ops,
 				       const gdb_byte *writebuf,
 				       ULONGEST offset,
 				       LONGEST len);
-static int (*tmp_to_insert_breakpoint) (struct gdbarch *,
+static int (*tmp_to_insert_breakpoint) (struct target_ops *,
+					struct gdbarch *,
 					struct bp_target_info *);
-static int (*tmp_to_remove_breakpoint) (struct gdbarch *,
+static int (*tmp_to_remove_breakpoint) (struct target_ops *ops,
+					struct gdbarch *,
 					struct bp_target_info *);
-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);
 
@@ -1510,12 +1515,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
@@ -1758,7 +1767,8 @@ record_full_init_record_breakpoints (void)
    when recording.  */
 
 static int
-record_full_insert_breakpoint (struct gdbarch *gdbarch,
+record_full_insert_breakpoint (struct target_ops *ops,
+			       struct gdbarch *gdbarch,
 			       struct bp_target_info *bp_tgt)
 {
   struct record_full_breakpoint *bp;
@@ -1775,7 +1785,8 @@ record_full_insert_breakpoint (struct gdbarch *gdbarch,
       int ret;
 
       old_cleanups = record_full_gdb_operation_disable_set ();
-      ret = record_full_beneath_to_insert_breakpoint (gdbarch, bp_tgt);
+      ret = record_full_beneath_to_insert_breakpoint (find_target_beneath (ops),
+						      gdbarch, bp_tgt);
       do_cleanups (old_cleanups);
 
       if (ret != 0)
@@ -1795,7 +1806,8 @@ record_full_insert_breakpoint (struct gdbarch *gdbarch,
 /* "to_remove_breakpoint" method for process record target.  */
 
 static int
-record_full_remove_breakpoint (struct gdbarch *gdbarch,
+record_full_remove_breakpoint (struct target_ops *ops,
+			       struct gdbarch *gdbarch,
 			       struct bp_target_info *bp_tgt)
 {
   struct record_full_breakpoint *bp;
@@ -1815,7 +1827,8 @@ record_full_remove_breakpoint (struct gdbarch *gdbarch,
 	      int ret;
 
 	      old_cleanups = record_full_gdb_operation_disable_set ();
-	      ret = record_full_beneath_to_remove_breakpoint (gdbarch, bp_tgt);
+	      ret = record_full_beneath_to_remove_breakpoint (find_target_beneath (ops),
+							      gdbarch, bp_tgt);
 	      do_cleanups (old_cleanups);
 
 	      if (ret != 0)
@@ -1890,25 +1903,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;
@@ -2264,7 +2278,8 @@ record_full_core_xfer_partial (struct target_ops *ops,
 /* "to_insert_breakpoint" method for prec over corefile.  */
 
 static int
-record_full_core_insert_breakpoint (struct gdbarch *gdbarch,
+record_full_core_insert_breakpoint (struct target_ops *ops,
+				    struct gdbarch *gdbarch,
 				    struct bp_target_info *bp_tgt)
 {
   return 0;
@@ -2273,7 +2288,8 @@ record_full_core_insert_breakpoint (struct gdbarch *gdbarch,
 /* "to_remove_breakpoint" method for prec over corefile.  */
 
 static int
-record_full_core_remove_breakpoint (struct gdbarch *gdbarch,
+record_full_core_remove_breakpoint (struct target_ops *ops,
+				    struct gdbarch *gdbarch,
 				    struct bp_target_info *bp_tgt)
 {
   return 0;
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index e81b2de..a127b8a 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1145,7 +1145,8 @@ m32r_mourn_inferior (struct target_ops *ops)
 }
 
 static int
-m32r_insert_breakpoint (struct gdbarch *gdbarch,
+m32r_insert_breakpoint (struct target_ops *ops,
+			struct gdbarch *gdbarch,
 			struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr = bp_tgt->placed_address;
@@ -1189,7 +1190,8 @@ m32r_insert_breakpoint (struct gdbarch *gdbarch,
 }
 
 static int
-m32r_remove_breakpoint (struct gdbarch *gdbarch,
+m32r_remove_breakpoint (struct target_ops *ops,
+			struct gdbarch *gdbarch,
 			struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr = bp_tgt->placed_address;
@@ -1476,7 +1478,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 e4e5083..44d127a 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -2362,27 +2362,29 @@ mips_mourn_inferior (struct target_ops *ops)
    target contents.  */
 
 static int
-mips_insert_breakpoint (struct gdbarch *gdbarch,
+mips_insert_breakpoint (struct target_ops *ops,
+			struct gdbarch *gdbarch,
 			struct bp_target_info *bp_tgt)
 {
   if (monitor_supports_breakpoints)
     return mips_set_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
 				BREAK_FETCH);
   else
-    return memory_insert_breakpoint (gdbarch, bp_tgt);
+    return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
 }
 
 /* Remove a breakpoint.  */
 
 static int
-mips_remove_breakpoint (struct gdbarch *gdbarch,
+mips_remove_breakpoint (struct target_ops *ops,
+			struct gdbarch *gdbarch,
 			struct bp_target_info *bp_tgt)
 {
   if (monitor_supports_breakpoints)
     return mips_clear_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
 				  BREAK_FETCH);
   else
-    return memory_remove_breakpoint (gdbarch, bp_tgt);
+    return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
 }
 
 /* Tell whether this target can support a hardware breakpoint.  CNT
@@ -2449,7 +2451,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 2ac8c36..a91e6aa 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);
 
@@ -8204,7 +8206,8 @@ remote_add_target_side_commands (struct gdbarch *gdbarch,
    which don't, we insert a traditional memory breakpoint.  */
 
 static int
-remote_insert_breakpoint (struct gdbarch *gdbarch,
+remote_insert_breakpoint (struct target_ops *ops,
+			  struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
   /* Try the "Z" s/w breakpoint packet if it is not already disabled.
@@ -8260,11 +8263,12 @@ remote_insert_breakpoint (struct gdbarch *gdbarch,
 	}
     }
 
-  return memory_insert_breakpoint (gdbarch, bp_tgt);
+  return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
 }
 
 static int
-remote_remove_breakpoint (struct gdbarch *gdbarch,
+remote_remove_breakpoint (struct target_ops *ops,
+			  struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
   CORE_ADDR addr = bp_tgt->placed_address;
@@ -8294,7 +8298,7 @@ remote_remove_breakpoint (struct gdbarch *gdbarch,
       return (rs->buf[0] == 'E');
     }
 
-  return memory_remove_breakpoint (gdbarch, bp_tgt);
+  return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
 }
 
 static int
@@ -8448,7 +8452,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 ();
 
@@ -8461,7 +8465,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;
@@ -11629,7 +11633,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 ();
 
@@ -11642,7 +11646,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 ();
 
@@ -11677,8 +11681,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 cf3f7d7..5fb342f 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 85b5037..092d50c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -95,12 +95,6 @@ static void debug_to_prepare_to_store (struct regcache *);
 
 static void debug_to_files_info (struct target_ops *);
 
-static int debug_to_insert_breakpoint (struct gdbarch *,
-				       struct bp_target_info *);
-
-static int debug_to_remove_breakpoint (struct gdbarch *,
-				       struct bp_target_info *);
-
 static int debug_to_can_use_hw_breakpoint (int, int, int);
 
 static int debug_to_insert_hw_breakpoint (struct gdbarch *,
@@ -115,8 +109,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 *,
@@ -751,7 +743,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 *))
@@ -829,7 +821,9 @@ update_current_target (void)
 	    (char *(*) (int))
 	    return_zero);
   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);
@@ -2472,7 +2466,8 @@ target_insert_breakpoint (struct gdbarch *gdbarch,
       return 1;
     }
 
-  return (*current_target.to_insert_breakpoint) (gdbarch, bp_tgt);
+  return (*current_target.to_insert_breakpoint) (&current_target,
+						 gdbarch, bp_tgt);
 }
 
 int
@@ -2489,7 +2484,8 @@ target_remove_breakpoint (struct gdbarch *gdbarch,
       return 1;
     }
 
-  return (*current_target.to_remove_breakpoint) (gdbarch, bp_tgt);
+  return (*current_target.to_remove_breakpoint) (&current_target,
+						 gdbarch, bp_tgt);
 }
 
 static void
@@ -3141,7 +3137,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;
 
@@ -3151,12 +3147,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;
 
@@ -3166,7 +3162,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;
 }
 
@@ -3768,7 +3764,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;
@@ -4520,12 +4517,13 @@ debug_to_files_info (struct target_ops *target)
 }
 
 static int
-debug_to_insert_breakpoint (struct gdbarch *gdbarch,
+debug_to_insert_breakpoint (struct target_ops *ops,
+			    struct gdbarch *gdbarch,
 			    struct bp_target_info *bp_tgt)
 {
   int retval;
 
-  retval = debug_target.to_insert_breakpoint (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",
@@ -4535,12 +4533,13 @@ debug_to_insert_breakpoint (struct gdbarch *gdbarch,
 }
 
 static int
-debug_to_remove_breakpoint (struct gdbarch *gdbarch,
+debug_to_remove_breakpoint (struct target_ops *ops,
+			    struct gdbarch *gdbarch,
 			    struct bp_target_info *bp_tgt)
 {
   int retval;
 
-  retval = debug_target.to_remove_breakpoint (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",
@@ -4597,11 +4596,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 f22e5c6..e00e38c 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -399,8 +399,10 @@ struct target_ops
 				   struct target_ops *target);
 
     void (*to_files_info) (struct target_ops *);
-    int (*to_insert_breakpoint) (struct gdbarch *, struct bp_target_info *);
-    int (*to_remove_breakpoint) (struct gdbarch *, struct bp_target_info *);
+    int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
+				 struct bp_target_info *);
+    int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
+				 struct bp_target_info *);
     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 *);
@@ -415,7 +417,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 *);
@@ -480,9 +482,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) (void (*) (enum inferior_event_type, void *), void *);
+    int (*to_can_async_p) (struct target_ops *);
+    int (*to_is_async_p) (struct target_ops *);
+    void (*to_async) (struct target_ops *,
+		      void (*) (enum inferior_event_type, void *), 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);
@@ -1411,16 +1414,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 ())
@@ -1494,8 +1497,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  */
 
@@ -1870,10 +1873,12 @@ extern struct target_section_table *target_get_section_table
 
 /* From mem-break.c */
 
-extern int memory_remove_breakpoint (struct gdbarch *,
+extern int memory_remove_breakpoint (struct target_ops *,
+				     struct gdbarch *,
 				     struct bp_target_info *);
 
-extern int memory_insert_breakpoint (struct gdbarch *,
+extern int memory_insert_breakpoint (struct target_ops *,
+				     struct gdbarch *,
 				     struct bp_target_info *);
 
 extern int default_memory_remove_breakpoint (struct gdbarch *,
-- 
1.8.1.4

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

* [RFC 02/32] introduce and use find_target_at
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
  2014-01-13 19:12 ` [RFC 03/32] introduce async_callback_ftype Tom Tromey
@ 2014-01-13 19:12 ` Tom Tromey
  2014-01-14 11:48   ` [PATCH] Fix "is a record target open" checks Pedro Alves
  2014-01-13 19:12 ` [RFC 01/32] add "this" pointers to more target APIs Tom Tromey
                   ` (32 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

RECORD_IS_USED and find_record_target look 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.

2014-01-08  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/record.h  |  2 +-
 gdb/target.c  | 14 ++++++++++++++
 gdb/target.h  |  5 +++++
 5 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/gdb/record.c b/gdb/record.c
index ec2a042..0fd8756 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -62,13 +62,7 @@ struct cmd_list_element *info_record_cmdlist = NULL;
 static 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/record.h b/gdb/record.h
index 124c32b..05a17a9 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -22,7 +22,7 @@
 
 struct cmd_list_element;
 
-#define RECORD_IS_USED	(current_target.to_stratum == record_stratum)
+#define RECORD_IS_USED	(find_target_at (record_stratum) != NULL)
 
 extern unsigned int record_debug;
 
diff --git a/gdb/target.c b/gdb/target.c
index 092d50c..d2a40ee 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3648,6 +3648,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 e00e38c..b219cff 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1903,6 +1903,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] 100+ messages in thread

* [RFC 12/32] Add target_ops argument to to_thread_name
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (10 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 24/32] convert to_disable_tracepoint Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 13:03   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 27/32] convert to_insert_mask_watchpoint Tom Tromey
                   ` (22 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 f0f938d..bb6c014 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 5fe5b8b..6777f35 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 6b37a17..ba6ffab 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 a422c46..f487864 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 c596034..862907f 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2252,7 +2252,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"));
 }
@@ -2527,7 +2527,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 858b464..7b8491f 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 e71343a..aa347c5 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 aa3b136..1116f9c 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -850,7 +850,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
@@ -2199,7 +2199,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;
     }
@@ -3997,7 +3997,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);
@@ -4037,7 +4037,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;
 
@@ -4101,7 +4101,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.  */
@@ -4522,7 +4523,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;
 }
@@ -4749,12 +4750,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 cf12c1b..94246ba 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");
@@ -2264,7 +2264,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)
@@ -2278,7 +2278,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 324efd8..924e908 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 8d6959a..cf14ea3 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 6fd3502..79e08c2 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -1220,7 +1220,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 4ce2ebb..6ae7f91 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);
@@ -142,9 +142,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);
@@ -4268,7 +4270,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);
 }
@@ -5061,7 +5063,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);
 
@@ -5476,7 +5479,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;
@@ -5549,7 +5552,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 9e8ac1e..61b1397 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1691,7 +1691,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;
 
@@ -1714,7 +1714,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 c37b6e2..eedc923 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1392,7 +1392,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 c4b7da1..42c63ba 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 61fc670..41147a2 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -155,7 +155,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);
 
@@ -5166,7 +5166,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");
@@ -9097,7 +9097,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 ();
@@ -10360,7 +10360,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 78e9085..659970e 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -127,7 +127,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 7a97e28..829b211 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -305,7 +305,7 @@ extern void serial_add_interface (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 4345ff6..dce3eac 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -142,7 +142,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
@@ -818,16 +818,16 @@ update_current_target (void)
 	    (char *(*) (struct target_ops *, struct thread_info *))
 	    return_zero);
   de_fault (to_thread_name,
-	    (char *(*) (struct thread_info *))
+	    (char *(*) (struct target_ops *, struct thread_info *))
 	    return_zero);
   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_zero);
   de_fault (to_thread_architecture,
 	    default_thread_architecture);
@@ -2698,7 +2698,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;
@@ -3139,13 +3139,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;
 }
 
@@ -3156,7 +3156,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;
 }
@@ -3691,7 +3691,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;
@@ -3699,7 +3700,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;
@@ -3707,7 +3709,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;
@@ -3715,7 +3717,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 ();
 }
@@ -3846,7 +3848,7 @@ target_stop (ptid_t ptid)
       return;
     }
 
-  (*current_target.to_stop) (ptid);
+  (*current_target.to_stop) (&current_target, ptid);
 }
 
 static void
@@ -4860,28 +4862,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);
@@ -4948,10 +4950,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 d2a1796..6071e8f 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -509,11 +509,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 *);
@@ -530,15 +531,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
@@ -1399,7 +1401,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
@@ -1509,7 +1511,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.  */
 
@@ -1524,21 +1526,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.  */
 
@@ -1827,7 +1829,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 24ad228..7132034 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -166,7 +166,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 *);
 
@@ -1985,7 +1985,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__
@@ -2394,7 +2394,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] 100+ messages in thread

* [RFC 27/32] convert to_insert_mask_watchpoint
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (11 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 12/32] Add target_ops argument to to_thread_name Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 19:15   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 19/32] convert to_detach Tom Tromey
                   ` (21 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  Tom Tromey <tromey@redhat.com>

	* target-delegates.c : Rebuild.
	* target.c (target_pid_to_exec_file): Unconditionally delegate.
	(init_dummy_target): Don't initialize to_pid_to_exec_file.
	* target.h (struct target_ops) <to_pid_to_exec_file>: Use
	TARGET_DEFAULT_FUNC.
---
 gdb/ChangeLog          |  76 ++++++++++++++++
 gdb/target-delegates.c | 139 +++++++++++++++++++++++++++++
 gdb/target.c           | 233 ++++++++++++++++++-------------------------------
 gdb/target.h           |  30 ++++---
 4 files changed, 319 insertions(+), 159 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 7667b2d..f32c90f 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 = dummy_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 17d29c7..636cfdb 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 *);
@@ -88,6 +93,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 *dummy_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);
@@ -450,19 +457,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
@@ -2473,15 +2471,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 *
@@ -2513,61 +2503,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
@@ -2576,51 +2558,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
@@ -3494,7 +3459,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;
@@ -3564,19 +3528,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
@@ -3759,25 +3713,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
@@ -3786,25 +3733,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
@@ -3813,13 +3753,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 75e802c..f83ece1 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -463,9 +463,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;
@@ -487,7 +489,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 *)
@@ -500,7 +503,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 *, 
@@ -515,7 +519,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)
@@ -525,20 +530,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 (dummy_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] 100+ messages in thread

* [RFC 32/32] minor cleanups to update_current_target
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (8 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 04/32] add make-target-delegates Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 20:10   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 24/32] convert to_disable_tracepoint Tom Tromey
                   ` (24 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 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-01-13  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 76316b5..a503220 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -590,147 +590,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] 100+ messages in thread

* [RFC 26/32] convert to_static_tracepoint_markers_by_strid
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (5 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 10/32] Add target_ops argument to to_terminal_init Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 18:57   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 31/32] change delegation for to_read_description Tom Tromey
                   ` (27 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 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-01-08  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-01-08  Tom Tromey <tromey@redhat.com>

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

convert to_use_agent

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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          |  81 +++++++++++++++++++++++++
 gdb/target-delegates.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target.c           |  65 ++++----------------
 gdb/target.h           |  31 ++++++----
 4 files changed, 272 insertions(+), 63 deletions(-)

diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 4d6c591..7667b2d 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 c6d5367..17d29c7 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -653,7 +653,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.  */
@@ -707,14 +707,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.  */
@@ -742,32 +743,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_zero);
-  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
 
@@ -3711,18 +3687,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
@@ -3861,13 +3828,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 9860cf4..75e802c 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -401,7 +401,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 *)
@@ -443,7 +444,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);
@@ -541,7 +543,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);
@@ -712,11 +715,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.
 
@@ -924,8 +929,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
@@ -940,14 +945,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 *)
@@ -1035,7 +1043,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);
 
     int to_magic;
     /* Need sub-structure for target machine related rather than comm related?
-- 
1.8.1.4

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

* [RFC 19/32] convert to_detach
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (12 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 27/32] convert to_insert_mask_watchpoint Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 13:32   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 11/32] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
                   ` (20 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 77f3113..5a5954d 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 1f3562f..794d099 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 *);
@@ -585,7 +587,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.  */
@@ -593,16 +595,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.  */
@@ -644,7 +646,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);
@@ -724,34 +726,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 *))
@@ -823,9 +801,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_zero);
@@ -2617,19 +2592,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
@@ -3736,9 +3702,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
@@ -3785,22 +3748,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
@@ -4951,16 +4902,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 4668c23..5f521c5 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -389,9 +389,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 ());
@@ -401,7 +404,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
@@ -429,26 +433,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);
@@ -512,7 +521,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] 100+ messages in thread

* [RFC 25/32] convert to_upload_trace_state_variables
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (3 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 08/32] remove extended_remote_create_inferior_1 Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 19:38   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 10/32] Add target_ops argument to to_terminal_init Tom Tromey
                   ` (29 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 ddcc89c..4d6c591 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 90e2709..c6d5367 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);
-
 void target_ignore (void);
 
 static void target_command (char *, int);
@@ -699,16 +697,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);
@@ -748,38 +746,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 *))
@@ -3443,12 +3409,6 @@ return_zero (void)
   return 0;
 }
 
-static int
-return_minus_one (void)
-{
-  return -1;
-}
-
 /*
  * Find the next target down the stack from the specified target.
  */
diff --git a/gdb/target.h b/gdb/target.h
index dfaad80..9860cf4 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -859,29 +859,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:
@@ -902,15 +909,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] 100+ messages in thread

* [RFC 31/32] change delegation for to_read_description
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (6 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 26/32] convert to_static_tracepoint_markers_by_strid Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 20:07   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 04/32] add make-target-delegates Tom Tromey
                   ` (26 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 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-01-13  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           |  7 ++++---
 7 files changed, 45 insertions(+), 24 deletions(-)

diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 7cd7d63..0416ba0 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 4b72203..a500aa5 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 34b8f6d..3f5f7f9 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9569,7 +9569,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))
     {
@@ -9588,7 +9588,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 66c0625..44e5fc2 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 df11fc0..76316b5 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -746,7 +746,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
 
@@ -2559,19 +2558,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 978941b..b68c336 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -673,9 +673,10 @@ 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);
+       Returns the description found.  If no description is found,
+       this should delegate to the "beneath" target.  */
+    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] 100+ messages in thread

* [RFC 10/32] Add target_ops argument to to_terminal_init
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (4 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 25/32] convert to_upload_trace_state_variables Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 12:51   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 26/32] convert to_static_tracepoint_markers_by_strid Tom Tromey
                   ` (28 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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           | 126 ++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/aarch64-linux-nat.c |   8 +--
 gdb/amd64-linux-nat.c   |   7 +--
 gdb/gnu-nat.c           |   2 +-
 gdb/go32-nat.c          |  15 +++---
 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, 242 insertions(+), 110 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index a59a6e7..6b3680e 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -825,16 +825,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 b1676ac..237e936 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 329d090..c596034 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2245,7 +2245,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 ef6ceef..5daeb4d 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -260,9 +260,10 @@ static void go32_mourn_inferior (struct target_ops *ops);
 static int go32_can_run (void);
 
 static struct target_ops go32_ops;
-static void go32_terminal_init (void);
-static void go32_terminal_inferior (void);
-static void go32_terminal_ours (void);
+static void go32_terminal_init (struct target_ops *self);
+static void go32_terminal_inferior (struct target_ops *self);
+static void go32_terminal_ours (struct target_ops *self,
+				struct target_ops *self);
 
 #define r_ofs(x) (offsetof(TSS,x))
 
@@ -871,14 +872,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
@@ -908,7 +909,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;
@@ -929,7 +930,7 @@ go32_terminal_inferior (void)
 }
 
 static void
-go32_terminal_ours (void)
+go32_terminal_ours (struct target_ops *self, 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 c2f4fcc..f886b39e 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 de36417..cde56a2 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 7f6f8bf..e71343a 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 d33a01a..248812f 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 062bf68..6d3b745 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 8e0f40b..53c3923 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -341,7 +341,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));
 }
@@ -702,13 +702,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;
 }
@@ -4551,16 +4551,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)
@@ -4574,19 +4574,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 4423d26..463220f 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 4292f47..cf12c1b 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -2196,7 +2196,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 58b19f2..c37b6e2 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1214,7 +1214,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 5c0b8a3..88e9977 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);
@@ -3532,7 +3532,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 9f1e5eb..c4b7da1 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 d23502c..547045b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -226,7 +226,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);
 
@@ -3056,7 +3056,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;
@@ -5206,7 +5206,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.  */
@@ -5229,7 +5229,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.  */
@@ -11484,7 +11484,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 daa2bc4..1c2c4aa 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -389,7 +389,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 411dbdf..9dcedfd 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);
@@ -128,17 +128,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);
 
@@ -458,7 +458,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
@@ -496,7 +496,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
@@ -521,7 +521,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"));
 }
@@ -765,33 +765,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))
@@ -4672,77 +4672,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);
@@ -4751,11 +4752,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 4fa3918..15bcbd3 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -473,19 +473,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);
@@ -1187,7 +1187,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.  */
@@ -1203,14 +1203,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
@@ -1218,13 +1218,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.  */
 
@@ -1263,7 +1263,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
@@ -1271,10 +1271,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] 100+ messages in thread

* [RFC 11/32] Add target_ops argument to to_insert_vfork_catchpoint
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (13 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 19/32] convert to_detach Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 12:52   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 09/32] Add target_ops argument to to_close Tom Tromey
                   ` (19 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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         |   4 +-
 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, 191 insertions(+), 69 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index df21a99..1a24eb0 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 1da4172..e00e0c2 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 5daeb4d..c42f48a 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -257,7 +257,7 @@ static void go32_kill_inferior (struct target_ops *ops);
 static void go32_create_inferior (struct target_ops *ops, char *exec_file,
 				  char *args, char **env, int from_tty);
 static void go32_mourn_inferior (struct target_ops *ops);
-static int go32_can_run (void);
+static int go32_can_run (struct target_ops *self);
 
 static struct target_ops go32_ops;
 static void go32_terminal_init (struct target_ops *self);
@@ -764,7 +764,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 cde56a2..858b464 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 4f94438..545af88 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 53c3923..aa3b136 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -714,31 +714,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 ())
@@ -829,7 +830,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;
 
@@ -1307,7 +1309,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);
 
@@ -1332,7 +1334,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 4cc3a4c..2e39aa8 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1764,7 +1764,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 22e8f46..6fd3502 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;
 }
@@ -1338,7 +1338,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 674d572..4365cae 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -364,7 +364,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 e9444a9..005d314 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 448ce04..4ce2ebb 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 *,
@@ -4230,7 +4231,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 0d60277..d912691 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 547045b..61fc670 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1684,7 +1684,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)
     {
@@ -1736,7 +1737,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)
     {
@@ -2862,7 +2864,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;
@@ -3611,7 +3613,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 9dcedfd..4345ff6 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -140,7 +140,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);
 
@@ -794,27 +794,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_zero);
   de_fault (to_thread_name,
 	    (char *(*) (struct thread_info *))
@@ -2747,7 +2748,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;
 	}
     }
@@ -2777,7 +2778,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;
 	}
     }
@@ -4765,11 +4766,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);
@@ -4778,11 +4779,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);
@@ -4791,11 +4792,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);
@@ -4804,11 +4805,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);
@@ -4817,11 +4818,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);
@@ -4830,11 +4833,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 15bcbd3..d2a1796 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -486,28 +486,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);
@@ -1277,10 +1278,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
@@ -1298,10 +1299,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.
 
@@ -1324,14 +1325,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
@@ -1345,7 +1348,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.
 
@@ -1486,7 +1489,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 3942f6f..24ad228 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2465,7 +2465,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] 100+ messages in thread

* [RFC 09/32] Add target_ops argument to to_close
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (14 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 11/32] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 12:48   ` Pedro Alves
  2014-01-13 19:23 ` [RFC 07/32] introduce remote_load Tom Tromey
                   ` (18 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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_prepare_to_store

2014-01-08  Tom Tromey  <tromey@redhat.com>

	* windows-nat.c (windows_prepare_to_store): Add 'self' argument.
	* target.h (struct target_ops) <to_prepare_to_store>: Add
	argument.
	(target_prepare_to_store): Add argument.
	* target.c (debug_to_prepare_to_store): Add argument.
	(update_current_target): Update.
	* remote.c (remote_prepare_to_store): Add 'self' argument.
	* remote-sim.c (gdbsim_prepare_to_store): Add 'self' argument.
	* remote-mips.c (mips_prepare_to_store): Add 'self' argument.
	* remote-m32r-sdi.c (m32r_prepare_to_store): Add 'self' argument.
	* record-full.c (record_full_core_prepare_to_store): Add 'self'
	argument.
	* ravenscar-thread.c (ravenscar_prepare_to_store): Add argument.
	* nto-procfs.c (procfs_prepare_to_store): Add 'self' argument.
	* monitor.c (monitor_prepare_to_store): Add 'self' argument.
	* inf-child.c (inf_child_prepare_to_store): Add 'self' argument.
	* go32-nat.c (go32_prepare_to_store): Add 'self' argument.

Add target_ops argument to to_can_use_hw_breakpoint

2014-01-08  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-01-08  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-01-08  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.
	* nto-procfs.c (procfs_remove_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-01-08  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-01-08  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-01-08  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-01-08  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           | 217 ++++++++++++++++++++++++++++++++++++++++++++++++
 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          |   9 +-
 gdb/i386-nat.c          |  16 ++--
 gdb/ia64-hpux-nat.c     |   3 +-
 gdb/ia64-linux-nat.c    |   9 +-
 gdb/inf-child.c         |   5 +-
 gdb/inf-ptrace.c        |   2 +-
 gdb/inf-ttrace.c        |  12 ++-
 gdb/linux-nat.c         |   6 +-
 gdb/mips-linux-nat.c    |  14 ++--
 gdb/monitor.c           |   4 +-
 gdb/monitor.h           |   2 +-
 gdb/nto-procfs.c        |  26 +++---
 gdb/ppc-linux-nat.c     |  21 +++--
 gdb/procfs.c            |  15 ++--
 gdb/ravenscar-thread.c  |   8 +-
 gdb/record-btrace.c     |   2 +-
 gdb/record-full.c       |   5 +-
 gdb/remote-m32r-sdi.c   |  13 +--
 gdb/remote-mips.c       |  18 ++--
 gdb/remote-sim.c        |   9 +-
 gdb/remote.c            |  25 +++---
 gdb/s390-linux-nat.c    |  12 ++-
 gdb/spu-linux-nat.c     |   5 +-
 gdb/spu-multiarch.c     |   6 +-
 gdb/target.c            | 105 ++++++++++++++---------
 gdb/target.h            |  51 +++++++-----
 gdb/tracepoint.c        |   2 +-
 gdb/windows-nat.c       |   4 +-
 36 files changed, 503 insertions(+), 173 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 5f4baa5..a59a6e7 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -938,7 +938,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;
 }
@@ -1198,7 +1199,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;
@@ -1230,7 +1232,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;
@@ -1334,7 +1337,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;
@@ -1366,7 +1370,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;
@@ -1395,7 +1400,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 0dc6e2a..7cd7d63 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 d1e7ca8..7d755e3 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -104,7 +104,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 0a2ea81..1da4172 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 50f89cf..4b72203 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 b886d67..239afb2 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1196,7 +1196,7 @@ ctf_open (char *dirname, int from_tty)
    CTF iterator and context.  */
 
 static void
-ctf_close (void)
+ctf_close (struct target_ops *self)
 {
   ctf_destroy ();
   xfree (trace_dirname);
diff --git a/gdb/exec.c b/gdb/exec.c
index 70409d9..5fe5b8b 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 c1172f6..ef6ceef 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -235,7 +235,7 @@ static int dr_ref_count[4];
 
 static int prog_has_started = 0;
 static void go32_open (char *name, int from_tty);
-static void go32_close (void);
+static void go32_close (struct target_ops *self);
 static void go32_attach (struct target_ops *ops, char *args, int from_tty);
 static void go32_detach (struct target_ops *ops, char *args, int from_tty);
 static void go32_resume (struct target_ops *ops,
@@ -246,7 +246,8 @@ static void go32_fetch_registers (struct target_ops *ops,
 static void store_register (const struct regcache *, int regno);
 static void go32_store_registers (struct target_ops *ops,
 				  struct regcache *, int regno);
-static void go32_prepare_to_store (struct regcache *);
+static void go32_prepare_to_store (struct target_ops *self,
+				   struct regcache *);
 static int go32_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
 			     int write,
 			     struct mem_attrib *attrib,
@@ -371,7 +372,7 @@ go32_open (char *name, int from_tty)
 }
 
 static void
-go32_close (void)
+go32_close (struct target_ops *self)
 {
 }
 
@@ -598,7 +599,7 @@ go32_store_registers (struct target_ops *ops,
 }
 
 static void
-go32_prepare_to_store (struct regcache *regcache)
+go32_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
 }
 
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 8d54ae0..dc61edb 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 e4e1d32..bb684a4 100644
--- a/gdb/ia64-hpux-nat.c
+++ b/gdb/ia64-hpux-nat.c
@@ -696,7 +696,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 51fbc81..5e05c9e 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 3db09c9..de36417 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.  */
@@ -100,7 +100,8 @@ inf_child_post_attach (int pid)
    program being debugged.  */
 
 static void
-inf_child_prepare_to_store (struct regcache *regcache)
+inf_child_prepare_to_store (struct target_ops *self,
+			    struct regcache *regcache)
 {
 }
 
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 34e206b..7f6f8bf 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 2193569..4f94438 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 6d839e6..8e0f40b 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -335,7 +335,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);
 }
@@ -4756,14 +4756,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 (linux_ops))
     linux_nat_async (linux_ops, 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 2285b4b..dbc710d 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 248109a..4292f47 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);
@@ -1427,7 +1427,7 @@ monitor_store_registers (struct target_ops *ops,
    debugged.  */
 
 static void
-monitor_prepare_to_store (struct regcache *regcache)
+monitor_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
   /* Do nothing, since we can store individual regs.  */
 }
diff --git a/gdb/monitor.h b/gdb/monitor.h
index f66d1e7..bb2e5ec 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 4e3d2d2..22e8f46 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);
@@ -930,7 +933,7 @@ procfs_insert_breakpoint (struct target_ops *ops,
 }
 
 static int
-procfs_remove_breakpoint (struct target_ops *ops,
+procfs_remove_breakpoint (struct target_ops *self, struct target_ops *ops,
 			  struct gdbarch *gdbarch,
 			  struct bp_target_info *bp_tgt)
 {
@@ -938,7 +941,7 @@ procfs_remove_breakpoint (struct target_ops *ops,
 }
 
 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,
@@ -1231,7 +1234,7 @@ procfs_kill_inferior (struct target_ops *ops)
 /* Store register REGNO, or all registers if REGNO == -1, from the contents
    of REGISTERS.  */
 static void
-procfs_prepare_to_store (struct regcache *regcache)
+procfs_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
 }
 
@@ -1490,20 +1493,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 82ed2c6..434a404 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 40a5dd5..448ce04 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -145,7 +145,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);
@@ -4837,7 +4838,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,
@@ -4900,7 +4902,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
@@ -4922,14 +4925,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/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 9ef265d..0d60277 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -62,7 +62,8 @@ static void ravenscar_fetch_registers (struct target_ops *ops,
                                        struct regcache *regcache, int regnum);
 static void ravenscar_store_registers (struct target_ops *ops,
                                        struct regcache *regcache, int regnum);
-static void ravenscar_prepare_to_store (struct regcache *regcache);
+static void ravenscar_prepare_to_store (struct target_ops *self,
+					struct regcache *regcache);
 static void ravenscar_resume (struct target_ops *ops, ptid_t ptid, int step,
 			      enum gdb_signal siggnal);
 static void ravenscar_mourn_inferior (struct target_ops *ops);
@@ -303,14 +304,15 @@ ravenscar_store_registers (struct target_ops *ops,
 }
 
 static void
-ravenscar_prepare_to_store (struct regcache *regcache)
+ravenscar_prepare_to_store (struct target_ops *self,
+			    struct regcache *regcache)
 {
   struct target_ops *beneath = find_target_beneath (&ravenscar_ops);
 
   if (!ravenscar_runtime_initialized ()
       || ptid_equal (inferior_ptid, base_magic_null_ptid)
       || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
-    beneath->to_prepare_to_store (regcache);
+    beneath->to_prepare_to_store (beneath, regcache);
   else
     {
       struct gdbarch *gdbarch = get_regcache_arch (regcache);
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 68f40c8..d1f36c9 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -190,7 +190,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)
 {
   /* Make sure automatic recording gets disabled even if we did not stop
      recording before closing the record-btrace target.  */
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 1d66c6e..9e8ac1e 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -867,7 +867,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;
 
@@ -1969,7 +1969,8 @@ record_full_core_fetch_registers (struct target_ops *ops,
 /* "to_prepare_to_store" method for prec over corefile.  */
 
 static void
-record_full_core_prepare_to_store (struct regcache *regcache)
+record_full_core_prepare_to_store (struct target_ops *self,
+				   struct regcache *regcache)
 {
 }
 
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index a127b8a..58b19f2 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -430,7 +430,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");
@@ -1013,7 +1013,7 @@ m32r_store_register (struct target_ops *ops,
    debugged.  */
 
 static void
-m32r_prepare_to_store (struct regcache *regcache)
+m32r_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
   /* Do nothing, since we can store individual regs.  */
   if (remote_debug)
@@ -1408,7 +1408,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;
 }
@@ -1418,7 +1419,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;
@@ -1443,7 +1445,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 44d127a..5c0b8a3 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -84,13 +84,14 @@ 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);
 
 static void mips_set_register (int regno, ULONGEST value);
 
-static void mips_prepare_to_store (struct regcache *regcache);
+static void mips_prepare_to_store (struct target_ops *self,
+				   struct regcache *regcache);
 
 static int mips_fetch_word (CORE_ADDR addr, unsigned int *valp);
 
@@ -1731,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)
     {
@@ -2064,7 +2065,7 @@ mips_fetch_registers (struct target_ops *ops,
    registers, so this function doesn't have to do anything.  */
 
 static void
-mips_prepare_to_store (struct regcache *regcache)
+mips_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
 }
 
@@ -2392,7 +2393,8 @@ mips_remove_breakpoint (struct target_ops *ops,
    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;
 }
@@ -2426,7 +2428,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))
@@ -2438,7 +2441,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 c0596b3..9f1e5eb 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -76,12 +76,13 @@ 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);
 
-static void gdbsim_prepare_to_store (struct regcache *regcache);
+static void gdbsim_prepare_to_store (struct target_ops *self,
+				     struct regcache *regcache);
 
 static void gdbsim_files_info (struct target_ops *target);
 
@@ -787,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);
@@ -1052,7 +1053,7 @@ gdbsim_wait (struct target_ops *ops,
    debugged.  */
 
 static void
-gdbsim_prepare_to_store (struct regcache *regcache)
+gdbsim_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
   /* Do nothing, since we can store individual regs.  */
 }
diff --git a/gdb/remote.c b/gdb/remote.c
index 3ecab65..d23502c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -98,7 +98,8 @@ static void async_handle_remote_sigint_twice (int);
 
 static void remote_files_info (struct target_ops *ignore);
 
-static void remote_prepare_to_store (struct regcache *regcache);
+static void remote_prepare_to_store (struct target_ops *self,
+				     struct regcache *regcache);
 
 static void remote_open (char *name, int from_tty);
 
@@ -106,7 +107,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);
 
@@ -3046,7 +3047,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 ();
 
@@ -6415,7 +6416,7 @@ remote_fetch_registers (struct target_ops *ops,
    first.  */
 
 static void
-remote_prepare_to_store (struct regcache *regcache)
+remote_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
   struct remote_arch_state *rsa = get_remote_arch_state ();
   int i;
@@ -8315,7 +8316,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 ();
@@ -8364,7 +8366,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 ();
@@ -8406,7 +8409,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;
@@ -8419,7 +8423,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)
     {
@@ -8469,7 +8474,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;
@@ -8533,7 +8538,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 5fb342f..fec2455 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 22ed483..daa2bc4 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -408,7 +408,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;
@@ -605,7 +605,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 f584a9a..dbe7628 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 6fc95fc..411dbdf 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;
 
@@ -91,22 +92,28 @@ static struct target_ops debug_target;
 
 static void debug_to_open (char *, int);
 
-static void debug_to_prepare_to_store (struct regcache *);
+static void debug_to_prepare_to_store (struct target_ops *self,
+				       struct regcache *);
 
 static void debug_to_files_info (struct target_ops *);
 
-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 *);
@@ -114,9 +121,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);
@@ -713,13 +722,13 @@ 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 regcache *))
+	    (void (*) (struct target_ops *, struct regcache *))
 	    noprocess);
   de_fault (deprecated_xfer_memory,
 	    (int (*) (CORE_ADDR, gdb_byte *, int, int,
@@ -729,26 +738,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))
@@ -3558,7 +3572,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);
 }
@@ -3753,7 +3768,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");
@@ -3834,9 +3849,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);
 }
@@ -4403,9 +4418,9 @@ target_call_history_range (ULONGEST begin, ULONGEST end, int flags)
 }
 
 static void
-debug_to_prepare_to_store (struct regcache *regcache)
+debug_to_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
-  debug_target.to_prepare_to_store (regcache);
+  debug_target.to_prepare_to_store (&debug_target, regcache);
 
   fprintf_unfiltered (gdb_stdlog, "target_prepare_to_store ()\n");
 }
@@ -4492,11 +4507,13 @@ debug_to_remove_breakpoint (struct target_ops *ops,
 }
 
 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",
@@ -4508,11 +4525,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",
@@ -4522,12 +4541,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,
@@ -4583,12 +4604,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",
@@ -4598,12 +4621,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",
@@ -4613,12 +4638,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",
@@ -4628,12 +4655,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 d1fa12f..4fa3918 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -388,9 +388,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)
@@ -401,7 +401,7 @@ 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 regcache *);
+    void (*to_prepare_to_store) (struct target_ops *, struct regcache *);
 
     /* Transfer LEN bytes of memory between GDB address MYADDR and
        target address MEMADDR.  If WRITE, transfer them to the target, else
@@ -436,15 +436,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);
@@ -461,9 +465,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);
@@ -986,7 +992,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
@@ -1044,7 +1050,7 @@ extern void target_store_registers (struct regcache *regcache, int regs);
    debugged.  */
 
 #define	target_prepare_to_store(regcache)	\
-     (*current_target.to_prepare_to_store) (regcache)
+     (*current_target.to_prepare_to_store) (&current_target, regcache)
 
 /* Determine current address space of thread PTID.  */
 
@@ -1560,13 +1566,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.
@@ -1576,10 +1584,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
@@ -1596,10 +1606,12 @@ extern int target_insert_mask_watchpoint (CORE_ADDR, CORE_ADDR, int);
 extern int target_remove_mask_watchpoint (CORE_ADDR, CORE_ADDR, int);
 
 #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.  */
@@ -1628,7 +1640,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 f30282b..a09bf37 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4749,7 +4749,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 f0545fc..3942f6f 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2459,7 +2459,7 @@ windows_kill_inferior (struct target_ops *ops)
 }
 
 static void
-windows_prepare_to_store (struct regcache *regcache)
+windows_prepare_to_store (struct target_ops *self, struct regcache *regcache)
 {
   /* Do nothing, since we can store individual regs.  */
 }
@@ -2471,7 +2471,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] 100+ messages in thread

* [RFC 08/32] remove extended_remote_create_inferior_1
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (2 preceding siblings ...)
  2014-01-13 19:12 ` [RFC 01/32] add "this" pointers to more target APIs Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 12:41   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 25/32] convert to_upload_trace_state_variables Tom Tromey
                   ` (30 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that extended_remote_create_inferior_1 is called from a
single spot.  This patch unifies the callee and caller.  It's just a
simple cleanup that made the coming refactoring simpler.

2014-01-08  Tom Tromey  <tromey@redhat.com>

	* remote.c (extended_remote_create_inferior): Rename from
	extended_remote_create_inferior_1.  Add "ops" argument.  Remove
	old implementation.
---
 gdb/ChangeLog |  6 ++++++
 gdb/remote.c  | 13 +++----------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 9efb985..3ecab65 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8079,8 +8079,9 @@ extended_remote_run (char *args)
    environment.  */
 
 static void
-extended_remote_create_inferior_1 (char *exec_file, char *args,
-				   char **env, int from_tty)
+extended_remote_create_inferior (struct target_ops *ops,
+				 char *exec_file, char *args,
+				 char **env, int from_tty)
 {
   int run_worked;
   char *stop_reply;
@@ -8126,14 +8127,6 @@ extended_remote_create_inferior_1 (char *exec_file, char *args,
   /* Get updated offsets, if the stub uses qOffsets.  */
   get_offsets ();
 }
-
-static void
-extended_remote_create_inferior (struct target_ops *ops, 
-				 char *exec_file, char *args,
-				 char **env, int from_tty)
-{
-  extended_remote_create_inferior_1 (exec_file, args, env, from_tty);
-}
 \f
 
 /* Given a location's target info BP_TGT and the packet buffer BUF,  output
-- 
1.8.1.4

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

* [RFC 24/32] convert to_disable_tracepoint
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (9 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 32/32] minor cleanups to update_current_target Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 18:49   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 12/32] Add target_ops argument to to_thread_name Tom Tromey
                   ` (23 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 53fabb1..ddcc89c 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 83dfee7..90e2709 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -689,16 +689,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);
@@ -748,38 +748,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 4a5573d..dfaad80 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -808,25 +808,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
@@ -835,18 +841,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] 100+ messages in thread

* [RFC 04/32] add make-target-delegates
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (7 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 31/32] change delegation for to_read_description Tom Tromey
@ 2014-01-13 19:13 ` Tom Tromey
  2014-01-14 10:52   ` Pedro Alves
  2014-01-13 19:13 ` [RFC 32/32] minor cleanups to update_current_target Tom Tromey
                   ` (25 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:13 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-01-08  Tom Tromey  <tromey@redhat.com>

	* 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             |  10 ++
 gdb/make-target-delegates | 253 ++++++++++++++++++++++++++++++++++++++++++++++
 gdb/target-delegates.c    |  14 +++
 gdb/target.c              |   9 ++
 gdb/target.h              |  24 +++++
 5 files changed, 310 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..47f960c
--- /dev/null
+++ b/gdb/make-target-delegates
@@ -0,0 +1,253 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2013 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 d2a40ee..1fe7ba3 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -85,6 +85,8 @@ static LONGEST current_xfer_partial (struct target_ops *ops,
 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;
@@ -352,6 +354,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
@@ -559,6 +563,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
@@ -3783,6 +3790,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 78c9d34..867b2f2 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -345,6 +345,30 @@ struct thread_info;		/* fwd decl for parameter list below: */
 
 typedef void async_callback_ftype (enum inferior_event_type, void *);
 
+/* 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] 100+ messages in thread

* [RFC 13/32] Add target_ops argument to to_get_ada_task_ptid
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (16 preceding siblings ...)
  2014-01-13 19:23 ` [RFC 07/32] introduce remote_load Tom Tromey
@ 2014-01-13 19:23 ` Tom Tromey
  2014-01-14 13:21   ` Pedro Alves
  2014-01-13 19:23 ` [RFC 17/32] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
                   ` (16 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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.

Add target_ops argument to to_can_execute_reverse

2014-01-08  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.

Add target_ops argument to to_execution_direction

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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          | 120 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/aix-thread.c       |   2 +-
 gdb/darwin-nat.c       |   4 +-
 gdb/dec-thread.c       |   5 ++-
 gdb/inf-child.c        |   3 +-
 gdb/inf-ttrace.c       |   2 +-
 gdb/linux-nat.c        |   4 +-
 gdb/linux-thread-db.c  |   2 +-
 gdb/ravenscar-thread.c |   2 +-
 gdb/record-full.c      |   4 +-
 gdb/remote.c           |  44 +++++++++---------
 gdb/sol-thread.c       |   2 +-
 gdb/target.c           |  24 +++++-----
 gdb/target.h           |  38 ++++++++--------
 gdb/windows-nat.c      |   2 +-
 15 files changed, 193 insertions(+), 65 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 1a24eb0..53d6840 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 bb6c014..9c4d511 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;
@@ -2059,7 +2059,7 @@ darwin_get_ada_task_ptid (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/dec-thread.c b/gdb/dec-thread.c
index 0376828..909f090 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-child.c b/gdb/inf-child.c
index 7b8491f..7a65bfe 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/inf-ttrace.c b/gdb/inf-ttrace.c
index 545af88..7efe1e0 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-nat.c b/gdb/linux-nat.c
index 1116f9c..8dfeb40 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4534,13 +4534,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/linux-thread-db.c b/gdb/linux-thread-db.c
index 2e39aa8..3c40c40 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1867,7 +1867,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 d912691..0286e9a 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/record-full.c b/gdb/record-full.c
index 61b1397..3b251c6 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1683,7 +1683,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;
 }
@@ -1740,7 +1740,7 @@ record_full_goto_bookmark (struct target_ops *self,
 }
 
 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 41147a2..1370c5d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -232,9 +232,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".  */
 
@@ -3025,7 +3025,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);
 }
@@ -7992,7 +7992,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);
@@ -8096,7 +8096,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.  */
@@ -8237,10 +8237,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);
@@ -8510,10 +8510,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);
@@ -9790,7 +9790,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 ();
@@ -10036,7 +10037,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);
@@ -10142,7 +10144,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)
@@ -10226,7 +10229,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);
 
@@ -10350,7 +10354,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)
@@ -10366,14 +10370,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 ();
 
@@ -10393,7 +10397,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 ();
 
@@ -10425,7 +10429,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 ();
 
@@ -10433,7 +10437,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 ();
 
@@ -10441,7 +10445,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/sol-thread.c b/gdb/sol-thread.c
index b480b58..b1d33ee 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -1186,7 +1186,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 dce3eac..5c886dc 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -533,13 +533,13 @@ 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);
 }
 
 static enum exec_direction_kind
-default_execution_direction (void)
+default_execution_direction (struct target_ops *self)
 {
   if (!target_can_execute_reverse)
     return EXEC_FORWARD;
@@ -833,16 +833,16 @@ 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))
+	    (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))
@@ -926,10 +926,10 @@ update_current_target (void)
 	    (struct traceframe_info * (*) (void))
 	    return_zero);
   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))
@@ -3194,13 +3194,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;
 }
 
@@ -3211,7 +3211,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;
 }
@@ -3299,7 +3299,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 6071e8f..d28bfd3 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -623,7 +623,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.
@@ -644,34 +645,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.
 
@@ -697,7 +698,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.
@@ -1070,7 +1072,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.  */
 
@@ -1080,22 +1082,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 *);
 
@@ -1476,7 +1478,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
@@ -1657,12 +1659,12 @@ 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 *);
 
 #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 7132034..c3982f1 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2571,7 +2571,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] 100+ messages in thread

* [RFC 20/32] convert to_remove_watchpoint
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (18 preceding siblings ...)
  2014-01-13 19:23 ` [RFC 17/32] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
@ 2014-01-13 19:23 ` Tom Tromey
  2014-01-14 18:39   ` Pedro Alves
  2014-01-13 19:24 ` [RFC 30/32] convert to_search_memory Tom Tromey
                   ` (14 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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_acce_watchpoint_condition

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 5a5954d..00dc2c5 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 794d099..f77fb77 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -605,23 +605,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.  */
@@ -730,35 +730,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 5f521c5..e16ff52 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -454,7 +454,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);
@@ -470,24 +471,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] 100+ messages in thread

* [RFC 07/32] introduce remote_load
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (15 preceding siblings ...)
  2014-01-13 19:13 ` [RFC 09/32] Add target_ops argument to to_close Tom Tromey
@ 2014-01-13 19:23 ` Tom Tromey
  2014-01-14 12:39   ` Pedro Alves
  2014-01-13 19:23 ` [RFC 13/32] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
                   ` (17 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19: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-01-08  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 6f3fc91..9efb985 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11483,6 +11483,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)
 {
@@ -11516,7 +11524,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] 100+ messages in thread

* [RFC 17/32] Add target_ops argument to to_static_tracepoint_markers_by_strid
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (17 preceding siblings ...)
  2014-01-13 19:23 ` [RFC 13/32] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
@ 2014-01-13 19:23 ` Tom Tromey
  2014-01-14 13:25   ` Pedro Alves
  2014-01-13 19:23 ` [RFC 20/32] convert to_remove_watchpoint Tom Tromey
                   ` (15 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 | 18 +++++++---
 gdb/ctf.c             |  2 +-
 gdb/i386-linux-nat.c  | 18 +++++++---
 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          | 19 ++++++-----
 gdb/target.c          | 21 ++++++------
 gdb/target.h          | 33 ++++++++++--------
 gdb/tracepoint.c      |  2 +-
 13 files changed, 174 insertions(+), 50 deletions(-)

diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 237e936..cbec370 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)
 {
   int errcode = linux_disable_btrace (tinfo);
 
@@ -1183,12 +1184,21 @@ 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 VEC (btrace_block_s) *
+amd64_linux_read_btrace (struct target_ops *self,
+			 struct btrace_target_info *tinfo,
+			 enum btrace_read_type type)
+{
+  return linux_read_btrace (tinfo, type);
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_amd64_linux_nat (void);
 
@@ -1232,7 +1242,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 db6032b..c41959b 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1732,7 +1732,7 @@ ctf_has_registers (struct target_ops *ops)
    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 f886b39e..01d7f71 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)
 {
   int errcode = linux_disable_btrace (tinfo);
 
@@ -1094,12 +1095,21 @@ 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 VEC (btrace_block_s) *
+i386_linux_read_btrace (struct target_ops *self,
+			struct btrace_target_info *tinfo,
+			enum btrace_read_type type)
+{
+  return linux_read_btrace (tinfo, type);
+}
+
 /* -Wmissing-prototypes */
 extern initialize_file_ftype _initialize_i386_linux_nat;
 
@@ -1138,7 +1148,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 061a46a..af3f105 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 8dfeb40..3cfd4e7 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4397,7 +4397,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 d1f36c9..c99e7c2 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -174,7 +174,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;
 
@@ -202,7 +202,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 3b251c6..8769795 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1746,7 +1746,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 0fd8756..77b1ce5 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -104,7 +104,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.  */
@@ -276,7 +276,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 c7cb2d3..5721178 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2974,7 +2974,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;
@@ -11188,7 +11189,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;
 
@@ -11326,7 +11327,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)
     {
@@ -11348,7 +11349,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);
 }
@@ -11377,7 +11378,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];
@@ -11413,7 +11414,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 ();
@@ -11445,7 +11447,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);
@@ -11454,7 +11457,7 @@ remote_teardown_btrace (struct btrace_target_info *tinfo)
 /* Read the branch trace.  */
 
 static VEC (btrace_block_s) *
-remote_read_btrace (struct btrace_target_info *tinfo,
+remote_read_btrace (struct target_ops *self, struct btrace_target_info *tinfo,
 		    enum btrace_read_type type)
 {
   struct packet_config *packet = &remote_protocol_packets[PACKET_qXfer_btrace];
diff --git a/gdb/target.c b/gdb/target.c
index 35ce7e8..4a698fe 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -924,10 +924,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_zero);
   de_fault (to_supports_evaluation_of_breakpoint_conditions,
 	    (int (*) (struct target_ops *))
@@ -936,10 +937,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))
@@ -4119,7 +4120,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;
@@ -4135,7 +4136,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;
       }
 
@@ -4152,7 +4153,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;
       }
 
@@ -4169,7 +4170,7 @@ target_read_btrace (struct btrace_target_info *btinfo,
 
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_read_btrace != NULL)
-      return t->to_read_btrace (btinfo, type);
+      return t->to_read_btrace (t, btinfo, type);
 
   tcomplain ();
   return NULL;
@@ -4185,7 +4186,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;
       }
 
@@ -4202,7 +4203,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 2a17b02..ca70a9e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -855,7 +855,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
@@ -870,14 +870,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 *)
@@ -885,26 +885,30 @@ 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.  */
-    VEC (btrace_block_s) *(*to_read_btrace) (struct btrace_target_info *,
+    VEC (btrace_block_s) *(*to_read_btrace) (struct target_ops *,
+					     struct btrace_target_info *,
 					     enum btrace_read_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);
@@ -1832,16 +1836,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 0fde73c..96b8a89 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -5299,7 +5299,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] 100+ messages in thread

* [RFC 30/32] convert to_search_memory
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (19 preceding siblings ...)
  2014-01-13 19:23 ` [RFC 20/32] convert to_remove_watchpoint Tom Tromey
@ 2014-01-13 19:24 ` Tom Tromey
  2014-01-14 19:45   ` Pedro Alves
  2014-01-13 19:24 ` [RFC 16/32] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
                   ` (13 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 77b1ce5..c81bd2a 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -103,8 +103,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 456f70e..66c0625 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 VEC (btrace_block_s) *
+delegate_read_btrace (struct target_ops *self, struct btrace_target_info *arg1, enum btrace_read_type arg2)
+{
+  self = self->beneath;
+  return self->to_read_btrace (self, arg1, arg2);
+}
+
+static VEC (btrace_block_s) *
+tdefault_read_btrace (struct target_ops *self, struct btrace_target_info *arg1, enum btrace_read_type arg2)
+{
+  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 c3a5e77..df11fc0 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 *);
@@ -644,7 +651,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.  */
@@ -739,9 +746,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
@@ -2392,24 +2396,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
@@ -2579,8 +2574,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).  */
 
@@ -2687,6 +2681,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.
 
@@ -2699,34 +2707,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);
@@ -2789,7 +2778,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;
@@ -3712,14 +3701,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.  */
@@ -3727,16 +3709,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.  */
@@ -3744,16 +3717,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.  */
@@ -3762,14 +3726,7 @@ VEC (btrace_block_s) *
 target_read_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, btinfo, type);
-
-  tcomplain ();
-  return NULL;
+  return current_target.to_read_btrace (&current_target, btinfo, type);
 }
 
 /* See target.h.  */
@@ -3777,16 +3734,7 @@ target_read_btrace (struct btrace_target_info *btinfo,
 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 987112e..978941b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -395,7 +395,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 *,
@@ -532,7 +533,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.  */
@@ -700,7 +702,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 *)
@@ -982,26 +985,31 @@ 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.  */
     VEC (btrace_block_s) *(*to_read_btrace) (struct target_ops *,
 					     struct btrace_target_info *,
-					     enum btrace_read_type);
+					     enum btrace_read_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] 100+ messages in thread

* [RFC 06/32] convert to_supports_btrace
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (21 preceding siblings ...)
  2014-01-13 19:24 ` [RFC 16/32] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
@ 2014-01-13 19:24 ` Tom Tromey
  2014-01-14 12:37   ` Pedro Alves
  2014-01-13 19:37 ` [RFC 21/32] convert to_load Tom Tromey
                   ` (11 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

---
 gdb/common/linux-btrace.c |  4 ++--
 gdb/common/linux-btrace.h |  2 +-
 gdb/gdbserver/target.h    |  7 ++++---
 gdb/remote.c              |  2 +-
 gdb/target-delegates.c    | 16 ++++++++++++++++
 gdb/target.c              | 14 --------------
 gdb/target.h              |  6 ++++--
 7 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c
index 7e20745..b3d1aaa 100644
--- a/gdb/common/linux-btrace.c
+++ b/gdb/common/linux-btrace.c
@@ -400,7 +400,7 @@ cpu_supports_btrace (void)
 /* See linux-btrace.h.  */
 
 int
-linux_supports_btrace (void)
+linux_supports_btrace (struct target_ops *ops)
 {
   static int cached;
 
@@ -554,7 +554,7 @@ linux_read_btrace (struct btrace_target_info *tinfo,
 /* 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 d4e8402..16c4bb1 100644
--- a/gdb/common/linux-btrace.h
+++ b/gdb/common/linux-btrace.h
@@ -62,7 +62,7 @@ struct btrace_target_info
 };
 
 /* Check whether branch tracing is supported.  */
-extern int linux_supports_btrace (void);
+extern int linux_supports_btrace (struct target_ops *);
 
 /* Enable branch tracing for @ptid.  */
 extern struct btrace_target_info *linux_enable_btrace (ptid_t ptid);
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index c5e6fee..277838d 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.  */
@@ -488,8 +488,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 a91e6aa..6f3fc91 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11340,7 +11340,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 484945f..77f3113 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 0f614bf..6fc95fc 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -4090,20 +4090,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 538bdf4..d1fa12f 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -854,7 +854,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.  */
@@ -1988,7 +1989,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] 100+ messages in thread

* [RFC 16/32] Add target_ops argument to to_upload_trace_state_variables
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (20 preceding siblings ...)
  2014-01-13 19:24 ` [RFC 30/32] convert to_search_memory Tom Tromey
@ 2014-01-13 19:24 ` Tom Tromey
  2014-01-14 13:24   ` Pedro Alves
  2014-01-13 19:24 ` [RFC 06/32] convert to_supports_btrace Tom Tromey
                   ` (12 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 8ad8409..c7cb2d3 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -202,7 +202,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,
@@ -211,7 +211,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);
 
@@ -2947,7 +2948,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 ();
@@ -3400,7 +3401,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.
 
@@ -3487,7 +3488,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);
     }
 
@@ -3775,7 +3776,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 ();
 
@@ -9454,7 +9455,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)
     {
@@ -11102,7 +11103,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;
@@ -11140,7 +11142,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 ();
 
@@ -11171,7 +11173,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;
@@ -11216,7 +11218,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;
@@ -11245,7 +11247,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)
@@ -11277,7 +11279,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 ();
@@ -11805,7 +11808,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 74e79cc..35ce7e8 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -892,34 +892,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 e8a2997..2a17b02 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -798,27 +798,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.
@@ -839,14 +841,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
@@ -1796,34 +1799,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 c3982f1..6e28b6e 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2556,7 +2556,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] 100+ messages in thread

* [RFC 21/32] convert to_load
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (22 preceding siblings ...)
  2014-01-13 19:24 ` [RFC 06/32] convert to_supports_btrace Tom Tromey
@ 2014-01-13 19:37 ` Tom Tromey
  2014-01-14 18:41   ` Pedro Alves
  2014-01-13 19:38 ` [RFC 22/32] convert to_extra_thread_info Tom Tromey
                   ` (10 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 00dc2c5..7abb393 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 f77fb77..076e4be 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);
 
 void target_ignore (void);
@@ -623,18 +621,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.  */
@@ -730,36 +728,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);
@@ -3542,12 +3510,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 e16ff52..6a563f7 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -499,20 +499,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] 100+ messages in thread

* [RFC 23/32] convert to_thread_architecture
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (26 preceding siblings ...)
  2014-01-13 19:38 ` [RFC 18/32] Add target_ops argument to to_save_record Tom Tromey
@ 2014-01-13 19:38 ` Tom Tromey
  2014-01-14 18:46   ` Pedro Alves
  2014-01-13 19:38 ` [RFC 28/32] convert to_get_section_table Tom Tromey
                   ` (6 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 a2293c4..53fabb1 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 604469c..83dfee7 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 *);
@@ -674,18 +677,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);
@@ -744,36 +747,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 bc2dc6a..4a5573d 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -662,7 +662,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.
@@ -694,17 +695,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?  */
@@ -724,7 +728,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.
 
@@ -778,23 +783,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] 100+ messages in thread

* [RFC 05/32] add target method delegation
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (24 preceding siblings ...)
  2014-01-13 19:38 ` [RFC 22/32] convert to_extra_thread_info Tom Tromey
@ 2014-01-13 19:38 ` Tom Tromey
  2014-01-14 12:32   ` Pedro Alves
  2014-01-13 19:38 ` [RFC 18/32] Add target_ops argument to to_save_record Tom Tromey
                   ` (8 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

MUST UPDATE

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.

To fix the problem, this patch introduces a handful of
target_delegate_* functions, which forward calls further down the
target stack.

2014-01-08  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)
	(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_insert_breakpoint)
	(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_can_async_p, record_full_is_async_p)
	(record_full_core_xfer_partial): Use target delegation.
	* target.c (update_current_target): Use target_delegate_xfer_partial.
	(target_delegate_xfer_partial): Now public.  Renamed from...
	(current_xfer_partial): ...this.  Remove.
	(target_delegate_async, target_delegate_is_async_p)
	(target_delegate_can_async_p, target_delegate_insert_breakpoint)
	(target_delegate_remove_breakpoint, target_delegate_wait)
	(target_delegate_resume, target_delegate_store_registers)
	(target_delegate_stopped_by_watchpoint)
	(target_delegate_stopped_data_address)
	(assert_delegation_failed): New functions.
	* target.h (target_delegate_async, target_delegate_is_async_p)
	(target_delegate_can_async_p, target_delegate_insert_breakpoint)
	(target_delegate_remove_breakpoint, target_delegate_wait)
	(target_delegate_resume, target_delegate_store_registers)
	(target_delegate_stopped_by_watchpoint)
	(target_delegate_stopped_data_address)
	(target_delegate_xfer_partial): Declare.
---
 gdb/ChangeLog          |  44 +++++++++
 gdb/record-full.c      | 239 +++++--------------------------------------------
 gdb/target-delegates.c | 152 +++++++++++++++++++++++++++++++
 gdb/target.c           | 158 ++++++++++----------------------
 gdb/target.h           |  33 ++++---
 5 files changed, 285 insertions(+), 341 deletions(-)

diff --git a/gdb/record-full.c b/gdb/record-full.c
index f4d760a..1d66c6e 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -215,43 +215,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 LONGEST
-  (*record_full_beneath_to_xfer_partial) (struct target_ops *ops,
-					  enum target_object object,
-					  const char *annex,
-					  gdb_byte *readbuf,
-					  const gdb_byte *writebuf,
-					  ULONGEST offset,
-					  LONGEST len);
-static int
-  (*record_full_beneath_to_insert_breakpoint) (struct target_ops *,
-					       struct gdbarch *,
-					       struct bp_target_info *);
-static int
-  (*record_full_beneath_to_remove_breakpoint) (struct target_ops *,
-					       struct gdbarch *,
-					       struct bp_target_info *);
-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);
@@ -798,36 +761,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 LONGEST (*tmp_to_xfer_partial) (struct target_ops *ops,
-				       enum target_object object,
-				       const char *annex,
-				       gdb_byte *readbuf,
-				       const gdb_byte *writebuf,
-				       ULONGEST offset,
-				       LONGEST len);
-static int (*tmp_to_insert_breakpoint) (struct target_ops *,
-					struct gdbarch *,
-					struct bp_target_info *);
-static int (*tmp_to_remove_breakpoint) (struct target_ops *ops,
-					struct gdbarch *,
-					struct bp_target_info *);
-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
@@ -890,26 +823,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);
 }
 
@@ -926,83 +839,16 @@ record_full_open (char *name, int from_tty)
     fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");
 
   /* Check if record target is already running.  */
-  if (current_target.to_stratum == record_stratum)
+  if (RECORD_IS_USED)
     error (_("Process record target already running.  Use \"record stop\" to "
              "stop record target first."));
 
-  /* 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;
-
-  /* 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;
-      if (!tmp_to_remove_breakpoint)
-	tmp_to_remove_breakpoint = t->to_remove_breakpoint;
-      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_remove_breakpoint = tmp_to_remove_breakpoint;
-  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
@@ -1126,8 +972,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),
@@ -1217,8 +1062,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
 	{
@@ -1229,8 +1073,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)
@@ -1314,9 +1157,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;
 		    }
 		}
@@ -1520,11 +1362,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
@@ -1533,7 +1371,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.  */
@@ -1636,8 +1474,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
@@ -1702,9 +1539,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
@@ -1785,8 +1622,7 @@ record_full_insert_breakpoint (struct target_ops *ops,
       int ret;
 
       old_cleanups = record_full_gdb_operation_disable_set ();
-      ret = record_full_beneath_to_insert_breakpoint (find_target_beneath (ops),
-						      gdbarch, bp_tgt);
+      ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
       do_cleanups (old_cleanups);
 
       if (ret != 0)
@@ -1827,8 +1663,8 @@ record_full_remove_breakpoint (struct target_ops *ops,
 	      int ret;
 
 	      old_cleanups = record_full_gdb_operation_disable_set ();
-	      ret = record_full_beneath_to_remove_breakpoint (find_target_beneath (ops),
-							      gdbarch, bp_tgt);
+	      ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch,
+							bp_tgt);
 	      do_cleanups (old_cleanups);
 
 	      if (ret != 0)
@@ -1902,32 +1738,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)
-{
-  /* We only enable async when the user specifically asks for it.  */
-  return target_async_permitted;
-}
-
-static int
-record_full_is_async_p (struct target_ops *ops)
-{
-  /* We only enable async when the user specifically asks for it.  */
-  return target_async_permitted;
-}
-
 static enum exec_direction_kind
 record_full_execution_direction (void)
 {
@@ -2092,9 +1902,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;
   record_full_ops.to_info_record = record_full_info;
   record_full_ops.to_save_record = record_full_save;
@@ -2251,10 +2058,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);
@@ -2270,9 +2077,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.  */
@@ -2334,9 +2140,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..484945f 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, LONGEST 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, LONGEST 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 1fe7ba3..0f614bf 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -76,15 +76,13 @@ static LONGEST default_xfer_partial (struct target_ops *ops,
 				     const gdb_byte *writebuf,
 				     ULONGEST offset, LONGEST len);
 
-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, LONGEST len);
-
 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);
@@ -589,8 +587,8 @@ update_current_target (void)
       INHERIT (to_prepare_to_store, t);
       INHERIT (deprecated_xfer_memory, t);
       INHERIT (to_files_info, t);
-      INHERIT (to_insert_breakpoint, t);
-      INHERIT (to_remove_breakpoint, t);
+      /* 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);
@@ -599,10 +597,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);
@@ -647,9 +645,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);
@@ -730,10 +728,6 @@ update_current_target (void)
   de_fault (to_files_info,
 	    (void (*) (struct target_ops *))
 	    target_ignore);
-  de_fault (to_insert_breakpoint,
-	    memory_insert_breakpoint);
-  de_fault (to_remove_breakpoint,
-	    memory_remove_breakpoint);
   de_fault (to_can_use_hw_breakpoint,
 	    (int (*) (int, int, int))
 	    return_zero);
@@ -749,12 +743,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,
@@ -820,18 +808,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_zero);
-  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;
@@ -2003,27 +1985,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, LONGEST 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.  */
@@ -2672,34 +2639,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 *
@@ -2737,26 +2696,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
@@ -3153,7 +3103,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;
 }
@@ -3168,7 +3118,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;
 }
@@ -3767,8 +3717,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;
@@ -3778,17 +3726,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);
@@ -4008,20 +3951,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
diff --git a/gdb/target.h b/gdb/target.h
index 867b2f2..538bdf4 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -393,11 +393,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 regcache *);
 
     /* Transfer LEN bytes of memory between GDB address MYADDR and
@@ -428,9 +431,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 *);
@@ -445,10 +450,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);
 
@@ -510,9 +517,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);
@@ -563,7 +573,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, LONGEST len);
+				ULONGEST offset, LONGEST 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
-- 
1.8.1.4

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

* [RFC 18/32] Add target_ops argument to to_save_record
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (25 preceding siblings ...)
  2014-01-13 19:38 ` [RFC 05/32] add target method delegation Tom Tromey
@ 2014-01-13 19:38 ` Tom Tromey
  2014-01-14 13:26   ` Pedro Alves
  2014-01-13 19:38 ` [RFC 23/32] convert to_thread_architecture Tom Tromey
                   ` (7 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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.

Add target_ops argument to to_goto_record_begin

2014-01-08  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.

Add target_ops argument to to_goto_record_end

2014-01-08  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.

Add target_ops argument to to_goto_record

2014-01-08  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.

Add target_ops argument to to_insn_history

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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       | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/record-btrace.c | 20 ++++++-----
 gdb/record-full.c   | 15 +++++----
 gdb/remote.c        |  2 +-
 gdb/target.c        | 26 +++++++--------
 gdb/target.h        | 32 ++++++++++--------
 6 files changed, 148 insertions(+), 43 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index c99e7c2..d536fea 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -263,7 +263,7 @@ btrace_insn_history (struct btrace_thread_info *btinfo, 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 cleanup *uiout_cleanup;
@@ -338,7 +338,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 cleanup *uiout_cleanup;
@@ -381,7 +382,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;
 
@@ -406,7 +408,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.  */
@@ -492,7 +494,7 @@ btrace_func_history (struct btrace_thread_info *btinfo, 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 cleanup *uiout_cleanup;
@@ -567,7 +569,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 cleanup *uiout_cleanup;
@@ -610,7 +613,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;
 
@@ -635,7 +639,7 @@ 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);
 }
 
 /* Initialize the record-btrace target ops.  */
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 8769795..eedb223 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -217,7 +217,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.  */
@@ -1792,7 +1793,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);
 }
@@ -1800,7 +1801,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;
 }
@@ -1835,7 +1836,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;
 
@@ -1849,7 +1850,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;
 
@@ -1865,7 +1866,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;
 
@@ -2454,7 +2455,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 5721178..34b8f6d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11501,7 +11501,7 @@ remote_read_btrace (struct target_ops *self, struct btrace_target_info *tinfo,
 }
 
 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 4a698fe..1f3562f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -943,7 +943,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);
 
@@ -4220,7 +4220,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;
       }
 
@@ -4251,7 +4251,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;
       }
 
@@ -4267,7 +4267,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;
 }
@@ -4282,7 +4282,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;
       }
 
@@ -4299,7 +4299,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;
       }
 
@@ -4316,7 +4316,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;
       }
 
@@ -4333,7 +4333,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;
       }
 
@@ -4350,7 +4350,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;
       }
 
@@ -4367,7 +4367,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;
       }
 
@@ -4384,7 +4384,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;
       }
 
@@ -4401,7 +4401,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;
       }
 
@@ -4418,7 +4418,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 ca70a9e..4668c23 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -911,57 +911,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 (exclusive).  */
-    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 (exclusive).  */
-    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 *);
 
     int to_magic;
     /* Need sub-structure for target machine related rather than comm related?
@@ -1849,7 +1853,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] 100+ messages in thread

* [RFC 28/32] convert to_get_section_table
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (27 preceding siblings ...)
  2014-01-13 19:38 ` [RFC 23/32] convert to_thread_architecture Tom Tromey
@ 2014-01-13 19:38 ` Tom Tromey
  2014-01-14 19:23   ` Pedro Alves
  2014-01-13 19:40 ` [RFC 29/32] convert to_insn_history Tom Tromey
                   ` (5 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 f32c90f..5af8460 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 636cfdb..dabb66c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1086,16 +1086,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.  */
@@ -1723,36 +1717,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
@@ -3664,47 +3640,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
@@ -4000,16 +3957,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.  */
@@ -4017,16 +3965,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.  */
@@ -4034,16 +3973,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.  */
@@ -4051,16 +3981,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.  */
@@ -4068,16 +3989,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 f83ece1..6c3e929 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -562,7 +562,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 *);
@@ -657,13 +658,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
@@ -912,14 +915,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.  */
@@ -1027,29 +1032,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 (exclusive).  */
     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 (exclusive).  */
     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] 100+ messages in thread

* [RFC 22/32] convert to_extra_thread_info
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (23 preceding siblings ...)
  2014-01-13 19:37 ` [RFC 21/32] convert to_load Tom Tromey
@ 2014-01-13 19:38 ` Tom Tromey
  2014-01-14 18:43   ` Pedro Alves
  2014-01-13 19:38 ` [RFC 05/32] add target method delegation Tom Tromey
                   ` (9 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 7abb393..a2293c4 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, LONGEST 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 076e4be..604469c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -80,10 +80,20 @@ static LONGEST default_xfer_partial (struct target_ops *ops,
 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);
@@ -640,13 +650,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.  */
@@ -657,13 +667,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);
@@ -731,18 +741,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_zero);
-  de_fault (to_thread_name,
-	    (char *(*) (struct target_ops *, struct thread_info *))
-	    return_zero);
   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_zero);
   de_fault (to_thread_architecture,
 	    default_thread_architecture);
   current_target.to_read_description = NULL;
@@ -859,7 +860,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
 
@@ -2603,15 +2603,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
@@ -3611,21 +3603,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.  */
 
@@ -3641,10 +3618,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 6a563f7..bc2dc6a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -537,14 +537,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 *);
@@ -564,13 +568,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
@@ -675,12 +683,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?  */
@@ -1711,8 +1721,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 *);
 
@@ -1887,12 +1896,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] 100+ messages in thread

* [RFC 29/32] convert to_insn_history
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (28 preceding siblings ...)
  2014-01-13 19:38 ` [RFC 28/32] convert to_get_section_table Tom Tromey
@ 2014-01-13 19:40 ` Tom Tromey
  2014-01-14 19:29   ` Pedro Alves
  2014-01-13 19:57 ` [RFC 14/32] Add target_ops argument to to_fileio_pwrite Tom Tromey
                   ` (4 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:40 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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

this one is more complicated than the norm

2014-01-08  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 437040a..c317765 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 0244cd8..db098ba 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 5af8460..456f70e 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 = dummy_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 dabb66c..c3a5e77 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);
 
@@ -1679,14 +1680,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;
 
@@ -3481,24 +3475,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
@@ -3827,16 +3811,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.  */
@@ -3858,16 +3833,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.  */
@@ -3875,13 +3841,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.  */
@@ -3889,16 +3849,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.  */
@@ -3906,16 +3857,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.  */
@@ -3923,16 +3865,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.  */
@@ -3940,16 +3873,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 6c3e929..987112e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -544,7 +544,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)
@@ -650,7 +651,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.
@@ -686,7 +688,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.
@@ -1004,28 +1007,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] 100+ messages in thread

* [RFC 15/32] Add target_ops argument to to_disable_tracepoint
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (30 preceding siblings ...)
  2014-01-13 19:57 ` [RFC 14/32] Add target_ops argument to to_fileio_pwrite Tom Tromey
@ 2014-01-13 19:57 ` Tom Tromey
  2014-01-14 13:23   ` Pedro Alves
  2014-01-14 20:31 ` go32 fix Pedro Alves
                   ` (2 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 239afb2..db6032b 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1489,7 +1489,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;
@@ -1606,7 +1607,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;
@@ -1801,7 +1802,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 b81501d..8ad8409 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -205,9 +205,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);
   
@@ -3481,7 +3483,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;
 
@@ -3625,14 +3627,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);
     }
@@ -10722,7 +10724,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;
@@ -10778,7 +10780,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];
@@ -10795,7 +10798,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;
@@ -10845,7 +10848,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);
@@ -10856,7 +10859,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;
@@ -10906,7 +10909,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 ();
@@ -10953,7 +10956,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);
@@ -10964,7 +10967,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)
 {
@@ -11046,7 +11050,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;
@@ -11070,7 +11075,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;
@@ -11779,7 +11784,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 0ef4cdc..74e79cc 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -860,34 +860,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 31a4ce9..e8a2997 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -757,41 +757,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);
 
@@ -1759,34 +1764,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 a09bf37..0fde73c 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4773,7 +4773,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.  */
@@ -4782,7 +4782,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.  */
@@ -4827,7 +4828,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;
@@ -5186,7 +5187,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] 100+ messages in thread

* [RFC 14/32] Add target_ops argument to to_fileio_pwrite
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (29 preceding siblings ...)
  2014-01-13 19:40 ` [RFC 29/32] convert to_insn_history Tom Tromey
@ 2014-01-13 19:57 ` Tom Tromey
  2014-01-14 13:22   ` Pedro Alves
  2014-01-13 19:57 ` [RFC 15/32] Add target_ops argument to to_disable_tracepoint Tom Tromey
                   ` (3 subsequent siblings)
  34 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-13 19:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 7a65bfe..061a46a 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 1370c5d..b81501d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9818,7 +9818,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 ();
@@ -9846,7 +9847,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 ();
@@ -9885,7 +9887,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;
@@ -9903,7 +9905,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;
@@ -9923,7 +9926,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;
@@ -10024,7 +10028,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);
 }
 
 
@@ -10061,7 +10065,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;
@@ -10078,7 +10082,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.  */
@@ -10189,7 +10194,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)
@@ -10208,7 +10214,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)
@@ -10250,7 +10256,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;
@@ -10265,7 +10272,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)
@@ -10282,7 +10289,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);
 
@@ -10453,7 +10461,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);
@@ -10524,7 +10532,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
 
@@ -10701,7 +10709,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;
@@ -10729,7 +10737,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;
@@ -10751,7 +10760,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 5c886dc..0ef4cdc 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -845,19 +845,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 *))
@@ -3327,7 +3327,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)
@@ -3357,7 +3357,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)
@@ -3385,7 +3385,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,
@@ -3410,7 +3410,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,
@@ -3436,7 +3436,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 d28bfd3..31a4ce9 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -705,27 +705,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.  */
@@ -734,20 +738,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);
@@ -1737,19 +1744,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] 100+ messages in thread

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-13 19:12 ` [RFC 03/32] introduce async_callback_ftype Tom Tromey
@ 2014-01-14 10:35   ` Pedro Alves
  2014-01-14 10:50     ` Joel Brobecker
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 10:35 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> This introduces async_callback_ftype.  This is needed for
> make-target-delegates to work properly, as it doesn't implement a real
> parser.  I think it's also an ok cleanup in its own right.

Agreed.  This could go in immediately.

> 
> 2014-01-08  Tom Tromey  <tromey@redhat.com>
> 
> 	* target.h (async_callback_ftype): New typedef.
> 	(struct target_ops) <to_async>: Use it.
> ---
>  gdb/ChangeLog | 5 +++++
>  gdb/target.h  | 7 +++++--
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/target.h b/gdb/target.h
> index b219cff..78c9d34 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -341,6 +341,10 @@ extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
>  \f
>  struct thread_info;		/* fwd decl for parameter list below: */
>  
> +/* The type of the callback to the to_async method.  */
> +
> +typedef void async_callback_ftype (enum inferior_event_type, void *);
> +
>  struct target_ops
>    {
>      struct target_ops *beneath;	/* To the target under this one.  */
> @@ -484,8 +488,7 @@ struct target_ops
>      /* 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 *,
> -		      void (*) (enum inferior_event_type, void *), void *);
> +    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);
> 


-- 
Pedro Alves

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

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-14 10:35   ` Pedro Alves
@ 2014-01-14 10:50     ` Joel Brobecker
  2014-01-14 15:06       ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Joel Brobecker @ 2014-01-14 10:50 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

> On 01/13/2014 07:12 PM, Tom Tromey wrote:
> > This introduces async_callback_ftype.  This is needed for
> > make-target-delegates to work properly, as it doesn't implement a real
> > parser.  I think it's also an ok cleanup in its own right.
> 
> Agreed.  This could go in immediately.
> 
> > 
> > 2014-01-08  Tom Tromey  <tromey@redhat.com>
> > 
> > 	* target.h (async_callback_ftype): New typedef.
> > 	(struct target_ops) <to_async>: Use it.

Just a tiny comment:

> > ---
> >  gdb/ChangeLog | 5 +++++
> >  gdb/target.h  | 7 +++++--
> >  2 files changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/gdb/target.h b/gdb/target.h
> > index b219cff..78c9d34 100644
> > --- a/gdb/target.h
> > +++ b/gdb/target.h
> > @@ -341,6 +341,10 @@ extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
> >  \f
> >  struct thread_info;		/* fwd decl for parameter list below: */
> >  
> > +/* The type of the callback to the to_async method.  */
> > +
> > +typedef void async_callback_ftype (enum inferior_event_type, void *);

I think it would be nice if the arguments were named, giving us more
tools to better document the intended behavior of this callback. It's
also a way to help implementors to choose consistent names for those
parameters. As for the documentation, unless completely trivial, it
seems reasonable to me to leave that for later, or even someone else!

Thanks!
-- 
Joel

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

* Re: [RFC 04/32] add make-target-delegates
  2014-01-13 19:13 ` [RFC 04/32] add make-target-delegates Tom Tromey
@ 2014-01-14 10:52   ` Pedro Alves
  2014-01-14 14:46     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 10:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 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-01-08  Tom Tromey  <tromey@redhat.com>
> 

Maybe add the PR number to this one.

> 	* 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.

Looks quite nice to me.

> ---
>  gdb/ChangeLog             |  10 ++
>  gdb/make-target-delegates | 253 ++++++++++++++++++++++++++++++++++++++++++++++
>  gdb/target-delegates.c    |  14 +++
>  gdb/target.c              |   9 ++
>  gdb/target.h              |  24 +++++
>  5 files changed, 310 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..47f960c
> --- /dev/null
> +++ b/gdb/make-target-delegates
> @@ -0,0 +1,253 @@
> +#!/usr/bin/perl
> +
> +# Copyright (C) 2013 Free Software Foundation, Inc.

2013-2014

-- 
Pedro Alves

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

* [PATCH] Fix "is a record target open" checks.
  2014-01-13 19:12 ` [RFC 02/32] introduce and use find_target_at Tom Tromey
@ 2014-01-14 11:48   ` Pedro Alves
  2014-01-14 15:30     ` Tom Tromey
  2014-01-15 16:22     ` Tom Tromey
  0 siblings, 2 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 11:48 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> RECORD_IS_USED and find_record_target look 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.

This rationale doesn't look right for find_record_target.

Actually, the patch isn't complete -- record_full_open also
has the problem for instance.  See below.

> 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.

I have no problem with find_target_at, though I think that
bit could/should instead be split and moved to the series that
actually needs it.

Instead, I'd rather apply a patch that fixes these record issues
completely, and only does that.  (IMO this one could go in
immediately).  WDYT?

---
Fix "is a record target open" checks.

RECORD_IS_USED and record_full_open look at current_target.to_stratum
to determine whether a record target is in use.  This is wrong because
arch_stratum is greater than record_stratum, so if an arch_stratum
target is pushed, RECORD_IS_USED and record_full_open will miss it.

To fix this, we can use the existing find_record_target instead, which
looks up for a record stratum target across the target stack.  Since
that means exporting find_record_target in record.h, RECORD_IS_USED
ends up redundant, so the patch eliminates it.

That exercise then reveals other issues:

- adjust_pc_after_break is gating record_full_... calls based on
RECORD_IS_USED.  But, record_full_ calls shouldn't be made when
recording with the record-btrace target.  So this adds a new
record_full_is_used predicate to be used in that spot.

- record_full_open says "Process record target already running", even
if the recording target is record-btrace ("process record" is the
original complete name of the record-full target).  record_btrace_open
only says "The process is already being recorded." and does not
suggest "record stop", like record-full does.  The patch factors out
and merges that error to a new record_preopen function that all record
targets call in their open routine.

Tested on x86_64 Fedora 17.

gdb/
2014-01-14  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* infrun.c (use_displaced_stepping): Use find_record_target
	instead of RECORD_IS_USED.
	(adjust_pc_after_break): Use record_full_is_used instead of
	RECORD_IS_USED.
	* record-btrace.c (record_btrace_open): Call record_preopen
	instead of checking RECORD_IS_USED.
	* record-full.c (record_full_shortname)
	(record_full_core_shortname): New globals.
	(record_full_is_used): New function.
	(find_full_open): Call record_preopen instead of checking
	RECORD_IS_USED.
	(init_record_full_ops): Set the target's shortname to
	record_full_shortname.
	(init_record_full_core_ops): Set the target's shortname to
	record_full_core_shortname.
	* record-full.h (record_full_is_used): Declare.
	* record.c (find_record_target): Make extern.
	(record_preopen): New function.
	* record.h (RECORD_IS_USED): Delete macro.
	(find_record_target, record_preopen): Declare functions.
---
 gdb/infrun.c        |  4 ++--
 gdb/record-btrace.c |  3 +--
 gdb/record-full.c   | 26 ++++++++++++++++++++------
 gdb/record-full.h   |  4 ++++
 gdb/record.c        | 13 +++++++++++--
 gdb/record.h        |  9 +++++++--
 6 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 73038a3..311bf9c 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1240,7 +1240,7 @@ use_displaced_stepping (struct gdbarch *gdbarch)
   return (((can_use_displaced_stepping == AUTO_BOOLEAN_AUTO && non_stop)
 	   || can_use_displaced_stepping == AUTO_BOOLEAN_TRUE)
 	  && gdbarch_displaced_step_copy_insn_p (gdbarch)
-	  && !RECORD_IS_USED);
+	  && find_record_target () == NULL);
 }

 /* Clean out any stray displaced stepping state.  */
@@ -3048,7 +3048,7 @@ adjust_pc_after_break (struct execution_control_state *ecs)
     {
       struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL);

-      if (RECORD_IS_USED)
+      if (record_full_is_used ())
 	record_full_gdb_operation_disable_set ();

       /* When using hardware single-step, a SIGTRAP is reported for both
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 5fd26e2..c3330e9 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -142,8 +142,7 @@ record_btrace_open (char *args, int from_tty)

   DEBUG ("open");

-  if (RECORD_IS_USED)
-    error (_("The process is already being recorded."));
+  record_preopen ();

   if (!target_has_execution)
     error (_("The program is not being run."));
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 3fb77ef..9b05db7 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -246,6 +246,23 @@ static void record_full_goto_insn (struct record_full_entry *entry,
 				   enum exec_direction_kind dir);
 static void record_full_save (const char *recfilename);

+/* The shortnames of the record full targets.  */
+static char record_full_shortname[] = "record-full";
+static char record_full_core_shortname[] = "record-core";
+
+/* See record-full.h.  */
+
+int
+record_full_is_used (void)
+{
+  struct target_ops *t;
+
+  t = find_record_target ();
+  return (t != NULL
+	  && (t->to_shortname == record_full_shortname
+	      || t->to_shortname == record_full_core_shortname));
+}
+
 /* Alloc and free functions for record_full_reg, record_full_mem, and
    record_full_end entries.  */

@@ -907,10 +924,7 @@ record_full_open (char *name, int from_tty)
   if (record_debug)
     fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");

-  /* Check if record target is already running.  */
-  if (current_target.to_stratum == record_stratum)
-    error (_("Process record target already running.  Use \"record stop\" to "
-             "stop record target first."));
+  record_preopen ();

   /* Reset the tmp beneath pointers.  */
   tmp_to_resume_ops = NULL;
@@ -2041,7 +2055,7 @@ record_full_goto (ULONGEST target_insn)
 static void
 init_record_full_ops (void)
 {
-  record_full_ops.to_shortname = "record-full";
+  record_full_ops.to_shortname = record_full_shortname;
   record_full_ops.to_longname = "Process record and replay target";
   record_full_ops.to_doc =
     "Log program while executing and replay execution from log.";
@@ -2277,7 +2291,7 @@ record_full_core_has_execution (struct target_ops *ops, ptid_t the_ptid)
 static void
 init_record_full_core_ops (void)
 {
-  record_full_core_ops.to_shortname = "record-core";
+  record_full_core_ops.to_shortname = record_full_core_shortname;
   record_full_core_ops.to_longname = "Process record and replay target";
   record_full_core_ops.to_doc =
     "Log program while executing and replay execution from log.";
diff --git a/gdb/record-full.h b/gdb/record-full.h
index 517d786..ef3b387 100644
--- a/gdb/record-full.h
+++ b/gdb/record-full.h
@@ -25,6 +25,10 @@ extern int record_full_memory_query;
 extern int record_full_arch_list_add_reg (struct regcache *regcache, int num);
 extern int record_full_arch_list_add_mem (CORE_ADDR addr, int len);
 extern int record_full_arch_list_add_end (void);
+
+/* Returns true if the process record target is open.  */
+extern int record_full_is_used (void);
+
 extern struct cleanup *record_full_gdb_operation_disable_set (void);

 #endif /* RECORD_FULL_H */
diff --git a/gdb/record.c b/gdb/record.c
index e0df6b1..771bcff 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -57,9 +57,9 @@ struct cmd_list_element *info_record_cmdlist = NULL;
   if (record_debug)							\
     fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args)

-/* Find the record target in the target stack.  */
+/* See record.h.  */

-static struct target_ops *
+struct target_ops *
 find_record_target (void)
 {
   struct target_ops *t;
@@ -86,6 +86,15 @@ require_record_target (void)
   return t;
 }

+void
+record_preopen (void)
+{
+  /* Check if a record target is already running.  */
+  if (find_record_target ())
+    error (_("The process is already being recorded.  Use \"record stop\" to "
+	     "stop recording first."));
+}
+
 /* See record.h.  */

 int
diff --git a/gdb/record.h b/gdb/record.h
index ab5ea4b..958affc 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -22,8 +22,6 @@

 struct cmd_list_element;

-#define RECORD_IS_USED	(current_target.to_stratum == record_stratum)
-
 extern unsigned int record_debug;

 /* Allow record targets to add their own sub-commands.  */
@@ -63,4 +61,11 @@ extern void record_mourn_inferior (struct target_ops *);
 /* The default "to_kill" target method for record targets.  */
 extern void record_kill (struct target_ops *);

+/* Find the record_stratum target in the target stack.  */
+extern struct target_ops *find_record_target (void);
+
+/* This is to be called by record_stratum targets' open routine before
+   it does anything.  */
+extern void record_preopen (void);
+
 #endif /* _RECORD_H_ */
-- 
1.7.11.7


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

* Re: [RFC 01/32] add "this" pointers to more target APIs
  2014-01-13 19:12 ` [RFC 01/32] add "this" pointers to more target APIs Tom Tromey
@ 2014-01-14 12:10   ` Pedro Alves
  2014-01-14 20:25     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:10 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

This looks about good to go to me.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> @@ -4761,8 +4759,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 (linux_ops))
> +    linux_nat_async (linux_ops, NULL, 0);

I still think linux_ops is the wrong target to
use here.  While to_close doesn't have a self
pointer, I'd suggest using NULL or adding a comment
(or storing the multi-threaded target pointer in a
global, though given the target really isn't used,
that's probably overkill).

>  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);
> +    }

(For the record, pedantically, this isn't strictly correct.  It's
not guaranteed the target just beneath is the one record_full_open
found had a non-NULL t->to_stopped_by_watchpoint implementation.
It'll end up fixed later in the series anyway though.)

-- 
Pedro Alves

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

* Re: [RFC 05/32] add target method delegation
  2014-01-13 19:38 ` [RFC 05/32] add target method delegation Tom Tromey
@ 2014-01-14 12:32   ` Pedro Alves
  2014-01-20 22:00     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> MUST UPDATE

Yes, must.  :-)

> -
> -static int
> -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 (struct target_ops *ops)
> -{
> -  /* We only enable async when the user specifically asks for it.  */
> -  return target_async_permitted;
> -}
> -

I think these were and still are necessary, due to how
find_default_target_can_async_p etc. is installed in the dummy target.
E.g., when debugging with the record-core target, without this, I
think we'll end up hitting the dummy target, because the core_ops
target delegates these methods.  That means we'll end up asking e.g.,
the GNU/Linux target whether it can async, while that isn't the
process_stratum target that is open.

This made me realize another issue with the find_default_target_can_async_p
(or really all find_default_...) being installed in the dummy/default
target.  E.g., considering a configuration that includes both remote-sim,
and a native target that can run.  When connected to the sim, we'll
end up calling that method in the default run target which is wrong.

But for the scope of this series, I think it'll suffice to leave
those record-full methods in place for now.

Otherwise looks good to me.

-- 
Pedro Alves

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

* Re: [RFC 06/32] convert to_supports_btrace
  2014-01-13 19:24 ` [RFC 06/32] convert to_supports_btrace Tom Tromey
@ 2014-01-14 12:37   ` Pedro Alves
  2014-01-15 16:55     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

(Looks like the patch merge script lost the commit log of this one.)

Looks good to me though.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> ---
>  gdb/common/linux-btrace.c |  4 ++--
>  gdb/common/linux-btrace.h |  2 +-
>  gdb/gdbserver/target.h    |  7 ++++---
>  gdb/remote.c              |  2 +-
>  gdb/target-delegates.c    | 16 ++++++++++++++++
>  gdb/target.c              | 14 --------------
>  gdb/target.h              |  6 ++++--
>  7 files changed, 28 insertions(+), 23 deletions(-)
> 
> diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c
> index 7e20745..b3d1aaa 100644
> --- a/gdb/common/linux-btrace.c
> +++ b/gdb/common/linux-btrace.c
> @@ -400,7 +400,7 @@ cpu_supports_btrace (void)
>  /* See linux-btrace.h.  */
>  
>  int
> -linux_supports_btrace (void)
> +linux_supports_btrace (struct target_ops *ops)
>  {
>    static int cached;
>  
> @@ -554,7 +554,7 @@ linux_read_btrace (struct btrace_target_info *tinfo,
>  /* 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 d4e8402..16c4bb1 100644
> --- a/gdb/common/linux-btrace.h
> +++ b/gdb/common/linux-btrace.h
> @@ -62,7 +62,7 @@ struct btrace_target_info
>  };
>  
>  /* Check whether branch tracing is supported.  */
> -extern int linux_supports_btrace (void);
> +extern int linux_supports_btrace (struct target_ops *);
>  
>  /* Enable branch tracing for @ptid.  */
>  extern struct btrace_target_info *linux_enable_btrace (ptid_t ptid);
> diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
> index c5e6fee..277838d 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.  */
> @@ -488,8 +488,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 a91e6aa..6f3fc91 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -11340,7 +11340,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 484945f..77f3113 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 0f614bf..6fc95fc 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -4090,20 +4090,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 538bdf4..d1fa12f 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -854,7 +854,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.  */
> @@ -1988,7 +1989,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);
> 


-- 
Pedro Alves

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

* Re: [RFC 07/32] introduce remote_load
  2014-01-13 19:23 ` [RFC 07/32] introduce remote_load Tom Tromey
@ 2014-01-14 12:39   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:39 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 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-01-08  Tom Tromey  <tromey@redhat.com>
> 
> 	* remote.c (remote_load): New function.
> 	(init_remote_ops): Use it.

Looks fine.

-- 
Pedro Alves

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

* Re: [RFC 08/32] remove extended_remote_create_inferior_1
  2014-01-13 19:13 ` [RFC 08/32] remove extended_remote_create_inferior_1 Tom Tromey
@ 2014-01-14 12:41   ` Pedro Alves
  2014-01-16 19:20     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:41 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> I noticed that extended_remote_create_inferior_1 is called from a
> single spot.  This patch unifies the callee and caller.  It's just a
> simple cleanup that made the coming refactoring simpler.

Yeah, used to be needed back when we had the "target async" target.

> 2014-01-08  Tom Tromey  <tromey@redhat.com>
> 
> 	* remote.c (extended_remote_create_inferior): Rename from
> 	extended_remote_create_inferior_1.  Add "ops" argument.  Remove
> 	old implementation.

OK.  Feel free to push it immediately.

Thanks,
-- 
Pedro Alves

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

* Re: [RFC 09/32] Add target_ops argument to to_close
  2014-01-13 19:13 ` [RFC 09/32] Add target_ops argument to to_close Tom Tromey
@ 2014-01-14 12:48   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:48 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks good to me.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
>  static void
> -ravenscar_prepare_to_store (struct regcache *regcache)
> +ravenscar_prepare_to_store (struct target_ops *self,
> +			    struct regcache *regcache)
>  {
>    struct target_ops *beneath = find_target_beneath (&ravenscar_ops);
>  
>    if (!ravenscar_runtime_initialized ()
>        || ptid_equal (inferior_ptid, base_magic_null_ptid)
>        || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
> -    beneath->to_prepare_to_store (regcache);
> +    beneath->to_prepare_to_store (beneath, regcache);
>    else
>      {
>        struct gdbarch *gdbarch = get_regcache_arch (regcache);

(At some point we should go through all find_target_beneath
users and make then follow self->beneath instead.)

-- 
Pedro Alves

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

* Re: [RFC 10/32] Add target_ops argument to to_terminal_init
  2014-01-13 19:13 ` [RFC 10/32] Add target_ops argument to to_terminal_init Tom Tromey
@ 2014-01-14 12:51   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:51 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine to me.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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           | 126 ++++++++++++++++++++++++++++++++++++++++++++++++
>  gdb/aarch64-linux-nat.c |   8 +--
>  gdb/amd64-linux-nat.c   |   7 +--
>  gdb/gnu-nat.c           |   2 +-
>  gdb/go32-nat.c          |  15 +++---
>  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, 242 insertions(+), 110 deletions(-)
> 
> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
> index a59a6e7..6b3680e 100644
> --- a/gdb/aarch64-linux-nat.c
> +++ b/gdb/aarch64-linux-nat.c
> @@ -825,16 +825,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 b1676ac..237e936 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 329d090..c596034 100644
> --- a/gdb/gnu-nat.c
> +++ b/gdb/gnu-nat.c
> @@ -2245,7 +2245,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 ef6ceef..5daeb4d 100644
> --- a/gdb/go32-nat.c
> +++ b/gdb/go32-nat.c
> @@ -260,9 +260,10 @@ static void go32_mourn_inferior (struct target_ops *ops);
>  static int go32_can_run (void);
>  
>  static struct target_ops go32_ops;
> -static void go32_terminal_init (void);
> -static void go32_terminal_inferior (void);
> -static void go32_terminal_ours (void);
> +static void go32_terminal_init (struct target_ops *self);
> +static void go32_terminal_inferior (struct target_ops *self);
> +static void go32_terminal_ours (struct target_ops *self,
> +				struct target_ops *self);
>  
>  #define r_ofs(x) (offsetof(TSS,x))
>  
> @@ -871,14 +872,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
> @@ -908,7 +909,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;
> @@ -929,7 +930,7 @@ go32_terminal_inferior (void)
>  }
>  
>  static void
> -go32_terminal_ours (void)
> +go32_terminal_ours (struct target_ops *self, 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 c2f4fcc..f886b39e 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 de36417..cde56a2 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 7f6f8bf..e71343a 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 d33a01a..248812f 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 062bf68..6d3b745 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 8e0f40b..53c3923 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -341,7 +341,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));
>  }
> @@ -702,13 +702,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;
>  }
> @@ -4551,16 +4551,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)
> @@ -4574,19 +4574,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 4423d26..463220f 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 4292f47..cf12c1b 100644
> --- a/gdb/monitor.c
> +++ b/gdb/monitor.c
> @@ -2196,7 +2196,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 58b19f2..c37b6e2 100644
> --- a/gdb/remote-m32r-sdi.c
> +++ b/gdb/remote-m32r-sdi.c
> @@ -1214,7 +1214,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 5c0b8a3..88e9977 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);
> @@ -3532,7 +3532,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 9f1e5eb..c4b7da1 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 d23502c..547045b 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -226,7 +226,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);
>  
> @@ -3056,7 +3056,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;
> @@ -5206,7 +5206,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.  */
> @@ -5229,7 +5229,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.  */
> @@ -11484,7 +11484,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 daa2bc4..1c2c4aa 100644
> --- a/gdb/spu-linux-nat.c
> +++ b/gdb/spu-linux-nat.c
> @@ -389,7 +389,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 411dbdf..9dcedfd 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);
> @@ -128,17 +128,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);
>  
> @@ -458,7 +458,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
> @@ -496,7 +496,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
> @@ -521,7 +521,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"));
>  }
> @@ -765,33 +765,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))
> @@ -4672,77 +4672,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);
> @@ -4751,11 +4752,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 4fa3918..15bcbd3 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -473,19 +473,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);
> @@ -1187,7 +1187,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.  */
> @@ -1203,14 +1203,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
> @@ -1218,13 +1218,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.  */
>  
> @@ -1263,7 +1263,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
> @@ -1271,10 +1271,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)
> 

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

* Re: [RFC 11/32] Add target_ops argument to to_insert_vfork_catchpoint
  2014-01-13 19:13 ` [RFC 11/32] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
@ 2014-01-14 12:52   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 12:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

-- 
Pedro Alves

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

* Re: [RFC 12/32] Add target_ops argument to to_thread_name
  2014-01-13 19:13 ` [RFC 12/32] Add target_ops argument to to_thread_name Tom Tromey
@ 2014-01-14 13:03   ` Pedro Alves
  2014-01-15 16:45     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine to me.

The patch is fine with me as is, but I'll note that I don't
think there's any need for exec_set_find_memory_regions
nowadays.  Seems to me that exec_ops.to_find_memory_regions could
always be set to objfile_find_memory_regions unconditionally.

-- 
Pedro Alves

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

* Re: [RFC 13/32] Add target_ops argument to to_get_ada_task_ptid
  2014-01-13 19:23 ` [RFC 13/32] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
@ 2014-01-14 13:21   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:21 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine to me.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> @@ -10036,7 +10037,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);

Ah, I see find_target_at is indeed used in this series.

(I ought to somehow resurrect my patch to make this
work with native targets too.  I.e., use target_hostio_xxx
instead.)

-- 
Pedro Alves

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

* Re: [RFC 14/32] Add target_ops argument to to_fileio_pwrite
  2014-01-13 19:57 ` [RFC 14/32] Add target_ops argument to to_fileio_pwrite Tom Tromey
@ 2014-01-14 13:22   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 7a65bfe..061a46a 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 1370c5d..b81501d 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -9818,7 +9818,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 ();
> @@ -9846,7 +9847,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 ();
> @@ -9885,7 +9887,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;
> @@ -9903,7 +9905,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;
> @@ -9923,7 +9926,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;
> @@ -10024,7 +10028,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);
>  }
>  
>  
> @@ -10061,7 +10065,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;
> @@ -10078,7 +10082,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.  */
> @@ -10189,7 +10194,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)
> @@ -10208,7 +10214,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)
> @@ -10250,7 +10256,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;
> @@ -10265,7 +10272,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)
> @@ -10282,7 +10289,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);
>  
> @@ -10453,7 +10461,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);
> @@ -10524,7 +10532,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
>  
> @@ -10701,7 +10709,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;
> @@ -10729,7 +10737,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;
> @@ -10751,7 +10760,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 5c886dc..0ef4cdc 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -845,19 +845,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 *))
> @@ -3327,7 +3327,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)
> @@ -3357,7 +3357,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)
> @@ -3385,7 +3385,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,
> @@ -3410,7 +3410,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,
> @@ -3436,7 +3436,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 d28bfd3..31a4ce9 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -705,27 +705,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.  */
> @@ -734,20 +738,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);
> @@ -1737,19 +1744,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)
> 


-- 
Pedro Alves

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

* Re: [RFC 15/32] Add target_ops argument to to_disable_tracepoint
  2014-01-13 19:57 ` [RFC 15/32] Add target_ops argument to to_disable_tracepoint Tom Tromey
@ 2014-01-14 13:23   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 239afb2..db6032b 100644
> --- a/gdb/ctf.c
> +++ b/gdb/ctf.c
> @@ -1489,7 +1489,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;
> @@ -1606,7 +1607,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;
> @@ -1801,7 +1802,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 b81501d..8ad8409 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -205,9 +205,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);
>    
> @@ -3481,7 +3483,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;
>  
> @@ -3625,14 +3627,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);
>      }
> @@ -10722,7 +10724,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;
> @@ -10778,7 +10780,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];
> @@ -10795,7 +10798,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;
> @@ -10845,7 +10848,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);
> @@ -10856,7 +10859,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;
> @@ -10906,7 +10909,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 ();
> @@ -10953,7 +10956,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);
> @@ -10964,7 +10967,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)
>  {
> @@ -11046,7 +11050,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;
> @@ -11070,7 +11075,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;
> @@ -11779,7 +11784,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 0ef4cdc..74e79cc 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -860,34 +860,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 31a4ce9..e8a2997 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -757,41 +757,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);
>  
> @@ -1759,34 +1764,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 a09bf37..0fde73c 100644
> --- a/gdb/tracepoint.c
> +++ b/gdb/tracepoint.c
> @@ -4773,7 +4773,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.  */
> @@ -4782,7 +4782,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.  */
> @@ -4827,7 +4828,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;
> @@ -5186,7 +5187,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;
> 


-- 
Pedro Alves

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

* Re: [RFC 16/32] Add target_ops argument to to_upload_trace_state_variables
  2014-01-13 19:24 ` [RFC 16/32] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
@ 2014-01-14 13:24   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 8ad8409..c7cb2d3 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -202,7 +202,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,
> @@ -211,7 +211,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);
>  
> @@ -2947,7 +2948,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 ();
> @@ -3400,7 +3401,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.
>  
> @@ -3487,7 +3488,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);
>      }
>  
> @@ -3775,7 +3776,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 ();
>  
> @@ -9454,7 +9455,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)
>      {
> @@ -11102,7 +11103,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;
> @@ -11140,7 +11142,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 ();
>  
> @@ -11171,7 +11173,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;
> @@ -11216,7 +11218,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;
> @@ -11245,7 +11247,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)
> @@ -11277,7 +11279,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 ();
> @@ -11805,7 +11808,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 74e79cc..35ce7e8 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -892,34 +892,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 e8a2997..2a17b02 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -798,27 +798,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.
> @@ -839,14 +841,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
> @@ -1796,34 +1799,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 c3982f1..6e28b6e 100644
> --- a/gdb/windows-nat.c
> +++ b/gdb/windows-nat.c
> @@ -2556,7 +2556,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;
>  
> 


-- 
Pedro Alves

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

* Re: [RFC 17/32] Add target_ops argument to to_static_tracepoint_markers_by_strid
  2014-01-13 19:23 ` [RFC 17/32] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
@ 2014-01-14 13:25   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:25 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 | 18 +++++++---
>  gdb/ctf.c             |  2 +-
>  gdb/i386-linux-nat.c  | 18 +++++++---
>  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          | 19 ++++++-----
>  gdb/target.c          | 21 ++++++------
>  gdb/target.h          | 33 ++++++++++--------
>  gdb/tracepoint.c      |  2 +-
>  13 files changed, 174 insertions(+), 50 deletions(-)
> 
> diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
> index 237e936..cbec370 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)
>  {
>    int errcode = linux_disable_btrace (tinfo);
>  
> @@ -1183,12 +1184,21 @@ 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 VEC (btrace_block_s) *
> +amd64_linux_read_btrace (struct target_ops *self,
> +			 struct btrace_target_info *tinfo,
> +			 enum btrace_read_type type)
> +{
> +  return linux_read_btrace (tinfo, type);
> +}
> +
>  /* Provide a prototype to silence -Wmissing-prototypes.  */
>  void _initialize_amd64_linux_nat (void);
>  
> @@ -1232,7 +1242,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 db6032b..c41959b 100644
> --- a/gdb/ctf.c
> +++ b/gdb/ctf.c
> @@ -1732,7 +1732,7 @@ ctf_has_registers (struct target_ops *ops)
>     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 f886b39e..01d7f71 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)
>  {
>    int errcode = linux_disable_btrace (tinfo);
>  
> @@ -1094,12 +1095,21 @@ 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 VEC (btrace_block_s) *
> +i386_linux_read_btrace (struct target_ops *self,
> +			struct btrace_target_info *tinfo,
> +			enum btrace_read_type type)
> +{
> +  return linux_read_btrace (tinfo, type);
> +}
> +
>  /* -Wmissing-prototypes */
>  extern initialize_file_ftype _initialize_i386_linux_nat;
>  
> @@ -1138,7 +1148,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 061a46a..af3f105 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 8dfeb40..3cfd4e7 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -4397,7 +4397,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 d1f36c9..c99e7c2 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -174,7 +174,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;
>  
> @@ -202,7 +202,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 3b251c6..8769795 100644
> --- a/gdb/record-full.c
> +++ b/gdb/record-full.c
> @@ -1746,7 +1746,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 0fd8756..77b1ce5 100644
> --- a/gdb/record.c
> +++ b/gdb/record.c
> @@ -104,7 +104,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.  */
> @@ -276,7 +276,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 c7cb2d3..5721178 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -2974,7 +2974,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;
> @@ -11188,7 +11189,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;
>  
> @@ -11326,7 +11327,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)
>      {
> @@ -11348,7 +11349,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);
>  }
> @@ -11377,7 +11378,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];
> @@ -11413,7 +11414,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 ();
> @@ -11445,7 +11447,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);
> @@ -11454,7 +11457,7 @@ remote_teardown_btrace (struct btrace_target_info *tinfo)
>  /* Read the branch trace.  */
>  
>  static VEC (btrace_block_s) *
> -remote_read_btrace (struct btrace_target_info *tinfo,
> +remote_read_btrace (struct target_ops *self, struct btrace_target_info *tinfo,
>  		    enum btrace_read_type type)
>  {
>    struct packet_config *packet = &remote_protocol_packets[PACKET_qXfer_btrace];
> diff --git a/gdb/target.c b/gdb/target.c
> index 35ce7e8..4a698fe 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -924,10 +924,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_zero);
>    de_fault (to_supports_evaluation_of_breakpoint_conditions,
>  	    (int (*) (struct target_ops *))
> @@ -936,10 +937,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))
> @@ -4119,7 +4120,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;
> @@ -4135,7 +4136,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;
>        }
>  
> @@ -4152,7 +4153,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;
>        }
>  
> @@ -4169,7 +4170,7 @@ target_read_btrace (struct btrace_target_info *btinfo,
>  
>    for (t = current_target.beneath; t != NULL; t = t->beneath)
>      if (t->to_read_btrace != NULL)
> -      return t->to_read_btrace (btinfo, type);
> +      return t->to_read_btrace (t, btinfo, type);
>  
>    tcomplain ();
>    return NULL;
> @@ -4185,7 +4186,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;
>        }
>  
> @@ -4202,7 +4203,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 2a17b02..ca70a9e 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -855,7 +855,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
> @@ -870,14 +870,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 *)
> @@ -885,26 +885,30 @@ 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.  */
> -    VEC (btrace_block_s) *(*to_read_btrace) (struct btrace_target_info *,
> +    VEC (btrace_block_s) *(*to_read_btrace) (struct target_ops *,
> +					     struct btrace_target_info *,
>  					     enum btrace_read_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);
> @@ -1832,16 +1836,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 0fde73c..96b8a89 100644
> --- a/gdb/tracepoint.c
> +++ b/gdb/tracepoint.c
> @@ -5299,7 +5299,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);
>  
> 

-- 
Pedro Alves

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

* Re: [RFC 18/32] Add target_ops argument to to_save_record
  2014-01-13 19:38 ` [RFC 18/32] Add target_ops argument to to_save_record Tom Tromey
@ 2014-01-14 13:26   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:26 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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.
> 
> Add target_ops argument to to_goto_record_begin
> 
> 2014-01-08  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.
> 
> Add target_ops argument to to_goto_record_end
> 
> 2014-01-08  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.
> 
> Add target_ops argument to to_goto_record
> 
> 2014-01-08  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.
> 
> Add target_ops argument to to_insn_history
> 
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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       | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  gdb/record-btrace.c | 20 ++++++-----
>  gdb/record-full.c   | 15 +++++----
>  gdb/remote.c        |  2 +-
>  gdb/target.c        | 26 +++++++--------
>  gdb/target.h        | 32 ++++++++++--------
>  6 files changed, 148 insertions(+), 43 deletions(-)
> 
> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
> index c99e7c2..d536fea 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -263,7 +263,7 @@ btrace_insn_history (struct btrace_thread_info *btinfo, 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 cleanup *uiout_cleanup;
> @@ -338,7 +338,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 cleanup *uiout_cleanup;
> @@ -381,7 +382,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;
>  
> @@ -406,7 +408,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.  */
> @@ -492,7 +494,7 @@ btrace_func_history (struct btrace_thread_info *btinfo, 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 cleanup *uiout_cleanup;
> @@ -567,7 +569,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 cleanup *uiout_cleanup;
> @@ -610,7 +613,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;
>  
> @@ -635,7 +639,7 @@ 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);
>  }
>  
>  /* Initialize the record-btrace target ops.  */
> diff --git a/gdb/record-full.c b/gdb/record-full.c
> index 8769795..eedb223 100644
> --- a/gdb/record-full.c
> +++ b/gdb/record-full.c
> @@ -217,7 +217,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.  */
> @@ -1792,7 +1793,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);
>  }
> @@ -1800,7 +1801,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;
>  }
> @@ -1835,7 +1836,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;
>  
> @@ -1849,7 +1850,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;
>  
> @@ -1865,7 +1866,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;
>  
> @@ -2454,7 +2455,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 5721178..34b8f6d 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -11501,7 +11501,7 @@ remote_read_btrace (struct target_ops *self, struct btrace_target_info *tinfo,
>  }
>  
>  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 4a698fe..1f3562f 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -943,7 +943,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);
>  
> @@ -4220,7 +4220,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;
>        }
>  
> @@ -4251,7 +4251,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;
>        }
>  
> @@ -4267,7 +4267,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;
>  }
> @@ -4282,7 +4282,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;
>        }
>  
> @@ -4299,7 +4299,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;
>        }
>  
> @@ -4316,7 +4316,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;
>        }
>  
> @@ -4333,7 +4333,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;
>        }
>  
> @@ -4350,7 +4350,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;
>        }
>  
> @@ -4367,7 +4367,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;
>        }
>  
> @@ -4384,7 +4384,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;
>        }
>  
> @@ -4401,7 +4401,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;
>        }
>  
> @@ -4418,7 +4418,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 ca70a9e..4668c23 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -911,57 +911,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 (exclusive).  */
> -    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 (exclusive).  */
> -    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 *);
>  
>      int to_magic;
>      /* Need sub-structure for target machine related rather than comm related?
> @@ -1849,7 +1853,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.  */
>  
> 


-- 
Pedro Alves

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

* Re: [RFC 19/32] convert to_detach
  2014-01-13 19:13 ` [RFC 19/32] convert to_detach Tom Tromey
@ 2014-01-14 13:32   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 13:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine to me.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
>  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);
>  }

Hurray!

-- 
Pedro Alves

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

* Re: [RFC 04/32] add make-target-delegates
  2014-01-14 10:52   ` Pedro Alves
@ 2014-01-14 14:46     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 14:46 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

>> +# Copyright (C) 2013 Free Software Foundation, Inc.

Pedro> 2013-2014

Yeah -- and FWIW I'll also be fixing all the ChangeLog dates during the
next rebase.

Tom

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

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-14 10:50     ` Joel Brobecker
@ 2014-01-14 15:06       ` Tom Tromey
  2014-01-14 17:19         ` Joel Brobecker
  0 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 15:06 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Pedro Alves, gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> I think it would be nice if the arguments were named, giving us more
Joel> tools to better document the intended behavior of this callback. It's
Joel> also a way to help implementors to choose consistent names for those
Joel> parameters. As for the documentation, unless completely trivial, it
Joel> seems reasonable to me to leave that for later, or even someone else!

How about this?

/* The type of the callback to the to_async method.  */

typedef void async_callback_ftype (enum inferior_event_type event_type,
				   void *context);

"context" is used in several places related to this.  OTOH the only
non-NULL function pointer ever passed to to_async is
'inferior_event_handler', which names the second argument "client_data".
I found them equally clear; particularly once I noticed that all
existing calls pass context==NULL :)

As for documentation, I think the docs should be comments before each
to_* method.  target.h has been laxly maintained in this regard.

Tom

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

* Re: [PATCH] Fix "is a record target open" checks.
  2014-01-14 11:48   ` [PATCH] Fix "is a record target open" checks Pedro Alves
@ 2014-01-14 15:30     ` Tom Tromey
  2014-01-14 18:27       ` Pedro Alves
  2014-01-15 16:22     ` Tom Tromey
  1 sibling, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 15:30 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

>> RECORD_IS_USED and find_record_target look 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.

Pedro> This rationale doesn't look right for find_record_target.

Yeah, good point.  I've changed the description on my branch.  Now it
says:

  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.

I consider the change to find_record_target to be a minor cleanup.
It seemed cleaner to me to have this kind of target stack iteration
isolated in target.c when possible.

This mattered more on the multi-target branch, where I converted the
target stack to be an array rather than a linked list -- it made the
conversion simpler.  However, I am not sure I am going to keep that
change.

Pedro> Instead, I'd rather apply a patch that fixes these record issues
Pedro> completely, and only does that.  (IMO this one could go in
Pedro> immediately).  WDYT?

I think it looks great, though I have a few nits :)

Pedro> +/* The shortnames of the record full targets.  */
Pedro> +static char record_full_shortname[] = "record-full";
Pedro> +static char record_full_core_shortname[] = "record-core";
Pedro> +
Pedro> +/* See record-full.h.  */
Pedro> +
Pedro> +int
Pedro> +record_full_is_used (void)
Pedro> +{
Pedro> +  struct target_ops *t;
Pedro> +
Pedro> +  t = find_record_target ();
Pedro> +  return (t != NULL
Pedro> +	  && (t->to_shortname == record_full_shortname
Pedro> +	      || t->to_shortname == record_full_core_shortname));

Could this check against record_full_*ops directly rather than checking
the shortname?  I'm curious about the rationale for this choice -- it's
all fine by me in the end, but if kept I think could use a comment.

Pedro> +void
Pedro> +record_preopen (void)
Pedro> +{

Need a "/* See record.h.  */"

Pedro> +  /* Check if a record target is already running.  */
Pedro> +  if (find_record_target ())

!= NULL

Pedro> +/* Find the record_stratum target in the target stack.  */
Pedro> +extern struct target_ops *find_record_target (void);

I think this should mention that it can return NULL.

Tom

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

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-14 15:06       ` Tom Tromey
@ 2014-01-14 17:19         ` Joel Brobecker
  2014-01-14 17:27           ` Tom Tromey
  2014-01-14 18:30           ` Pedro Alves
  0 siblings, 2 replies; 100+ messages in thread
From: Joel Brobecker @ 2014-01-14 17:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Pedro Alves, gdb-patches

> /* The type of the callback to the to_async method.  */
> 
> typedef void async_callback_ftype (enum inferior_event_type event_type,
> 				   void *context);
> "context" is used in several places related to this.  OTOH the only
> non-NULL function pointer ever passed to to_async is
> 'inferior_event_handler', which names the second argument "client_data".
> I found them equally clear; particularly once I noticed that all
> existing calls pass context==NULL :)

That looks good to me, thank you!

> As for documentation, I think the docs should be comments before each
> to_* method.

That works for me.

> target.h has been laxly maintained in this regard.

We're getting better at this, though :-). I think we generally
understand better the value of providing good documentation.

Thanks, Tom.
-- 
Joel

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

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-14 17:19         ` Joel Brobecker
@ 2014-01-14 17:27           ` Tom Tromey
  2014-01-14 18:30           ` Pedro Alves
  1 sibling, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 17:27 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Pedro Alves, gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Tom> target.h has been laxly maintained in this regard.

Joel> We're getting better at this, though :-). I think we generally
Joel> understand better the value of providing good documentation.

Yeah, sorry, I didn't mean to imply otherwise.
We're quite consistent about the doc comments now.
Most likely the undocumented target methods date back quite a ways.

I'm looking forward to the doxygen patch providing us with a nudge to go
back and add the missing bits.

Tom

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

* Re: [PATCH] Fix "is a record target open" checks.
  2014-01-14 15:30     ` Tom Tromey
@ 2014-01-14 18:27       ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:27 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/14/2014 03:30 PM, Tom Tromey wrote:

> Pedro> +/* See record-full.h.  */
> Pedro> +
> Pedro> +int
> Pedro> +record_full_is_used (void)
> Pedro> +{
> Pedro> +  struct target_ops *t;
> Pedro> +
> Pedro> +  t = find_record_target ();
> Pedro> +  return (t != NULL
> Pedro> +	  && (t->to_shortname == record_full_shortname
> Pedro> +	      || t->to_shortname == record_full_core_shortname));
> 
> Could this check against record_full_*ops directly rather than checking
> the shortname?  

Oh yes it could.  I don't really know why I didn't think
of that...  Adjusted.

> I'm curious about the rationale for this choice 

ENOCAFFEINE I guess.  :-)

> Pedro> +void
> Pedro> +record_preopen (void)
> Pedro> +{
> 
> Need a "/* See record.h.  */"

Fixed.

> 
> Pedro> +  /* Check if a record target is already running.  */
> Pedro> +  if (find_record_target ())
> 
> != NULL
> 

Fixed.

> Pedro> +/* Find the record_stratum target in the target stack.  */
> Pedro> +extern struct target_ops *find_record_target (void);
> 
> I think this should mention that it can return NULL.

Fixed.

Below's what I pushed after retesting.

Thanks.

----------
Subject: [PATCH] Fix "is a record target open" checks.

RECORD_IS_USED and record_full_open look at current_target.to_stratum
to determine whether a record target is in use.  This is wrong because
arch_stratum is greater than record_stratum, so if an arch_stratum
target is pushed, RECORD_IS_USED and record_full_open will miss it.

To fix this, we can use the existing find_record_target instead, which
looks up for a record stratum target across the target stack.  Since
that means exporting find_record_target in record.h, RECORD_IS_USED
ends up redundant, so the patch eliminates it.

That exercise then reveals other issues:

- adjust_pc_after_break is gating record_full_... calls based on
RECORD_IS_USED.  But, record_full_ calls shouldn't be made when
recording with the record-btrace target.  So this adds a new
record_full_is_used predicate to be used in that spot.

- record_full_open says "Process record target already running", even
if the recording target is record-btrace ("process record" is the
original complete name of the record-full target).  record_btrace_open
only says "The process is already being recorded." and does not
suggest "record stop", like record-full does.  The patch factors out
and merges that error to a new record_preopen function that all record
targets call in their open routine.

Tested on x86_64 Fedora 17.

gdb/
2014-01-14  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tromey@redhat.com>

	* infrun.c (use_displaced_stepping): Use find_record_target
	instead of RECORD_IS_USED.
	(adjust_pc_after_break): Use record_full_is_used instead of
	RECORD_IS_USED.
	* record-btrace.c (record_btrace_open): Call record_preopen
	instead of checking RECORD_IS_USED.
	* record-full.c (record_full_shortname)
	(record_full_core_shortname): New globals.
	(record_full_is_used): New function.
	(find_full_open): Call record_preopen instead of checking
	RECORD_IS_USED.
	(init_record_full_ops): Set the target's shortname to
	record_full_shortname.
	(init_record_full_core_ops): Set the target's shortname to
	record_full_core_shortname.
	* record-full.h (record_full_is_used): Declare.
	* record.c (find_record_target): Make extern.
	(record_preopen): New function.
	* record.h (RECORD_IS_USED): Delete macro.
	(find_record_target, record_preopen): Declare functions.
---
 gdb/ChangeLog       | 24 ++++++++++++++++++++++++
 gdb/infrun.c        |  4 ++--
 gdb/record-btrace.c |  3 +--
 gdb/record-full.c   | 18 ++++++++++++++----
 gdb/record-full.h   |  4 ++++
 gdb/record.c        | 15 +++++++++++++--
 gdb/record.h        | 10 ++++++++--
 7 files changed, 66 insertions(+), 12 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 40e703f..3daf77f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,27 @@
+2014-01-14  Pedro Alves  <palves@redhat.com>
+	    Tom Tromey  <tromey@redhat.com>
+
+	* infrun.c (use_displaced_stepping): Use find_record_target
+	instead of RECORD_IS_USED.
+	(adjust_pc_after_break): Use record_full_is_used instead of
+	RECORD_IS_USED.
+	* record-btrace.c (record_btrace_open): Call record_preopen
+	instead of checking RECORD_IS_USED.
+	* record-full.c (record_full_shortname)
+	(record_full_core_shortname): New globals.
+	(record_full_is_used): New function.
+	(find_full_open): Call record_preopen instead of checking
+	RECORD_IS_USED.
+	(init_record_full_ops): Set the target's shortname to
+	record_full_shortname.
+	(init_record_full_core_ops): Set the target's shortname to
+	record_full_core_shortname.
+	* record-full.h (record_full_is_used): Declare.
+	* record.c (find_record_target): Make extern.
+	(record_preopen): New function.
+	* record.h (RECORD_IS_USED): Delete macro.
+	(find_record_target, record_preopen): Declare functions.
+
 2014-01-14  Yao Qi  <yao@codesourcery.com>
 
 	* gdbarch.sh (core_xfer_shared_libraries): Change its argument
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 73038a3..311bf9c 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1240,7 +1240,7 @@ use_displaced_stepping (struct gdbarch *gdbarch)
   return (((can_use_displaced_stepping == AUTO_BOOLEAN_AUTO && non_stop)
 	   || can_use_displaced_stepping == AUTO_BOOLEAN_TRUE)
 	  && gdbarch_displaced_step_copy_insn_p (gdbarch)
-	  && !RECORD_IS_USED);
+	  && find_record_target () == NULL);
 }
 
 /* Clean out any stray displaced stepping state.  */
@@ -3048,7 +3048,7 @@ adjust_pc_after_break (struct execution_control_state *ecs)
     {
       struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL);
 
-      if (RECORD_IS_USED)
+      if (record_full_is_used ())
 	record_full_gdb_operation_disable_set ();
 
       /* When using hardware single-step, a SIGTRAP is reported for both
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 5fd26e2..c3330e9 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -142,8 +142,7 @@ record_btrace_open (char *args, int from_tty)
 
   DEBUG ("open");
 
-  if (RECORD_IS_USED)
-    error (_("The process is already being recorded."));
+  record_preopen ();
 
   if (!target_has_execution)
     error (_("The program is not being run."));
diff --git a/gdb/record-full.c b/gdb/record-full.c
index a9fc018..a93418c 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -208,6 +208,19 @@ static ULONGEST record_full_insn_count;
 static struct target_ops record_full_ops;
 static struct target_ops record_full_core_ops;
 
+/* See record-full.h.  */
+
+int
+record_full_is_used (void)
+{
+  struct target_ops *t;
+
+  t = find_record_target ();
+  return (t == &record_full_ops
+	  || t == &record_full_core_ops);
+}
+
+
 /* Command lists for "set/show record full".  */
 static struct cmd_list_element *set_record_full_cmdlist;
 static struct cmd_list_element *show_record_full_cmdlist;
@@ -907,10 +920,7 @@ record_full_open (char *name, int from_tty)
   if (record_debug)
     fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");
 
-  /* Check if record target is already running.  */
-  if (current_target.to_stratum == record_stratum)
-    error (_("Process record target already running.  Use \"record stop\" to "
-             "stop record target first."));
+  record_preopen ();
 
   /* Reset the tmp beneath pointers.  */
   tmp_to_resume_ops = NULL;
diff --git a/gdb/record-full.h b/gdb/record-full.h
index 517d786..ef3b387 100644
--- a/gdb/record-full.h
+++ b/gdb/record-full.h
@@ -25,6 +25,10 @@ extern int record_full_memory_query;
 extern int record_full_arch_list_add_reg (struct regcache *regcache, int num);
 extern int record_full_arch_list_add_mem (CORE_ADDR addr, int len);
 extern int record_full_arch_list_add_end (void);
+
+/* Returns true if the process record target is open.  */
+extern int record_full_is_used (void);
+
 extern struct cleanup *record_full_gdb_operation_disable_set (void);
 
 #endif /* RECORD_FULL_H */
diff --git a/gdb/record.c b/gdb/record.c
index e0df6b1..f2cfcc8 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -57,9 +57,9 @@ struct cmd_list_element *info_record_cmdlist = NULL;
   if (record_debug)							\
     fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args)
 
-/* Find the record target in the target stack.  */
+/* See record.h.  */
 
-static struct target_ops *
+struct target_ops *
 find_record_target (void)
 {
   struct target_ops *t;
@@ -88,6 +88,17 @@ require_record_target (void)
 
 /* See record.h.  */
 
+void
+record_preopen (void)
+{
+  /* Check if a record target is already running.  */
+  if (find_record_target () != NULL)
+    error (_("The process is already being recorded.  Use \"record stop\" to "
+	     "stop recording first."));
+}
+
+/* See record.h.  */
+
 int
 record_read_memory (struct gdbarch *gdbarch,
 		    CORE_ADDR memaddr, gdb_byte *myaddr,
diff --git a/gdb/record.h b/gdb/record.h
index ab5ea4b..962e382 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -22,8 +22,6 @@
 
 struct cmd_list_element;
 
-#define RECORD_IS_USED	(current_target.to_stratum == record_stratum)
-
 extern unsigned int record_debug;
 
 /* Allow record targets to add their own sub-commands.  */
@@ -63,4 +61,12 @@ extern void record_mourn_inferior (struct target_ops *);
 /* The default "to_kill" target method for record targets.  */
 extern void record_kill (struct target_ops *);
 
+/* Find the record_stratum target in the current target stack.
+   Returns NULL if none is found.  */
+extern struct target_ops *find_record_target (void);
+
+/* This is to be called by record_stratum targets' open routine before
+   it does anything.  */
+extern void record_preopen (void);
+
 #endif /* _RECORD_H_ */
-- 
1.7.11.7


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

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-14 17:19         ` Joel Brobecker
  2014-01-14 17:27           ` Tom Tromey
@ 2014-01-14 18:30           ` Pedro Alves
  2014-01-14 19:45             ` Tom Tromey
  1 sibling, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:30 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On 01/14/2014 05:18 PM, Joel Brobecker wrote:
>> /* The type of the callback to the to_async method.  */
>>
>> typedef void async_callback_ftype (enum inferior_event_type event_type,
>> 				   void *context);
>> "context" is used in several places related to this.  OTOH the only
>> non-NULL function pointer ever passed to to_async is
>> 'inferior_event_handler', which names the second argument "client_data".
>> I found them equally clear; particularly once I noticed that all
>> existing calls pass context==NULL :)
> 
> That looks good to me, thank you!

To me too FWIW.

I'd suggest just going ahead and pushing this change in.

-- 
Pedro Alves

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

* Re: [RFC 20/32] convert to_remove_watchpoint
  2014-01-13 19:23 ` [RFC 20/32] convert to_remove_watchpoint Tom Tromey
@ 2014-01-14 18:39   ` Pedro Alves
  2014-01-14 18:55     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:39 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> convert to_can_acce_watchpoint_condition

Typo: "accel"

> 
> 2014-01-08  Tom Tromey <tromey@redhat.com>
> 
> 	* target-delegates.c : Rebuild.

(Spurious space before ":" (in all similar patches
actually), but please do leave it if not super trivial to fix.)

-- 
Pedro Alves

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

* Re: [RFC 21/32] convert to_load
  2014-01-13 19:37 ` [RFC 21/32] convert to_load Tom Tromey
@ 2014-01-14 18:41   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:41 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 00dc2c5..7abb393 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 f77fb77..076e4be 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);
>  
>  void target_ignore (void);
> @@ -623,18 +621,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.  */
> @@ -730,36 +728,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);
> @@ -3542,12 +3510,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 e16ff52..6a563f7 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -499,20 +499,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 *);
>  
> 


-- 
Pedro Alves

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

* Re: [RFC 22/32] convert to_extra_thread_info
  2014-01-13 19:38 ` [RFC 22/32] convert to_extra_thread_info Tom Tromey
@ 2014-01-14 18:43   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:43 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 7abb393..a2293c4 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, LONGEST 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 076e4be..604469c 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -80,10 +80,20 @@ static LONGEST default_xfer_partial (struct target_ops *ops,
>  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);
> @@ -640,13 +650,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.  */
> @@ -657,13 +667,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);
> @@ -731,18 +741,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_zero);
> -  de_fault (to_thread_name,
> -	    (char *(*) (struct target_ops *, struct thread_info *))
> -	    return_zero);
>    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_zero);
>    de_fault (to_thread_architecture,
>  	    default_thread_architecture);
>    current_target.to_read_description = NULL;
> @@ -859,7 +860,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
>  
> @@ -2603,15 +2603,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
> @@ -3611,21 +3603,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.  */
>  
> @@ -3641,10 +3618,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 6a563f7..bc2dc6a 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -537,14 +537,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 *);
> @@ -564,13 +568,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
> @@ -675,12 +683,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?  */
> @@ -1711,8 +1721,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 *);
>  
> @@ -1887,12 +1896,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);
> 


-- 
Pedro Alves

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

* Re: [RFC 23/32] convert to_thread_architecture
  2014-01-13 19:38 ` [RFC 23/32] convert to_thread_architecture Tom Tromey
@ 2014-01-14 18:46   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 a2293c4..53fabb1 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 604469c..83dfee7 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 *);
> @@ -674,18 +677,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);
> @@ -744,36 +747,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 bc2dc6a..4a5573d 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -662,7 +662,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.
> @@ -694,17 +695,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?  */
> @@ -724,7 +728,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.
>  
> @@ -778,23 +783,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 *,
> 


-- 
Pedro Alves

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

* Re: [RFC 24/32] convert to_disable_tracepoint
  2014-01-13 19:13 ` [RFC 24/32] convert to_disable_tracepoint Tom Tromey
@ 2014-01-14 18:49   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:49 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 53fabb1..ddcc89c 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 83dfee7..90e2709 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -689,16 +689,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);
> @@ -748,38 +748,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 4a5573d..dfaad80 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -808,25 +808,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
> @@ -835,18 +841,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);
> 


-- 
Pedro Alves

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

* Re: [RFC 20/32] convert to_remove_watchpoint
  2014-01-14 18:39   ` Pedro Alves
@ 2014-01-14 18:55     ` Tom Tromey
  2014-01-14 19:07       ` Tom Tromey
  2014-01-14 20:38       ` Pedro Alves
  0 siblings, 2 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 18:55 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>> convert to_can_acce_watchpoint_condition

Pedro> Typo: "accel"

Thanks, I fixed it.

>> 2014-01-08  Tom Tromey <tromey@redhat.com>
>> 
>> * target-delegates.c : Rebuild.

Pedro> (Spurious space before ":" (in all similar patches
Pedro> actually), but please do leave it if not super trivial to fix.)

I already have the mass-rewriting tools; it's easy to modify them to
make this fix.

Tom

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

* Re: [RFC 26/32] convert to_static_tracepoint_markers_by_strid
  2014-01-13 19:13 ` [RFC 26/32] convert to_static_tracepoint_markers_by_strid Tom Tromey
@ 2014-01-14 18:57   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 18:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches


On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 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.

Fine with me.  Patch looks good to me.

-- 
Pedro Alves

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

* Re: [RFC 20/32] convert to_remove_watchpoint
  2014-01-14 18:55     ` Tom Tromey
@ 2014-01-14 19:07       ` Tom Tromey
  2014-01-14 20:38       ` Pedro Alves
  1 sibling, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 19:07 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>> * target-delegates.c : Rebuild.

Pedro> (Spurious space before ":" (in all similar patches
Pedro> actually), but please do leave it if not super trivial to fix.)

Tom> I already have the mass-rewriting tools; it's easy to modify them to
Tom> make this fix.

I made this change and pushed it.

Tom

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

* Re: [RFC 27/32] convert to_insert_mask_watchpoint
  2014-01-13 19:13 ` [RFC 27/32] convert to_insert_mask_watchpoint Tom Tromey
@ 2014-01-14 19:15   ` Pedro Alves
  2014-01-14 19:23     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 19:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> +    char *(*to_pid_to_str) (struct target_ops *, ptid_t)
> +      TARGET_DEFAULT_FUNC (dummy_pid_to_str);

This use of "dummy" in the default looked odd to me.
I'd suggest renaming it to default_pid_to_str (now or at some
point), in line with the other default methods.

Otherwise looked good to me.

-- 
Pedro Alves

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

* Re: [RFC 27/32] convert to_insert_mask_watchpoint
  2014-01-14 19:15   ` Pedro Alves
@ 2014-01-14 19:23     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 19:23 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

Pedro> On 01/13/2014 07:12 PM, Tom Tromey wrote:
>> +    char *(*to_pid_to_str) (struct target_ops *, ptid_t)
>> +      TARGET_DEFAULT_FUNC (dummy_pid_to_str);

Pedro> This use of "dummy" in the default looked odd to me.
Pedro> I'd suggest renaming it to default_pid_to_str (now or at some
Pedro> point), in line with the other default methods.

I made this change.

Tom

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

* Re: [RFC 28/32] convert to_get_section_table
  2014-01-13 19:38 ` [RFC 28/32] convert to_get_section_table Tom Tromey
@ 2014-01-14 19:23   ` Pedro Alves
  2014-01-14 19:29     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 19:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine to me.

> -    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);

(I noticed now that methods that return a pointer could
 say 'TARGET_DEFAULT_RETURN (NULL)' instead of 0.  I'm guessing
you wrote 0 in the previous version where TARGET_DEFAULT
would require a digit.)

-- 
Pedro Alves

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

* Re: [RFC 28/32] convert to_get_section_table
  2014-01-14 19:23   ` Pedro Alves
@ 2014-01-14 19:29     ` Tom Tromey
  2014-01-14 19:30       ` Pedro Alves
  0 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 19:29 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

Pedro> Looks fine to me.
>> - 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);

Pedro> (I noticed now that methods that return a pointer could
Pedro>  say 'TARGET_DEFAULT_RETURN (NULL)' instead of 0.  I'm guessing
Pedro> you wrote 0 in the previous version where TARGET_DEFAULT
Pedro> would require a digit.)

Yeah.  Unfortunately I didn't think of this early enough.  I can fix
this if you like, but unlike other rewrites, I'd prefer to do it as a
cleanup patch on top.  I found the hard way that modifications to these
lines cause conflicts to bubble up through the entire patch series.

Tom

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

* Re: [RFC 29/32] convert to_insn_history
  2014-01-13 19:40 ` [RFC 29/32] convert to_insn_history Tom Tromey
@ 2014-01-14 19:29   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 19:29 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:

> convert to_auxv_parse
> 
> this one is more complicated than the norm

I'm wondering whether I missed something, as
it didn't look like more complicated to me.

Patch looked good.

> 2014-01-08  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.
-- 
Pedro Alves

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

* Re: [RFC 28/32] convert to_get_section_table
  2014-01-14 19:29     ` Tom Tromey
@ 2014-01-14 19:30       ` Pedro Alves
  2014-01-15 16:43         ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 19:30 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/14/2014 07:28 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> Looks fine to me.
>>> - 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);
> 
> Pedro> (I noticed now that methods that return a pointer could
> Pedro>  say 'TARGET_DEFAULT_RETURN (NULL)' instead of 0.  I'm guessing
> Pedro> you wrote 0 in the previous version where TARGET_DEFAULT
> Pedro> would require a digit.)
> 
> Yeah.  Unfortunately I didn't think of this early enough.  I can fix
> this if you like, but unlike other rewrites, I'd prefer to do it as a
> cleanup patch on top.  I found the hard way that modifications to these
> lines cause conflicts to bubble up through the entire patch series.

Yeah, please leave it as is.  We can always clean up afterwards.

-- 
Pedro Alves

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

* Re: [RFC 25/32] convert to_upload_trace_state_variables
  2014-01-13 19:13 ` [RFC 25/32] convert to_upload_trace_state_variables Tom Tromey
@ 2014-01-14 19:38   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 19:38 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 ddcc89c..4d6c591 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 90e2709..c6d5367 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);
> -
>  void target_ignore (void);
>  
>  static void target_command (char *, int);
> @@ -699,16 +697,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);
> @@ -748,38 +746,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 *))
> @@ -3443,12 +3409,6 @@ return_zero (void)
>    return 0;
>  }
>  
> -static int
> -return_minus_one (void)
> -{
> -  return -1;
> -}
> -
>  /*
>   * Find the next target down the stack from the specified target.
>   */
> diff --git a/gdb/target.h b/gdb/target.h
> index dfaad80..9860cf4 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -859,29 +859,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:
> @@ -902,15 +909,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.  */
> 


-- 
Pedro Alves

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

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-14 18:30           ` Pedro Alves
@ 2014-01-14 19:45             ` Tom Tromey
  2014-01-15 15:25               ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 19:45 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Joel Brobecker, gdb-patches

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

Pedro> I'd suggest just going ahead and pushing this change in.

I'll push it tomorrow morning.

Tom

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

* Re: [RFC 30/32] convert to_search_memory
  2014-01-13 19:24 ` [RFC 30/32] convert to_search_memory Tom Tromey
@ 2014-01-14 19:45   ` Pedro Alves
  2014-01-14 20:20     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 19:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Looks good.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> @@ -2789,7 +2778,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))

OOC, I'm wondering how you envision translating checks
like this into a C++ world?

>  	{
>  	  runable = *t;
>  	  ++count;

-- 
Pedro Alves

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

* Re: [RFC 31/32] change delegation for to_read_description
  2014-01-13 19:13 ` [RFC 31/32] change delegation for to_read_description Tom Tromey
@ 2014-01-14 20:07   ` Pedro Alves
  2014-01-14 20:22     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 20:07 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 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.
> 

Looks good to me.  A suggestion below.

> 2014-01-13  Tom Tromey  <tromey@redhat.com>
> 
> 	* arm-linux-nat.c (arm_linux_read_description): Delegate when
> 	needed

Missing period.

>      /* 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);
> +       Returns the description found.  If no description is found,
> +       this should delegate to the "beneath" target.  */

"Returns ... found ... If not found ..." reads a little like a
paradox to me.  I'd suggest leaving the NULL sentences as is,
something like:

      /* 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);

-- 
Pedro Alves

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

* Re: [RFC 32/32] minor cleanups to update_current_target
  2014-01-13 19:13 ` [RFC 32/32] minor cleanups to update_current_target Tom Tromey
@ 2014-01-14 20:10   ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 20:10 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 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.

Looks good to me.

> 
> 2014-01-13  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 76316b5..a503220 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -590,147 +590,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)               \
> 


-- 
Pedro Alves

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

* Re: [RFC 30/32] convert to_search_memory
  2014-01-14 19:45   ` Pedro Alves
@ 2014-01-14 20:20     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 20:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

>> -      if ((*t)->to_can_run && target_can_run (*t))
>> +      if ((*t)->to_can_run != delegate_can_run && target_can_run (*t))

Pedro> OOC, I'm wondering how you envision translating checks
Pedro> like this into a C++ world?

Good question.

Code like this only appears in places like find_default_run_target.
These functions iterate over all the target_ops structures to find a
suitable one to return.

In the multi-target model, this idea does not really work.  Abstractly,
find_default_run_target is returning a type, not an instance; but in the
long run we want most of the code to deal solely with instances.  I'm
not sure if this way of putting it makes sense... basically
find_default_run_target can't return an instance of a target, but in
order to do nearly anything useful with a target (in the multi-target
future) the target must be instantiated to have an object with state.

This means we're already going to need some restructuring in this area.
So, while a straightforward translation to C++ is not really possible, I
suspect it will also not be needed.

But, if it is needed in the end, I think it can be done simply by adding
fields to target_ops.

Tom

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

* Re: [RFC 31/32] change delegation for to_read_description
  2014-01-14 20:07   ` Pedro Alves
@ 2014-01-14 20:22     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 20:22 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

Pedro> Missing period.

Fixed.

Pedro>       /* Describe the architecture-specific features of this target.
Pedro> 	 If OPS doesn't have a description, this should delegate
Pedro> 	 to the "beneath" target.  Returns the description found, or
Pedro> 	 NULL if no description was available.  */

Thanks, I used this comment instead.  I agree it is clearer.

Tom

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

* Re: [RFC 01/32] add "this" pointers to more target APIs
  2014-01-14 12:10   ` Pedro Alves
@ 2014-01-14 20:25     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 20:25 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

>> /* Unregister from the event loop.  */
>> -  if (linux_nat_is_async_p ())
>> -    linux_nat_async (NULL, 0);
>> +  if (linux_nat_is_async_p (linux_ops))
>> +    linux_nat_async (linux_ops, NULL, 0);

Pedro> I still think linux_ops is the wrong target to
Pedro> use here.

I'm sorry if I missed some earlier review note of it.
It wasn't intentional.

Pedro> While to_close doesn't have a self
Pedro> pointer, I'd suggest using NULL or adding a comment
Pedro> (or storing the multi-threaded target pointer in a
Pedro> global, though given the target really isn't used,
Pedro> that's probably overkill).

Yes, I agree.  I used "NULL".

The native targets are unusual because, in gdb's design, they are
inherently singletons.

Tom

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

* go32 fix
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (31 preceding siblings ...)
  2014-01-13 19:57 ` [RFC 15/32] Add target_ops argument to to_disable_tracepoint Tom Tromey
@ 2014-01-14 20:31 ` Pedro Alves
  2014-01-14 21:58   ` Tom Tromey
  2014-01-15 12:55 ` [RFC 00/32] clean up target delegation Pedro Alves
  2014-01-16 19:09 ` Tom Tromey
  34 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 20:31 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> Because this touches every target, I built this on many platforms.  I
> mostly did build tests because most of the patches are obviously
> semantically neutral.
>
>    x86-64 Fedora 18 (native).  I built every revision (cumulatively of
>    course).  Regression tested native and with the native-gdbserver
>    target board.
>    x86-64 Fedora 18, cross build with Mingw tools.  I cross built each
>    revision.
>    PPC64 Linux (gcc110 in the compile farm).  Built each revision both
>    normally and with the SPU target enabled.
>    AIX (gcc111 in the compile farm).
>    NetBSD 5.1 (gcc70 in the compile farm).

I had the cross toolchain handy, so I build the branch for
go32/djgpp (i586-pc-msdosdjgpp).  It caught a buglet:

---
 gdb/go32-nat.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index c42f48a..161e4e7 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -262,8 +262,7 @@ static int go32_can_run (struct target_ops *self);
 static struct target_ops go32_ops;
 static void go32_terminal_init (struct target_ops *self);
 static void go32_terminal_inferior (struct target_ops *self);
-static void go32_terminal_ours (struct target_ops *self,
-				struct target_ops *self);
+static void go32_terminal_ours (struct target_ops *self);

 #define r_ofs(x) (offsetof(TSS,x))

@@ -930,7 +929,7 @@ go32_terminal_inferior (struct target_ops *self)
 }

 static void
-go32_terminal_ours (struct target_ops *self, struct target_ops *self)
+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.  */
-- 
1.7.11.7


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

* Re: [RFC 20/32] convert to_remove_watchpoint
  2014-01-14 18:55     ` Tom Tromey
  2014-01-14 19:07       ` Tom Tromey
@ 2014-01-14 20:38       ` Pedro Alves
  2014-01-14 21:47         ` Tom Tromey
  1 sibling, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-14 20:38 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/14/2014 06:54 PM, Tom Tromey wrote:
>>> convert to_can_acce_watchpoint_condition
> 
> Pedro> Typo: "accel"
> 
> Thanks, I fixed it.
> 
>>> 2014-01-08  Tom Tromey <tromey@redhat.com>
>>>
>>> * target-delegates.c : Rebuild.
> 
> Pedro> (Spurious space before ":" (in all similar patches
> Pedro> actually), but please do leave it if not super trivial to fix.)
> 
> I already have the mass-rewriting tools; it's easy to modify them to
> make this fix.

Alright, thanks.  Another nit then:

>>> 2014-01-08  Tom Tromey <tromey@redhat.com>
                          |
   double space ----------+

-- 
Pedro Alves

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

* Re: [RFC 20/32] convert to_remove_watchpoint
  2014-01-14 20:38       ` Pedro Alves
@ 2014-01-14 21:47         ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 21:47 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

Pedro> Alright, thanks.  Another nit then:
>>>> 2014-01-08  Tom Tromey <tromey@redhat.com>
Pedro>                           |
Pedro>    double space ----------+

Two bugs in my ChangeLog generator?  Clearly I should have written it in
elisp instead.

I've fixed this on the branch.

Tom

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

* Re: go32 fix
  2014-01-14 20:31 ` go32 fix Pedro Alves
@ 2014-01-14 21:58   ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-14 21:58 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

Pedro> I had the cross toolchain handy, so I build the branch for
Pedro> go32/djgpp (i586-pc-msdosdjgpp).  It caught a buglet:

Thanks.
The to_terminal_ours_for_output patch introduced the first "self", and
then the to_terminal_ours patch introduced the second one.
The perils of automated patching...
Anyway I fixed both patches on my branch.

Tom

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

* Re: [RFC 00/32] clean up target delegation
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (32 preceding siblings ...)
  2014-01-14 20:31 ` go32 fix Pedro Alves
@ 2014-01-15 12:55 ` Pedro Alves
  2014-01-15 16:11   ` Tom Tromey
  2014-01-16 19:09 ` Tom Tromey
  34 siblings, 1 reply; 100+ messages in thread
From: Pedro Alves @ 2014-01-15 12:55 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/13/2014 07:12 PM, Tom Tromey wrote:

> After this patch, nearly every remaining INHERIT is for a scalar
> field.  I think it would be worth eliminating these as well; the
> simplest would seem to be to convert each to a new target method.  I'm
> happy to do this if others agree.

For a couple, I think the simplest yet would be to change their
respective macros/functions to return the field in the topmost target:

-#define	target_shortname	(current_target.to_shortname)
-#define	target_longname		(current_target.to_longname)
+#define	target_shortname	(current_target.beneath->to_shortname)
+#define	target_longname		(current_target.beneath->to_longname)

Actually, it seems to be that most, if not all, hacks^W uses
of target_shortname are wrong, in that they want to know the
name of the process_stratum target, not the topmost target.

to_doc is never used in the squashed target, so we just can
stop inheriting that.

to_attach_no_wait does indeed look like best be made a method that
delegates, as it may not be topmost target that handles that
to_attach detail (it'll usually be the process_stratum target).
Same for to_have_steppable_watchpoint, to_have_continuable_watchpoint
and to_has_thread_control.

> The remaining method using INHERIT is deprecated_xfer_memory.  This is
> also a method not using delegation or getting the "target_ops"
> treatment.  I didn't bother with this one because my understanding is
> that Pedro is working on eliminating this method entirely.

Yeah.  There's deprecated_xfer_memory branch on my github that
does that.  Needs writing ChangeLog's and posting...

> There are also three remaining uses of de_fault: to_open, to_close,
> and deprecated_xfer_memory.  to_open and to_close are just special.

target_open and target_close are always called on a specific real target
OPS, never on the squashed &current_target.  ISTM these de_fault's are
useless and can just be removed, even on current mainline.

> They may need some work for the multi-target feature, but I didn't
> want to attempt it now.  deprecated_xfer_memory, again, is hopefully
> just going away.

-- 
Pedro Alves

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

* Re: [RFC 03/32] introduce async_callback_ftype
  2014-01-14 19:45             ` Tom Tromey
@ 2014-01-15 15:25               ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-15 15:25 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Joel Brobecker, gdb-patches

Pedro> I'd suggest just going ahead and pushing this change in.

Tom> I'll push it tomorrow morning.

Here is the version I am checking it.  It differs slightly from the
patch in the series because it does not include the "self" argument.  I
tested it by rebuilding.

Tom

commit b0a16e66b0391025b04acb79af36d4618379cb14
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu Dec 19 14:33:07 2013 -0700

    introduce async_callback_ftype
    
    This introduces async_callback_ftype.  This is needed for
    make-target-delegates to work properly, as it doesn't implement a real
    parser.  I think it's also an ok cleanup in its own right.
    
    2014-01-15  Tom Tromey  <tromey@redhat.com>
    
    	* target.h (async_callback_ftype): New typedef.
    	(struct target_ops) <to_async>: Use it.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e752dd0..e3b3eaa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-15  Tom Tromey  <tromey@redhat.com>
+
+	* target.h (async_callback_ftype): New typedef.
+	(struct target_ops) <to_async>: Use it.
+
 2014-01-15  Joel Brobecker  <brobecker@adacore.com>
 
 	* python/py-value.c (get_field_type): Remove unnecessary curly
diff --git a/gdb/target.h b/gdb/target.h
index 9a39839..37ca302 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -345,6 +345,11 @@ extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
 \f
 struct thread_info;		/* fwd decl for parameter list below: */
 
+/* The type of the callback to the to_async method.  */
+
+typedef void async_callback_ftype (enum inferior_event_type event_type,
+				   void *context);
+
 struct target_ops
   {
     struct target_ops *beneath;	/* To the target under this one.  */
@@ -486,7 +491,7 @@ struct target_ops
     /* ASYNC target controls */
     int (*to_can_async_p) (void);
     int (*to_is_async_p) (void);
-    void (*to_async) (void (*) (enum inferior_event_type, void *), void *);
+    void (*to_async) (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);

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

* Re: [RFC 00/32] clean up target delegation
  2014-01-15 12:55 ` [RFC 00/32] clean up target delegation Pedro Alves
@ 2014-01-15 16:11   ` Tom Tromey
  2014-01-15 20:05     ` Tom Tromey
  0 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-15 16:11 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

Pedro> For a couple, I think the simplest yet would be to change their
Pedro> respective macros/functions to return the field in the topmost target:
[...]

I started implementing the easy bits but then I realized that the debug
target puts a wrinkle into this.  For instance, inheriting to_shortname
is needed when target debug is active.

We discussed before that it would be nice to get rid of the debug target.
That's a reasonable amount of typing, though ... there's ~80 target
functions that are just #defines in target.h.  It sure would be nice to
automate this as well, but I didn't really see a reasonable way.

It looks like a second round of target cleanups will be needed.

Pedro> Actually, it seems to be that most, if not all, hacks^W uses
Pedro> of target_shortname are wrong, in that they want to know the
Pedro> name of the process_stratum target, not the topmost target.

Wow, I had no idea about this.  What hacks!
I filed a bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16454

Tom

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

* Re: [PATCH] Fix "is a record target open" checks.
  2014-01-14 11:48   ` [PATCH] Fix "is a record target open" checks Pedro Alves
  2014-01-14 15:30     ` Tom Tromey
@ 2014-01-15 16:22     ` Tom Tromey
  1 sibling, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-15 16:22 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro> I have no problem with find_target_at, though I think that
Pedro> bit could/should instead be split and moved to the series that
Pedro> actually needs it.

Just for the record, I'm leaving this one in the series; since as you
noticed it is used later on as well.

Tom

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

* Re: [RFC 28/32] convert to_get_section_table
  2014-01-14 19:30       ` Pedro Alves
@ 2014-01-15 16:43         ` Tom Tromey
  2014-01-16 17:51           ` Pedro Alves
  0 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-15 16:43 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Tom> Yeah.  Unfortunately I didn't think of this early enough.  I can fix
Tom> this if you like, but unlike other rewrites, I'd prefer to do it as a
Tom> cleanup patch on top.  I found the hard way that modifications to these
Tom> lines cause conflicts to bubble up through the entire patch series.

Pedro> Yeah, please leave it as is.  We can always clean up afterwards.

I applied this patch to my branch to clean this up.

Tom

commit 9ca52ccf3084a6e25a93de7e1974997491404d95
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 15 09:30:05 2014 -0700

    pass NULL to TARGET_DEFAULT_RETURN when appropriate
    
    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-01-15  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.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1e638db..ca5b145 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2014-01-15  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.
+
 2014-01-13  Tom Tromey  <tromey@redhat.com>
 
 	* target.c (complete_target_initialization): Remove casts.  Use
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 474fe80..6e59588 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 2d1c2d6..d2651b6 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -554,20 +554,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 *);
@@ -655,7 +655,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.
@@ -678,7 +678,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
@@ -970,7 +970,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.  */

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

* Re: [RFC 12/32] Add target_ops argument to to_thread_name
  2014-01-14 13:03   ` Pedro Alves
@ 2014-01-15 16:45     ` Tom Tromey
  2014-01-16 17:50       ` Pedro Alves
  0 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-15 16:45 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro> The patch is fine with me as is, but I'll note that I don't
Pedro> think there's any need for exec_set_find_memory_regions
Pedro> nowadays.  Seems to me that exec_ops.to_find_memory_regions could
Pedro> always be set to objfile_find_memory_regions unconditionally.

Good point.

Here is a patch I've added to my branch to fix this up.
It's cleaner and also more obviously correct in the multi-target case.

Tom

commit a6a3bf71f7c81b589ffd13ade0d29be010e794c8
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 15 09:40:13 2014 -0700

    remove exec_set_find_memory_regions
    
    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-01-15  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.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ca5b145..d8765c9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
 2014-01-15  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.
+
+2014-01-15  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,
diff --git a/gdb/defs.h b/gdb/defs.h
index 1469299..1361562 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 6777f35..d03fff4 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 49f9b22..6228f22 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 0f67a1e..1240b49 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 */

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

* Re: [RFC 06/32] convert to_supports_btrace
  2014-01-14 12:37   ` Pedro Alves
@ 2014-01-15 16:55     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-15 16:55 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro> (Looks like the patch merge script lost the commit log of this one.)
Pedro> Looks good to me though.

I must have forgotten to write a ChangeLog and commit note for this one.
I'm fixing it.

Tom

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

* Re: [RFC 00/32] clean up target delegation
  2014-01-15 16:11   ` Tom Tromey
@ 2014-01-15 20:05     ` Tom Tromey
  2014-01-16 17:33       ` Pedro Alves
  0 siblings, 1 reply; 100+ messages in thread
From: Tom Tromey @ 2014-01-15 20:05 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Tom> I started implementing the easy bits but then I realized that the debug
Tom> target puts a wrinkle into this.  For instance, inheriting to_shortname
Tom> is needed when target debug is active.

I did go ahead and write the appended, which removes the calls that
truly aren't needed.

Tom

commit b15ac78fa8b7c50df3eae348871c0e0d2e231199
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 15 12:58:50 2014 -0700

    remove some calls to INHERIT and de_fault
    
    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-01-15  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.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7a1b817..f4c9923 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2014-01-15  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.
+
+2014-01-15  Tom Tromey  <tromey@redhat.com>
+
 	* gcore.h (objfile_find_memory_regions): Declare.
 	* gcore.c (objfile_find_memory_regions): No longer static.  Add
 	"self" argument.
diff --git a/gdb/target.c b/gdb/target.c
index 44e2490..f121e91 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -604,13 +604,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
 
@@ -622,12 +620,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 *))

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

* Re: [RFC 00/32] clean up target delegation
  2014-01-15 20:05     ` Tom Tromey
@ 2014-01-16 17:33       ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-16 17:33 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/15/2014 08:05 PM, Tom Tromey wrote:
> Tom> I started implementing the easy bits but then I realized that the debug
> Tom> target puts a wrinkle into this.  For instance, inheriting to_shortname
> Tom> is needed when target debug is active.
> 
> I did go ahead and write the appended, which removes the calls that
> truly aren't needed.

Excellent.  Thanks.

For the archives, last night I updated my deprecated_xfer_memory removal
branch (in github), rebasing on top of Tom's.  After that, de_fault
is gone.

> 
> Tom
> 
> commit b15ac78fa8b7c50df3eae348871c0e0d2e231199
> Author: Tom Tromey <tromey@redhat.com>
> Date:   Wed Jan 15 12:58:50 2014 -0700
> 
>     remove some calls to INHERIT and de_fault
>     
>     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-01-15  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.
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 7a1b817..f4c9923 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,5 +1,10 @@
>  2014-01-15  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.
> +
> +2014-01-15  Tom Tromey  <tromey@redhat.com>
> +
>  	* gcore.h (objfile_find_memory_regions): Declare.
>  	* gcore.c (objfile_find_memory_regions): No longer static.  Add
>  	"self" argument.
> diff --git a/gdb/target.c b/gdb/target.c
> index 44e2490..f121e91 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -604,13 +604,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
>  
> @@ -622,12 +620,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 *))
> 


-- 
Pedro Alves

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

* Re: [RFC 12/32] Add target_ops argument to to_thread_name
  2014-01-15 16:45     ` Tom Tromey
@ 2014-01-16 17:50       ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-16 17:50 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/15/2014 04:45 PM, Tom Tromey wrote:
> Pedro> The patch is fine with me as is, but I'll note that I don't
> Pedro> think there's any need for exec_set_find_memory_regions
> Pedro> nowadays.  Seems to me that exec_ops.to_find_memory_regions could
> Pedro> always be set to objfile_find_memory_regions unconditionally.
> 
> Good point.
> 
> Here is a patch I've added to my branch to fix this up.
> It's cleaner and also more obviously correct in the multi-target case.

Thanks.  Looks good to me.

-- 
Pedro Alves

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

* Re: [RFC 28/32] convert to_get_section_table
  2014-01-15 16:43         ` Tom Tromey
@ 2014-01-16 17:51           ` Pedro Alves
  0 siblings, 0 replies; 100+ messages in thread
From: Pedro Alves @ 2014-01-16 17:51 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 01/15/2014 04:43 PM, Tom Tromey wrote:
> Tom> Yeah.  Unfortunately I didn't think of this early enough.  I can fix
> Tom> this if you like, but unlike other rewrites, I'd prefer to do it as a
> Tom> cleanup patch on top.  I found the hard way that modifications to these
> Tom> lines cause conflicts to bubble up through the entire patch series.
> 
> Pedro> Yeah, please leave it as is.  We can always clean up afterwards.
> 
> I applied this patch to my branch to clean this up.

Thank you.

-- 
Pedro Alves

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

* Re: [RFC 00/32] clean up target delegation
  2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
                   ` (33 preceding siblings ...)
  2014-01-15 12:55 ` [RFC 00/32] clean up target delegation Pedro Alves
@ 2014-01-16 19:09 ` Tom Tromey
  34 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-16 19:09 UTC (permalink / raw)
  To: gdb-patches

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

Tom> This patch series cleans up most of the target API.
Tom> It changes nearly every target method to take a "self" argument.  This
Tom> was done in a mostly automated way.  This is PR 8626.
[...]

Tom> If you want to see the atomized series in its full glory, it is all on
Tom> the "target-cleanup" branch in my gitorious repository.

I've rebased this on top of master and (force-) pushed to my branch.

It required a few changes in various spots in the series to adapt to
changes on master, mostly Markus' btrace series.  I've also written two
more little cleanup patches at the end, one to fix a bug I found in
nto-procfs.c, and one to convert to_decr_pc_after_break to the new
delegation style (and consequently remove
forward_target_decr_pc_after_break).

I believe I've addressed all the review comments except one (about
record_full_can_async_p and friends); I'll deal with that before long.

After that I'll do the squash-and-resubmit thing; I have a few other
things to attend to first.

Tom

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

* Re: [RFC 08/32] remove extended_remote_create_inferior_1
  2014-01-14 12:41   ` Pedro Alves
@ 2014-01-16 19:20     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-16 19:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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

>> 2014-01-08  Tom Tromey  <tromey@redhat.com>
>> 
>> * remote.c (extended_remote_create_inferior): Rename from
>> extended_remote_create_inferior_1.  Add "ops" argument.  Remove
>> old implementation.

Pedro> OK.  Feel free to push it immediately.

I cherry-picked it to master, updated the ChangeLog, and built it.
I'm going to push it now.

Tom

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

* Re: [RFC 05/32] add target method delegation
  2014-01-14 12:32   ` Pedro Alves
@ 2014-01-20 22:00     ` Tom Tromey
  0 siblings, 0 replies; 100+ messages in thread
From: Tom Tromey @ 2014-01-20 22:00 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>> MUST UPDATE

Pedro> Yes, must.  :-)

Hah, thanks for noticing that.
That was just a note to myself that I needed to update the ChangeLog
and/or description for that patch.
I've fixed it on my branch.

>> -record_full_can_async_p (struct target_ops *ops)
[...]
>> -record_full_is_async_p (struct target_ops *ops)

Pedro> I think these were and still are necessary, due to how
Pedro> find_default_target_can_async_p etc. is installed in the dummy target.
Pedro> E.g., when debugging with the record-core target, without this, I
Pedro> think we'll end up hitting the dummy target, because the core_ops
Pedro> target delegates these methods.  That means we'll end up asking e.g.,
Pedro> the GNU/Linux target whether it can async, while that isn't the
Pedro> process_stratum target that is open.

I finally sat down to think about this, and I agree.
I will restore these.

I probably won't have an updated patch series until Feb at this point.

Pedro> This made me realize another issue with the
Pedro> find_default_target_can_async_p (or really all find_default_...)
Pedro> being installed in the dummy/default target.  E.g., considering a
Pedro> configuration that includes both remote-sim, and a native target
Pedro> that can run.  When connected to the sim, we'll end up calling
Pedro> that method in the default run target which is wrong.

I may end up having to clean up these methods a bit for multi-target
anyhow.  I mean, I know I have to do something, due to the previously
mentioned "type-vs-instance" problem these methods have; but whether or
not it would necessarily fix the above, I don't know.

Tom

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

end of thread, other threads:[~2014-01-20 22:00 UTC | newest]

Thread overview: 100+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
2014-01-13 19:12 ` [RFC 03/32] introduce async_callback_ftype Tom Tromey
2014-01-14 10:35   ` Pedro Alves
2014-01-14 10:50     ` Joel Brobecker
2014-01-14 15:06       ` Tom Tromey
2014-01-14 17:19         ` Joel Brobecker
2014-01-14 17:27           ` Tom Tromey
2014-01-14 18:30           ` Pedro Alves
2014-01-14 19:45             ` Tom Tromey
2014-01-15 15:25               ` Tom Tromey
2014-01-13 19:12 ` [RFC 02/32] introduce and use find_target_at Tom Tromey
2014-01-14 11:48   ` [PATCH] Fix "is a record target open" checks Pedro Alves
2014-01-14 15:30     ` Tom Tromey
2014-01-14 18:27       ` Pedro Alves
2014-01-15 16:22     ` Tom Tromey
2014-01-13 19:12 ` [RFC 01/32] add "this" pointers to more target APIs Tom Tromey
2014-01-14 12:10   ` Pedro Alves
2014-01-14 20:25     ` Tom Tromey
2014-01-13 19:13 ` [RFC 08/32] remove extended_remote_create_inferior_1 Tom Tromey
2014-01-14 12:41   ` Pedro Alves
2014-01-16 19:20     ` Tom Tromey
2014-01-13 19:13 ` [RFC 25/32] convert to_upload_trace_state_variables Tom Tromey
2014-01-14 19:38   ` Pedro Alves
2014-01-13 19:13 ` [RFC 10/32] Add target_ops argument to to_terminal_init Tom Tromey
2014-01-14 12:51   ` Pedro Alves
2014-01-13 19:13 ` [RFC 26/32] convert to_static_tracepoint_markers_by_strid Tom Tromey
2014-01-14 18:57   ` Pedro Alves
2014-01-13 19:13 ` [RFC 31/32] change delegation for to_read_description Tom Tromey
2014-01-14 20:07   ` Pedro Alves
2014-01-14 20:22     ` Tom Tromey
2014-01-13 19:13 ` [RFC 04/32] add make-target-delegates Tom Tromey
2014-01-14 10:52   ` Pedro Alves
2014-01-14 14:46     ` Tom Tromey
2014-01-13 19:13 ` [RFC 32/32] minor cleanups to update_current_target Tom Tromey
2014-01-14 20:10   ` Pedro Alves
2014-01-13 19:13 ` [RFC 24/32] convert to_disable_tracepoint Tom Tromey
2014-01-14 18:49   ` Pedro Alves
2014-01-13 19:13 ` [RFC 12/32] Add target_ops argument to to_thread_name Tom Tromey
2014-01-14 13:03   ` Pedro Alves
2014-01-15 16:45     ` Tom Tromey
2014-01-16 17:50       ` Pedro Alves
2014-01-13 19:13 ` [RFC 27/32] convert to_insert_mask_watchpoint Tom Tromey
2014-01-14 19:15   ` Pedro Alves
2014-01-14 19:23     ` Tom Tromey
2014-01-13 19:13 ` [RFC 19/32] convert to_detach Tom Tromey
2014-01-14 13:32   ` Pedro Alves
2014-01-13 19:13 ` [RFC 11/32] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
2014-01-14 12:52   ` Pedro Alves
2014-01-13 19:13 ` [RFC 09/32] Add target_ops argument to to_close Tom Tromey
2014-01-14 12:48   ` Pedro Alves
2014-01-13 19:23 ` [RFC 07/32] introduce remote_load Tom Tromey
2014-01-14 12:39   ` Pedro Alves
2014-01-13 19:23 ` [RFC 13/32] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
2014-01-14 13:21   ` Pedro Alves
2014-01-13 19:23 ` [RFC 17/32] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
2014-01-14 13:25   ` Pedro Alves
2014-01-13 19:23 ` [RFC 20/32] convert to_remove_watchpoint Tom Tromey
2014-01-14 18:39   ` Pedro Alves
2014-01-14 18:55     ` Tom Tromey
2014-01-14 19:07       ` Tom Tromey
2014-01-14 20:38       ` Pedro Alves
2014-01-14 21:47         ` Tom Tromey
2014-01-13 19:24 ` [RFC 30/32] convert to_search_memory Tom Tromey
2014-01-14 19:45   ` Pedro Alves
2014-01-14 20:20     ` Tom Tromey
2014-01-13 19:24 ` [RFC 16/32] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
2014-01-14 13:24   ` Pedro Alves
2014-01-13 19:24 ` [RFC 06/32] convert to_supports_btrace Tom Tromey
2014-01-14 12:37   ` Pedro Alves
2014-01-15 16:55     ` Tom Tromey
2014-01-13 19:37 ` [RFC 21/32] convert to_load Tom Tromey
2014-01-14 18:41   ` Pedro Alves
2014-01-13 19:38 ` [RFC 22/32] convert to_extra_thread_info Tom Tromey
2014-01-14 18:43   ` Pedro Alves
2014-01-13 19:38 ` [RFC 05/32] add target method delegation Tom Tromey
2014-01-14 12:32   ` Pedro Alves
2014-01-20 22:00     ` Tom Tromey
2014-01-13 19:38 ` [RFC 18/32] Add target_ops argument to to_save_record Tom Tromey
2014-01-14 13:26   ` Pedro Alves
2014-01-13 19:38 ` [RFC 23/32] convert to_thread_architecture Tom Tromey
2014-01-14 18:46   ` Pedro Alves
2014-01-13 19:38 ` [RFC 28/32] convert to_get_section_table Tom Tromey
2014-01-14 19:23   ` Pedro Alves
2014-01-14 19:29     ` Tom Tromey
2014-01-14 19:30       ` Pedro Alves
2014-01-15 16:43         ` Tom Tromey
2014-01-16 17:51           ` Pedro Alves
2014-01-13 19:40 ` [RFC 29/32] convert to_insn_history Tom Tromey
2014-01-14 19:29   ` Pedro Alves
2014-01-13 19:57 ` [RFC 14/32] Add target_ops argument to to_fileio_pwrite Tom Tromey
2014-01-14 13:22   ` Pedro Alves
2014-01-13 19:57 ` [RFC 15/32] Add target_ops argument to to_disable_tracepoint Tom Tromey
2014-01-14 13:23   ` Pedro Alves
2014-01-14 20:31 ` go32 fix Pedro Alves
2014-01-14 21:58   ` Tom Tromey
2014-01-15 12:55 ` [RFC 00/32] clean up target delegation Pedro Alves
2014-01-15 16:11   ` Tom Tromey
2014-01-15 20:05     ` Tom Tromey
2014-01-16 17:33       ` Pedro Alves
2014-01-16 19:09 ` 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).