daily update
[deliverable/binutils-gdb.git] / gdb / target.c
index 5270f00e230071d290d03b8bded66ebe99913422..fa9f1fa612c1a56f78641a430d41336fbf5157b3 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.
 
@@ -114,9 +114,9 @@ static int deprecated_debug_xfer_memory (CORE_ADDR, char *, int, int,
 
 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);
 
@@ -203,6 +203,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);
 
@@ -960,9 +966,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)
@@ -995,7 +1001,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, bfd_byte *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,
@@ -1005,9 +1011,9 @@ target_read_memory (CORE_ADDR memaddr, bfd_byte *myaddr, int len)
 }
 
 int
-target_write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
+target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
 {
-  bfd_byte *bytes = alloca (len);
+  gdb_byte *bytes = alloca (len);
   memcpy (bytes, myaddr, len);
   if (target_xfer_partial_p ())
     return xfer_using_stratum (TARGET_OBJECT_MEMORY, NULL,
@@ -1032,6 +1038,14 @@ target_stopped_data_address_p (struct target_ops *target)
 #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.
@@ -1235,8 +1249,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);
 }
@@ -1245,8 +1277,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);
 }
@@ -1328,7 +1378,7 @@ target_read (struct target_ops *ops,
   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)
@@ -1350,7 +1400,7 @@ target_write (struct target_ops *ops,
   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)
@@ -1446,19 +1496,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)
 {
@@ -1753,15 +1790,17 @@ 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];
+  int size;
 
-  sprintf (buf, "process %d", PIDGET (ptid));
+  size = snprintf (buf, sizeof buf, "process %d", ptid_get_pid (ptid));
+  gdb_assert (size < sizeof buf);
   return buf;
 }
 
@@ -2016,7 +2055,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;
 
@@ -2030,7 +2069,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;
 
@@ -2559,7 +2598,7 @@ 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."),
                            NULL,
-                           NULL, /* FIXME: i18n: */
+                           show_targetdebug,
                            &setdebuglist, &showdebuglist);
 
   add_setshow_boolean_cmd ("trust-readonly-sections", class_support, 
@@ -2570,7 +2609,7 @@ 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."),
                           NULL,
-                          NULL, /* FIXME: i18n: Mode for reading from readonly sections is %s.  */
+                          show_trust_readonly,
                           &setlist, &showlist);
 
   add_com ("monitor", class_obscure, do_monitor_command,
This page took 0.037302 seconds and 4 git commands to generate.