* README-vms: Delete.
[deliverable/binutils-gdb.git] / gdb / target.c
index 48bf8fb6f5abd12bce2643a76015dd2bee04f777..83501e609619d8408705ced086ce3880ec5d75f1 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, 2004 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -71,8 +71,8 @@ static void nosupport_runtime (void);
 
 static LONGEST default_xfer_partial (struct target_ops *ops,
                                     enum target_object object,
-                                    const char *annex, void *readbuf,
-                                    const void *writebuf,
+                                    const char *annex, gdb_byte *readbuf,
+                                    const gdb_byte *writebuf,
                                     ULONGEST offset, LONGEST len);
 
 /* Transfer LEN bytes between target address MEMADDR and GDB address
@@ -81,11 +81,13 @@ static LONGEST default_xfer_partial (struct target_ops *ops,
    partial transfers, try either target_read_memory_partial or
    target_write_memory_partial).  */
 
-static int target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
+static int target_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
                               int write);
 
 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);
@@ -106,20 +108,17 @@ 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 void debug_to_files_info (struct target_ops *);
 
-static int debug_to_insert_breakpoint (CORE_ADDR, char *);
+static int debug_to_insert_breakpoint (CORE_ADDR, gdb_byte *);
 
-static int debug_to_remove_breakpoint (CORE_ADDR, char *);
+static int debug_to_remove_breakpoint (CORE_ADDR, gdb_byte *);
 
 static int debug_to_can_use_hw_breakpoint (int, int, int);
 
-static int debug_to_insert_hw_breakpoint (CORE_ADDR, char *);
+static int debug_to_insert_hw_breakpoint (CORE_ADDR, gdb_byte *);
 
-static int debug_to_remove_hw_breakpoint (CORE_ADDR, char *);
+static int debug_to_remove_hw_breakpoint (CORE_ADDR, gdb_byte *);
 
 static int debug_to_insert_watchpoint (CORE_ADDR, int, int);
 
@@ -127,7 +126,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);
 
@@ -163,7 +162,7 @@ static void debug_to_stop (void);
    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 child_ops;
+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 
@@ -200,6 +199,12 @@ int attach_flag;
 /* Non-zero if we want to see trace of target level stuff.  */
 
 static int targetdebug = 0;
+static void
+show_targetdebug (struct ui_file *file, int from_tty,
+                 struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("Target debugging is %s.\n"), value);
+}
 
 static void setup_target_debug (void);
 
@@ -239,12 +244,12 @@ add_target (struct target_ops *t)
   target_structs[target_struct_size++] = t;
 
   if (targetlist == NULL)
-    add_prefix_cmd ("target", class_run, target_command,
-                   "Connect to a target machine or process.\n\
+    add_prefix_cmd ("target", class_run, target_command, _("\
+Connect to a target machine or process.\n\
 The first argument is the type or protocol of the target machine.\n\
 Remaining arguments are interpreted by the target protocol.  For more\n\
 information on the arguments for a particular protocol, type\n\
-`help target ' followed by the protocol name.",
+`help target ' followed by the protocol name."),
                    &targetlist, "target ", 0, &cmdlist);
   add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
 }
@@ -274,14 +279,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
@@ -296,14 +301,14 @@ 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"));
 }
 
 
 static void
 default_terminal_info (char *args, int from_tty)
 {
-  printf_unfiltered ("No saved terminal information.\n");
+  printf_unfiltered (_("No saved terminal information.\n"));
 }
 
 /* This is the default target_create_inferior and target_attach function.
@@ -316,18 +321,18 @@ kill_or_be_killed (int from_tty)
 {
   if (target_has_execution)
     {
-      printf_unfiltered ("You are already running a program:\n");
+      printf_unfiltered (_("You are already running a program:\n"));
       target_files_info ();
       if (query ("Kill it? "))
        {
          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 ();
@@ -388,7 +393,7 @@ update_current_target (void)
       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);
@@ -495,8 +500,8 @@ update_current_target (void)
   de_fault (to_prepare_to_store, 
            (void (*) (void)) 
            noprocess);
-  de_fault (to_xfer_memory, 
-           (int (*) (CORE_ADDR, char *, int, int, struct mem_attrib *, struct target_ops *)) 
+  de_fault (deprecated_xfer_memory, 
+           (int (*) (CORE_ADDR, gdb_byte *, int, int, struct mem_attrib *, struct target_ops *)) 
            nomemory);
   de_fault (to_files_info, 
            (void (*) (struct target_ops *)) 
@@ -509,10 +514,10 @@ update_current_target (void)
            (int (*) (int, int, int))
            return_zero);
   de_fault (to_insert_hw_breakpoint,
-           (int (*) (CORE_ADDR, char *))
+           (int (*) (CORE_ADDR, gdb_byte *))
            return_minus_one);
   de_fault (to_remove_hw_breakpoint,
-           (int (*) (CORE_ADDR, char *))
+           (int (*) (CORE_ADDR, gdb_byte *))
            return_minus_one);
   de_fault (to_insert_watchpoint,
            (int (*) (CORE_ADDR, int, int))
@@ -524,7 +529,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);
@@ -563,13 +568,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)) 
@@ -578,7 +583,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)) 
@@ -661,7 +666,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.  */
@@ -746,7 +751,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
@@ -762,7 +767,7 @@ int
 target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
 {
   int tlen, origlen, offset, i;
-  char buf[4];
+  gdb_byte buf[4];
   int errcode = 0;
   char *buffer;
   int buffer_allocated;
@@ -781,7 +786,7 @@ target_read_string (CORE_ADDR memaddr, char **string, int len, int *errnop)
       tlen = MIN (len, 4 - (memaddr & 3));
       offset = memaddr & 3;
 
-      errcode = target_read_memory (memaddr & ~3, buf, 4);
+      errcode = target_read_memory (memaddr & ~3, buf, sizeof buf);
       if (errcode != 0)
        {
          /* The transfer request might have crossed the boundary to an
@@ -957,9 +962,9 @@ xfer_using_stratum (enum target_object object, const char *annex,
            return 0;
          offset += xfered;
          if (readbuf != NULL)
-           readbuf = (bfd_byte *) readbuf + xfered;
+           readbuf = (gdb_byte *) readbuf + xfered;
          if (writebuf != NULL)
-           writebuf = (bfd_byte *) writebuf + xfered;
+           writebuf = (gdb_byte *) writebuf + xfered;
          target = target_stack;
        }
       else if (xfered < 0)
@@ -992,7 +997,7 @@ xfer_using_stratum (enum target_object object, const char *annex,
    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, gdb_byte *myaddr, int len)
 {
   if (target_xfer_partial_p ())
     return xfer_using_stratum (TARGET_OBJECT_MEMORY, NULL,
@@ -1002,16 +1007,41 @@ target_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
 }
 
 int
-target_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
+target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
 {
+  gdb_byte *bytes = alloca (len);
+  memcpy (bytes, myaddr, len);
   if (target_xfer_partial_p ())
     return xfer_using_stratum (TARGET_OBJECT_MEMORY, NULL,
-                              memaddr, len, NULL, myaddr);
+                              memaddr, len, NULL, bytes);
   else
-    return target_xfer_memory (memaddr, myaddr, len, 1);
+    return target_xfer_memory (memaddr, bytes, len, 1);
 }
 
+#ifndef target_stopped_data_address_p
+int
+target_stopped_data_address_p (struct target_ops *target)
+{
+  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;
+static void
+show_trust_readonly (struct ui_file *file, int from_tty,
+                    struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("\
+Mode for reading from readonly sections is %s.\n"),
+                   value);
+}
 
 /* Move memory to or from the targets.  The top target gets priority;
    if it cannot handle it, it is offered to the next one down, etc.
@@ -1019,7 +1049,7 @@ static int trust_readonly = 0;
    Result is -1 on error, or the number of bytes transfered.  */
 
 int
-do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+do_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
                struct mem_attrib *attrib)
 {
   int res;
@@ -1030,8 +1060,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)
@@ -1048,7 +1078,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. */
@@ -1059,7 +1089,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)
@@ -1080,7 +1110,7 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
    Result is 0 or errno value.  */
 
 static int
-target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
+target_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write)
 {
   int res;
   int reg_len;
@@ -1117,7 +1147,7 @@ target_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write)
        {
          if (region->attrib.cache)
            res = dcache_xfer_memory (target_dcache, memaddr, myaddr,
-                                    reg_len, write);
+                                     reg_len, write);
          else
            res = do_xfer_memory (memaddr, myaddr, reg_len, write,
                                 &region->attrib);
@@ -1215,8 +1245,26 @@ int
 target_read_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
 {
   if (target_xfer_partial_p ())
-    return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL,
-                               buf, NULL, memaddr, len);
+    {
+      int retval;
+
+      retval = target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY,
+                                   NULL, buf, NULL, memaddr, len);
+
+      if (retval <= 0)
+       {
+         if (errno)
+           *err = errno;
+         else
+           *err = EIO;
+         return -1;
+       }
+      else
+       {
+         *err = 0;
+         return retval;
+       }
+    }
   else
     return target_xfer_memory_partial (memaddr, buf, len, 0, err);
 }
@@ -1225,8 +1273,26 @@ int
 target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
 {
   if (target_xfer_partial_p ())
-    return target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY, NULL,
-                               NULL, buf, memaddr, len);
+    {
+      int retval;
+
+      retval = target_xfer_partial (target_stack, TARGET_OBJECT_MEMORY,
+                                   NULL, NULL, buf, memaddr, len);
+
+      if (retval <= 0)
+       {
+         if (errno)
+           *err = errno;
+         else
+           *err = EIO;
+         return -1;
+       }
+      else
+       {
+         *err = 0;
+         return retval;
+       }
+    }
   else
     return target_xfer_memory_partial (memaddr, buf, len, 1, err);
 }
@@ -1235,13 +1301,13 @@ target_write_memory_partial (CORE_ADDR memaddr, char *buf, int len, int *err)
 
 static LONGEST
 default_xfer_partial (struct target_ops *ops, enum target_object object,
-                     const char *annex, void *readbuf, 
-                     const void *writebuf, ULONGEST offset, LONGEST len)
+                     const char *annex, gdb_byte *readbuf, 
+                     const gdb_byte *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;
@@ -1250,18 +1316,18 @@ 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;
@@ -1282,7 +1348,7 @@ default_xfer_partial (struct target_ops *ops, enum target_object object,
 LONGEST
 target_read_partial (struct target_ops *ops,
                     enum target_object object,
-                    const char *annex, void *buf,
+                    const char *annex, gdb_byte *buf,
                     ULONGEST offset, LONGEST len)
 {
   return target_xfer_partial (ops, object, annex, buf, NULL, offset, len);
@@ -1291,7 +1357,7 @@ target_read_partial (struct target_ops *ops,
 LONGEST
 target_write_partial (struct target_ops *ops,
                      enum target_object object,
-                     const char *annex, const void *buf,
+                     const char *annex, const gdb_byte *buf,
                      ULONGEST offset, LONGEST len)
 {
   return target_xfer_partial (ops, object, annex, NULL, buf, offset, len);
@@ -1301,14 +1367,14 @@ target_write_partial (struct target_ops *ops,
 LONGEST
 target_read (struct target_ops *ops,
             enum target_object object,
-            const char *annex, void *buf,
+            const char *annex, gdb_byte *buf,
             ULONGEST offset, LONGEST len)
 {
   LONGEST xfered = 0;
   while (xfered < len)
     {
       LONGEST xfer = target_read_partial (ops, object, annex,
-                                         (bfd_byte *) buf + xfered,
+                                         (gdb_byte *) buf + xfered,
                                          offset + xfered, len - xfered);
       /* Call an observer, notifying them of the xfer progress?  */
       if (xfer <= 0)
@@ -1323,14 +1389,14 @@ target_read (struct target_ops *ops,
 LONGEST
 target_write (struct target_ops *ops,
              enum target_object object,
-             const char *annex, const void *buf,
+             const char *annex, const gdb_byte *buf,
              ULONGEST offset, LONGEST len)
 {
   LONGEST xfered = 0;
   while (xfered < len)
     {
       LONGEST xfer = target_write_partial (ops, object, annex,
-                                          (bfd_byte *) buf + xfered,
+                                          (gdb_byte *) buf + xfered,
                                           offset + xfered, len - xfered);
       /* Call an observer, notifying them of the xfer progress?  */
       if (xfer <= 0)
@@ -1345,7 +1411,7 @@ target_write (struct target_ops *ops,
 /* Memory transfer methods.  */
 
 void
-get_target_memory (struct target_ops *ops, CORE_ADDR addr, void *buf,
+get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf,
                   LONGEST len)
 {
   if (target_read (ops, TARGET_OBJECT_MEMORY, NULL, buf, addr, len)
@@ -1371,7 +1437,7 @@ target_info (char *args, int from_tty)
   int has_all_mem = 0;
 
   if (symfile_objfile != NULL)
-    printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
+    printf_unfiltered (_("Symbols from \"%s\".\n"), symfile_objfile->name);
 
   for (t = target_stack; t != NULL; t = t->beneath)
     {
@@ -1381,7 +1447,7 @@ target_info (char *args, int from_tty)
       if ((int) (t->to_stratum) <= (int) dummy_stratum)
        continue;
       if (has_all_mem)
-       printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
+       printf_unfiltered (_("\tWhile running this, GDB does not access memory from...\n"));
       printf_unfiltered ("%s:\n", t->to_longname);
       (t->to_files_info) (t);
       has_all_mem = t->to_has_all_memory;
@@ -1399,10 +1465,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
@@ -1426,19 +1492,6 @@ target_disconnect (char *args, int from_tty)
   (current_target.to_disconnect) (args, from_tty);
 }
 
-void
-target_link (char *modname, CORE_ADDR *t_reloc)
-{
-  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);
-    }
-  else
-    *t_reloc = (CORE_ADDR) -1;
-}
-
 int
 target_async_mask (int mask)
 {
@@ -1473,7 +1526,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;
 }
@@ -1733,29 +1786,29 @@ store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
 int (*target_activity_function) (void);
 int target_activity_fd;
 \f
-/* Convert a normal process ID to a string.  Returns the string in a static
-   buffer.  */
+/* Convert a normal process ID to a string.  Returns the string in a
+   static buffer.  */
 
 char *
 normal_pid_to_str (ptid_t ptid)
 {
-  static char buf[30];
+  static char buf[32];
 
-  sprintf (buf, "process %d", PIDGET (ptid));
+  xsnprintf (buf, sizeof buf, "process %d", ptid_get_pid (ptid));
   return buf;
 }
 
 /* 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;
 }
 
@@ -1778,9 +1831,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)
 {
@@ -1950,14 +2000,14 @@ 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, bfd_byte *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",
@@ -1999,7 +2049,7 @@ debug_to_files_info (struct target_ops *target)
 }
 
 static int
-debug_to_insert_breakpoint (CORE_ADDR addr, char *save)
+debug_to_insert_breakpoint (CORE_ADDR addr, gdb_byte *save)
 {
   int retval;
 
@@ -2013,7 +2063,7 @@ debug_to_insert_breakpoint (CORE_ADDR addr, char *save)
 }
 
 static int
-debug_to_remove_breakpoint (CORE_ADDR addr, char *save)
+debug_to_remove_breakpoint (CORE_ADDR addr, gdb_byte *save)
 {
   int retval;
 
@@ -2069,21 +2119,22 @@ 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;
 }
 
 static int
-debug_to_insert_hw_breakpoint (CORE_ADDR addr, char *save)
+debug_to_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
 {
   int retval;
 
@@ -2097,7 +2148,7 @@ debug_to_insert_hw_breakpoint (CORE_ADDR addr, char *save)
 }
 
 static int
-debug_to_remove_hw_breakpoint (CORE_ADDR addr, char *save)
+debug_to_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
 {
   int retval;
 
@@ -2241,17 +2292,13 @@ debug_to_acknowledge_created_inferior (int pid)
                      pid);
 }
 
-static int
+static void
 debug_to_insert_fork_catchpoint (int pid)
 {
-  int retval;
+  debug_target.to_insert_fork_catchpoint (pid);
 
-  retval = 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
@@ -2267,17 +2314,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
@@ -2304,17 +2347,13 @@ debug_to_follow_fork (int follow_child)
   return retval;
 }
 
-static int
+static void
 debug_to_insert_exec_catchpoint (int pid)
 {
-  int retval;
-
-  retval = debug_target.to_insert_exec_catchpoint (pid);
-
-  fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d) = %d\n",
-                     pid, retval);
+  debug_target.to_insert_exec_catchpoint (pid);
 
-  return retval;
+  fprintf_unfiltered (gdb_stdlog, "target_insert_exec_catchpoint (%d)\n",
+                     pid);
 }
 
 static int
@@ -2472,7 +2511,7 @@ setup_target_debug (void)
   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;
@@ -2533,9 +2572,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);
 }
 
@@ -2548,28 +2585,29 @@ initialize_targets (void)
   add_info ("target", target_info, targ_desc);
   add_info ("files", target_info, targ_desc);
 
-  deprecated_add_show_from_set 
-    (add_set_cmd ("target", class_maintenance, var_zinteger,
-                 (char *) &targetdebug,
-                 "Set target debugging.\n\
+  add_setshow_zinteger_cmd ("target", class_maintenance, &targetdebug, _("\
+Set target debugging."), _("\
+Show target debugging."), _("\
 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);
+command."),
+                           NULL,
+                           show_targetdebug,
+                           &setdebuglist, &showdebuglist);
 
   add_setshow_boolean_cmd ("trust-readonly-sections", class_support, 
-                          &trust_readonly, "\
-Set mode for reading from readonly sections.""\
-Show mode for reading from readonly sections.""\
+                          &trust_readonly, _("\
+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.", "\
-Mode for reading from readonly sections is %s.",
-                          NULL, NULL,
+result in significant performance improvement for remote targets."),
+                          NULL,
+                          show_trust_readonly,
                           &setlist, &showlist);
 
   add_com ("monitor", class_obscure, do_monitor_command,
-          "Send a command to the remote monitor (remote targets only).");
+          _("Send a command to the remote monitor (remote targets only)."));
 
   target_dcache = dcache_init ();
 }
This page took 0.065896 seconds and 4 git commands to generate.