2005-02-10 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / target.c
index 18b5a77e1b903b6edda8d68953ed0587df4563c4..3499470ef9be6f1a5e125e9ea4a383f6ccba5224 100644 (file)
@@ -41,8 +41,6 @@
 
 static void target_info (char *, int);
 
-static void maybe_kill_then_create_inferior (char *, char *, char **);
-
 static void maybe_kill_then_attach (char *, int);
 
 static void kill_or_be_killed (int);
@@ -88,6 +86,8 @@ static int target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
 
 static void init_dummy_target (void);
 
+static struct target_ops debug_target;
+
 static void debug_to_open (char *, int);
 
 static void debug_to_close (int);
@@ -108,8 +108,9 @@ static void debug_to_store_registers (int);
 
 static void debug_to_prepare_to_store (void);
 
-static int debug_to_xfer_memory (CORE_ADDR, char *, int, int,
-                                struct mem_attrib *, struct target_ops *);
+static int deprecated_debug_xfer_memory (CORE_ADDR, char *, int, int,
+                                        struct mem_attrib *,
+                                        struct target_ops *);
 
 static void debug_to_files_info (struct target_ops *);
 
@@ -129,7 +130,7 @@ static int debug_to_remove_watchpoint (CORE_ADDR, int, int);
 
 static int debug_to_stopped_by_watchpoint (void);
 
-static CORE_ADDR debug_to_stopped_data_address (void);
+static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
 
 static int debug_to_region_size_ok_for_hw_watchpoint (int);
 
@@ -151,8 +152,6 @@ static void debug_to_load (char *, int);
 
 static int debug_to_lookup_symbol (char *, CORE_ADDR *);
 
-static void debug_to_create_inferior (char *, char *, char **);
-
 static void debug_to_mourn_inferior (void);
 
 static int debug_to_can_run (void);
@@ -163,6 +162,12 @@ static int debug_to_thread_alive (ptid_t);
 
 static void debug_to_stop (void);
 
+/* NOTE: cagney/2004-09-29: Many targets reference this variable in
+   wierd and mysterious ways.  Putting the variable here lets those
+   wierd and mysterious ways keep building while they are being
+   converted to the inferior inheritance structure.  */
+struct target_ops deprecated_child_ops;
+
 /* Pointer to array of target architecture structures; the size of the
    array; the current index into the array; the allocated size of the 
    array.  */
@@ -272,14 +277,14 @@ nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write,
 static void
 tcomplain (void)
 {
-  error ("You can't do that when your target is `%s'",
+  error (_("You can't do that when your target is `%s'"),
         current_target.to_shortname);
 }
 
 void
 noprocess (void)
 {
-  error ("You can't do that without a process to debug.");
+  error (_("You can't do that without a process to debug."));
 }
 
 static int
@@ -294,7 +299,7 @@ nosupport_runtime (void)
   if (ptid_equal (inferior_ptid, null_ptid))
     noprocess ();
   else
-    error ("No run-time support for this");
+    error (_("No run-time support for this"));
 }
 
 
@@ -320,12 +325,12 @@ kill_or_be_killed (int from_tty)
        {
          target_kill ();
          if (target_has_execution)
-           error ("Killing the program did not help.");
+           error (_("Killing the program did not help."));
          return;
        }
       else
        {
-         error ("Program not killed.");
+         error (_("Program not killed."));
        }
     }
   tcomplain ();
@@ -339,10 +344,11 @@ maybe_kill_then_attach (char *args, int from_tty)
 }
 
 static void
-maybe_kill_then_create_inferior (char *exec, char *args, char **env)
+maybe_kill_then_create_inferior (char *exec, char *args, char **env,
+                                int from_tty)
 {
   kill_or_be_killed (0);
-  target_create_inferior (exec, args, env);
+  target_create_inferior (exec, args, env, from_tty);
 }
 
 /* Go through the target stack from top to bottom, copying over zero
@@ -382,11 +388,10 @@ update_current_target (void)
       INHERIT (to_disconnect, t);
       INHERIT (to_resume, t);
       INHERIT (to_wait, t);
-      INHERIT (to_post_wait, t);
       INHERIT (to_fetch_registers, t);
       INHERIT (to_store_registers, t);
       INHERIT (to_prepare_to_store, t);
-      INHERIT (to_xfer_memory, t);
+      INHERIT (deprecated_xfer_memory, t);
       INHERIT (to_files_info, t);
       INHERIT (to_insert_breakpoint, t);
       INHERIT (to_remove_breakpoint, t);
@@ -484,9 +489,6 @@ update_current_target (void)
   de_fault (to_wait, 
            (ptid_t (*) (ptid_t, struct target_waitstatus *)) 
            noprocess);
-  de_fault (to_post_wait, 
-           (void (*) (ptid_t, int)) 
-           target_ignore);
   de_fault (to_fetch_registers, 
            (void (*) (int)) 
            target_ignore);
@@ -496,7 +498,7 @@ update_current_target (void)
   de_fault (to_prepare_to_store, 
            (void (*) (void)) 
            noprocess);
-  de_fault (to_xfer_memory, 
+  de_fault (deprecated_xfer_memory, 
            (int (*) (CORE_ADDR, char *, int, int, struct mem_attrib *, struct target_ops *)) 
            nomemory);
   de_fault (to_files_info, 
@@ -525,7 +527,7 @@ update_current_target (void)
            (int (*) (void))
            return_zero);
   de_fault (to_stopped_data_address,
-           (CORE_ADDR (*) (void))
+           (int (*) (struct target_ops *, CORE_ADDR *))
            return_zero);
   de_fault (to_region_size_ok_for_hw_watchpoint,
            default_region_size_ok_for_hw_watchpoint);
@@ -564,13 +566,13 @@ update_current_target (void)
            (void (*) (int)) 
            target_ignore);
   de_fault (to_insert_fork_catchpoint, 
-           (int (*) (int)) 
+           (void (*) (int)) 
            tcomplain);
   de_fault (to_remove_fork_catchpoint, 
            (int (*) (int)) 
            tcomplain);
   de_fault (to_insert_vfork_catchpoint, 
-           (int (*) (int)) 
+           (void (*) (int)) 
            tcomplain);
   de_fault (to_remove_vfork_catchpoint, 
            (int (*) (int)) 
@@ -579,7 +581,7 @@ update_current_target (void)
            (int (*) (int)) 
            target_ignore);
   de_fault (to_insert_exec_catchpoint, 
-           (int (*) (int)) 
+           (void (*) (int)) 
            tcomplain);
   de_fault (to_remove_exec_catchpoint, 
            (int (*) (int)) 
@@ -782,7 +784,7 @@ target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
       tlen = MIN (len, 4 - (memaddr & 3));
       offset = memaddr & 3;
 
-      errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
+      errcode = target_read_memory (memaddr & ~3, buf, 4);
       if (errcode != 0)
        {
          /* The transfer request might have crossed the boundary to an
@@ -790,7 +792,7 @@ target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
             a single byte.  */
          tlen = 1;
          offset = 0;
-         errcode = target_xfer_memory (memaddr, buf, 1, 0);
+         errcode = target_read_memory (memaddr, buf, 1);
          if (errcode != 0)
            goto done;
        }
@@ -841,6 +843,147 @@ target_section_by_addr (struct target_ops *target, CORE_ADDR addr)
   return NULL;
 }
 
+/* Return non-zero when the target vector has supplied an xfer_partial
+   method and it, rather than xfer_memory, should be used.  */
+static int
+target_xfer_partial_p (void)
+{
+  return (target_stack != NULL
+         && target_stack->to_xfer_partial != default_xfer_partial);
+}
+
+static LONGEST
+target_xfer_partial (struct target_ops *ops,
+                    enum target_object object, const char *annex,
+                    void *readbuf, const void *writebuf,
+                    ULONGEST offset, LONGEST len)
+{
+  LONGEST retval;
+
+  gdb_assert (ops->to_xfer_partial != NULL);
+  retval = ops->to_xfer_partial (ops, object, annex, readbuf, writebuf,
+                                offset, len);
+  if (targetdebug)
+    {
+      const unsigned char *myaddr = NULL;
+
+      fprintf_unfiltered (gdb_stdlog,
+                         "%s:target_xfer_partial (%d, %s, 0x%lx,  0x%lx,  0x%s, %s) = %s",
+                         ops->to_shortname,
+                         (int) object,
+                         (annex ? annex : "(null)"),
+                         (long) readbuf, (long) writebuf,
+                         paddr_nz (offset), paddr_d (len), paddr_d (retval));
+
+      if (readbuf)
+       myaddr = readbuf;
+      if (writebuf)
+       myaddr = writebuf;
+      if (retval > 0 && myaddr != NULL)
+       {
+         int i;
+         
+         fputs_unfiltered (", bytes =", gdb_stdlog);
+         for (i = 0; i < retval; i++)
+           {
+             if ((((long) &(myaddr[i])) & 0xf) == 0)
+               {
+                 if (targetdebug < 2 && i > 0)
+                   {
+                     fprintf_unfiltered (gdb_stdlog, " ...");
+                     break;
+                   }
+                 fprintf_unfiltered (gdb_stdlog, "\n");
+               }
+             
+             fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
+           }
+       }
+      
+      fputc_unfiltered ('\n', gdb_stdlog);
+    }
+  return retval;
+}
+
+/* Attempt a transfer all LEN bytes starting at OFFSET between the
+   inferior's KIND:ANNEX space and GDB's READBUF/WRITEBUF buffer.  If
+   the transfer succeeds, return zero, otherwize the host ERRNO is
+   returned.
+
+   The inferior is formed from several layers.  In the case of
+   corefiles, inf-corefile is layered above inf-exec and a request for
+   text (corefiles do not include text pages) will be first sent to
+   the core-stratum, fail, and then sent to the object-file where it
+   will succeed.
+
+   NOTE: cagney/2004-09-30:
+
+   The old code tried to use four separate mechanisms for mapping an
+   object:offset:len tuple onto an inferior and its address space: the
+   target stack; the inferior's TO_SECTIONS; solib's SO_LIST;
+   overlays.
+
+   This is stupid.
+
+   The code below is instead using a single mechanism (currently
+   strata).  If that mechanism proves insufficient then re-factor it
+   implementing another singluar mechanism (for instance, a generic
+   object:annex onto inferior:object:annex say).  */
+
+static LONGEST
+xfer_using_stratum (enum target_object object, const char *annex,
+                   ULONGEST offset, LONGEST len, void *readbuf,
+                   const void *writebuf)
+{
+  LONGEST xfered;
+  struct target_ops *target;
+
+  /* Always successful.  */
+  if (len == 0)
+    return 0;
+  /* Never successful.  */
+  if (target_stack == NULL)
+    return EIO;
+
+  target = target_stack;
+  while (1)
+    {
+      xfered = target_xfer_partial (target, object, annex,
+                                   readbuf, writebuf, offset, len);
+      if (xfered > 0)
+       {
+         /* The partial xfer succeeded, update the counts, check that
+            the xfer hasn't finished and if it hasn't set things up
+            for the next round.  */
+         len -= xfered;
+         if (len <= 0)
+           return 0;
+         offset += xfered;
+         if (readbuf != NULL)
+           readbuf = (bfd_byte *) readbuf + xfered;
+         if (writebuf != NULL)
+           writebuf = (bfd_byte *) writebuf + xfered;
+         target = target_stack;
+       }
+      else if (xfered < 0)
+       {
+         /* Something totally screwed up, abandon the attempt to
+            xfer.  */
+         if (errno)
+           return errno;
+         else
+           return EIO;
+       }
+      else
+       {
+         /* This "stratum" didn't work, try the next one down.  */
+         target = target->beneath;
+         if (target == NULL)
+           return EIO;
+       }
+    }
+}
+
 /* Read LEN bytes of target memory at address MEMADDR, placing the results in
    GDB's memory at MYADDR.  Returns either 0 for success or an errno value
    if any error occurs.
@@ -852,16 +995,41 @@ target_section_by_addr (struct target_ops *target, CORE_ADDR addr)
    deal with partial reads should call target_read_memory_partial. */
 
 int
-target_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
+target_read_memory (CORE_ADDR memaddr, bfd_byte *myaddr, int len)
+{
+  if (target_xfer_partial_p ())
+    return xfer_using_stratum (TARGET_OBJECT_MEMORY, NULL,
+                              memaddr, len, myaddr, NULL);
+  else
+    return target_xfer_memory (memaddr, myaddr, len, 0);
+}
+
+int
+target_write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
 {
-  return target_xfer_memory (memaddr, myaddr, len, 0);
+  bfd_byte *bytes = alloca (len);
+  memcpy (bytes, myaddr, len);
+  if (target_xfer_partial_p ())
+    return xfer_using_stratum (TARGET_OBJECT_MEMORY, NULL,
+                              memaddr, len, NULL, bytes);
+  else
+    return target_xfer_memory (memaddr, bytes, len, 1);
 }
 
+#ifndef target_stopped_data_address_p
 int
-target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
+target_stopped_data_address_p (struct target_ops *target)
 {
-  return target_xfer_memory (memaddr, myaddr, len, 1);
+  if (target->to_stopped_data_address
+      == (int (*) (struct target_ops *, CORE_ADDR *)) return_zero)
+    return 0;
+  if (target->to_stopped_data_address == debug_to_stopped_data_address
+      && (debug_target.to_stopped_data_address
+         == (int (*) (struct target_ops *, CORE_ADDR *)) return_zero))
+    return 0;
+  return 1;
 }
+#endif
 
 static int trust_readonly = 0;
 
@@ -882,8 +1050,8 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
   if (len == 0)
     return 0;
 
-  /* to_xfer_memory is not guaranteed to set errno, even when it returns
-     0.  */
+  /* deprecated_xfer_memory is not guaranteed to set errno, even when
+     it returns 0.  */
   errno = 0;
 
   if (!write && trust_readonly)
@@ -900,7 +1068,7 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
     }
 
   /* The quick case is that the top target can handle the transfer.  */
-  res = current_target.to_xfer_memory
+  res = current_target.deprecated_xfer_memory
     (memaddr, myaddr, len, write, attrib, &current_target);
 
   /* If res <= 0 then we call it again in the loop.  Ah well. */
@@ -911,7 +1079,7 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
          if (!t->to_has_memory)
            continue;
 
-         res = t->to_xfer_memory (memaddr, myaddr, len, write, attrib, t);
+         res = t->deprecated_xfer_memory (memaddr, myaddr, len, write, attrib, t);
          if (res > 0)
            break;              /* Handled all or part of xfer */
          if (t->to_has_all_memory)
@@ -1066,13 +1234,21 @@ target_xfer_memory_partial (CORE_ADDR memaddr, char *myaddr, int len,
 int
 target_read_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
 {
-  return target_xfer_memory_partial (memaddr, buf, len, 0, err);
+  if (target_xfer_partial_p ())
+    return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL,
+                               buf, NULL, memaddr, len);
+  else
+    return target_xfer_memory_partial (memaddr, buf, len, 0, err);
 }
 
 int
 target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
 {
-  return target_xfer_memory_partial (memaddr, buf, len, 1, err);
+  if (target_xfer_partial_p ())
+    return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL,
+                               NULL, buf, memaddr, len);
+  else
+    return target_xfer_memory_partial (memaddr, buf, len, 1, err);
 }
 
 /* More generic transfers.  */
@@ -1083,9 +1259,9 @@ default_xfer_partial (struct target_ops *ops, enum target_object object,
                      const void *writebuf, ULONGEST offset, LONGEST len)
 {
   if (object == TARGET_OBJECT_MEMORY
-      && ops->to_xfer_memory != NULL)
-    /* If available, fall back to the target's "to_xfer_memory"
-       method.  */
+      && ops->deprecated_xfer_memory != NULL)
+    /* If available, fall back to the target's
+       "deprecated_xfer_memory" method.  */
     {
       int xfered = -1;
       errno = 0;
@@ -1094,25 +1270,25 @@ default_xfer_partial (struct target_ops *ops, enum target_object object,
          void *buffer = xmalloc (len);
          struct cleanup *cleanup = make_cleanup (xfree, buffer);
          memcpy (buffer, writebuf, len);
-         xfered = ops->to_xfer_memory (offset, buffer, len, 1/*write*/, NULL,
-                                       ops);
+         xfered = ops->deprecated_xfer_memory (offset, buffer, len,
+                                               1/*write*/, NULL, ops);
          do_cleanups (cleanup);
        }
       if (readbuf != NULL)
-       xfered = ops->to_xfer_memory (offset, readbuf, len, 0/*read*/, NULL,
-                                     ops);
+       xfered = ops->deprecated_xfer_memory (offset, readbuf, len, 0/*read*/,
+                                             NULL, ops);
       if (xfered > 0)
        return xfered;
       else if (xfered == 0 && errno == 0)
-       /* "to_xfer_memory" uses 0, cross checked against ERRNO as one
-           indication of an error.  */
+       /* "deprecated_xfer_memory" uses 0, cross checked against
+           ERRNO as one indication of an error.  */
        return 0;
       else
        return -1;
     }
   else if (ops->beneath != NULL)
-    return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
-                                         readbuf, writebuf, offset, len);
+    return target_xfer_partial (ops->beneath, object, annex,
+                               readbuf, writebuf, offset, len);
   else
     return -1;
 }
@@ -1129,8 +1305,7 @@ target_read_partial (struct target_ops *ops,
                     const char *annex, void *buf,
                     ULONGEST offset, LONGEST len)
 {
-  gdb_assert (ops->to_xfer_partial != NULL);
-  return ops->to_xfer_partial (ops, object, annex, buf, NULL, offset, len);
+  return target_xfer_partial (ops, object, annex, buf, NULL, offset, len);
 }
 
 LONGEST
@@ -1139,8 +1314,7 @@ target_write_partial (struct target_ops *ops,
                      const char *annex, const void *buf,
                      ULONGEST offset, LONGEST len)
 {
-  gdb_assert (ops->to_xfer_partial != NULL);
-  return ops->to_xfer_partial (ops, object, annex, NULL, buf, offset, len);
+  return target_xfer_partial (ops, object, annex, NULL, buf, offset, len);
 }
 
 /* Wrappers to perform the full transfer.  */
@@ -1219,11 +1393,6 @@ target_info (char *args, int from_tty)
   if (symfile_objfile != NULL)
     printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
 
-#ifdef FILES_INFO_HOOK
-  if (FILES_INFO_HOOK ())
-    return;
-#endif
-
   for (t = target_stack; t != NULL; t = t->beneath)
     {
       if (!t->to_has_memory)
@@ -1253,7 +1422,7 @@ target_preopen (int from_tty)
           || query ("A program is being debugged already.  Kill it? "))
        target_kill ();
       else
-       error ("Program not killed.");
+       error (_("Program not killed."));
     }
 
   /* Calling target_kill may remove the target from the stack.  But if
@@ -1268,20 +1437,12 @@ target_preopen (int from_tty)
 void
 target_detach (char *args, int from_tty)
 {
-  /* Handle any optimized stores to the inferior.  */
-#ifdef DO_DEFERRED_STORES
-  DO_DEFERRED_STORES;
-#endif
   (current_target.to_detach) (args, from_tty);
 }
 
 void
 target_disconnect (char *args, int from_tty)
 {
-  /* Handle any optimized stores to the inferior.  */
-#ifdef DO_DEFERRED_STORES
-  DO_DEFERRED_STORES;
-#endif
   (current_target.to_disconnect) (args, from_tty);
 }
 
@@ -1292,7 +1453,7 @@ target_link (char *modname, CORE_ADDR *t_reloc)
     {
       (current_target.to_lookup_symbol) (modname, t_reloc);
       if (*t_reloc == 0)
-       error ("Unable to link to %s and get relocation in rombug", modname);
+       error (_("Unable to link to %s and get relocation in rombug"), modname);
     }
   else
     *t_reloc = (CORE_ADDR) -1;
@@ -1332,7 +1493,7 @@ find_default_run_target (char *do_mesg)
     }
 
   if (count != 1)
-    error ("Don't know how to %s.  Try \"help target\".", do_mesg);
+    error (_("Don't know how to %s.  Try \"help target\"."), do_mesg);
 
   return runable;
 }
@@ -1348,19 +1509,20 @@ find_default_attach (char *args, int from_tty)
 }
 
 void
-find_default_create_inferior (char *exec_file, char *allargs, char **env)
+find_default_create_inferior (char *exec_file, char *allargs, char **env,
+                             int from_tty)
 {
   struct target_ops *t;
 
   t = find_default_run_target ("run");
-  (t->to_create_inferior) (exec_file, allargs, env);
+  (t->to_create_inferior) (exec_file, allargs, env, from_tty);
   return;
 }
 
 static int
 default_region_size_ok_for_hw_watchpoint (int byte_count)
 {
-  return (byte_count <= DEPRECATED_REGISTER_SIZE);
+  return (byte_count <= TYPE_LENGTH (builtin_type_void_data_ptr));
 }
 
 static int
@@ -1425,6 +1587,13 @@ target_resize_to_sections (struct target_ops *target, int num_added)
              (*t)->to_sections_end = target->to_sections_end;
            }
        }
+      /* There is a flattened view of the target stack in current_target,
+        so its to_sections pointer might also need updating. */
+      if (current_target.to_sections == old_value)
+       {
+         current_target.to_sections = target->to_sections;
+         current_target.to_sections_end = target->to_sections_end;
+       }
     }
   
   return old_count;
@@ -1536,11 +1705,6 @@ generic_mourn_inferior (void)
   breakpoint_init_inferior (inf_exited);
   registers_changed ();
 
-#ifdef CLEAR_DEFERRED_STORES
-  /* Delete any pending stores to the inferior... */
-  CLEAR_DEFERRED_STORES;
-#endif
-
   reopen_exec_file ();
   reinit_frame_cache ();
 
@@ -1551,8 +1715,8 @@ generic_mourn_inferior (void)
   if (!show_breakpoint_hit_counts)
     breakpoint_clear_ignore_counts ();
 
-  if (detach_hook)
-    detach_hook ();
+  if (deprecated_detach_hook)
+    deprecated_detach_hook ();
 }
 \f
 /* Helper function for child_wait and the Lynx derivatives of child_wait.
@@ -1604,14 +1768,14 @@ normal_pid_to_str (ptid_t ptid)
 /* Error-catcher for target_find_memory_regions */
 static int dummy_find_memory_regions (int (*ignore1) (), void *ignore2)
 {
-  error ("No target.");
+  error (_("No target."));
   return 0;
 }
 
 /* Error-catcher for target_make_corefile_notes */
 static char * dummy_make_corefile_notes (bfd *ignore1, int *ignore2)
 {
-  error ("No target.");
+  error (_("No target."));
   return NULL;
 }
 
@@ -1634,9 +1798,6 @@ init_dummy_target (void)
   dummy_target.to_magic = OPS_MAGIC;
 }
 \f
-
-static struct target_ops debug_target;
-
 static void
 debug_to_open (char *args, int from_tty)
 {
@@ -1753,15 +1914,6 @@ debug_to_wait (ptid_t ptid, struct target_waitstatus *status)
   return retval;
 }
 
-static void
-debug_to_post_wait (ptid_t ptid, int status)
-{
-  debug_target.to_post_wait (ptid, status);
-
-  fprintf_unfiltered (gdb_stdlog, "target_post_wait (%d, %d)\n",
-                     PIDGET (ptid), status);
-}
-
 static void
 debug_print_register (const char * func, int regno)
 {
@@ -1777,11 +1929,11 @@ debug_print_register (const char * func, int regno)
       unsigned char buf[MAX_REGISTER_SIZE];
       deprecated_read_register_gen (regno, buf);
       fprintf_unfiltered (gdb_stdlog, " = ");
-      for (i = 0; i < DEPRECATED_REGISTER_RAW_SIZE (regno); i++)
+      for (i = 0; i < register_size (current_gdbarch, regno); i++)
        {
          fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
        }
-      if (DEPRECATED_REGISTER_RAW_SIZE (regno) <= sizeof (LONGEST))
+      if (register_size (current_gdbarch, regno) <= sizeof (LONGEST))
        {
          fprintf_unfiltered (gdb_stdlog, " 0x%s %s",
                              paddr_nz (read_register (regno)),
@@ -1815,22 +1967,20 @@ debug_to_prepare_to_store (void)
 }
 
 static int
-debug_to_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
-                     struct mem_attrib *attrib,
-                     struct target_ops *target)
+deprecated_debug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
+                             int write, struct mem_attrib *attrib,
+                             struct target_ops *target)
 {
   int retval;
 
-  retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write,
-                                       attrib, target);
+  retval = debug_target.deprecated_xfer_memory (memaddr, myaddr, len, write,
+                                               attrib, target);
 
   fprintf_unfiltered (gdb_stdlog,
                      "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
                      (unsigned int) memaddr,   /* possable truncate long long */
                      len, write ? "write" : "read", retval);
 
-
-
   if (retval > 0)
     {
       int i;
@@ -1839,7 +1989,15 @@ debug_to_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
       for (i = 0; i < retval; i++)
        {
          if ((((long) &(myaddr[i])) & 0xf) == 0)
-           fprintf_unfiltered (gdb_stdlog, "\n");
+           {
+             if (targetdebug < 2 && i > 0)
+               {
+                 fprintf_unfiltered (gdb_stdlog, " ...");
+                 break;
+               }
+             fprintf_unfiltered (gdb_stdlog, "\n");
+           }
+         
          fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
        }
     }
@@ -1928,16 +2086,17 @@ debug_to_stopped_by_watchpoint (void)
   return retval;
 }
 
-static CORE_ADDR
-debug_to_stopped_data_address (void)
+static int
+debug_to_stopped_data_address (struct target_ops *target, CORE_ADDR *addr)
 {
-  CORE_ADDR retval;
+  int retval;
 
-  retval = debug_target.to_stopped_data_address ();
+  retval = debug_target.to_stopped_data_address (target, addr);
 
   fprintf_unfiltered (gdb_stdlog,
-                     "target_stopped_data_address () = 0x%lx\n",
-                     (unsigned long) retval);
+                     "target_stopped_data_address ([0x%lx]) = %ld\n",
+                     (unsigned long)*addr,
+                     (unsigned long)retval);
   return retval;
 }
 
@@ -2073,12 +2232,13 @@ debug_to_lookup_symbol (char *name, CORE_ADDR *addrp)
 }
 
 static void
-debug_to_create_inferior (char *exec_file, char *args, char **env)
+debug_to_create_inferior (char *exec_file, char *args, char **env,
+                         int from_tty)
 {
-  debug_target.to_create_inferior (exec_file, args, env);
+  debug_target.to_create_inferior (exec_file, args, env, from_tty);
 
-  fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx)\n",
-                     exec_file, args);
+  fprintf_unfiltered (gdb_stdlog, "target_create_inferior (%s, %s, xxx, %d)\n",
+                     exec_file, args, from_tty);
 }
 
 static void
@@ -2099,17 +2259,13 @@ debug_to_acknowledge_created_inferior (int pid)
                      pid);
 }
 
-static int
+static void
 debug_to_insert_fork_catchpoint (int pid)
 {
-  int retval;
-
-  retval = debug_target.to_insert_fork_catchpoint (pid);
+  debug_target.to_insert_fork_catchpoint (pid);
 
-  fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
-                     pid, retval);
-
-  return retval;
+  fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d)\n",
+                     pid);
 }
 
 static int
@@ -2125,17 +2281,13 @@ debug_to_remove_fork_catchpoint (int pid)
   return retval;
 }
 
-static int
+static void
 debug_to_insert_vfork_catchpoint (int pid)
 {
-  int retval;
+  debug_target.to_insert_vfork_catchpoint (pid);
 
-  retval = debug_target.to_insert_vfork_catchpoint (pid);
-
-  fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)= %d\n",
-                     pid, retval);
-
-  return retval;
+  fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)\n",
+                     pid);
 }
 
 static int
@@ -2162,17 +2314,13 @@ debug_to_follow_fork (int follow_child)
   return retval;
 }
 
-static int
+static void
 debug_to_insert_exec_catchpoint (int pid)
 {
-  int retval;
+  debug_target.to_insert_exec_catchpoint (pid);
 
-  retval = debug_target.to_insert_exec_catchpoint (pid);
-
-  fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
-                     pid, retval);
-
-  return retval;
+  fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d)\n",
+                     pid);
 }
 
 static int
@@ -2273,25 +2421,6 @@ debug_to_stop (void)
   fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
 }
 
-static LONGEST
-debug_to_xfer_partial (struct target_ops *ops, enum target_object object,
-                      const char *annex, void *readbuf, const void *writebuf,
-                      ULONGEST offset, LONGEST len)
-{
-  LONGEST retval;
-
-  retval = debug_target.to_xfer_partial (&debug_target, object, annex,
-                                        readbuf, writebuf, offset, len);
-
-  fprintf_unfiltered (gdb_stdlog,
-                     "target_xfer_partial (%d, %s, 0x%lx,  0x%lx,  0x%s, %s) = %s\n",
-                     (int) object, (annex ? annex : "(null)"),
-                     (long) readbuf, (long) writebuf, paddr_nz (offset),
-                     paddr_d (len), paddr_d (retval));
-
-  return retval;
-}
-
 static void
 debug_to_rcmd (char *command,
               struct ui_file *outbuf)
@@ -2346,11 +2475,10 @@ setup_target_debug (void)
   current_target.to_disconnect = debug_to_disconnect;
   current_target.to_resume = debug_to_resume;
   current_target.to_wait = debug_to_wait;
-  current_target.to_post_wait = debug_to_post_wait;
   current_target.to_fetch_registers = debug_to_fetch_registers;
   current_target.to_store_registers = debug_to_store_registers;
   current_target.to_prepare_to_store = debug_to_prepare_to_store;
-  current_target.to_xfer_memory = debug_to_xfer_memory;
+  current_target.deprecated_xfer_memory = deprecated_debug_xfer_memory;
   current_target.to_files_info = debug_to_files_info;
   current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
   current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
@@ -2389,7 +2517,6 @@ setup_target_debug (void)
   current_target.to_thread_alive = debug_to_thread_alive;
   current_target.to_find_new_threads = debug_to_find_new_threads;
   current_target.to_stop = debug_to_stop;
-  current_target.to_xfer_partial = debug_to_xfer_partial;
   current_target.to_rcmd = debug_to_rcmd;
   current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
   current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
@@ -2412,9 +2539,7 @@ do_monitor_command (char *cmd,
       || (current_target.to_rcmd == debug_to_rcmd
          && (debug_target.to_rcmd
              == (void (*) (char *, struct ui_file *)) tcomplain)))
-    {
-      error ("\"monitor\" command not supported by this target.\n");
-    }
+    error (_("\"monitor\" command not supported by this target."));
   target_rcmd (cmd, gdb_stdtarg);
 }
 
@@ -2427,20 +2552,23 @@ initialize_targets (void)
   add_info ("target", target_info, targ_desc);
   add_info ("files", target_info, targ_desc);
 
-  add_show_from_set 
+  deprecated_add_show_from_set 
     (add_set_cmd ("target", class_maintenance, var_zinteger,
                  (char *) &targetdebug,
                  "Set target debugging.\n\
-When non-zero, target debugging is enabled.", &setdebuglist),
+When non-zero, target debugging is enabled.  Higher numbers are more\n\
+verbose.  Changes do not take effect until the next \"run\" or \"target\"\n\
+command.", &setdebuglist),
      &showdebuglist);
 
   add_setshow_boolean_cmd ("trust-readonly-sections", class_support, 
                           &trust_readonly, "\
-Set mode for reading from readonly sections.\n\
+Set mode for reading from readonly sections.", "\
+Show mode for reading from readonly sections.", "\
 When this mode is on, memory reads from readonly sections (such as .text)\n\
 will be read from the object file instead of from the target.  This will\n\
-result in significant performance improvement for remote targets.", "\
-Show mode for reading from readonly sections.\n",
+result in significant performance improvement for remote targets.",
+                          NULL, /* PRINT: Mode for reading from readonly sections is %s.  */
                           NULL, NULL,
                           &setlist, &showlist);
 
This page took 0.036584 seconds and 4 git commands to generate.