Add target_ops argument to to_trace_set_readonly_regions
[deliverable/binutils-gdb.git] / gdb / target.c
index 612d909f045e89e477945d4d53d516e3a7204c38..cbdce77a20c0081d3a6c6296dece5c87f0f86a8f 100644 (file)
 
 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);
 
-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;
 
@@ -74,11 +75,15 @@ static struct target_ops *find_default_run_target (char *);
 
 static target_xfer_partial_ftype default_xfer_partial;
 
-static target_xfer_partial_ftype current_xfer_partial;
-
 static struct gdbarch *default_thread_architecture (struct target_ops *ops,
                                                    ptid_t ptid);
 
+static int find_default_can_async_p (struct target_ops *ignore);
+
+static int find_default_is_async_p (struct target_ops *ignore);
+
+#include "target-delegates.c"
+
 static void init_dummy_target (void);
 
 static struct target_ops debug_target;
@@ -96,47 +101,52 @@ static int debug_to_insert_breakpoint (struct target_ops *, struct gdbarch *,
 static int debug_to_remove_breakpoint (struct target_ops *, struct gdbarch *,
                                       struct bp_target_info *);
 
-static int debug_to_can_use_hw_breakpoint (int, int, int);
+static int debug_to_can_use_hw_breakpoint (struct target_ops *self,
+                                          int, int, int);
 
-static int debug_to_insert_hw_breakpoint (struct gdbarch *,
+static int debug_to_insert_hw_breakpoint (struct target_ops *self,
+                                         struct gdbarch *,
                                          struct bp_target_info *);
 
-static int debug_to_remove_hw_breakpoint (struct gdbarch *,
+static int debug_to_remove_hw_breakpoint (struct target_ops *self,
+                                         struct gdbarch *,
                                          struct bp_target_info *);
 
-static int debug_to_insert_watchpoint (CORE_ADDR, int, int,
+static int debug_to_insert_watchpoint (struct target_ops *self,
+                                      CORE_ADDR, int, int,
                                       struct expression *);
 
-static int debug_to_remove_watchpoint (CORE_ADDR, int, int,
+static int debug_to_remove_watchpoint (struct target_ops *self,
+                                      CORE_ADDR, int, int,
                                       struct expression *);
 
-static int debug_to_stopped_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 *,
                                                  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);
+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);
+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
@@ -355,6 +365,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
@@ -450,7 +462,7 @@ void
 target_load (char *arg, int from_tty)
 {
   target_dcache_invalidate ();
-  (*current_target.to_load) (arg, from_tty);
+  (*current_target.to_load) (&current_target, arg, from_tty);
 }
 
 void
@@ -488,7 +500,7 @@ target_terminal_inferior (void)
 
   /* If GDB is resuming the inferior in the foreground, install
      inferior's terminal modes.  */
-  (*current_target.to_terminal_inferior) ();
+  (*current_target.to_terminal_inferior) (&current_target);
 }
 
 static int
@@ -513,7 +525,7 @@ noprocess (void)
 }
 
 static void
-default_terminal_info (const char *args, int from_tty)
+default_terminal_info (struct target_ops *self, const char *args, int from_tty)
 {
   printf_unfiltered (_("No saved terminal information.\n"));
 }
@@ -525,13 +537,13 @@ default_terminal_info (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;
@@ -562,6 +574,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
@@ -595,10 +610,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);
@@ -643,9 +658,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);
@@ -711,10 +726,10 @@ update_current_target (void)
            (void (*) (char *, int))
            tcomplain);
   de_fault (to_close,
-           (void (*) (void))
+           (void (*) (struct target_ops *))
            target_ignore);
   de_fault (to_post_attach,
-           (void (*) (int))
+           (void (*) (struct target_ops *, int))
            target_ignore);
   de_fault (to_prepare_to_store,
            (void (*) (struct target_ops *, struct regcache *))
@@ -727,136 +742,132 @@ 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_stopped_by_watchpoint,
-           (int (*) (void))
-           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,
            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))
+           (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))
+           (int (*) (struct target_ops *, int))
            return_one);
   de_fault (to_remove_vfork_catchpoint,
-           (int (*) (int))
+           (int (*) (struct target_ops *, int))
            return_one);
   de_fault (to_insert_exec_catchpoint,
-           (int (*) (int))
+           (int (*) (struct target_ops *, int))
            return_one);
   de_fault (to_remove_exec_catchpoint,
-           (int (*) (int))
+           (int (*) (struct target_ops *, int))
            return_one);
   de_fault (to_set_syscall_catchpoint,
-           (int (*) (int, int, int, int, int *))
+           (int (*) (struct target_ops *, int, int, int, int, int *))
            return_one);
   de_fault (to_has_exited,
-           (int (*) (int, int, int *))
+           (int (*) (struct target_ops *, int, int, int *))
            return_zero);
   de_fault (to_can_run,
+           (int (*) (struct target_ops *))
            return_zero);
   de_fault (to_extra_thread_info,
-           (char *(*) (struct thread_info *))
+           (char *(*) (struct target_ops *, struct thread_info *))
            return_null);
   de_fault (to_thread_name,
-           (char *(*) (struct thread_info *))
+           (char *(*) (struct target_ops *, struct thread_info *))
            return_null);
   de_fault (to_stop,
-           (void (*) (ptid_t))
+           (void (*) (struct target_ops *, ptid_t))
            target_ignore);
-  current_target.to_xfer_partial = current_xfer_partial;
   de_fault (to_rcmd,
-           (void (*) (char *, struct ui_file *))
+           (void (*) (struct target_ops *, char *, struct ui_file *))
            tcomplain);
   de_fault (to_pid_to_exec_file,
-           (char *(*) (int))
+           (char *(*) (struct target_ops *, int))
            return_null);
-  de_fault (to_async,
-           (void (*) (void (*) (enum inferior_event_type, void*), void*))
-           tcomplain);
   de_fault (to_thread_architecture,
            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))
+           (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 *))
+           (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))
@@ -919,10 +930,10 @@ update_current_target (void)
            (struct traceframe_info * (*) (void))
            return_null);
   de_fault (to_supports_evaluation_of_breakpoint_conditions,
-           (int (*) (void))
+           (int (*) (struct target_ops *))
            return_zero);
   de_fault (to_can_run_breakpoint_commands,
-           (int (*) (void))
+           (int (*) (struct target_ops *))
            return_zero);
   de_fault (to_use_agent,
            (int (*) (int))
@@ -1185,7 +1196,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
 }
 
 const char *
-target_xfer_error_to_string (enum target_xfer_error err)
+target_xfer_status_to_string (enum target_xfer_status err)
 {
 #define CASE(X) case X: return #X
   switch (err)
@@ -1312,11 +1323,12 @@ target_section_by_addr (struct target_ops *target, CORE_ADDR addr)
 /* Read memory from the live target, even if currently inspecting a
    traceframe.  The return is the same as that of target_read.  */
 
-static LONGEST
+static enum target_xfer_status
 target_read_live_memory (enum target_object object,
-                        ULONGEST memaddr, gdb_byte *myaddr, ULONGEST len)
+                        ULONGEST memaddr, gdb_byte *myaddr, ULONGEST len,
+                        ULONGEST *xfered_len)
 {
-  LONGEST ret;
+  enum target_xfer_status ret;
   struct cleanup *cleanup;
 
   /* Switch momentarily out of tfind mode so to access live memory.
@@ -1326,8 +1338,8 @@ target_read_live_memory (enum target_object object,
   cleanup = make_cleanup_restore_traceframe_number ();
   set_traceframe_number (-1);
 
-  ret = target_read (current_target.beneath, object, NULL,
-                    myaddr, memaddr, len);
+  ret = target_xfer_partial (current_target.beneath, object, NULL,
+                            myaddr, NULL, memaddr, len, xfered_len);
 
   do_cleanups (cleanup);
   return ret;
@@ -1340,11 +1352,11 @@ target_read_live_memory (enum target_object object,
    For interface/parameters/return description see target.h,
    to_xfer_partial.  */
 
-static LONGEST
+static enum target_xfer_status
 memory_xfer_live_readonly_partial (struct target_ops *ops,
                                   enum target_object object,
                                   gdb_byte *readbuf, ULONGEST memaddr,
-                                  ULONGEST len)
+                                  ULONGEST len, ULONGEST *xfered_len)
 {
   struct target_section *secp;
   struct target_section_table *table;
@@ -1368,7 +1380,7 @@ memory_xfer_live_readonly_partial (struct target_ops *ops,
                {
                  /* Entire transfer is within this section.  */
                  return target_read_live_memory (object, memaddr,
-                                                 readbuf, len);
+                                                 readbuf, len, xfered_len);
                }
              else if (memaddr >= p->endaddr)
                {
@@ -1380,30 +1392,36 @@ memory_xfer_live_readonly_partial (struct target_ops *ops,
                  /* This section overlaps the transfer.  Just do half.  */
                  len = p->endaddr - memaddr;
                  return target_read_live_memory (object, memaddr,
-                                                 readbuf, len);
+                                                 readbuf, len, xfered_len);
                }
            }
        }
     }
 
-  return 0;
+  return TARGET_XFER_EOF;
 }
 
 /* Read memory from more than one valid target.  A core file, for
    instance, could have some of memory but delegate other bits to
    the target below it.  So, we must manually try all targets.  */
 
-static LONGEST
-raw_memory_xfer_partial (struct target_ops *ops, void *readbuf,
-                        const void *writebuf, ULONGEST memaddr, LONGEST len)
+static enum target_xfer_status
+raw_memory_xfer_partial (struct target_ops *ops, gdb_byte *readbuf,
+                        const gdb_byte *writebuf, ULONGEST memaddr, LONGEST len,
+                        ULONGEST *xfered_len)
 {
-  LONGEST res;
+  enum target_xfer_status res;
 
   do
     {
       res = ops->to_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL,
-                                 readbuf, writebuf, memaddr, len);
-      if (res > 0)
+                                 readbuf, writebuf, memaddr, len,
+                                 xfered_len);
+      if (res == TARGET_XFER_OK)
+       break;
+
+      /* Stop if the target reports that the memory is not available.  */
+      if (res == TARGET_XFER_E_UNAVAILABLE)
        break;
 
       /* We want to continue past core files to executables, but not
@@ -1421,12 +1439,12 @@ raw_memory_xfer_partial (struct target_ops *ops, void *readbuf,
 /* Perform a partial memory transfer.
    For docs see target.h, to_xfer_partial.  */
 
-static LONGEST
+static enum target_xfer_status
 memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
-                      void *readbuf, const void *writebuf, ULONGEST memaddr,
-                      ULONGEST len)
+                      gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr,
+                      ULONGEST len, ULONGEST *xfered_len)
 {
-  LONGEST res;
+  enum target_xfer_status res;
   int reg_len;
   struct mem_region *region;
   struct inferior *inf;
@@ -1445,7 +1463,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
 
          memaddr = overlay_mapped_address (memaddr, section);
          return section_table_xfer_memory_partial (readbuf, writebuf,
-                                                   memaddr, len,
+                                                   memaddr, len, xfered_len,
                                                    table->sections,
                                                    table->sections_end,
                                                    section_name);
@@ -1466,7 +1484,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
        {
          table = target_get_section_table (ops);
          return section_table_xfer_memory_partial (readbuf, writebuf,
-                                                   memaddr, len,
+                                                   memaddr, len, xfered_len,
                                                    table->sections,
                                                    table->sections_end,
                                                    NULL);
@@ -1507,13 +1525,17 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
 
              /* This goes through the topmost target again.  */
              res = memory_xfer_live_readonly_partial (ops, object,
-                                                      readbuf, memaddr, len);
-             if (res > 0)
-               return res;
-
-             /* No use trying further, we know some memory starting
-                at MEMADDR isn't available.  */
-             return TARGET_XFER_E_UNAVAILABLE;
+                                                      readbuf, memaddr,
+                                                      len, xfered_len);
+             if (res == TARGET_XFER_OK)
+               return TARGET_XFER_OK;
+             else
+               {
+                 /* No use trying further, we know some memory starting
+                    at MEMADDR isn't available.  */
+                 *xfered_len = len;
+                 return TARGET_XFER_E_UNAVAILABLE;
+               }
            }
 
          /* Don't try to read more than how much is available, in
@@ -1538,12 +1560,12 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
     {
     case MEM_RO:
       if (writebuf != NULL)
-       return -1;
+       return TARGET_XFER_E_IO;
       break;
 
     case MEM_WO:
       if (readbuf != NULL)
-       return -1;
+       return TARGET_XFER_E_IO;
       break;
 
     case MEM_FLASH:
@@ -1553,7 +1575,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
       break;
 
     case MEM_NONE:
-      return -1;
+      return TARGET_XFER_E_IO;
     }
 
   if (!ptid_equal (inferior_ptid, null_ptid))
@@ -1571,19 +1593,23 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
          || (code_cache_enabled_p () && object == TARGET_OBJECT_CODE_MEMORY)))
     {
       DCACHE *dcache = target_dcache_get_or_init ();
+      int l;
 
       if (readbuf != NULL)
-       res = dcache_xfer_memory (ops, dcache, memaddr, readbuf, reg_len, 0);
+       l = dcache_xfer_memory (ops, dcache, memaddr, readbuf, reg_len, 0);
       else
        /* FIXME drow/2006-08-09: If we're going to preserve const
           correctness dcache_xfer_memory should take readbuf and
           writebuf.  */
-       res = dcache_xfer_memory (ops, dcache, memaddr, (void *) writebuf,
+       l = dcache_xfer_memory (ops, dcache, memaddr, (void *) writebuf,
                                  reg_len, 1);
-      if (res <= 0)
-       return -1;
+      if (l <= 0)
+       return TARGET_XFER_E_IO;
       else
-       return res;
+       {
+         *xfered_len = (ULONGEST) l;
+         return TARGET_XFER_OK;
+       }
     }
 
   /* If none of those methods found the memory we wanted, fall back
@@ -1591,14 +1617,19 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
      to_xfer_partial is enough; if it doesn't recognize an object
      it will call the to_xfer_partial of the next target down.
      But for memory this won't do.  Memory is the only target
-     object which can be read from more than one valid target.  */
-  res = raw_memory_xfer_partial (ops, readbuf, writebuf, memaddr, reg_len);
+     object which can be read from more than one valid target.
+     A core file, for instance, could have some of memory but
+     delegate other bits to the target below it.  So, we must
+     manually try all targets.  */
+
+  res = raw_memory_xfer_partial (ops, readbuf, writebuf, memaddr, reg_len,
+                                xfered_len);
 
   /* Make sure the cache gets updated no matter what - if we are writing
      to the stack.  Even if this write is not tagged as such, we still need
      to update the cache.  */
 
-  if (res > 0
+  if (res == TARGET_XFER_OK
       && inf != NULL
       && writebuf != NULL
       && target_dcache_init_p ()
@@ -1608,7 +1639,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
     {
       DCACHE *dcache = target_dcache_get ();
 
-      dcache_update (dcache, memaddr, (void *) writebuf, res);
+      dcache_update (dcache, memaddr, (void *) writebuf, reg_len);
     }
 
   /* If we still haven't got anything, return the last error.  We
@@ -1619,25 +1650,26 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
 /* Perform a partial memory transfer.  For docs see target.h,
    to_xfer_partial.  */
 
-static LONGEST
+static enum target_xfer_status
 memory_xfer_partial (struct target_ops *ops, enum target_object object,
-                    void *readbuf, const void *writebuf, ULONGEST memaddr,
-                    ULONGEST len)
+                    gdb_byte *readbuf, const gdb_byte *writebuf,
+                    ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
 {
-  int res;
+  enum target_xfer_status res;
 
   /* Zero length requests are ok and require no work.  */
   if (len == 0)
-    return 0;
+    return TARGET_XFER_EOF;
 
   /* Fill in READBUF with breakpoint shadows, or WRITEBUF with
      breakpoint insns, thus hiding out from higher layers whether
      there are software breakpoints inserted in the code stream.  */
   if (readbuf != NULL)
     {
-      res = memory_xfer_partial_1 (ops, object, readbuf, NULL, memaddr, len);
+      res = memory_xfer_partial_1 (ops, object, readbuf, NULL, memaddr, len,
+                                  xfered_len);
 
-      if (res > 0 && !show_memory_breakpoints)
+      if (res == TARGET_XFER_OK && !show_memory_breakpoints)
        breakpoint_xfer_memory (readbuf, NULL, NULL, memaddr, res);
     }
   else
@@ -1657,7 +1689,8 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object,
       memcpy (buf, writebuf, len);
 
       breakpoint_xfer_memory (NULL, buf, writebuf, memaddr, len);
-      res = memory_xfer_partial_1 (ops, object, NULL, buf, memaddr, len);
+      res = memory_xfer_partial_1 (ops, object, NULL, buf, memaddr, len,
+                                  xfered_len);
 
       do_cleanups (old_chain);
     }
@@ -1683,35 +1716,43 @@ make_show_memory_breakpoints_cleanup (int show)
 
 /* For docs see target.h, to_xfer_partial.  */
 
-LONGEST
+enum target_xfer_status
 target_xfer_partial (struct target_ops *ops,
                     enum target_object object, const char *annex,
                     gdb_byte *readbuf, const gdb_byte *writebuf,
-                    ULONGEST offset, ULONGEST len)
+                    ULONGEST offset, ULONGEST len,
+                    ULONGEST *xfered_len)
 {
-  LONGEST retval;
+  enum target_xfer_status retval;
 
   gdb_assert (ops->to_xfer_partial != NULL);
 
+  /* Transfer is done when LEN is zero.  */
+  if (len == 0)
+    return TARGET_XFER_EOF;
+
   if (writebuf && !may_write_memory)
     error (_("Writing to memory is not allowed (addr %s, len %s)"),
           core_addr_to_string_nz (offset), plongest (len));
 
+  *xfered_len = 0;
+
   /* If this is a memory transfer, let the memory-specific code
      have a look at it instead.  Memory transfers are more
      complicated.  */
   if (object == TARGET_OBJECT_MEMORY || object == TARGET_OBJECT_STACK_MEMORY
       || object == TARGET_OBJECT_CODE_MEMORY)
     retval = memory_xfer_partial (ops, object, readbuf,
-                                 writebuf, offset, len);
+                                 writebuf, offset, len, xfered_len);
   else if (object == TARGET_OBJECT_RAW_MEMORY)
     {
       /* Request the normal memory object from other layers.  */
-      retval = raw_memory_xfer_partial (ops, readbuf, writebuf, offset, len);
+      retval = raw_memory_xfer_partial (ops, readbuf, writebuf, offset, len,
+                                       xfered_len);
     }
   else
     retval = ops->to_xfer_partial (ops, object, annex, readbuf,
-                                  writebuf, offset, len);
+                                  writebuf, offset, len, xfered_len);
 
   if (targetdebug)
     {
@@ -1719,25 +1760,26 @@ target_xfer_partial (struct target_ops *ops,
 
       fprintf_unfiltered (gdb_stdlog,
                          "%s:target_xfer_partial "
-                         "(%d, %s, %s, %s, %s, %s) = %s",
+                         "(%d, %s, %s, %s, %s, %s) = %d, %s",
                          ops->to_shortname,
                          (int) object,
                          (annex ? annex : "(null)"),
                          host_address_to_string (readbuf),
                          host_address_to_string (writebuf),
                          core_addr_to_string_nz (offset),
-                         pulongest (len), plongest (retval));
+                         pulongest (len), retval,
+                         pulongest (*xfered_len));
 
       if (readbuf)
        myaddr = readbuf;
       if (writebuf)
        myaddr = writebuf;
-      if (retval > 0 && myaddr != NULL)
+      if (retval == TARGET_XFER_OK && myaddr != NULL)
        {
          int i;
 
          fputs_unfiltered (", bytes =", gdb_stdlog);
-         for (i = 0; i < retval; i++)
+         for (i = 0; i < *xfered_len; i++)
            {
              if ((((intptr_t) &(myaddr[i])) & 0xf) == 0)
                {
@@ -1755,12 +1797,19 @@ target_xfer_partial (struct target_ops *ops,
 
       fputc_unfiltered ('\n', gdb_stdlog);
     }
+
+  /* Check implementations of to_xfer_partial update *XFERED_LEN
+     properly.  Do assertion after printing debug messages, so that we
+     can find more clues on assertion failure from debugging messages.  */
+  if (retval == TARGET_XFER_OK || retval == TARGET_XFER_E_UNAVAILABLE)
+    gdb_assert (*xfered_len > 0);
+
   return retval;
 }
 
 /* Read LEN bytes of target memory at address MEMADDR, placing the
    results in GDB's memory at MYADDR.  Returns either 0 for success or
-   a target_xfer_error value if any error occurs.
+   TARGET_XFER_E_IO if any error occurs.
 
    If an error occurs, no guarantee is made about the contents of the data at
    MYADDR.  In particular, the caller should not depend upon partial reads
@@ -1829,7 +1878,7 @@ target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
 }
 
 /* Write LEN bytes from MYADDR to target memory at address MEMADDR.
-   Returns either 0 for success or a target_xfer_error value if any
+   Returns either 0 for success or TARGET_XFER_E_IO if any
    error occurs.  If an error occurs, no guarantee is made about how
    much data got written.  Callers that can deal with partial writes
    should call target_write.  */
@@ -1847,7 +1896,7 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
 }
 
 /* Write LEN bytes from MYADDR to target raw memory at address
-   MEMADDR.  Returns either 0 for success or a target_xfer_error value
+   MEMADDR.  Returns either 0 for success or TARGET_XFER_E_IO
    if any error occurs.  If an error occurs, no guarantee is made
    about how much data got written.  Callers that can deal with
    partial writes should call target_write.  */
@@ -1958,10 +2007,11 @@ show_trust_readonly (struct ui_file *file, int from_tty,
 
 /* More generic transfers.  */
 
-static LONGEST
+static enum target_xfer_status
 default_xfer_partial (struct target_ops *ops, enum target_object object,
                      const char *annex, gdb_byte *readbuf,
-                     const gdb_byte *writebuf, ULONGEST offset, ULONGEST len)
+                     const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+                     ULONGEST *xfered_len)
 {
   if (object == TARGET_OBJECT_MEMORY
       && ops->deprecated_xfer_memory != NULL)
@@ -1985,55 +2035,47 @@ default_xfer_partial (struct target_ops *ops, enum target_object object,
        xfered = ops->deprecated_xfer_memory (offset, readbuf, len, 
                                              0/*read*/, NULL, ops);
       if (xfered > 0)
-       return xfered;
+       {
+         *xfered_len = (ULONGEST) xfered;
+         return TARGET_XFER_E_IO;
+       }
       else if (xfered == 0 && errno == 0)
        /* "deprecated_xfer_memory" uses 0, cross checked against
            ERRNO as one indication of an error.  */
-       return 0;
+       return TARGET_XFER_EOF;
       else
-       return -1;
+       return TARGET_XFER_E_IO;
     }
-  else if (ops->beneath != NULL)
-    return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
-                                         readbuf, writebuf, offset, len);
   else
-    return -1;
-}
-
-/* The xfer_partial handler for the topmost target.  Unlike the default,
-   it does not need to handle memory specially; it just passes all
-   requests down the stack.  */
-
-static LONGEST
-current_xfer_partial (struct target_ops *ops, enum target_object object,
-                     const char *annex, gdb_byte *readbuf,
-                     const gdb_byte *writebuf, ULONGEST offset, ULONGEST len)
-{
-  if (ops->beneath != NULL)
-    return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
-                                         readbuf, writebuf, offset, len);
-  else
-    return -1;
+    {
+      gdb_assert (ops->beneath != NULL);
+      return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+                                           readbuf, writebuf, offset, len,
+                                           xfered_len);
+    }
 }
 
 /* Target vector read/write partial wrapper functions.  */
 
-static LONGEST
+static enum target_xfer_status
 target_read_partial (struct target_ops *ops,
                     enum target_object object,
                     const char *annex, gdb_byte *buf,
-                    ULONGEST offset, LONGEST len)
+                    ULONGEST offset, ULONGEST len,
+                    ULONGEST *xfered_len)
 {
-  return target_xfer_partial (ops, object, annex, buf, NULL, offset, len);
+  return target_xfer_partial (ops, object, annex, buf, NULL, offset, len,
+                             xfered_len);
 }
 
-static LONGEST
+static enum target_xfer_status
 target_write_partial (struct target_ops *ops,
                      enum target_object object,
                      const char *annex, const gdb_byte *buf,
-                     ULONGEST offset, LONGEST len)
+                     ULONGEST offset, LONGEST len, ULONGEST *xfered_len)
 {
-  return target_xfer_partial (ops, object, annex, NULL, buf, offset, len);
+  return target_xfer_partial (ops, object, annex, NULL, buf, offset, len,
+                             xfered_len);
 }
 
 /* Wrappers to perform the full transfer.  */
@@ -2050,17 +2092,25 @@ target_read (struct target_ops *ops,
 
   while (xfered < len)
     {
-      LONGEST xfer = target_read_partial (ops, object, annex,
-                                         (gdb_byte *) buf + xfered,
-                                         offset + xfered, len - xfered);
+      ULONGEST xfered_len;
+      enum target_xfer_status status;
+
+      status = target_read_partial (ops, object, annex,
+                                   (gdb_byte *) buf + xfered,
+                                   offset + xfered, len - xfered,
+                                   &xfered_len);
 
       /* Call an observer, notifying them of the xfer progress?  */
-      if (xfer == 0)
+      if (status == TARGET_XFER_EOF)
        return xfered;
-      if (xfer < 0)
+      else if (status == TARGET_XFER_OK)
+       {
+         xfered += xfered_len;
+         QUIT;
+       }
+      else
        return -1;
-      xfered += xfer;
-      QUIT;
+
     }
   return len;
 }
@@ -2096,6 +2146,7 @@ read_whatever_is_readable (struct target_ops *ops,
   ULONGEST current_end = end;
   int forward;
   memory_read_result_s r;
+  ULONGEST xfered_len;
 
   /* If we previously failed to read 1 byte, nothing can be done here.  */
   if (end - begin <= 1)
@@ -2108,13 +2159,14 @@ read_whatever_is_readable (struct target_ops *ops,
      if not.  This heuristic is meant to permit reading accessible memory
      at the boundary of accessible region.  */
   if (target_read_partial (ops, TARGET_OBJECT_MEMORY, NULL,
-                          buf, begin, 1) == 1)
+                          buf, begin, 1, &xfered_len) == TARGET_XFER_OK)
     {
       forward = 1;
       ++current_begin;
     }
   else if (target_read_partial (ops, TARGET_OBJECT_MEMORY, NULL,
-                               buf + (end-begin) - 1, end - 1, 1) == 1)
+                               buf + (end-begin) - 1, end - 1, 1,
+                               &xfered_len) == TARGET_XFER_OK)
     {
       forward = 0;
       --current_end;
@@ -2289,19 +2341,24 @@ target_write_with_progress (struct target_ops *ops,
 
   while (xfered < len)
     {
-      LONGEST xfer = target_write_partial (ops, object, annex,
-                                          (gdb_byte *) buf + xfered,
-                                          offset + xfered, len - xfered);
+      ULONGEST xfered_len;
+      enum target_xfer_status status;
 
-      if (xfer == 0)
+      status = target_write_partial (ops, object, annex,
+                                    (gdb_byte *) buf + xfered,
+                                    offset + xfered, len - xfered,
+                                    &xfered_len);
+
+      if (status == TARGET_XFER_EOF)
        return xfered;
-      if (xfer < 0)
+      if (TARGET_XFER_STATUS_ERROR_P (status))
        return -1;
 
+      gdb_assert (status == TARGET_XFER_OK);
       if (progress)
-       (*progress) (xfer, baton);
+       (*progress) (xfered_len, baton);
 
-      xfered += xfer;
+      xfered += xfered_len;
       QUIT;
     }
   return len;
@@ -2331,7 +2388,6 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object,
 {
   size_t buf_alloc, buf_pos;
   gdb_byte *buf;
-  LONGEST n;
 
   /* This function does not have a length parameter; it reads the
      entire OBJECT).  Also, it doesn't support objects fetched partly
@@ -2347,15 +2403,14 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object,
   buf_pos = 0;
   while (1)
     {
-      n = target_read_partial (ops, object, annex, &buf[buf_pos],
-                              buf_pos, buf_alloc - buf_pos - padding);
-      if (n < 0)
-       {
-         /* An error occurred.  */
-         xfree (buf);
-         return -1;
-       }
-      else if (n == 0)
+      ULONGEST xfered_len;
+      enum target_xfer_status status;
+
+      status = target_read_partial (ops, object, annex, &buf[buf_pos],
+                                   buf_pos, buf_alloc - buf_pos - padding,
+                                   &xfered_len);
+
+      if (status == TARGET_XFER_EOF)
        {
          /* Read all there was.  */
          if (buf_pos == 0)
@@ -2364,8 +2419,14 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object,
            *buf_p = buf;
          return buf_pos;
        }
+      else if (status != TARGET_XFER_OK)
+       {
+         /* An error occurred.  */
+         xfree (buf);
+         return TARGET_XFER_E_IO;
+       }
 
-      buf_pos += n;
+      buf_pos += xfered_len;
 
       /* If the buffer is filling up, expand it.  */
       if (buf_alloc < buf_pos * 2)
@@ -2455,20 +2516,6 @@ get_target_memory_unsigned (struct target_ops *ops, CORE_ADDR addr,
 
 /* See target.h.  */
 
-int
-forward_target_insert_breakpoint (struct target_ops *ops,
-                                 struct gdbarch *gdbarch,
-                                 struct bp_target_info *bp_tgt)
-{
-  for (; ops != NULL; ops = ops->beneath)
-    if (ops->to_insert_breakpoint != NULL)
-      return ops->to_insert_breakpoint (ops, gdbarch, bp_tgt);
-
-  return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
-}
-
-/* See target.h.  */
-
 int
 target_insert_breakpoint (struct gdbarch *gdbarch,
                          struct bp_target_info *bp_tgt)
@@ -2479,15 +2526,15 @@ target_insert_breakpoint (struct gdbarch *gdbarch,
       return 1;
     }
 
-  return forward_target_insert_breakpoint (&current_target, gdbarch, bp_tgt);
+  return current_target.to_insert_breakpoint (&current_target,
+                                             gdbarch, bp_tgt);
 }
 
 /* See target.h.  */
 
 int
-forward_target_remove_breakpoint (struct target_ops *ops,
-                                 struct gdbarch *gdbarch,
-                                 struct bp_target_info *bp_tgt)
+target_remove_breakpoint (struct gdbarch *gdbarch,
+                         struct bp_target_info *bp_tgt)
 {
   /* This is kind of a weird case to handle, but the permission might
      have been changed after breakpoints were inserted - in which case
@@ -2499,20 +2546,8 @@ forward_target_remove_breakpoint (struct target_ops *ops,
       return 1;
     }
 
-  for (; ops != NULL; ops = ops->beneath)
-    if (ops->to_remove_breakpoint != NULL)
-      return ops->to_remove_breakpoint (ops, gdbarch, bp_tgt);
-
-  return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
-}
-
-/* See target.h.  */
-
-int
-target_remove_breakpoint (struct gdbarch *gdbarch,
-                         struct bp_target_info *bp_tgt)
-{
-  return forward_target_remove_breakpoint (&current_target, gdbarch, bp_tgt);
+  return current_target.to_remove_breakpoint (&current_target,
+                                             gdbarch, bp_tgt);
 }
 
 static void
@@ -2692,34 +2727,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);
-
-         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);
-           }
+      char *status_string;
+      char *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 *
@@ -2744,7 +2771,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;
@@ -2757,26 +2784,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
@@ -2803,7 +2821,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;
        }
     }
@@ -2833,7 +2851,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;
        }
     }
@@ -3164,7 +3182,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;
 
@@ -3173,13 +3191,13 @@ find_default_can_async_p (void)
      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)
-    return (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;
 }
 
 static int
-find_default_is_async_p (void)
+find_default_is_async_p (struct target_ops *ignore)
 {
   struct target_ops *t;
 
@@ -3188,19 +3206,19 @@ find_default_is_async_p (void)
      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)
-    return (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;
 }
 
 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;
 }
 
@@ -3211,7 +3229,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;
 }
@@ -3249,13 +3267,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;
 }
 
@@ -3266,7 +3284,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;
 }
@@ -3354,7 +3372,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,
@@ -3382,7 +3400,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)
@@ -3412,7 +3430,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)
@@ -3440,7 +3458,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,
@@ -3465,7 +3483,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,
@@ -3491,7 +3509,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,
@@ -3628,7 +3646,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);
 }
@@ -3681,6 +3700,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!  */
 
@@ -3737,7 +3770,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;
@@ -3745,7 +3779,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;
@@ -3753,7 +3788,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;
@@ -3761,7 +3796,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 ();
 }
@@ -3779,8 +3814,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;
@@ -3790,17 +3823,15 @@ 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 = 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);
 }
 \f
 static void
@@ -3819,7 +3850,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");
@@ -3896,13 +3927,13 @@ target_stop (ptid_t ptid)
       return;
     }
 
-  (*current_target.to_stop) (ptid);
+  (*current_target.to_stop) (&current_target, 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);
 }
@@ -4017,20 +4048,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
@@ -4165,20 +4187,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)
 {
@@ -4228,18 +4236,19 @@ target_teardown_btrace (struct btrace_target_info *btinfo)
 
 /* See target.h.  */
 
-VEC (btrace_block_s) *
-target_read_btrace (struct btrace_target_info *btinfo,
+enum btrace_error
+target_read_btrace (VEC (btrace_block_s) **btrace,
+                   struct btrace_target_info *btinfo,
                    enum btrace_read_type type)
 {
   struct target_ops *t;
 
   for (t = current_target.beneath; t != NULL; t = t->beneath)
     if (t->to_read_btrace != NULL)
-      return t->to_read_btrace (btinfo, type);
+      return t->to_read_btrace (btrace, btinfo, type);
 
   tcomplain ();
-  return NULL;
+  return BTRACE_ERR_NOT_SUPPORTED;
 }
 
 /* See target.h.  */
@@ -4527,6 +4536,27 @@ target_get_tailcall_unwinder (void)
   return NULL;
 }
 
+/* See target.h.  */
+
+CORE_ADDR
+forward_target_decr_pc_after_break (struct target_ops *ops,
+                                   struct gdbarch *gdbarch)
+{
+  for (; ops != NULL; ops = ops->beneath)
+    if (ops->to_decr_pc_after_break != NULL)
+      return ops->to_decr_pc_after_break (ops, gdbarch);
+
+  return gdbarch_decr_pc_after_break (gdbarch);
+}
+
+/* See target.h.  */
+
+CORE_ADDR
+target_decr_pc_after_break (struct gdbarch *gdbarch)
+{
+  return forward_target_decr_pc_after_break (current_target.beneath, gdbarch);
+}
+
 static int
 deprecated_debug_xfer_memory (CORE_ADDR memaddr, bfd_byte *myaddr, int len,
                              int write, struct mem_attrib *attrib,
@@ -4582,7 +4612,7 @@ debug_to_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 {
   int retval;
 
-  retval = forward_target_insert_breakpoint (&debug_target, gdbarch, bp_tgt);
+  retval = debug_target.to_insert_breakpoint (&debug_target, gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
                      "target_insert_breakpoint (%s, xxx) = %ld\n",
@@ -4597,7 +4627,7 @@ debug_to_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 {
   int retval;
 
-  retval = forward_target_remove_breakpoint (&debug_target, gdbarch, bp_tgt);
+  retval = debug_target.to_remove_breakpoint (&debug_target, gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
                      "target_remove_breakpoint (%s, xxx) = %ld\n",
@@ -4607,11 +4637,13 @@ debug_to_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
 }
 
 static int
-debug_to_can_use_hw_breakpoint (int type, int cnt, int from_tty)
+debug_to_can_use_hw_breakpoint (struct target_ops *self,
+                               int type, int cnt, int from_tty)
 {
   int retval;
 
-  retval = debug_target.to_can_use_hw_breakpoint (type, cnt, from_tty);
+  retval = debug_target.to_can_use_hw_breakpoint (&debug_target,
+                                                 type, cnt, from_tty);
 
   fprintf_unfiltered (gdb_stdlog,
                      "target_can_use_hw_breakpoint (%ld, %ld, %ld) = %ld\n",
@@ -4623,11 +4655,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",
@@ -4637,12 +4671,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,
@@ -4654,11 +4690,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",
@@ -4698,12 +4734,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",
@@ -4713,12 +4751,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",
@@ -4728,12 +4768,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",
@@ -4743,12 +4785,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",
@@ -4758,77 +4802,78 @@ debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type,
 }
 
 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);
@@ -4837,11 +4882,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);
@@ -4850,11 +4895,11 @@ debug_to_remove_fork_catchpoint (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);
@@ -4863,11 +4908,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);
@@ -4876,11 +4921,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);
@@ -4889,11 +4934,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);
@@ -4902,11 +4947,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);
@@ -4915,11 +4962,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);
 
@@ -4942,28 +4989,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);
@@ -5030,10 +5077,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);
 }
This page took 0.06536 seconds and 4 git commands to generate.