2004-10-06 Felix Lee <felix+log1@specifixinc.com>
[deliverable/binutils-gdb.git] / gdb / remote.c
index 55bc135a9b25e761ff865bcea0f09439fe7e303b..7cbbbd89bb0374659bba64006b6c92f0051650b7 100644 (file)
@@ -43,9 +43,6 @@
 
 #include <ctype.h>
 #include <sys/time.h>
-#ifdef USG
-#include <sys/types.h>
-#endif
 
 #include "event-loop.h"
 #include "event-top.h"
@@ -107,9 +104,6 @@ static void extended_remote_restart (void);
 
 static void extended_remote_mourn (void);
 
-static void extended_remote_create_inferior (char *, char *, char **);
-static void extended_remote_async_create_inferior (char *, char *, char **);
-
 static void remote_mourn_1 (struct target_ops *);
 
 static void remote_send (char *buf, long sizeof_buf);
@@ -211,7 +205,7 @@ struct packet_reg
   long regnum; /* GDB's internal register number.  */
   LONGEST pnum; /* Remote protocol register number.  */
   int in_g_packet; /* Always part of G packet.  */
-  /* long size in bytes;  == DEPRECATED_REGISTER_RAW_SIZE (regnum); at present.  */
+  /* long size in bytes;  == register_size (current_gdbarch, regnum); at present.  */
   /* char *name; == REGISTER_NAME (regnum); at present.  */
 };
 
@@ -253,8 +247,8 @@ 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;
+  if (deprecated_register_bytes () != 0)
+    rs->sizeof_g_packet = deprecated_register_bytes ();
   else
     rs->sizeof_g_packet = 0;
 
@@ -271,7 +265,7 @@ 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)
+      if (deprecated_register_bytes () == 0)
         rs->sizeof_g_packet += register_size (current_gdbarch, regnum);
     }
 
@@ -292,7 +286,7 @@ init_remote_state (struct gdbarch *gdbarch)
      little. */
   if (rs->sizeof_g_packet > ((rs->remote_packet_size - 32) / 2))
     rs->remote_packet_size = (rs->sizeof_g_packet * 2 + 32);
-  
+
   /* This one is filled in when a ``g'' packet is received. */
   rs->actual_register_packet_size = 0;
 
@@ -649,26 +643,31 @@ add_packet_config_cmd (struct packet_config *config,
   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;
   config->support = PACKET_SUPPORT_UNKNOWN;
-  xasprintf (&set_doc, "Set use of remote protocol `%s' (%s) packet",
-            name, title);
-  xasprintf (&show_doc, "Show current use of remote protocol `%s' (%s) packet",
-            name, title);
+  set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet",
+                       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} */
-  xasprintf (&cmd_name, "%s-packet", title);
+  cmd_name = xstrprintf ("%s-packet", title);
   add_setshow_auto_boolean_cmd (cmd_name, class_obscure,
                                &config->detect, set_doc, show_doc,
+                               "", print,
                                set_func, show_func,
                                set_remote_list, show_remote_list);
   /* set/show remote NAME-packet {auto,on,off} -- legacy */
   if (legacy)
     {
       char *legacy_name;
-      xasprintf (&legacy_name, "%s-packet", name);
+      legacy_name = xstrprintf ("%s-packet", name);
       add_alias_cmd (legacy_name, cmd_name, class_obscure, 0,
                     set_remote_list);
       add_alias_cmd (legacy_name, cmd_name, class_obscure, 0,
@@ -774,42 +773,6 @@ show_remote_protocol_qSymbol_packet_cmd (char *args, int from_tty,
   show_packet_config_cmd (&remote_protocol_qSymbol);
 }
 
-/* Should we try the 'e' (step over range) request? */
-static struct packet_config remote_protocol_e;
-
-static void
-set_remote_protocol_e_packet_cmd (char *args, int from_tty,
-                                 struct cmd_list_element *c)
-{
-  update_packet_config (&remote_protocol_e);
-}
-
-static void
-show_remote_protocol_e_packet_cmd (char *args, int from_tty,
-                                  struct cmd_list_element *c)
-{
-  show_packet_config_cmd (&remote_protocol_e);
-}
-  
-
-/* Should we try the 'E' (step over range / w signal #) request? */
-static struct packet_config remote_protocol_E;
-
-static void
-set_remote_protocol_E_packet_cmd (char *args, int from_tty,
-                                 struct cmd_list_element *c)
-{
-  update_packet_config (&remote_protocol_E);
-}
-
-static void
-show_remote_protocol_E_packet_cmd (char *args, int from_tty,
-                                  struct cmd_list_element *c)
-{
-  show_packet_config_cmd (&remote_protocol_E);
-}
-  
-
 /* Should we try the 'P' (set register) request?  */
 
 static struct packet_config remote_protocol_P;
@@ -960,7 +923,7 @@ static struct packet_config remote_protocol_binary_download;
    This variable (NOT available to the user: auto-detect only!)
    determines whether GDB will use the new, simpler "ThreadInfo"
    query or the older, more complex syntax for thread queries.
-   This is an auto-detect variable (set to true at each connect, 
+   This is an auto-detect variable (set to true at each connect,
    and set to false when the target fails to recognize it).  */
 
 static int use_threadinfo_query;
@@ -981,6 +944,40 @@ show_remote_protocol_binary_download_cmd (char *args, int from_tty,
   show_packet_config_cmd (&remote_protocol_binary_download);
 }
 
+/* Should we try the 'qPart:auxv' (target auxiliary vector read) request? */
+static struct packet_config remote_protocol_qPart_auxv;
+
+static void
+set_remote_protocol_qPart_auxv_packet_cmd (char *args, int from_tty,
+                                          struct cmd_list_element *c)
+{
+  update_packet_config (&remote_protocol_qPart_auxv);
+}
+
+static void
+show_remote_protocol_qPart_auxv_packet_cmd (char *args, int from_tty,
+                                           struct cmd_list_element *c)
+{
+  show_packet_config_cmd (&remote_protocol_qPart_auxv);
+}
+
+static struct packet_config remote_protocol_p;
+
+static void
+set_remote_protocol_p_packet_cmd (char *args, int from_tty,
+                                 struct cmd_list_element *c)
+{
+  update_packet_config (&remote_protocol_p);
+}
+
+static void
+show_remote_protocol_p_packet_cmd (char *args, int from_tty,
+                                  struct cmd_list_element *c)
+{
+  show_packet_config_cmd (&remote_protocol_p);
+}
+
+
 
 /* Tokens for use by the asynchronous signal handlers for SIGINT */
 static void *sigint_remote_twice_token;
@@ -989,8 +986,8 @@ static void *sigint_remote_token;
 /* These are pointers to hook functions that may be set in order to
    modify resume/wait behavior for a particular architecture.  */
 
-void (*target_resume_hook) (void);
-void (*target_wait_loop_hook) (void);
+void (*deprecated_target_resume_hook) (void);
+void (*deprecated_target_wait_loop_hook) (void);
 \f
 
 
@@ -1455,7 +1452,7 @@ pack_threadinfo_request (char *pkt, int mode, threadref *id)
                                   fetch registers and its stack */
 #define TAG_DISPLAY 4          /* A short thing maybe to put on a window */
 #define TAG_THREADNAME 8       /* string, maps 1-to-1 with a thread is */
-#define TAG_MOREDISPLAY 16     /* Whatever the kernel wants to say about 
+#define TAG_MOREDISPLAY 16     /* Whatever the kernel wants to say about
                                   the process */
 
 static int
@@ -1743,8 +1740,8 @@ remote_current_thread (ptid_t oldpid)
     return oldpid;
 }
 
-/* Find new threads for info threads command.  
- * Original version, using John Metzler's thread protocol.  
+/* Find new threads for info threads command.
+ * Original version, using John Metzler's thread protocol.
  */
 
 static void
@@ -1780,7 +1777,7 @@ remote_threads_info (void)
       bufp = buf;
       getpkt (bufp, (rs->remote_packet_size), 0);
       if (bufp[0] != '\0')             /* q packet recognized */
-       {       
+       {
          while (*bufp++ == 'm')        /* reply contains one or more TID */
            {
              do
@@ -1804,12 +1801,12 @@ remote_threads_info (void)
   return;
 }
 
-/* 
+/*
  * Collect a descriptive string about the given thread.
  * The target may say anything it wants to about the thread
  * (typically info about its blocked / runnable state, name, etc.).
  * This string will appear in the info threads display.
- * 
+ *
  * Optional: targets are not required to implement this function.
  */
 
@@ -1969,9 +1966,9 @@ get_offsets (void)
   if (symfile_objfile == NULL)
     return;
 
-  offs = ((struct section_offsets *) 
+  offs = ((struct section_offsets *)
          alloca (SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections)));
-  memcpy (offs, symfile_objfile->section_offsets, 
+  memcpy (offs, symfile_objfile->section_offsets,
          SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections));
 
   offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
@@ -2060,9 +2057,8 @@ static void
 init_all_packet_configs (void)
 {
   int i;
-  update_packet_config (&remote_protocol_e);
-  update_packet_config (&remote_protocol_E);
   update_packet_config (&remote_protocol_P);
+  update_packet_config (&remote_protocol_p);
   update_packet_config (&remote_protocol_qSymbol);
   update_packet_config (&remote_protocol_vcont);
   for (i = 0; i < NR_Z_PACKET_TYPES; i++)
@@ -2070,6 +2066,7 @@ init_all_packet_configs (void)
   /* Force remote_write_bytes to check whether target supports binary
      downloading. */
   update_packet_config (&remote_protocol_binary_download);
+  update_packet_config (&remote_protocol_qPart_auxv);
 }
 
 /* Symbol look-up. */
@@ -2103,7 +2100,7 @@ remote_check_symbols (struct objfile *objfile)
       if (sym == NULL)
        sprintf (msg, "qSymbol::%s", &reply[8]);
       else
-       sprintf (msg, "qSymbol:%s:%s", 
+       sprintf (msg, "qSymbol:%s:%s",
                 paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
                 &reply[8]);
       putpkt (msg);
@@ -2146,6 +2143,9 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
   if (!async_p)
     wait_forever_enabled_p = 1;
 
+  reopen_exec_file ();
+  reread_symbols ();
+
   target_preopen (from_tty);
 
   unpush_target (target);
@@ -2183,7 +2183,7 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
   push_target (target);                /* Switch to using remote target now */
 
   init_all_packet_configs ();
-  
+
   general_thread = -2;
   continue_thread = -2;
 
@@ -2259,10 +2259,10 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
       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 
+  /* 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
-     to the open function for any remote target that wants to 
+     to the open function for any remote target that wants to
      support svr4 shared libraries.  */
 
   /* Set up to detect and load shared libraries. */
@@ -2531,8 +2531,8 @@ remote_resume (ptid_t ptid, int step, enum target_signal siggnal)
 
   /* A hook for when we need to do something at the last moment before
      resumption.  */
-  if (target_resume_hook)
-    (*target_resume_hook) ();
+  if (deprecated_target_resume_hook)
+    (*deprecated_target_resume_hook) ();
 
   /* The vCont packet doesn't need to specify threads via Hc.  */
   if (remote_vcont_resume (ptid, step, siggnal))
@@ -2544,60 +2544,6 @@ remote_resume (ptid_t ptid, int step, enum target_signal siggnal)
   else
     set_thread (pid, 0);       /* run this thread */
 
-  /* The s/S/c/C packets do not return status.  So if the target does
-     not support the S or C packets, the debug agent returns an empty
-     string which is detected in remote_wait().  This protocol defect
-     is fixed in the e/E packets. */
-
-  if (step && step_range_end)
-    {
-      /* If the target does not support the 'E' packet, we try the 'S'
-        packet.  Ideally we would fall back to the 'e' packet if that
-        too is not supported.  But that would require another copy of
-        the code to issue the 'e' packet (and fall back to 's' if not
-        supported) in remote_wait().  */
-      
-      if (siggnal != TARGET_SIGNAL_0)
-       {
-         if (remote_protocol_E.support != PACKET_DISABLE)
-           {
-             p = buf;
-             *p++ = 'E';
-             *p++ = tohex (((int) siggnal >> 4) & 0xf);
-             *p++ = tohex (((int) siggnal) & 0xf);
-             *p++ = ',';
-             p += hexnumstr (p, (ULONGEST) step_range_start);
-             *p++ = ',';
-             p += hexnumstr (p, (ULONGEST) step_range_end);
-             *p++ = 0;
-
-             putpkt (buf);
-             getpkt (buf, (rs->remote_packet_size), 0);
-
-             if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
-               return;
-           }
-       }
-      else
-       {
-         if (remote_protocol_e.support != PACKET_DISABLE)
-           {
-             p = buf;
-             *p++ = 'e';
-             p += hexnumstr (p, (ULONGEST) step_range_start);
-             *p++ = ',';
-             p += hexnumstr (p, (ULONGEST) step_range_end);
-             *p++ = 0;
-
-             putpkt (buf);
-             getpkt (buf, (rs->remote_packet_size), 0);
-
-             if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
-               return;
-           }
-       }
-    }
-
   if (siggnal != TARGET_SIGNAL_0)
     {
       buf[0] = step ? 'S' : 'C';
@@ -2624,7 +2570,7 @@ remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal)
   /* FIXME: ezannoni 1999-09-28: We may need to move this out of here
      into infcmd.c in order to allow inferior function calls to work
      NOT asynchronously. */
-  if (event_loop_p && target_can_async_p ())
+  if (target_can_async_p ())
     target_async (inferior_event_handler, 0);
   /* Tell the world that the target is now executing. */
   /* FIXME: cagney/1999-09-23: Is it the targets responsibility to set
@@ -2838,7 +2784,7 @@ remote_console_output (char *msg)
 
 /* Wait until the remote machine stops, then return,
    storing status in STATUS just as `wait' would.
-   Returns "pid", which in the case of a multi-threaded 
+   Returns "pid", which in the case of a multi-threaded
    remote OS, is the thread-id.  */
 
 static ptid_t
@@ -2862,8 +2808,8 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
 
       /* This is a hook for when we need to do something (perhaps the
          collection of trace data) every time the target stops.  */
-      if (target_wait_loop_hook)
-       (*target_wait_loop_hook) ();
+      if (deprecated_target_wait_loop_hook)
+       (*deprecated_target_wait_loop_hook) ();
 
       remote_stopped_by_watchpoint_p = 0;
 
@@ -2896,7 +2842,7 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
                LONGEST pnum = 0;
 
                /* If the packet contains a register number save it in pnum
-                  and set p1 to point to the character following it. 
+                  and set p1 to point to the character following it.
                   Otherwise p1 points to p.  */
 
                /* If this packet is an awatch packet, don't parse the 'a'
@@ -2908,7 +2854,7 @@ remote_wait (ptid_t ptid, struct target_waitstatus *status)
                    pnum = strtol (p, &p_temp, 16);
                    p1 = (unsigned char *) p_temp;
                  }
-               else 
+               else
                  p1 = p;
 
                if (p1 == p)    /* No register number present here */
@@ -2953,11 +2899,11 @@ Packet: '%s'\n",
                      error ("Remote sent bad register number %s: %s\nPacket: '%s'\n",
                             phex_nz (pnum, 0), p, buf);
 
-                   fieldsize = hex2bin (p, regs, DEPRECATED_REGISTER_RAW_SIZE (reg->regnum));
+                   fieldsize = hex2bin (p, regs, register_size (current_gdbarch, reg->regnum));
                    p += 2 * fieldsize;
-                   if (fieldsize < DEPRECATED_REGISTER_RAW_SIZE (reg->regnum))
+                   if (fieldsize < register_size (current_gdbarch, reg->regnum))
                      warning ("Remote reply is too short: %s", buf);
-                   supply_register (reg->regnum, regs);
+                   regcache_raw_supply (current_regcache, reg->regnum, regs);
                  }
 
                if (*p++ != ';')
@@ -3053,8 +2999,8 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
 
       /* This is a hook for when we need to do something (perhaps the
          collection of trace data) every time the target stops.  */
-      if (target_wait_loop_hook)
-       (*target_wait_loop_hook) ();
+      if (deprecated_target_wait_loop_hook)
+       (*deprecated_target_wait_loop_hook) ();
 
       switch (buf[0])
        {
@@ -3085,19 +3031,19 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
                long pnum = 0;
 
                /* If the packet contains a register number, save it in pnum
-                  and set p1 to point to the character following it. 
+                  and set p1 to point to the character following it.
                   Otherwise p1 points to p.  */
 
                /* If this packet is an awatch packet, don't parse the 'a'
                   as a register number.  */
-               
+
                if (!strncmp (p, "awatch", strlen ("awatch")) != 0)
                  {
                    /* Read the register number.  */
                    pnum = strtol (p, &p_temp, 16);
                    p1 = (unsigned char *) p_temp;
                  }
-               else 
+               else
                  p1 = p;
 
                if (p1 == p)    /* No register number present here */
@@ -3128,7 +3074,7 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
                          p = p_temp;
                      }
                  }
-               
+
                else
                  {
                    struct packet_reg *reg = packet_reg_from_pnum (rs, pnum);
@@ -3141,11 +3087,11 @@ remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
                      error ("Remote sent bad register number %ld: %s\nPacket: '%s'\n",
                             pnum, p, buf);
 
-                   fieldsize = hex2bin (p, regs, DEPRECATED_REGISTER_RAW_SIZE (reg->regnum));
+                   fieldsize = hex2bin (p, regs, register_size (current_gdbarch, reg->regnum));
                    p += 2 * fieldsize;
-                   if (fieldsize < DEPRECATED_REGISTER_RAW_SIZE (reg->regnum))
+                   if (fieldsize < register_size (current_gdbarch, reg->regnum))
                      warning ("Remote reply is too short: %s", buf);
-                   supply_register (reg->regnum, regs);
+                   regcache_raw_supply (current_regcache, reg->regnum, regs);
                  }
 
                if (*p++ != ';')
@@ -3222,6 +3168,36 @@ static int register_bytes_found;
 /* Read the remote registers into the block REGS.  */
 /* Currently we just read all the registers, so we don't use regnum.  */
 
+static int
+fetch_register_using_p (int regnum)
+{
+  struct remote_state *rs = get_remote_state ();
+  char *buf = alloca (rs->remote_packet_size), *p;
+  char regp[MAX_REGISTER_SIZE];
+  int i;
+
+  buf[0] = 'p';
+  bin2hex((char *) &regnum, &buf[1], sizeof(regnum));
+  buf[9] = 0;
+  remote_send (buf, rs->remote_packet_size);
+  if (buf[0] != 0 && buf[0] != 'E') {
+     p = buf;
+     i = 0;
+     while (p[0] != 0) {
+       if (p[1] == 0) {
+               error("fetch_register_using_p: early buf termination");
+               return 0;
+       }
+       regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]);
+        p += 2;
+    }
+    regcache_raw_supply (current_regcache, regnum, regp);
+    return 1;
+ }
+
+ return 0;
+}
+
 static void
 remote_fetch_registers (int regnum)
 {
@@ -3242,6 +3218,31 @@ remote_fetch_registers (int regnum)
                        "Attempt to fetch a non G-packet register when this "
                        "remote.c does not support the p-packet.");
     }
+      switch (remote_protocol_p.support)
+       {
+       case PACKET_DISABLE:
+         break;
+       case PACKET_ENABLE:
+         if (fetch_register_using_p (regnum))
+           return;
+         else
+           error ("Protocol error: p packet not recognized by stub");
+       case PACKET_SUPPORT_UNKNOWN:
+         if (fetch_register_using_p (regnum))
+           {
+             /* The stub recognized the 'p' packet.  Remember this.  */
+             remote_protocol_p.support = PACKET_ENABLE;
+             return;
+           }
+         else
+           {
+             /* The stub does not support the 'P' packet.  Use 'G'
+                instead, and don't try using 'P' in the future (it
+                will just waste our time).  */
+             remote_protocol_p.support = PACKET_DISABLE;
+             break;
+           }
+       }
 
   sprintf (buf, "g");
   remote_send (buf, (rs->remote_packet_size));
@@ -3371,8 +3372,8 @@ store_register_using_P (int regnum)
 
   sprintf (buf, "P%s=", phex_nz (reg->pnum, 0));
   p = buf + strlen (buf);
-  regcache_collect (reg->regnum, regp);
-  bin2hex (regp, p, DEPRECATED_REGISTER_RAW_SIZE (reg->regnum));
+  regcache_raw_collect (current_regcache, reg->regnum, regp);
+  bin2hex (regp, p, register_size (current_gdbarch, reg->regnum));
   remote_send (buf, rs->remote_packet_size);
 
   return buf[0] != '\0';
@@ -3432,7 +3433,7 @@ remote_store_registers (int regnum)
       {
        struct packet_reg *r = &rs->regs[i];
        if (r->in_g_packet)
-         regcache_collect (r->regnum, regs + r->offset);
+         regcache_raw_collect (current_regcache, r->regnum, regs + r->offset);
       }
   }
 
@@ -3529,7 +3530,7 @@ check_binary_download (CORE_ADDR addr)
       {
        char *buf = alloca (rs->remote_packet_size);
        char *p;
-       
+
        p = buf;
        *p++ = 'X';
        p += hexnumstr (p, (ULONGEST) addr);
@@ -3537,7 +3538,7 @@ check_binary_download (CORE_ADDR addr)
        p += hexnumstr (p, (ULONGEST) 0);
        *p++ = ':';
        *p = '\0';
-       
+
        putpkt_binary (buf, (int) (p - buf));
        getpkt (buf, (rs->remote_packet_size), 0);
 
@@ -3619,14 +3620,14 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
     default:
       internal_error (__FILE__, __LINE__, "bad switch");
     }
-  
+
   /* Append "<memaddr>".  */
   memaddr = remote_address_masked (memaddr);
   p += hexnumstr (p, (ULONGEST) memaddr);
 
   /* Append ",".  */
   *p++ = ',';
-  
+
   /* Append <len>.  Retain the location/size of <len>.  It may need to
      be adjusted once the packet body has been created.  */
   plen = p;
@@ -3636,7 +3637,7 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
   /* Append ":".  */
   *p++ = ':';
   *p = '\0';
-  
+
   /* Append the packet body.  */
   payload_start = p;
   switch (remote_protocol_binary_download.support)
@@ -3665,7 +3666,7 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
        }
       if (nr_bytes < todo)
        {
-         /* Escape chars have filled up the buffer prematurely, 
+         /* Escape chars have filled up the buffer prematurely,
             and we have actually sent fewer bytes than planned.
             Fix-up the length field of the packet.  Use the same
             number of characters as before.  */
@@ -3686,10 +3687,10 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
     default:
       internal_error (__FILE__, __LINE__, "bad switch");
     }
-  
+
   putpkt_binary (buf, (int) (p - buf));
   getpkt (buf, sizeof_buf, 0);
-  
+
   if (buf[0] == 'E')
     {
       /* There is no correspondance between what the remote protocol
@@ -3699,7 +3700,7 @@ remote_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
       errno = EIO;
       return 0;
     }
-  
+
   /* Return NR_BYTES, not TODO, in case escape chars caused us to send fewer
      bytes than we'd planned.  */
   return nr_bytes;
@@ -4051,7 +4052,7 @@ read_frame (char *buf,
            check_0 = readchar (remote_timeout);
            if (check_0 >= 0)
              check_1 = readchar (remote_timeout);
-           
+
            if (check_0 == SERIAL_TIMEOUT || check_1 == SERIAL_TIMEOUT)
              {
                if (remote_debug)
@@ -4092,7 +4093,7 @@ read_frame (char *buf,
 
            /* The character before ``*'' is repeated. */
 
-           if (repeat > 0 && repeat <= 255 
+           if (repeat > 0 && repeat <= 255
                && bc > 0
                 && bc + repeat - 1 < sizeof_buf - 1)
              {
@@ -4293,7 +4294,7 @@ extended_remote_mourn (void)
 {
   /* We do _not_ want to mourn the target like this; this will
      remove the extended remote target  from the target stack,
-     and the next time the user says "run" it'll fail. 
+     and the next time the user says "run" it'll fail.
 
      FIXME: What is the right thing to do here?  */
 #if 0
@@ -4311,13 +4312,14 @@ remote_mourn_1 (struct target_ops *target)
 
 /* In the extended protocol we want to be able to do things like
    "run" and have them basically work as expected.  So we need
-   a special create_inferior function. 
+   a special create_inferior function.
 
    FIXME: One day add support for changing the exec file
    we're debugging, arguments and an environment.  */
 
 static void
-extended_remote_create_inferior (char *exec_file, char *args, char **env)
+extended_remote_create_inferior (char *exec_file, char *args, char **env,
+                                int from_tty)
 {
   /* Rip out the breakpoints; we'll reinsert them after restarting
      the remote server.  */
@@ -4339,7 +4341,8 @@ extended_remote_create_inferior (char *exec_file, char *args, char **env)
 
 /* Async version of extended_remote_create_inferior. */
 static void
-extended_remote_async_create_inferior (char *exec_file, char *args, char **env)
+extended_remote_async_create_inferior (char *exec_file, char *args, char **env,
+                                      int from_tty)
 {
   /* Rip out the breakpoints; we'll reinsert them after restarting
      the remote server.  */
@@ -4347,7 +4350,7 @@ extended_remote_async_create_inferior (char *exec_file, char *args, char **env)
 
   /* If running asynchronously, register the target file descriptor
      with the event loop. */
-  if (event_loop_p && target_can_async_p ())
+  if (target_can_async_p ())
     target_async (inferior_event_handler, 0);
 
   /* Now restart the remote server.  */
@@ -4408,19 +4411,19 @@ remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
   struct remote_state *rs = get_remote_state ();
 #ifdef DEPRECATED_REMOTE_BREAKPOINT
   int val;
-#endif  
+#endif
   int bp_size;
 
   /* Try the "Z" s/w breakpoint packet if it is not already disabled.
      If it succeeds, then set the support to PACKET_ENABLE.  If it
      fails, and the user has explicitly requested the Z support then
      report an error, otherwise, mark it disabled and go on. */
-  
+
   if (remote_protocol_Z[Z_PACKET_SOFTWARE_BP].support != PACKET_DISABLE)
     {
       char *buf = alloca (rs->remote_packet_size);
       char *p = buf;
-      
+
       addr = remote_address_masked (addr);
       *(p++) = 'Z';
       *(p++) = '0';
@@ -4428,7 +4431,7 @@ remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
       p += hexnumstr (p, (ULONGEST) addr);
       BREAKPOINT_FROM_PC (&addr, &bp_size);
       sprintf (p, ",%d", bp_size);
-      
+
       putpkt (buf);
       getpkt (buf, (rs->remote_packet_size), 0);
 
@@ -4443,7 +4446,7 @@ remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
        }
     }
 
-#ifdef DEPRECATED_REMOTE_BREAKPOINT  
+#ifdef DEPRECATED_REMOTE_BREAKPOINT
   val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
 
   if (val == 0)
@@ -4472,7 +4475,7 @@ remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
     {
       char *buf = alloca (rs->remote_packet_size);
       char *p = buf;
-      
+
       *(p++) = 'z';
       *(p++) = '0';
       *(p++) = ',';
@@ -4481,7 +4484,7 @@ remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
       p += hexnumstr (p, (ULONGEST) addr);
       BREAKPOINT_FROM_PC (&addr, &bp_size);
       sprintf (p, ",%d", bp_size);
-      
+
       putpkt (buf);
       getpkt (buf, (rs->remote_packet_size), 0);
 
@@ -4527,13 +4530,13 @@ remote_insert_watchpoint (CORE_ADDR addr, int len, int type)
     error ("Can't set hardware watchpoints without the '%s' (%s) packet\n",
           remote_protocol_Z[packet].name,
           remote_protocol_Z[packet].title);
-  
+
   sprintf (buf, "Z%x,", packet);
   p = strchr (buf, '\0');
   addr = remote_address_masked (addr);
   p += hexnumstr (p, (ULONGEST) addr);
   sprintf (p, ",%x", len);
-  
+
   putpkt (buf);
   getpkt (buf, (rs->remote_packet_size), 0);
 
@@ -4562,7 +4565,7 @@ remote_remove_watchpoint (CORE_ADDR addr, int len, int type)
     error ("Can't clear hardware watchpoints without the '%s' (%s) packet\n",
           remote_protocol_Z[packet].name,
           remote_protocol_Z[packet].title);
-  
+
   sprintf (buf, "z%x,", packet);
   p = strchr (buf, '\0');
   addr = remote_address_masked (addr);
@@ -4619,10 +4622,13 @@ remote_stopped_by_watchpoint (void)
     return remote_stopped_by_watchpoint_p;
 }
 
+extern int stepped_after_stopped_by_watchpoint;
+
 static CORE_ADDR
 remote_stopped_data_address (void)
 {
-  if (remote_stopped_by_watchpoint ())
+  if (remote_stopped_by_watchpoint ()
+      || stepped_after_stopped_by_watchpoint)
     return remote_watch_data_address;
   return (CORE_ADDR)0;
 }
@@ -4635,21 +4641,21 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, char *shadow)
   struct remote_state *rs = get_remote_state ();
   char *buf = alloca (rs->remote_packet_size);
   char *p = buf;
-      
+
   /* The length field should be set to the size of a breakpoint
      instruction.  */
 
-  BREAKPOINT_FROM_PC (&addr, &len);  
+  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",
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].name,
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].title);
-  
+
   *(p++) = 'Z';
   *(p++) = '1';
   *(p++) = ',';
-  
+
   addr = remote_address_masked (addr);
   p += hexnumstr (p, (ULONGEST) addr);
   sprintf (p, ",%x", len);
@@ -4670,7 +4676,7 @@ remote_insert_hw_breakpoint (CORE_ADDR addr, char *shadow)
 }
 
 
-static int 
+static int
 remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
 {
   int len;
@@ -4687,18 +4693,18 @@ remote_remove_hw_breakpoint (CORE_ADDR addr, char *shadow)
     error ("Can't clear hardware breakpoint without the '%s' (%s) packet\n",
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].name,
           remote_protocol_Z[Z_PACKET_HARDWARE_BP].title);
-  
+
   *(p++) = 'z';
   *(p++) = '1';
   *(p++) = ',';
-  
+
   addr = remote_address_masked (addr);
   p += hexnumstr (p, (ULONGEST) addr);
   sprintf (p, ",%x", len);
 
   putpkt(buf);
   getpkt (buf, (rs->remote_packet_size), 0);
-  
+
   switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP]))
     {
     case PACKET_ERROR:
@@ -4798,7 +4804,7 @@ compare_sections_command (char *args, int from_tty)
       if (!(s->flags & SEC_LOAD))
        continue;               /* skip non-loadable section */
 
-      size = bfd_get_section_size_before_reloc (s);
+      size = bfd_get_section_size (s);
       if (size == 0)
        continue;               /* skip zero-length section */
 
@@ -4858,6 +4864,31 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
   char *p2 = &buf2[0];
   char query_type;
 
+  /* Handle memory using remote_xfer_memory.  */
+  if (object == TARGET_OBJECT_MEMORY)
+    {
+      int xfered;
+      errno = 0;
+
+      if (writebuf != NULL)
+       {
+         void *buffer = xmalloc (len);
+         struct cleanup *cleanup = make_cleanup (xfree, buffer);
+         memcpy (buffer, writebuf, len);
+         xfered = remote_xfer_memory (offset, buffer, len, 1, NULL, ops);
+         do_cleanups (cleanup);
+       }
+      else
+       xfered = remote_xfer_memory (offset, readbuf, len, 0, NULL, ops);
+
+      if (xfered > 0)
+       return xfered;
+      else if (xfered == 0 && errno == 0)
+       return 0;
+      else
+       return -1;
+    }
+
   /* Only handle reads.  */
   if (writebuf != NULL || readbuf == NULL)
     return -1;
@@ -4872,6 +4903,41 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
     case TARGET_OBJECT_AVR:
       query_type = 'R';
       break;
+
+    case TARGET_OBJECT_AUXV:
+      if (remote_protocol_qPart_auxv.support != PACKET_DISABLE)
+       {
+         unsigned int total = 0;
+         while (len > 0)
+           {
+             LONGEST n = min ((rs->remote_packet_size - 2) / 2, len);
+             snprintf (buf2, rs->remote_packet_size,
+                       "qPart:auxv:read::%s,%s",
+                       phex_nz (offset, sizeof offset),
+                       phex_nz (n, sizeof n));
+             i = putpkt (buf2);
+             if (i < 0)
+               return total > 0 ? total : i;
+             buf2[0] = '\0';
+             getpkt (buf2, rs->remote_packet_size, 0);
+             if (packet_ok (buf2, &remote_protocol_qPart_auxv) != PACKET_OK)
+               return total > 0 ? total : -1;
+             if (buf2[0] == 'O' && buf2[1] == 'K' && buf2[2] == '\0')
+               break;          /* Got EOF indicator.  */
+             /* Got some data.  */
+             i = hex2bin (buf2, readbuf, len);
+             if (i > 0)
+               {
+                 readbuf = (void *) ((char *) readbuf + i);
+                 offset += i;
+                 len -= i;
+                 total += i;
+               }
+           }
+         return total;
+       }
+      return -1;
+
     default:
       return -1;
     }
@@ -5363,12 +5429,12 @@ 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_e_packet_cmd (args, from_tty, NULL);
-  show_remote_protocol_E_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);
 }
 
 static void
@@ -5402,7 +5468,7 @@ _initialize_remote (void)
   struct cmd_list_element *tmpcmd;
 
   /* architecture specific data */
-  remote_gdbarch_data_handle = register_gdbarch_data (init_remote_state);
+  remote_gdbarch_data_handle = gdbarch_data_register_post_init (init_remote_state);
 
   /* Old tacky stuff.  NOTE: This comes after the remote protocol so
      that the remote protocol has been initialized.  */
@@ -5422,8 +5488,8 @@ _initialize_remote (void)
   add_target (&extended_async_remote_ops);
 
   /* Hook into new objfile notification.  */
-  remote_new_objfile_chain = target_new_objfile_hook;
-  target_new_objfile_hook  = remote_new_objfile;
+  remote_new_objfile_chain = deprecated_target_new_objfile_hook;
+  deprecated_target_new_objfile_hook  = remote_new_objfile;
 
 #if 0
   init_remote_threadtests ();
@@ -5458,9 +5524,11 @@ response packet.  GDB supplies the initial `$' character, and the\n\
 terminating `#' character and checksum.",
           &maintenancelist);
 
-  add_setshow_boolean_cmd ("remotebreak", no_class, &remote_break,
-                          "Set whether to send break if interrupted.\n",
-                          "Show whether to send break if interrupted.\n",
+  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,
                           &setlist, &showlist);
 
@@ -5497,20 +5565,24 @@ terminating `#' character and checksum.",
           "Show the maximum number of bytes per memory-read packet.\n",
           &remote_show_cmdlist);
 
-  add_setshow_cmd ("hardware-watchpoint-limit", no_class,
-                  var_zinteger, &remote_hw_watchpoint_limit, "\
-Set the maximum number of target hardware watchpoints.\n\
+  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.", "\
-Show the maximum number of target hardware watchpoints.\n",
-                  NULL, NULL, &remote_set_cmdlist, &remote_show_cmdlist);
-  add_setshow_cmd ("hardware-breakpoint-limit", no_class,
-                  var_zinteger, &remote_hw_breakpoint_limit, "\
-Set the maximum number of target hardware breakpoints.\n\
+The maximum number of target hardware watchpoints is %s.",
+                           NULL, NULL,
+                           &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.", "\
-Show the maximum number of target hardware breakpoints.\n",
-                  NULL, NULL, &remote_set_cmdlist, &remote_show_cmdlist);
+The maximum number of target hardware breakpoints is %s.",
+                           NULL, NULL,
+                           &remote_set_cmdlist, &remote_show_cmdlist);
 
-  add_show_from_set
+  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) \
@@ -5527,7 +5599,7 @@ in a memory packet.\n",
 #if 0
   /* XXXX - should ``set remotebinarydownload'' be retained for
      compatibility. */
-  add_show_from_set
+  deprecated_add_show_from_set
     (add_set_cmd ("remotebinarydownload", no_class,
                  var_boolean, (char *) &remote_binary_download,
                  "Set binary downloads.\n", &setlist),
@@ -5548,28 +5620,6 @@ in a memory packet.\n",
                         &remote_set_cmdlist, &remote_show_cmdlist,
                         0);
 
-  add_packet_config_cmd (&remote_protocol_e,
-                        "e", "step-over-range",
-                        set_remote_protocol_e_packet_cmd,
-                        show_remote_protocol_e_packet_cmd,
-                        &remote_set_cmdlist, &remote_show_cmdlist,
-                        0);
-  /* Disable by default.  The ``e'' packet has nasty interactions with
-     the threading code - it relies on global state.  */
-  remote_protocol_e.detect = AUTO_BOOLEAN_FALSE;
-  update_packet_config (&remote_protocol_e);
-
-  add_packet_config_cmd (&remote_protocol_E,
-                        "E", "step-over-range-w-signal",
-                        set_remote_protocol_E_packet_cmd,
-                        show_remote_protocol_E_packet_cmd,
-                        &remote_set_cmdlist, &remote_show_cmdlist,
-                        0);
-  /* Disable by default.  The ``e'' packet has nasty interactions with
-     the threading code - it relies on global state.  */
-  remote_protocol_E.detect = AUTO_BOOLEAN_FALSE;
-  update_packet_config (&remote_protocol_E);
-
   add_packet_config_cmd (&remote_protocol_P,
                         "P", "set-register",
                         set_remote_protocol_P_packet_cmd,
@@ -5577,6 +5627,13 @@ in a memory packet.\n",
                         &remote_set_cmdlist, &remote_show_cmdlist,
                         1);
 
+  add_packet_config_cmd (&remote_protocol_p,
+                        "p", "fetch-register",
+                        set_remote_protocol_p_packet_cmd,
+                        show_remote_protocol_p_packet_cmd,
+                        &remote_set_cmdlist, &remote_show_cmdlist,
+                        1);
+
   add_packet_config_cmd (&remote_protocol_Z[Z_PACKET_SOFTWARE_BP],
                         "Z0", "software-breakpoint",
                         set_remote_protocol_Z_software_bp_packet_cmd,
@@ -5612,11 +5669,21 @@ in a memory packet.\n",
                         &remote_set_cmdlist, &remote_show_cmdlist,
                         0);
 
+  add_packet_config_cmd (&remote_protocol_qPart_auxv,
+                        "qPart_auxv", "read-aux-vector",
+                        set_remote_protocol_qPart_auxv_packet_cmd,
+                        show_remote_protocol_qPart_auxv_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 ",
+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",
                                set_remote_protocol_Z_packet_cmd,
                                show_remote_protocol_Z_packet_cmd,
                                &remote_set_cmdlist, &remote_show_cmdlist);
This page took 0.039477 seconds and 4 git commands to generate.