2005-02-11 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / target.c
index e99d9472d9632769e77b5e5d7345b3edfe33d510..2db2f08489481fe8a1aabddb3a69a1adc7fbe94d 100644 (file)
@@ -1,7 +1,7 @@
 /* Select target systems and architectures at runtime for GDB.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -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);
@@ -71,16 +69,11 @@ static struct target_ops *find_default_run_target (char *);
 
 static void nosupport_runtime (void);
 
-static void normal_target_post_startup_inferior (ptid_t ptid);
-
-static LONGEST default_read_partial (struct target_ops *ops,
+static LONGEST default_xfer_partial (struct target_ops *ops,
                                     enum target_object object,
-                                    const char *annex, void *buf,
+                                    const char *annex, void *readbuf,
+                                    const void *writebuf,
                                     ULONGEST offset, LONGEST len);
-static LONGEST default_write_partial (struct target_ops *ops,
-                                     enum target_object object,
-                                     const char *annex, const void *buf,
-                                     ULONGEST offset, LONGEST len);
 
 /* Transfer LEN bytes between target address MEMADDR and GDB address
    MYADDR.  Returns 0 for success, errno code for failure (which
@@ -93,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);
@@ -113,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 *);
 
@@ -134,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);
 
@@ -156,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);
@@ -168,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.  */
@@ -223,8 +223,8 @@ void
 add_target (struct target_ops *t)
 {
   /* Provide default values for all "must have" methods.  */
-  t->to_read_partial = default_read_partial;
-  t->to_write_partial = default_write_partial;
+  if (t->to_xfer_partial == NULL)
+    t->to_xfer_partial = default_xfer_partial;
 
   if (!target_structs)
     {
@@ -277,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
@@ -299,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"));
 }
 
 
@@ -325,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 ();
@@ -344,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
@@ -387,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);
@@ -433,8 +433,7 @@ update_current_target (void)
       INHERIT (to_pid_to_str, t);
       INHERIT (to_extra_thread_info, t);
       INHERIT (to_stop, t);
-      /* Do not inherit to_read_partial.  */
-      /* Do not inherit to_write_partial.  */
+      /* Do not inherit to_xfer_partial.  */
       INHERIT (to_rcmd, t);
       INHERIT (to_enable_exception_callback, t);
       INHERIT (to_get_current_exception_event, t);
@@ -490,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);
@@ -502,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, 
@@ -531,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);
@@ -570,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)) 
@@ -585,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)) 
@@ -616,8 +612,7 @@ update_current_target (void)
   de_fault (to_stop, 
            (void (*) (void)) 
            target_ignore);
-  current_target.to_read_partial = default_read_partial;
-  current_target.to_write_partial = default_write_partial;
+  current_target.to_xfer_partial = default_xfer_partial;
   de_fault (to_rcmd, 
            (void (*) (char *, struct ui_file *)) 
            tcomplain);
@@ -669,7 +664,7 @@ push_target (struct target_ops *t)
       fprintf_unfiltered (gdb_stderr,
                          "Magic number of %s target struct wrong\n",
                          t->to_shortname);
-      internal_error (__FILE__, __LINE__, "failed internal consistency check");
+      internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
     }
 
   /* Find the proper stratum to install this target in.  */
@@ -714,8 +709,6 @@ unpush_target (struct target_ops *t)
   struct target_ops **cur;
   struct target_ops *tmp;
 
-  target_close (t, 0);
-
   /* Look for the specified target.  Note that we assume that a target
      can only occur once in the target stack. */
 
@@ -728,6 +721,14 @@ unpush_target (struct target_ops *t)
   if ((*cur) == NULL)
     return 0;                  /* Didn't find target_ops, quit now */
 
+  /* NOTE: cagney/2003-12-06: In '94 the close call was made
+     unconditional by moving it to before the above check that the
+     target was in the target stack (something about "Change the way
+     pushing and popping of targets work to support target overlays
+     and inheritance").  This doesn't make much sense - only open
+     targets should be closed.  */
+  target_close (t, 0);
+
   /* Unchain the target */
   tmp = (*cur);
   (*cur) = (*cur)->beneath;
@@ -748,7 +749,7 @@ pop_target (void)
   fprintf_unfiltered (gdb_stderr,
                      "pop_target couldn't find target %s\n",
                      current_target.to_shortname);
-  internal_error (__FILE__, __LINE__, "failed internal consistency check");
+  internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
 }
 
 #undef MIN
@@ -783,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
@@ -791,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;
        }
@@ -842,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.
@@ -853,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;
 
@@ -883,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)
@@ -901,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. */
@@ -912,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)
@@ -1067,79 +1234,61 @@ 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.  */
 
 static LONGEST
-default_read_partial (struct target_ops *ops,
-                     enum target_object object,
-                     const char *annex, void *buf,
-                     ULONGEST offset, LONGEST len)
+default_xfer_partial (struct target_ops *ops, enum target_object object,
+                     const char *annex, void *readbuf, 
+                     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;
+      int xfered = -1;
       errno = 0;
-      xfered = ops->to_xfer_memory (offset, buf, 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.  */
-       return 0;
-      else
-       return -1;
-    }
-  else if (ops->beneath != NULL)
-    return target_read_partial (ops->beneath, object, annex, buf, offset, len);
-  else
-    return -1;
-}
-
-static LONGEST
-default_write_partial (struct target_ops *ops,
-                      enum target_object object,
-                      const char *annex, const void *buf,
-                      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.  */
-    {
-      int xfered;
-      errno = 0;
-      {
-       void *buffer = xmalloc (len);
-       struct cleanup *cleanup = make_cleanup (xfree, buffer);
-       memcpy (buffer, buf, len);
-       xfered = ops->to_xfer_memory (offset, buffer, len, 1/*write*/, NULL,
-                                     ops);
-       do_cleanups (cleanup);
-      }
+      if (writebuf != NULL)
+       {
+         void *buffer = xmalloc (len);
+         struct cleanup *cleanup = make_cleanup (xfree, buffer);
+         memcpy (buffer, writebuf, len);
+         xfered = ops->deprecated_xfer_memory (offset, buffer, len,
+                                               1/*write*/, NULL, ops);
+         do_cleanups (cleanup);
+       }
+      if (readbuf != NULL)
+       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 target_write_partial (ops->beneath, object, annex, buf, offset,
-                                len);
+    return target_xfer_partial (ops->beneath, object, annex,
+                               readbuf, writebuf, offset, len);
   else
     return -1;
 }
@@ -1156,8 +1305,7 @@ target_read_partial (struct target_ops *ops,
                     const char *annex, void *buf,
                     ULONGEST offset, LONGEST len)
 {
-  gdb_assert (ops->to_read_partial != NULL);
-  return ops->to_read_partial (ops, object, annex, buf, offset, len);
+  return target_xfer_partial (ops, object, annex, buf, NULL, offset, len);
 }
 
 LONGEST
@@ -1166,8 +1314,7 @@ target_write_partial (struct target_ops *ops,
                      const char *annex, const void *buf,
                      ULONGEST offset, LONGEST len)
 {
-  gdb_assert (ops->to_write_partial != NULL);
-  return ops->to_write_partial (ops, object, annex, buf, offset, len);
+  return target_xfer_partial (ops, object, annex, NULL, buf, offset, len);
 }
 
 /* Wrappers to perform the full transfer.  */
@@ -1246,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)
@@ -1277,10 +1419,10 @@ target_preopen (int from_tty)
   if (target_has_execution)
     {
       if (!from_tty
-          || query ("A program is being debugged already.  Kill it? "))
+          || 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
@@ -1295,31 +1437,23 @@ 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);
 }
 
 void
 target_link (char *modname, CORE_ADDR *t_reloc)
 {
-  if (STREQ (current_target.to_shortname, "rombug"))
+  if (DEPRECATED_STREQ (current_target.to_shortname, "rombug"))
     {
       (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;
@@ -1359,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;
 }
@@ -1375,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
@@ -1452,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;
@@ -1563,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 ();
 
@@ -1578,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.
@@ -1628,35 +1765,17 @@ normal_pid_to_str (ptid_t ptid)
   return buf;
 }
 
-/* Some targets (such as ttrace-based HPUX) don't allow us to request
-   notification of inferior events such as fork and vork immediately
-   after the inferior is created.  (This because of how gdb gets an
-   inferior created via invoking a shell to do it.  In such a scenario,
-   if the shell init file has commands in it, the shell will fork and
-   exec for each of those commands, and we will see each such fork
-   event.  Very bad.)
-
-   This function is used by all targets that allow us to request
-   notification of forks, etc at inferior creation time; e.g., in
-   target_acknowledge_forked_child.
- */
-static void
-normal_target_post_startup_inferior (ptid_t ptid)
-{
-  /* This space intentionally left blank. */
-}
-
 /* 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;
 }
 
@@ -1675,12 +1794,10 @@ init_dummy_target (void)
   dummy_target.to_stratum = dummy_stratum;
   dummy_target.to_find_memory_regions = dummy_find_memory_regions;
   dummy_target.to_make_corefile_notes = dummy_make_corefile_notes;
+  dummy_target.to_xfer_partial = default_xfer_partial;
   dummy_target.to_magic = OPS_MAGIC;
 }
 \f
-
-static struct target_ops debug_target;
-
 static void
 debug_to_open (char *args, int from_tty)
 {
@@ -1797,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)
 {
@@ -1821,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)),
@@ -1859,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;
@@ -1883,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);
        }
     }
@@ -1972,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;
 }
 
@@ -2117,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
@@ -2143,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);
-
-  fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d) = %d\n",
-                     pid, retval);
+  debug_target.to_insert_fork_catchpoint (pid);
 
-  return retval;
+  fprintf_unfiltered (gdb_stdlog, "target_insert_fork_catchpoint (%d)\n",
+                     pid);
 }
 
 static int
@@ -2169,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;
-
-  retval = debug_target.to_insert_vfork_catchpoint (pid);
-
-  fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)= %d\n",
-                     pid, retval);
+  debug_target.to_insert_vfork_catchpoint (pid);
 
-  return retval;
+  fprintf_unfiltered (gdb_stdlog, "target_insert_vfork_catchpoint (%d)\n",
+                     pid);
 }
 
 static int
@@ -2206,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
@@ -2317,46 +2421,6 @@ debug_to_stop (void)
   fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
 }
 
-static LONGEST
-debug_to_read_partial (struct target_ops *ops,
-                      enum target_object object,
-                      const char *annex, void *buf,
-                      ULONGEST offset, LONGEST len)
-{
-  LONGEST retval;
-
-  retval = target_read_partial (&debug_target, object, annex, buf, offset,
-                               len);
-
-  fprintf_unfiltered (gdb_stdlog,
-                     "target_read_partial (%d, %s, 0x%lx,  0x%s, %s) = %s\n",
-                     (int) object, (annex ? annex : "(null)"),
-                     (long) buf, paddr_nz (offset),
-                     paddr_d (len), paddr_d (retval));
-
-  return retval;
-}
-
-static LONGEST
-debug_to_write_partial (struct target_ops *ops,
-                       enum target_object object,
-                       const char *annex, const void *buf,
-                       ULONGEST offset, LONGEST len)
-{
-  LONGEST retval;
-
-  retval = target_write_partial (&debug_target, object, annex, buf, offset,
-                               len);
-
-  fprintf_unfiltered (gdb_stdlog,
-                     "target_write_partial (%d, %s, 0x%lx,  0x%s, %s) = %s\n",
-                     (int) object, (annex ? annex : "(null)"),
-                     (long) buf, paddr_nz (offset),
-                     paddr_d (len), paddr_d (retval));
-
-  return retval;
-}
-
 static void
 debug_to_rcmd (char *command,
               struct ui_file *outbuf)
@@ -2411,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;
@@ -2454,8 +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_read_partial = debug_to_read_partial;
-  current_target.to_write_partial = debug_to_write_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;
@@ -2478,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);
 }
 
@@ -2493,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.038798 seconds and 4 git commands to generate.