* dwarf2-frame.c (dwarf2_frame_prev_register): Use gdb_byte.
[deliverable/binutils-gdb.git] / gdb / remote.c
index 108b5e882041698ed7fd1ca14165d98f7e018731..bc12efd26c37e520c07e2039843dcb2fb9cb864d 100644 (file)
@@ -1,7 +1,7 @@
 /* Remote target communications for serial-line targets in custom GDB protocol
 
    Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -41,6 +41,8 @@
 #include "regcache.h"
 #include "value.h"
 #include "gdb_assert.h"
+#include "observer.h"
+#include "solib.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -70,11 +72,6 @@ static void build_remote_gdbarch_data (void);
 
 static void remote_files_info (struct target_ops *ignore);
 
-static int remote_xfer_memory (CORE_ADDR memaddr, char *myaddr,
-                              int len, int should_write,
-                              struct mem_attrib *attrib,
-                              struct target_ops *target);
-
 static void remote_prepare_to_store (void);
 
 static void remote_fetch_registers (int regno);
@@ -83,8 +80,6 @@ static void remote_resume (ptid_t ptid, int step,
                            enum target_signal siggnal);
 static void remote_async_resume (ptid_t ptid, int step,
                                 enum target_signal siggnal);
-static int remote_start_remote (struct ui_out *uiout, void *dummy);
-
 static void remote_open (char *name, int from_tty);
 static void remote_async_open (char *name, int from_tty);
 
@@ -137,9 +132,9 @@ static void get_offsets (void);
 
 static long read_frame (char *buf, long sizeof_buf);
 
-static int remote_insert_breakpoint (CORE_ADDR, char *);
+static int remote_insert_breakpoint (CORE_ADDR, bfd_byte *);
 
-static int remote_remove_breakpoint (CORE_ADDR, char *);
+static int remote_remove_breakpoint (CORE_ADDR, bfd_byte *);
 
 static int hexnumlen (ULONGEST num);
 
@@ -249,10 +244,7 @@ init_remote_state (struct gdbarch *gdbarch)
   int regnum;
   struct remote_state *rs = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_state);
 
-  if (deprecated_register_bytes () != 0)
-    rs->sizeof_g_packet = deprecated_register_bytes ();
-  else
-    rs->sizeof_g_packet = 0;
+  rs->sizeof_g_packet = 0;
 
   /* Assume a 1:1 regnum<->pnum table.  */
   rs->regs = GDBARCH_OBSTACK_CALLOC (gdbarch, NUM_REGS + NUM_PSEUDO_REGS,
@@ -267,8 +259,8 @@ init_remote_state (struct gdbarch *gdbarch)
       /* ...name = REGISTER_NAME (regnum); */
 
       /* Compute packet size by accumulating the size of all registers.  */
-      if (deprecated_register_bytes () == 0)
-        rs->sizeof_g_packet += register_size (current_gdbarch, regnum);
+      if (regnum < NUM_REGS)
+       rs->sizeof_g_packet += register_size (current_gdbarch, regnum);
     }
 
   /* Default maximum number of characters in a packet body. Many
@@ -414,9 +406,9 @@ get_memory_packet_size (struct memory_packet_config *config)
 #ifndef MAX_REMOTE_PACKET_SIZE
 #define MAX_REMOTE_PACKET_SIZE 16384
 #endif
-  /* NOTE: 16 is just chosen at random.  */
+  /* NOTE: 20 ensures we can write at least one byte.  */
 #ifndef MIN_REMOTE_PACKET_SIZE
-#define MIN_REMOTE_PACKET_SIZE 16
+#define MIN_REMOTE_PACKET_SIZE 20
 #endif
   long what_they_get;
   if (config->fixed_p)
@@ -454,7 +446,7 @@ set_memory_packet_size (char *args, struct memory_packet_config *config)
   int fixed_p = config->fixed_p;
   long size = config->size;
   if (args == NULL)
-    error ("Argument required (integer, `fixed' or `limited').");
+    error (_("Argument required (integer, `fixed' or `limited')."));
   else if (strcmp (args, "hard") == 0
       || strcmp (args, "fixed") == 0)
     fixed_p = 1;
@@ -466,23 +458,23 @@ set_memory_packet_size (char *args, struct memory_packet_config *config)
       char *end;
       size = strtoul (args, &end, 0);
       if (args == end)
-       error ("Invalid %s (bad syntax).", config->name);
+       error (_("Invalid %s (bad syntax)."), config->name);
 #if 0
       /* Instead of explicitly capping the size of a packet to
          MAX_REMOTE_PACKET_SIZE or dissallowing it, the user is
          instead allowed to set the size to something arbitrarily
          large.  */
       if (size > MAX_REMOTE_PACKET_SIZE)
-       error ("Invalid %s (too large).", config->name);
+       error (_("Invalid %s (too large)."), config->name);
 #endif
     }
   /* Extra checks?  */
   if (fixed_p && !config->fixed_p)
     {
-      if (! query ("The target may not be able to correctly handle a %s\n"
-                  "of %ld bytes. Change the packet size? ",
+      if (! query (_("The target may not be able to correctly handle a %s\n"
+                  "of %ld bytes. Change the packet size? "),
                   config->name, size))
-       error ("Packet size not changed.");
+       error (_("Packet size not changed."));
     }
   /* Update the config.  */
   config->fixed_p = fixed_p;
@@ -492,12 +484,12 @@ set_memory_packet_size (char *args, struct memory_packet_config *config)
 static void
 show_memory_packet_size (struct memory_packet_config *config)
 {
-  printf_filtered ("The %s is %ld. ", config->name, config->size);
+  printf_filtered (_("The %s is %ld. "), config->name, config->size);
   if (config->fixed_p)
-    printf_filtered ("Packets are fixed at %ld bytes.\n",
+    printf_filtered (_("Packets are fixed at %ld bytes.\n"),
                     get_memory_packet_size (config));
   else
-    printf_filtered ("Packets are limited to %ld bytes.\n",
+    printf_filtered (_("Packets are limited to %ld bytes.\n"),
                     get_memory_packet_size (config));
 }
 
@@ -620,12 +612,12 @@ show_packet_config_cmd (struct packet_config *config)
   switch (config->detect)
     {
     case AUTO_BOOLEAN_AUTO:
-      printf_filtered ("Support for remote protocol `%s' (%s) packet is auto-detected, currently %s.\n",
+      printf_filtered (_("Support for remote protocol `%s' (%s) packet is auto-detected, currently %s.\n"),
                       config->name, config->title, support);
       break;
     case AUTO_BOOLEAN_TRUE:
     case AUTO_BOOLEAN_FALSE:
-      printf_filtered ("Support for remote protocol `%s' (%s) packet is currently %s.\n",
+      printf_filtered (_("Support for remote protocol `%s' (%s) packet is currently %s.\n"),
                       config->name, config->title, support);
       break;
     }
@@ -636,18 +628,15 @@ add_packet_config_cmd (struct packet_config *config,
                       char *name,
                       char *title,
                       cmd_sfunc_ftype *set_func,
-                      cmd_sfunc_ftype *show_func,
+                      show_value_ftype *show_func,
                       struct cmd_list_element **set_remote_list,
                       struct cmd_list_element **show_remote_list,
                       int legacy)
 {
-  struct cmd_list_element *set_cmd;
-  struct cmd_list_element *show_cmd;
   char *set_doc;
   char *show_doc;
-  char *help_doc;
-  char *print;
   char *cmd_name;
+
   config->name = name;
   config->title = title;
   config->detect = AUTO_BOOLEAN_AUTO;
@@ -656,13 +645,10 @@ add_packet_config_cmd (struct packet_config *config,
                        name, title);
   show_doc = xstrprintf ("Show current use of remote protocol `%s' (%s) packet",
                         name, title);
-  print = xstrprintf ("Current use of remote protocol `%s' (%s) is %%s",
-                     name, title);
   /* set/show TITLE-packet {auto,on,off} */
   cmd_name = xstrprintf ("%s-packet", title);
   add_setshow_auto_boolean_cmd (cmd_name, class_obscure,
-                               &config->detect, set_doc, show_doc,
-                               "", print,
+                               &config->detect, set_doc, show_doc, NULL, /* help_doc */
                                set_func, show_func,
                                set_remote_list, show_remote_list);
   /* set/show remote NAME-packet {auto,on,off} -- legacy.  */
@@ -695,7 +681,7 @@ packet_ok (const char *buf, struct packet_config *config)
          break;
        case PACKET_DISABLE:
          internal_error (__FILE__, __LINE__,
-                         "packet_ok: attempt to use a disabled packet");
+                         _("packet_ok: attempt to use a disabled packet"));
          break;
        case PACKET_ENABLE:
          break;
@@ -720,11 +706,11 @@ packet_ok (const char *buf, struct packet_config *config)
          if (config->detect == AUTO_BOOLEAN_AUTO)
            /* If the stub previously indicated that the packet was
               supported then there is a protocol error..  */
-           error ("Protocol error: %s (%s) conflicting enabled responses.",
+           error (_("Protocol error: %s (%s) conflicting enabled responses."),
                   config->name, config->title);
          else
            /* The user set it wrong.  */
-           error ("Enabled packet %s (%s) not recognized by stub",
+           error (_("Enabled packet %s (%s) not recognized by stub"),
                   config->name, config->title);
          break;
        case PACKET_SUPPORT_UNKNOWN:
@@ -752,8 +738,9 @@ set_remote_protocol_vcont_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_vcont_packet_cmd (char *args, int from_tty,
-                                      struct cmd_list_element *c)
+show_remote_protocol_vcont_packet_cmd (struct ui_file *file, int from_tty,
+                                      struct cmd_list_element *c,
+                                      const char *value)
 {
   show_packet_config_cmd (&remote_protocol_vcont);
 }
@@ -769,8 +756,9 @@ set_remote_protocol_qSymbol_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_qSymbol_packet_cmd (char *args, int from_tty,
-                                        struct cmd_list_element *c)
+show_remote_protocol_qSymbol_packet_cmd (struct ui_file *file, int from_tty,
+                                        struct cmd_list_element *c,
+                                        const char *value)
 {
   show_packet_config_cmd (&remote_protocol_qSymbol);
 }
@@ -787,8 +775,9 @@ set_remote_protocol_P_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_P_packet_cmd (char *args, int from_tty,
-                                  struct cmd_list_element *c)
+show_remote_protocol_P_packet_cmd (struct ui_file *file, int from_tty,
+                                  struct cmd_list_element *c,
+                                  const char *value)
 {
   show_packet_config_cmd (&remote_protocol_P);
 }
@@ -818,8 +807,9 @@ set_remote_protocol_Z_software_bp_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_Z_software_bp_packet_cmd (char *args, int from_tty,
-                                              struct cmd_list_element *c)
+show_remote_protocol_Z_software_bp_packet_cmd (struct ui_file *file, int from_tty,
+                                              struct cmd_list_element *c,
+                                              const char *value)
 {
   show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_SOFTWARE_BP]);
 }
@@ -832,8 +822,9 @@ set_remote_protocol_Z_hardware_bp_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_Z_hardware_bp_packet_cmd (char *args, int from_tty,
-                                              struct cmd_list_element *c)
+show_remote_protocol_Z_hardware_bp_packet_cmd (struct ui_file *file, int from_tty,
+                                              struct cmd_list_element *c,
+                                              const char *value)
 {
   show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_HARDWARE_BP]);
 }
@@ -846,8 +837,9 @@ set_remote_protocol_Z_write_wp_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_Z_write_wp_packet_cmd (char *args, int from_tty,
-                                           struct cmd_list_element *c)
+show_remote_protocol_Z_write_wp_packet_cmd (struct ui_file *file, int from_tty,
+                                           struct cmd_list_element *c,
+                                           const char *value)
 {
   show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_WRITE_WP]);
 }
@@ -860,8 +852,9 @@ set_remote_protocol_Z_read_wp_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_Z_read_wp_packet_cmd (char *args, int from_tty,
-                                          struct cmd_list_element *c)
+show_remote_protocol_Z_read_wp_packet_cmd (struct ui_file *file, int from_tty,
+                                          struct cmd_list_element *c,
+                                          const char *value)
 {
   show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_READ_WP]);
 }
@@ -874,8 +867,9 @@ set_remote_protocol_Z_access_wp_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_Z_access_wp_packet_cmd (char *args, int from_tty,
-                                            struct cmd_list_element *c)
+show_remote_protocol_Z_access_wp_packet_cmd (struct ui_file *file, int from_tty,
+                                            struct cmd_list_element *c,
+                                            const char *value)
 {
   show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_ACCESS_WP]);
 }
@@ -898,8 +892,9 @@ set_remote_protocol_Z_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_Z_packet_cmd (char *args, int from_tty,
-                                  struct cmd_list_element *c)
+show_remote_protocol_Z_packet_cmd (struct ui_file *file, int from_tty,
+                                  struct cmd_list_element *c,
+                                  const char *value)
 {
   int i;
   for (i = 0; i < NR_Z_PACKET_TYPES; i++)
@@ -940,8 +935,9 @@ set_remote_protocol_binary_download_cmd (char *args,
 }
 
 static void
-show_remote_protocol_binary_download_cmd (char *args, int from_tty,
-                                         struct cmd_list_element *c)
+show_remote_protocol_binary_download_cmd (struct ui_file *file, int from_tty,
+                                         struct cmd_list_element *c,
+                                         const char *value)
 {
   show_packet_config_cmd (&remote_protocol_binary_download);
 }
@@ -957,12 +953,31 @@ set_remote_protocol_qPart_auxv_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_qPart_auxv_packet_cmd (char *args, int from_tty,
-                                           struct cmd_list_element *c)
+show_remote_protocol_qPart_auxv_packet_cmd (struct ui_file *file, int from_tty,
+                                           struct cmd_list_element *c,
+                                           const char *value)
 {
   show_packet_config_cmd (&remote_protocol_qPart_auxv);
 }
 
+/* Should we try the 'qGetTLSAddr' (Get Thread Local Storage Address) request? */
+static struct packet_config remote_protocol_qGetTLSAddr;
+
+static void
+set_remote_protocol_qGetTLSAddr_packet_cmd (char *args, int from_tty,
+                                 struct cmd_list_element *c)
+{
+  update_packet_config (&remote_protocol_qGetTLSAddr);
+}
+
+static void
+show_remote_protocol_qGetTLSAddr_packet_cmd (struct ui_file *file, int from_tty,
+                                            struct cmd_list_element *c,
+                                            const char *value)
+{
+  show_packet_config_cmd (&remote_protocol_qGetTLSAddr);
+}
+
 static struct packet_config remote_protocol_p;
 
 static void
@@ -973,8 +988,9 @@ set_remote_protocol_p_packet_cmd (char *args, int from_tty,
 }
 
 static void
-show_remote_protocol_p_packet_cmd (char *args, int from_tty,
-                                  struct cmd_list_element *c)
+show_remote_protocol_p_packet_cmd (struct ui_file *file, int from_tty,
+                                  struct cmd_list_element *c,
+                                  const char *value)
 {
   show_packet_config_cmd (&remote_protocol_p);
 }
@@ -1488,10 +1504,10 @@ remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
   pkt = unpack_threadid (pkt, &ref);
 
   if (mask == 0)
-    warning ("Incomplete response to threadinfo request\n");
+    warning (_("Incomplete response to threadinfo request."));
   if (!threadmatch (&ref, expectedref))
     {                  /* This is an answer to a different request.  */
-      warning ("ERROR RMT Thread info mismatch\n");
+      warning (_("ERROR RMT Thread info mismatch."));
       return 0;
     }
   copy_threadref (&info->threadid, &ref);
@@ -1505,7 +1521,7 @@ remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
       pkt = unpack_byte (pkt, &length);        /* length */
       if (!(tag & mask))               /* Tags out of synch with mask.  */
        {
-         warning ("ERROR RMT: threadinfo tag mismatch\n");
+         warning (_("ERROR RMT: threadinfo tag mismatch."));
          retval = 0;
          break;
        }
@@ -1513,7 +1529,7 @@ remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
        {
          if (length != 16)
            {
-             warning ("ERROR RMT: length of threadid is not 16\n");
+             warning (_("ERROR RMT: length of threadid is not 16."));
              retval = 0;
              break;
            }
@@ -1528,7 +1544,7 @@ remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
          mask = mask & ~(TAG_EXISTS);
          if (length > 8)
            {
-             warning ("ERROR RMT: 'exists' length too long\n");
+             warning (_("ERROR RMT: 'exists' length too long."));
              retval = 0;
              break;
            }
@@ -1552,7 +1568,7 @@ remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
          mask = mask & ~TAG_MOREDISPLAY;
          continue;
        }
-      warning ("ERROR RMT: unknown thread info tag\n");
+      warning (_("ERROR RMT: unknown thread info tag."));
       break;                   /* Not a tag we know about.  */
     }
   return retval;
@@ -1652,14 +1668,14 @@ remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
          exit
          wait for packet, then exit
        */
-      warning ("HMM: threadlist did not echo arg thread, dropping it\n");
+      warning (_("HMM: threadlist did not echo arg thread, dropping it."));
       return 0;                        /* I choose simply exiting.  */
     }
   if (*result_count <= 0)
     {
       if (*done != 1)
        {
-         warning ("RMT ERROR : failed to get remote thread list\n");
+         warning (_("RMT ERROR : failed to get remote thread list."));
          result = 0;
        }
       return result;           /* break; */
@@ -1667,7 +1683,7 @@ remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
   if (*result_count > result_limit)
     {
       *result_count = 0;
-      warning ("RMT ERROR: threadlist response longer than requested\n");
+      warning (_("RMT ERROR: threadlist response longer than requested."));
       return 0;
     }
   return result;
@@ -1704,7 +1720,7 @@ remote_threadlist_iterator (rmt_thread_action stepfunction, void *context,
       if (loopcount++ > looplimit)
        {
          result = 0;
-         warning ("Remote fetch threadlist -infinite loop-\n");
+         warning (_("Remote fetch threadlist -infinite loop-."));
          break;
        }
       if (!remote_get_threadlist (startflag, &nextthread, MAXTHREADLISTRESULTS,
@@ -1788,7 +1804,7 @@ remote_threads_info (void)
   int tid;
 
   if (remote_desc == 0)                /* paranoia */
-    error ("Command can only be used when connected to the remote target.");
+    error (_("Command can only be used when connected to the remote target."));
 
   if (use_threadinfo_query)
     {
@@ -1849,7 +1865,7 @@ remote_threads_extra_info (struct thread_info *tp)
 
   if (remote_desc == 0)                /* paranoia */
     internal_error (__FILE__, __LINE__,
-                   "remote_threads_extra_info");
+                   _("remote_threads_extra_info"));
 
   if (use_threadextra_query)
     {
@@ -1945,7 +1961,7 @@ get_offsets (void)
                                   this command.  */
   if (buf[0] == 'E')
     {
-      warning ("Remote failure reply: %s", buf);
+      warning (_("Remote failure reply: %s"), buf);
       return;
     }
 
@@ -1986,7 +2002,7 @@ get_offsets (void)
     lose = 1;
 
   if (lose)
-    error ("Malformed response to offset query, %s", buf);
+    error (_("Malformed response to offset query, %s"), buf);
 
   if (symfile_objfile == NULL)
     return;
@@ -2019,7 +2035,7 @@ remote_start_remote_dummy (struct ui_out *uiout, void *dummy)
   return 1;
 }
 
-static int
+static void
 remote_start_remote (struct ui_out *uiout, void *dummy)
 {
   immediate_quit++;            /* Allow user to interrupt it.  */
@@ -2037,9 +2053,7 @@ remote_start_remote (struct ui_out *uiout, void *dummy)
   putpkt ("?");                        /* Initiate a query from remote machine.  */
   immediate_quit--;
 
-  /* NOTE: See comment above in remote_start_remote_dummy().  This
-     function returns something >=0.  */
-  return remote_start_remote_dummy (uiout, dummy);
+  remote_start_remote_dummy (uiout, dummy);
 }
 
 /* Open a connection to a remote debugger.
@@ -2092,6 +2106,7 @@ init_all_packet_configs (void)
      downloading.  */
   update_packet_config (&remote_protocol_binary_download);
   update_packet_config (&remote_protocol_qPart_auxv);
+  update_packet_config (&remote_protocol_qGetTLSAddr);
 }
 
 /* Symbol look-up.  */
@@ -2144,9 +2159,9 @@ remote_serial_open (char *name)
      to be.  */
   if (!udp_warning && strncmp (name, "udp:", 4) == 0)
     {
-      warning ("The remote protocol may be unreliable over UDP.");
-      warning ("Some events may be lost, rendering further debugging "
-              "impossible.");
+      warning (_("\
+The remote protocol may be unreliable over UDP.\n\
+Some events may be lost, rendering further debugging impossible."));
       udp_warning = 1;
     }
 
@@ -2157,12 +2172,11 @@ static void
 remote_open_1 (char *name, int from_tty, struct target_ops *target,
               int extended_p, int async_p)
 {
-  int ex;
   struct remote_state *rs = get_remote_state ();
   if (name == 0)
-    error ("To open a remote debug connection, you need to specify what\n"
+    error (_("To open a remote debug connection, you need to specify what\n"
           "serial device is attached to the remote system\n"
-          "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
+          "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.)."));
 
   /* See FIXME above.  */
   if (!async_p)
@@ -2240,10 +2254,8 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
       wait_forever_enabled_p = 0;
     }
 
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
   /* First delete any symbols previously loaded from shared libraries.  */
   no_shared_libraries (NULL, 0);
-#endif
 
   /* Start the remote connection.  If error() or QUIT, discard this
      target (we'd otherwise be in an inconsistent state) and then
@@ -2260,18 +2272,17 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
      been fixed - the function set_cmd_context() makes it possible for
      all the ``target ....'' commands to share a common callback
      function.  See cli-dump.c.  */
-  ex = catch_exceptions (uiout,
-                        remote_start_remote, NULL,
-                        "Couldn't establish connection to remote"
-                        " target\n",
-                        RETURN_MASK_ALL);
-  if (ex < 0)
-    {
-      pop_target ();
-      if (async_p)
-       wait_forever_enabled_p = 1;
-      throw_reason (ex);
-    }
+  {
+    struct gdb_exception ex
+      = catch_exception (uiout, remote_start_remote, NULL, RETURN_MASK_ALL);
+    if (ex.reason < 0)
+      {
+       pop_target ();
+       if (async_p)
+         wait_forever_enabled_p = 1;
+       throw_exception (ex);
+      }
+  }
 
   if (async_p)
     wait_forever_enabled_p = 1;
@@ -2283,7 +2294,7 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
       putpkt ("!");
       getpkt (buf, (rs->remote_packet_size), 0);
     }
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
+
   /* FIXME: need a master target_open vector from which all
      remote_opens can be called, so that stuff like this can
      go there.  Failing that, the following code must be copied
@@ -2293,10 +2304,15 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
   /* Set up to detect and load shared libraries.  */
   if (exec_bfd)        /* No use without an exec file.  */
     {
+#ifdef SOLIB_CREATE_INFERIOR_HOOK
       SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
+#else
+      solib_create_inferior_hook ();
+#endif
       remote_check_symbols (symfile_objfile);
     }
-#endif
+
+  observer_notify_inferior_created (&current_target, from_tty);
 }
 
 /* This takes a program previously attached to and detaches it.  After
@@ -2311,7 +2327,7 @@ remote_detach (char *args, int from_tty)
   char *buf = alloca (rs->remote_packet_size);
 
   if (args)
-    error ("Argument given to \"detach\" when remotely debugging.");
+    error (_("Argument given to \"detach\" when remotely debugging."));
 
   /* Tell the remote target to detach.  */
   strcpy (buf, "D");
@@ -2331,11 +2347,8 @@ remote_detach (char *args, int from_tty)
 static void
 remote_disconnect (char *args, int from_tty)
 {
-  struct remote_state *rs = get_remote_state ();
-  char *buf = alloca (rs->remote_packet_size);
-
   if (args)
-    error ("Argument given to \"detach\" when remotely debugging.");
+    error (_("Argument given to \"detach\" when remotely debugging."));
 
   /* Unregister the file descriptor from the event loop.  */
   if (target_is_async_p ())
@@ -2358,7 +2371,7 @@ fromhex (int a)
   else if (a >= 'A' && a <= 'F')
     return a - 'A' + 10;
   else
-    error ("Reply contains invalid hex digit %d", a);
+    error (_("Reply contains invalid hex digit %d"), a);
 }
 
 static int
@@ -2549,7 +2562,6 @@ remote_resume (ptid_t ptid, int step, enum target_signal siggnal)
   struct remote_state *rs = get_remote_state ();
   char *buf = alloca (rs->remote_packet_size);
   int pid = PIDGET (ptid);
-  char *p;
 
   last_sent_signal = siggnal;
   last_sent_step = step;
@@ -2738,7 +2750,7 @@ interrupt_query (void)
 Give up (and stop debugging it)? "))
     {
       target_mourn_inferior ();
-      throw_reason (RETURN_QUIT);
+      deprecated_throw_reason (RETURN_QUIT);
     }
 
   target_terminal_inferior ();
@@ -2843,14 +2855,13 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
       switch (buf[0])
        {
        case 'E':               /* Error of some sort.  */
-         warning ("Remote failure reply: %s", buf);
+         warning (_("Remote failure reply: %s"), buf);
          continue;
        case 'F':               /* File-I/O request.  */
          remote_fileio_request (buf);
          continue;
        case 'T':               /* Status with PC, SP, FP, ...  */
          {
-           int i;
            char regs[MAX_REGISTER_SIZE];
 
            /* Expedited reply, containing Signal, {regno, reg} repeat.  */
@@ -2888,8 +2899,8 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
                  {
                    p1 = (unsigned char *) strchr (p, ':');
                    if (p1 == NULL)
-                     warning ("Malformed packet(a) (missing colon): %s\n\
-Packet: '%s'\n",
+                     warning (_("Malformed packet(a) (missing colon): %s\n\
+Packet: '%s'\n"),
                               p, buf);
                    if (strncmp (p, "thread", p1 - p) == 0)
                      {
@@ -2919,13 +2930,13 @@ Packet: '%s'\n",
                    p = p1;
 
                    if (*p++ != ':')
-                     error ("Malformed packet(b) (missing colon): %s\n\
-Packet: '%s'\n",
+                     error (_("Malformed packet(b) (missing colon): %s\n\
+Packet: '%s'\n"),
                             p, buf);
 
                    if (reg == NULL)
-                     error ("Remote sent bad register number %s: %s\n\
-Packet: '%s'\n",
+                     error (_("Remote sent bad register number %s: %s\n\
+Packet: '%s'\n"),
                             phex_nz (pnum, 0), p, buf);
 
                    fieldsize = hex2bin (p, regs, 
@@ -2934,13 +2945,13 @@ Packet: '%s'\n",
                    p += 2 * fieldsize;
                    if (fieldsize < register_size (current_gdbarch, 
                                                   reg->regnum))
-                     warning ("Remote reply is too short: %s", buf);
+                     warning (_("Remote reply is too short: %s"), buf);
                    regcache_raw_supply (current_regcache, 
                                         reg->regnum, regs);
                  }
 
                if (*p++ != ';')
-                 error ("Remote register badly formatted: %s\nhere: %s"
+                 error (_("Remote register badly formatted: %s\nhere: %s")
                         buf, p);
              }
          }
@@ -2991,7 +3002,7 @@ Packet: '%s'\n",
            }
          /* else fallthrough */
        default:
-         warning ("Invalid remote reply: %s", buf);
+         warning (_("Invalid remote reply: %s"), buf);
          continue;
        }
     }
@@ -3039,14 +3050,13 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
       switch (buf[0])
        {
        case 'E':               /* Error of some sort.  */
-         warning ("Remote failure reply: %s", buf);
+         warning (_("Remote failure reply: %s"), buf);
          continue;
        case 'F':               /* File-I/O request.  */
          remote_fileio_request (buf);
          continue;
        case 'T':               /* Status with PC, SP, FP, ...  */
          {
-           int i;
            char regs[MAX_REGISTER_SIZE];
 
            /* Expedited reply, containing Signal, {regno, reg} repeat.  */
@@ -3084,8 +3094,8 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
                  {
                    p1 = (unsigned char *) strchr (p, ':');
                    if (p1 == NULL)
-                     error ("Malformed packet(a) (missing colon): %s\n\
-Packet: '%s'\n",
+                     error (_("Malformed packet(a) (missing colon): %s\n\
+Packet: '%s'\n"),
                             p, buf);
                    if (strncmp (p, "thread", p1 - p) == 0)
                      {
@@ -3115,13 +3125,13 @@ Packet: '%s'\n",
                    struct packet_reg *reg = packet_reg_from_pnum (rs, pnum);
                    p = p1;
                    if (*p++ != ':')
-                     error ("Malformed packet(b) (missing colon): %s\n\
-Packet: '%s'\n",
+                     error (_("Malformed packet(b) (missing colon): %s\n\
+Packet: '%s'\n"),
                             p, buf);
 
                    if (reg == NULL)
-                     error ("Remote sent bad register number %ld: %s\n\
-Packet: '%s'\n",
+                     error (_("Remote sent bad register number %ld: %s\n\
+Packet: '%s'\n"),
                             pnum, p, buf);
 
                    fieldsize = hex2bin (p, regs, 
@@ -3130,12 +3140,12 @@ Packet: '%s'\n",
                    p += 2 * fieldsize;
                    if (fieldsize < register_size (current_gdbarch, 
                                                   reg->regnum))
-                     warning ("Remote reply is too short: %s", buf);
+                     warning (_("Remote reply is too short: %s"), buf);
                    regcache_raw_supply (current_regcache, reg->regnum, regs);
                  }
 
                if (*p++ != ';')
-                 error ("Remote register badly formatted: %s\nhere: %s",
+                 error (_("Remote register badly formatted: %s\nhere: %s"),
                         buf, p);
              }
          }
@@ -3189,7 +3199,7 @@ Packet: '%s'\n",
            }
          /* else fallthrough */
        default:
-         warning ("Invalid remote reply: %s", buf);
+         warning (_("Invalid remote reply: %s"), buf);
          continue;
        }
     }
@@ -3242,7 +3252,7 @@ fetch_register_using_p (int regnum)
     {
       if (p[1] == 0)
         {
-          error ("fetch_register_using_p: early buf termination");
+          error (_("fetch_register_using_p: early buf termination"));
           return 0;
         }
 
@@ -3270,8 +3280,8 @@ remote_fetch_registers (int regnum)
       gdb_assert (reg != NULL);
       if (!reg->in_g_packet)
        internal_error (__FILE__, __LINE__,
-                       "Attempt to fetch a non G-packet register when this "
-                       "remote.c does not support the p-packet.");
+                       _("Attempt to fetch a non G-packet register when this "
+                       "remote.c does not support the p-packet."));
     }
       switch (remote_protocol_p.support)
        {
@@ -3281,7 +3291,7 @@ remote_fetch_registers (int regnum)
          if (fetch_register_using_p (regnum))
            return;
          else
-           error ("Protocol error: p packet not recognized by stub");
+           error (_("Protocol error: p packet not recognized by stub"));
        case PACKET_SUPPORT_UNKNOWN:
          if (fetch_register_using_p (regnum))
            {
@@ -3315,6 +3325,7 @@ remote_fetch_registers (int regnum)
      in the buffer is not a hex character, assume that has happened
      and try to fetch another packet to read.  */
   while ((buf[0] < '0' || buf[0] > '9')
+        && (buf[0] < 'A' || buf[0] > 'F')
         && (buf[0] < 'a' || buf[0] > 'f')
         && buf[0] != 'x')      /* New: unavailable register value.  */
     {
@@ -3335,7 +3346,7 @@ remote_fetch_registers (int regnum)
        break;
       if (p[1] == 0)
        {
-         warning ("Remote reply is of odd length: %s", buf);
+         warning (_("Remote reply is of odd length: %s"), buf);
          /* Don't change register_bytes_found in this case, and don't
             print a second warning.  */
          goto supply_them;
@@ -3352,7 +3363,7 @@ remote_fetch_registers (int regnum)
       register_bytes_found = i;
       if (REGISTER_BYTES_OK_P ()
          && !REGISTER_BYTES_OK (i))
-       warning ("Remote reply is too short: %s", buf);
+       warning (_("Remote reply is too short: %s"), buf);
     }
 
  supply_them:
@@ -3423,7 +3434,6 @@ store_register_using_P (int regnum)
   char *buf = alloca (rs->remote_packet_size);
   char regp[MAX_REGISTER_SIZE];
   char *p;
-  int i;
 
   sprintf (buf, "P%s=", phex_nz (reg->pnum, 0));
   p = buf + strlen (buf);
@@ -3444,7 +3454,6 @@ remote_store_registers (int regnum)
   struct remote_state *rs = get_remote_state ();
   char *buf;
   char *regs;
-  int i;
   char *p;
 
   set_thread (PIDGET (inferior_ptid), 1);
@@ -3459,7 +3468,7 @@ remote_store_registers (int regnum)
          if (store_register_using_P (regnum))
            return;
          else
-           error ("Protocol error: P packet not recognized by stub");
+           error (_("Protocol error: P packet not recognized by stub"));
        case PACKET_SUPPORT_UNKNOWN:
          if (store_register_using_P (regnum))
            {
@@ -3483,7 +3492,7 @@ remote_store_registers (int regnum)
   {
     int i;
     regs = alloca (rs->sizeof_g_packet);
-    memset (regs, rs->sizeof_g_packet, 0);
+    memset (regs, 0, rs->sizeof_g_packet);
     for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
       {
        struct packet_reg *r = &rs->regs[i];
@@ -3642,16 +3651,18 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
   /* Verify that the target can support a binary download.  */
   check_binary_download (memaddr);
 
+  payload_size = get_memory_write_packet_size ();
+  
   /* Compute the size, and then allocate space for the largest
-     possible packet.  Include space for an extra trailing NULL.  */
-  sizeof_buf = get_memory_write_packet_size () + 1;
+     possible packet.  Include space for an extra trailing NUL.  */
+  sizeof_buf = payload_size + 1;
   buf = alloca (sizeof_buf);
 
   /* Compute the size of the actual payload by subtracting out the
-     packet header and footer overhead: "$M<memaddr>,<len>:...#nn".  */
-  payload_size = (get_memory_write_packet_size () - (strlen ("$M,:#NN")
-                                                    + hexnumlen (memaddr)
-                                                    + hexnumlen (len)));
+     packet header and footer overhead: "$M<memaddr>,<len>:...#nn".
+     */
+  payload_size -= strlen ("$M,:#NN");
+  payload_size -= hexnumlen (memaddr);
 
   /* Construct the packet header: "[MX]<memaddr>,<len>:".   */
 
@@ -3664,18 +3675,25 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
       *p++ = 'X';
       /* Best guess at number of bytes that will fit.  */
       todo = min (len, payload_size);
+      payload_size -= hexnumlen (todo);
+      todo = min (todo, payload_size);
       break;
     case PACKET_DISABLE:
       *p++ = 'M';
       /* Num bytes that will fit.  */
       todo = min (len, payload_size / 2);
+      payload_size -= hexnumlen (todo);
+      todo = min (todo, payload_size / 2);
       break;
     case PACKET_SUPPORT_UNKNOWN:
       internal_error (__FILE__, __LINE__,
-                     "remote_write_bytes: bad internal state");
+                     _("remote_write_bytes: bad internal state"));
     default:
-      internal_error (__FILE__, __LINE__, "bad switch");
+      internal_error (__FILE__, __LINE__, _("bad switch"));
     }
+  if (todo <= 0)
+    internal_error (__FILE__, __LINE__,
+                   _("minumum packet size too small to write data"));
 
   /* Append "<memaddr>".  */
   memaddr = remote_address_masked (memaddr);
@@ -3739,9 +3757,9 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
       break;
     case PACKET_SUPPORT_UNKNOWN:
       internal_error (__FILE__, __LINE__,
-                     "remote_write_bytes: bad internal state");
+                     _("remote_write_bytes: bad internal state"));
     default:
-      internal_error (__FILE__, __LINE__, "bad switch");
+      internal_error (__FILE__, __LINE__, _("bad switch"));
     }
 
   putpkt_binary (buf, (int) (p - buf));
@@ -3848,7 +3866,7 @@ remote_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
    read; 0 for error.  TARGET is unused.  */
 
 static int
-remote_xfer_memory (CORE_ADDR mem_addr, char *buffer, int mem_len,
+remote_xfer_memory (CORE_ADDR mem_addr, gdb_byte *buffer, int mem_len,
                    int should_write, struct mem_attrib *attrib,
                    struct target_ops *target)
 {
@@ -3898,10 +3916,10 @@ readchar (int timeout)
     {
     case SERIAL_EOF:
       target_mourn_inferior ();
-      error ("Remote connection closed");
+      error (_("Remote connection closed"));
       /* no return */
     case SERIAL_ERROR:
-      perror_with_name ("Remote communication error");
+      perror_with_name (_("Remote communication error"));
       /* no return */
     case SERIAL_TIMEOUT:
       break;
@@ -3920,7 +3938,7 @@ remote_send (char *buf,
   getpkt (buf, sizeof_buf, 0);
 
   if (buf[0] == 'E')
-    error ("Remote failure reply: %s", buf);
+    error (_("Remote failure reply: %s"), buf);
 }
 
 /* Display a null-terminated packet on stdout, for debugging, using C
@@ -3990,7 +4008,7 @@ putpkt_binary (char *buf, int cnt)
          gdb_flush (gdb_stdlog);
        }
       if (serial_write (remote_desc, buf2, p - buf2))
-       perror_with_name ("putpkt: write failed");
+       perror_with_name (_("putpkt: write failed"));
 
       /* Read until either a timeout occurs (-2) or '+' is read.  */
       while (1)
@@ -4169,7 +4187,7 @@ read_frame (char *buf,
              }
 
            buf[bc] = '\0';
-           printf_filtered ("Repeat count %d too large for buffer: "
+           printf_filtered (_("Repeat count %d too large for buffer: ")
                             repeat);
            puts_filtered (buf);
            puts_filtered ("\n");
@@ -4262,7 +4280,7 @@ getpkt_sane (char *buf,
                {
                  QUIT;
                  target_mourn_inferior ();
-                 error ("Watchdog has expired.  Target detached.\n");
+                 error (_("Watchdog has expired.  Target detached."));
                }
              if (remote_debug)
                fputs_filtered ("Timed out.\n", gdb_stdlog);
@@ -4295,7 +4313,7 @@ getpkt_sane (char *buf,
   /* We have tried hard enough, and just can't receive the packet.  
      Give up.  */
 
-  printf_unfiltered ("Ignoring packet error, continuing...\n");
+  printf_unfiltered (_("Ignoring packet error, continuing...\n"));
   serial_write (remote_desc, "+", 1);
   return 1;
 }
@@ -4476,7 +4494,7 @@ static unsigned char little_break_insn[] = DEPRECATED_LITTLE_REMOTE_BREAKPOINT;
    of bytes returned by BREAKPOINT_FROM_PC.  */
 
 static int
-remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
 {
   struct remote_state *rs = get_remote_state ();
 #ifdef DEPRECATED_REMOTE_BREAKPOINT
@@ -4536,7 +4554,7 @@ remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
 }
 
 static int
-remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
 {
   struct remote_state *rs = get_remote_state ();
   int bp_size;
@@ -4584,7 +4602,7 @@ watchpoint_to_Z_packet (int type)
       break;
     default:
       internal_error (__FILE__, __LINE__,
-                     "hw_bp_to_z: bad watchpoint type %d", type);
+                     _("hw_bp_to_z: bad watchpoint type %d"), type);
     }
 }
 
@@ -4597,7 +4615,7 @@ remote_insert_watchpoint (CORE_ADDR addr, int len, int type)
   enum Z_packet_type packet = watchpoint_to_Z_packet (type);
 
   if (remote_protocol_Z[packet].support == PACKET_DISABLE)
-    error ("Can't set hardware watchpoints without the '%s' (%s) packet\n",
+    error (_("Can't set hardware watchpoints without the '%s' (%s) packet."),
           remote_protocol_Z[packet].name,
           remote_protocol_Z[packet].title);
 
@@ -4619,7 +4637,7 @@ remote_insert_watchpoint (CORE_ADDR addr, int len, int type)
       return 0;
     }
   internal_error (__FILE__, __LINE__,
-                 "remote_insert_watchpoint: reached end of function");
+                 _("remote_insert_watchpoint: reached end of function"));
 }
 
 
@@ -4632,7 +4650,7 @@ remote_remove_watchpoint (CORE_ADDR addr, int len, int type)
   enum Z_packet_type packet = watchpoint_to_Z_packet (type);
 
   if (remote_protocol_Z[packet].support == PACKET_DISABLE)
-    error ("Can't clear hardware watchpoints without the '%s' (%s) packet\n",
+    error (_("Can't clear hardware watchpoints without the '%s' (%s) packet."),
           remote_protocol_Z[packet].name,
           remote_protocol_Z[packet].title);
 
@@ -4653,7 +4671,7 @@ remote_remove_watchpoint (CORE_ADDR addr, int len, int type)
       return 0;
     }
   internal_error (__FILE__, __LINE__,
-                 "remote_remove_watchpoint: reached end of function");
+                 _("remote_remove_watchpoint: reached end of function"));
 }
 
 
@@ -4710,7 +4728,7 @@ remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
 
 
 static int
-remote_insert_hw_breakpoint (CORE_ADDR addr, char *shadow)
+remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
 {
   int len = 0;
   struct remote_state *rs = get_remote_state ();
@@ -4723,7 +4741,7 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, char *shadow)
   BREAKPOINT_FROM_PC (&addr, &len);
 
   if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
-    error ("Can't set hardware breakpoint without the '%s' (%s) packet\n",
+    error (_("Can't set hardware breakpoint without the '%s' (%s) packet."),
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].name,
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].title);
 
@@ -4747,12 +4765,12 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, char *shadow)
       return 0;
     }
   internal_error (__FILE__, __LINE__,
-                 "remote_insert_hw_breakpoint: reached end of function");
+                 _("remote_insert_hw_breakpoint: reached end of function"));
 }
 
 
 static int
-remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
+remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
 {
   int len;
   struct remote_state *rs = get_remote_state ();
@@ -4765,7 +4783,7 @@ remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
   BREAKPOINT_FROM_PC (&addr, &len);
 
   if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
-    error ("Can't clear hardware breakpoint without the '%s' (%s) packet\n",
+    error (_("Can't clear hardware breakpoint without the '%s' (%s) packet."),
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].name,
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].title);
 
@@ -4789,7 +4807,7 @@ remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
       return 0;
     }
   internal_error (__FILE__, __LINE__,
-                 "remote_remove_hw_breakpoint: reached end of function");
+                 _("remote_remove_hw_breakpoint: reached end of function"));
 }
 
 /* Some targets are only capable of doing downloads, and afterwards
@@ -4805,7 +4823,7 @@ remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
 void
 push_remote_target (char *name, int from_tty)
 {
-  printf_filtered ("Switching to remote protocol\n");
+  printf_filtered (_("Switching to remote protocol\n"));
   remote_open (name, from_tty);
 }
 
@@ -4869,10 +4887,10 @@ compare_sections_command (char *args, int from_tty)
   int mismatched = 0;
 
   if (!exec_bfd)
-    error ("command cannot be used without an exec file");
+    error (_("command cannot be used without an exec file"));
   if (!current_target.to_shortname ||
       strcmp (current_target.to_shortname, "remote") != 0)
-    error ("command can only be used with remote target");
+    error (_("command can only be used with remote target"));
 
   for (s = exec_bfd->sections; s; s = s->next)
     {
@@ -4902,10 +4920,10 @@ compare_sections_command (char *args, int from_tty)
 
       getpkt (buf, (rs->remote_packet_size), 0);
       if (buf[0] == 'E')
-       error ("target memory fault, section %s, range 0x%s -- 0x%s",
+       error (_("target memory fault, section %s, range 0x%s -- 0x%s"),
               sectname, paddr (lma), paddr (lma + size));
       if (buf[0] != 'C')
-       error ("remote target does not support this operation");
+       error (_("remote target does not support this operation"));
 
       for (target_crc = 0, tmp = &buf[1]; *tmp; tmp++)
        target_crc = target_crc * 16 + fromhex (*tmp);
@@ -4923,16 +4941,16 @@ compare_sections_command (char *args, int from_tty)
       do_cleanups (old_chain);
     }
   if (mismatched > 0)
-    warning ("One or more sections of the remote executable does not match\n\
-the loaded file\n");
+    warning (_("One or more sections of the remote executable does not match\n\
+the loaded file\n"));
   if (args && !matched)
-    printf_filtered ("No loaded section named '%s'.\n", args);
+    printf_filtered (_("No loaded section named '%s'.\n"), args);
 }
 
 static LONGEST
 remote_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)
 {
   struct remote_state *rs = get_remote_state ();
   int i;
@@ -5030,7 +5048,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
 
   /* Except for querying the minimum buffer size, target must be open.  */
   if (!remote_desc)
-    error ("remote query is only available after target open");
+    error (_("remote query is only available after target open"));
 
   gdb_assert (annex != NULL);
   gdb_assert (readbuf != NULL);
@@ -5068,12 +5086,11 @@ remote_rcmd (char *command,
             struct ui_file *outbuf)
 {
   struct remote_state *rs = get_remote_state ();
-  int i;
   char *buf = alloca (rs->remote_packet_size);
   char *p = buf;
 
   if (!remote_desc)
-    error ("remote rcmd is only available after target open");
+    error (_("remote rcmd is only available after target open"));
 
   /* Send a NULL command across as an empty command.  */
   if (command == NULL)
@@ -5084,13 +5101,13 @@ remote_rcmd (char *command,
   p = strchr (buf, '\0');
 
   if ((strlen (buf) + strlen (command) * 2 + 8/*misc*/) > (rs->remote_packet_size))
-    error ("\"monitor\" command ``%s'' is too long\n", command);
+    error (_("\"monitor\" command ``%s'' is too long."), command);
 
   /* Encode the actual command.  */
   bin2hex (command, p, 0);
 
   if (putpkt (buf) < 0)
-    error ("Communication problem with target\n");
+    error (_("Communication problem with target."));
 
   /* get/display the response */
   while (1)
@@ -5099,7 +5116,7 @@ remote_rcmd (char *command,
       buf[0] = '\0';
       getpkt (buf, (rs->remote_packet_size), 0);
       if (buf[0] == '\0')
-       error ("Target does not support this command\n");
+       error (_("Target does not support this command."));
       if (buf[0] == 'O' && buf[1] != 'K')
        {
          remote_console_output (buf + 1); /* 'O' message from stub.  */
@@ -5110,7 +5127,7 @@ remote_rcmd (char *command,
       if (strlen (buf) == 3 && buf[0] == 'E'
          && isdigit (buf[1]) && isdigit (buf[2]))
        {
-         error ("Protocol error with Rcmd");
+         error (_("Protocol error with Rcmd"));
        }
       for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2)
        {
@@ -5128,10 +5145,10 @@ packet_command (char *args, int from_tty)
   char *buf = alloca (rs->remote_packet_size);
 
   if (!remote_desc)
-    error ("command can only be used with remote target");
+    error (_("command can only be used with remote target"));
 
   if (!args)
-    error ("remote-packet command requires packet text as argument");
+    error (_("remote-packet command requires packet text as argument"));
 
   puts_filtered ("sending: ");
   print_packet (args);
@@ -5172,7 +5189,7 @@ threadset_test_cmd (char *cmd, int tty)
 {
   int sample_thread = SAMPLE_THREAD;
 
-  printf_filtered ("Remote threadset test\n");
+  printf_filtered (_("Remote threadset test\n"));
   set_thread (sample_thread, 1);
 }
 
@@ -5275,16 +5292,16 @@ threadlist_update_test_cmd (char *cmd, int tty)
 static void
 init_remote_threadtests (void)
 {
-  add_com ("tlist", class_obscure, threadlist_test_cmd,
-     "Fetch and print the remote list of thread identifiers, one pkt only");
+  add_com ("tlist", class_obscure, threadlist_test_cmd, _("\
+Fetch and print the remote list of thread identifiers, one pkt only"));
   add_com ("tinfo", class_obscure, threadinfo_test_cmd,
-          "Fetch and display info about one thread");
+          _("Fetch and display info about one thread"));
   add_com ("tset", class_obscure, threadset_test_cmd,
-          "Test setting to a different thread");
+          _("Test setting to a different thread"));
   add_com ("tupd", class_obscure, threadlist_update_test_cmd,
-          "Iterate through updating all remote thread info");
+          _("Iterate through updating all remote thread info"));
   add_com ("talive", class_obscure, threadalive_test,
-          " Remote thread alive test ");
+          _(" Remote thread alive test "));
 }
 
 #endif /* 0 */
@@ -5295,12 +5312,60 @@ init_remote_threadtests (void)
 static char *
 remote_pid_to_str (ptid_t ptid)
 {
-  static char buf[30];
+  static char buf[32];
+  int size;
 
-  sprintf (buf, "Thread %d", PIDGET (ptid));
+  size = snprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid));
+  gdb_assert (size < sizeof buf);
   return buf;
 }
 
+/* Get the address of the thread local variable in OBJFILE which is
+   stored at OFFSET within the thread local storage for thread PTID.  */
+
+static CORE_ADDR
+remote_get_thread_local_address (ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset)
+{
+  if (remote_protocol_qGetTLSAddr.support != PACKET_DISABLE)
+    {
+      struct remote_state *rs = get_remote_state ();
+      char *buf = alloca (rs->remote_packet_size);
+      char *p = buf;
+      enum packet_result result;
+
+      strcpy (p, "qGetTLSAddr:");
+      p += strlen (p);
+      p += hexnumstr (p, PIDGET (ptid));
+      *p++ = ',';
+      p += hexnumstr (p, offset);
+      *p++ = ',';
+      p += hexnumstr (p, lm);
+      *p++ = '\0';
+
+      putpkt (buf);
+      getpkt (buf, rs->remote_packet_size, 0);
+      result = packet_ok (buf, &remote_protocol_qGetTLSAddr);
+      if (result == PACKET_OK)
+       {
+         ULONGEST result;
+
+         unpack_varlen_hex (buf, &result);
+         return result;
+       }
+      else if (result == PACKET_UNKNOWN)
+       throw_error (TLS_GENERIC_ERROR,
+                    _("Remote target doesn't support qGetTLSAddr packet"));
+      else
+       throw_error (TLS_GENERIC_ERROR,
+                    _("Remote target failed to process qGetTLSAddr request"));
+    }
+  else
+    throw_error (TLS_GENERIC_ERROR,
+                _("TLS not supported or disabled on this target"));
+  /* Not reached.  */
+  return 0;
+}
+
 static void
 init_remote_ops (void)
 {
@@ -5340,6 +5405,7 @@ Specify the serial device it is connected to\n\
   remote_ops.to_stop = remote_stop;
   remote_ops.to_xfer_partial = remote_xfer_partial;
   remote_ops.to_rcmd = remote_rcmd;
+  remote_ops.to_get_thread_local_address = remote_get_thread_local_address;
   remote_ops.to_stratum = process_stratum;
   remote_ops.to_has_all_memory = 1;
   remote_ops.to_has_memory = 1;
@@ -5406,7 +5472,7 @@ remote_async (void (*callback) (enum inferior_event_type event_type,
 {
   if (current_target.to_async_mask_value == 0)
     internal_error (__FILE__, __LINE__,
-                   "Calling remote_async when async is masked");
+                   _("Calling remote_async when async is masked"));
 
   if (callback != NULL)
     {
@@ -5508,13 +5574,14 @@ show_remote_cmd (char *args, int from_tty)
 {
   /* FIXME: cagney/2002-06-15: This function should iterate over
      remote_show_cmdlist for a list of sub commands to show.  */
-  show_remote_protocol_Z_packet_cmd (args, from_tty, NULL);
-  show_remote_protocol_P_packet_cmd (args, from_tty, NULL);
-  show_remote_protocol_p_packet_cmd (args, from_tty, NULL);
-  show_remote_protocol_qSymbol_packet_cmd (args, from_tty, NULL);
-  show_remote_protocol_vcont_packet_cmd (args, from_tty, NULL);
-  show_remote_protocol_binary_download_cmd (args, from_tty, NULL);
-  show_remote_protocol_qPart_auxv_packet_cmd (args, from_tty, NULL);
+  show_remote_protocol_Z_packet_cmd (gdb_stdout, from_tty, NULL, NULL);
+  show_remote_protocol_P_packet_cmd (gdb_stdout, from_tty, NULL, NULL);
+  show_remote_protocol_p_packet_cmd (gdb_stdout, from_tty, NULL, NULL);
+  show_remote_protocol_qSymbol_packet_cmd (gdb_stdout, from_tty, NULL, NULL);
+  show_remote_protocol_vcont_packet_cmd (gdb_stdout, from_tty, NULL, NULL);
+  show_remote_protocol_binary_download_cmd (gdb_stdout, from_tty, NULL, NULL);
+  show_remote_protocol_qPart_auxv_packet_cmd (gdb_stdout, from_tty, NULL, NULL);
+  show_remote_protocol_qGetTLSAddr_packet_cmd (gdb_stdout, from_tty, NULL, NULL);
 }
 
 static void
@@ -5545,7 +5612,6 @@ _initialize_remote (void)
 {
   static struct cmd_list_element *remote_set_cmdlist;
   static struct cmd_list_element *remote_show_cmdlist;
-  struct cmd_list_element *tmpcmd;
 
   /* architecture specific data */
   remote_gdbarch_data_handle = 
@@ -5578,98 +5644,95 @@ _initialize_remote (void)
 
   /* set/show remote ...  */
 
-  add_prefix_cmd ("remote", class_maintenance, set_remote_cmd, "\
+  add_prefix_cmd ("remote", class_maintenance, set_remote_cmd, _("\
 Remote protocol specific variables\n\
 Configure various remote-protocol specific variables such as\n\
-the packets being used",
+the packets being used"),
                  &remote_set_cmdlist, "set remote ",
                  0 /* allow-unknown */, &setlist);
-  add_prefix_cmd ("remote", class_maintenance, show_remote_cmd, "\
+  add_prefix_cmd ("remote", class_maintenance, show_remote_cmd, _("\
 Remote protocol specific variables\n\
 Configure various remote-protocol specific variables such as\n\
-the packets being used",
+the packets being used"),
                  &remote_show_cmdlist, "show remote ",
                  0 /* allow-unknown */, &showlist);
 
-  add_cmd ("compare-sections", class_obscure, compare_sections_command,
-          "Compare section data on target to the exec file.\n\
-Argument is a single section name (default: all loaded sections).",
+  add_cmd ("compare-sections", class_obscure, compare_sections_command, _("\
+Compare section data on target to the exec file.\n\
+Argument is a single section name (default: all loaded sections)."),
           &cmdlist);
 
-  add_cmd ("packet", class_maintenance, packet_command,
-          "Send an arbitrary packet to a remote target.\n\
+  add_cmd ("packet", class_maintenance, packet_command, _("\
+Send an arbitrary packet to a remote target.\n\
    maintenance packet TEXT\n\
 If GDB is talking to an inferior via the GDB serial protocol, then\n\
 this command sends the string TEXT to the inferior, and displays the\n\
 response packet.  GDB supplies the initial `$' character, and the\n\
-terminating `#' character and checksum.",
+terminating `#' character and checksum."),
           &maintenancelist);
 
-  add_setshow_boolean_cmd ("remotebreak", no_class, &remote_break, "\
-Set whether to send break if interrupted.", "\
-Show whether to send break if interrupted.", "\
-If set, a break, instead of a cntrl-c, is sent to the remote target.", "\
-Whether to send break if interrupted is %s.",
-                          NULL, NULL,
+  add_setshow_boolean_cmd ("remotebreak", no_class, &remote_break, _("\
+Set whether to send break if interrupted."), _("\
+Show whether to send break if interrupted."), _("\
+If set, a break, instead of a cntrl-c, is sent to the remote target."),
+                          NULL, NULL, /* FIXME: i18n: Whether to send break if interrupted is %s.  */
                           &setlist, &showlist);
 
   /* Install commands for configuring memory read/write packets.  */
 
-  add_cmd ("remotewritesize", no_class, set_memory_write_packet_size,
-          "Set the maximum number of bytes per memory write packet (deprecated).\n",
+  add_cmd ("remotewritesize", no_class, set_memory_write_packet_size, _("\
+Set the maximum number of bytes per memory write packet (deprecated)."),
           &setlist);
-  add_cmd ("remotewritesize", no_class, show_memory_write_packet_size,
-          "Show the maximum number of bytes per memory write packet (deprecated).\n",
+  add_cmd ("remotewritesize", no_class, show_memory_write_packet_size, _("\
+Show the maximum number of bytes per memory write packet (deprecated)."),
           &showlist);
   add_cmd ("memory-write-packet-size", no_class,
-          set_memory_write_packet_size,
-          "Set the maximum number of bytes per memory-write packet.\n"
-          "Specify the number of bytes in a packet or 0 (zero) for the\n"
-          "default packet size.  The actual limit is further reduced\n"
-          "dependent on the target.  Specify ``fixed'' to disable the\n"
-          "further restriction and ``limit'' to enable that restriction\n",
+          set_memory_write_packet_size, _("\
+Set the maximum number of bytes per memory-write packet.\n\
+Specify the number of bytes in a packet or 0 (zero) for the\n\
+default packet size.  The actual limit is further reduced\n\
+dependent on the target.  Specify ``fixed'' to disable the\n\
+further restriction and ``limit'' to enable that restriction."),
           &remote_set_cmdlist);
   add_cmd ("memory-read-packet-size", no_class,
-          set_memory_read_packet_size,
-          "Set the maximum number of bytes per memory-read packet.\n"
-          "Specify the number of bytes in a packet or 0 (zero) for the\n"
-          "default packet size.  The actual limit is further reduced\n"
-          "dependent on the target.  Specify ``fixed'' to disable the\n"
-          "further restriction and ``limit'' to enable that restriction\n",
+          set_memory_read_packet_size, _("\
+Set the maximum number of bytes per memory-read packet.\n\
+Specify the number of bytes in a packet or 0 (zero) for the\n\
+default packet size.  The actual limit is further reduced\n\
+dependent on the target.  Specify ``fixed'' to disable the\n\
+further restriction and ``limit'' to enable that restriction."),
           &remote_set_cmdlist);
   add_cmd ("memory-write-packet-size", no_class,
           show_memory_write_packet_size,
-          "Show the maximum number of bytes per memory-write packet.\n",
+          _("Show the maximum number of bytes per memory-write packet."),
           &remote_show_cmdlist);
   add_cmd ("memory-read-packet-size", no_class,
           show_memory_read_packet_size,
-          "Show the maximum number of bytes per memory-read packet.\n",
+          _("Show the maximum number of bytes per memory-read packet."),
           &remote_show_cmdlist);
 
   add_setshow_zinteger_cmd ("hardware-watchpoint-limit", no_class,
-                           &remote_hw_watchpoint_limit, "\
-Set the maximum number of target hardware watchpoints.", "\
-Show the maximum number of target hardware watchpoints.", "\
-Specify a negative limit for unlimited.", "\
-The maximum number of target hardware watchpoints is %s.",
-                           NULL, NULL,
+                           &remote_hw_watchpoint_limit, _("\
+Set the maximum number of target hardware watchpoints."), _("\
+Show the maximum number of target hardware watchpoints."), _("\
+Specify a negative limit for unlimited."),
+                           NULL, NULL, /* FIXME: i18n: The maximum number of target hardware watchpoints is %s.  */
                            &remote_set_cmdlist, &remote_show_cmdlist);
   add_setshow_zinteger_cmd ("hardware-breakpoint-limit", no_class,
-                           &remote_hw_breakpoint_limit, "\
-Set the maximum number of target hardware breakpoints.", "\
-Show the maximum number of target hardware breakpoints.", "\
-Specify a negative limit for unlimited.", "\
-The maximum number of target hardware breakpoints is %s.",
-                           NULL, NULL,
+                           &remote_hw_breakpoint_limit, _("\
+Set the maximum number of target hardware breakpoints."), _("\
+Show the maximum number of target hardware breakpoints."), _("\
+Specify a negative limit for unlimited."),
+                           NULL, NULL, /* FIXME: i18n: The maximum number of target hardware breakpoints is %s.  */
                            &remote_set_cmdlist, &remote_show_cmdlist);
 
-  deprecated_add_show_from_set
-    (add_set_cmd ("remoteaddresssize", class_obscure,
-                 var_integer, (char *) &remote_address_size,
-                 "Set the maximum size of the address (in bits) \
-in a memory packet.\n",
-                 &setlist),
-     &showlist);
+  add_setshow_integer_cmd ("remoteaddresssize", class_obscure,
+                          &remote_address_size, _("\
+Set the maximum size of the address (in bits) in a memory packet."), _("\
+Show the maximum size of the address (in bits) in a memory packet."), NULL,
+                          NULL,
+                          NULL, /* FIXME: i18n: */
+                          &setlist, &showlist);
 
   add_packet_config_cmd (&remote_protocol_binary_download,
                         "X", "binary-download",
@@ -5677,15 +5740,6 @@ in a memory packet.\n",
                         show_remote_protocol_binary_download_cmd,
                         &remote_set_cmdlist, &remote_show_cmdlist,
                         1);
-#if 0
-  /* XXXX - should ``set remotebinarydownload'' be retained for
-     compatibility.  */
-  deprecated_add_show_from_set
-    (add_set_cmd ("remotebinarydownload", no_class,
-                 var_boolean, (char *) &remote_binary_download,
-                 "Set binary downloads.\n", &setlist),
-     &showlist);
-#endif
 
   add_packet_config_cmd (&remote_protocol_vcont,
                         "vCont", "verbose-resume",
@@ -5757,16 +5811,22 @@ in a memory packet.\n",
                         &remote_set_cmdlist, &remote_show_cmdlist,
                         0);
 
+  add_packet_config_cmd (&remote_protocol_qGetTLSAddr,
+                        "qGetTLSAddr", "get-thread-local-storage-address",
+                        set_remote_protocol_qGetTLSAddr_packet_cmd,
+                        show_remote_protocol_qGetTLSAddr_packet_cmd,
+                        &remote_set_cmdlist, &remote_show_cmdlist,
+                        0);
+
   /* Keep the old ``set remote Z-packet ...'' working.  */
   add_setshow_auto_boolean_cmd ("Z-packet", class_obscure,
-                               &remote_Z_packet_detect, "\
-Set use of remote protocol `Z' packets""\
-Show use of remote protocol `Z' packets ""\
+                               &remote_Z_packet_detect, _("\
+Set use of remote protocol `Z' packets"), _("\
+Show use of remote protocol `Z' packets "), _("\
 When set, GDB will attempt to use the remote breakpoint and watchpoint\n\
-packets.", "\
-Use of remote protocol `Z' packets is %s",
+packets."),
                                set_remote_protocol_Z_packet_cmd,
-                               show_remote_protocol_Z_packet_cmd,
+                               show_remote_protocol_Z_packet_cmd, /* FIXME: i18n: Use of remote protocol `Z' packets is %s.  */
                                &remote_set_cmdlist, &remote_show_cmdlist);
 
   /* Eventually initialize fileio.  See fileio.c */
This page took 0.151208 seconds and 4 git commands to generate.