This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Move globals to remote object


Hello,

This patch, as far as pratical, moves the remote.c global state 
variables into a local ``struct remote_state'' object.  Several things 
don't get moved.  Namely global variables that are managed by the CLI.

This change is actually mechanical.  Tested on an embedded x86 board.

Andrew
2001-11-14  Andrew Cagney  <ac131313@redhat.com>

	* remote.c (struct remote_state): Declare.
	(get_remote_state): New function.
	(init_remote_state): New function.
	(remote_gdbarch_data_handle): New global.
	(build_remote_packet_sizes): Delete function, moved to
	init_remote_state.
	(register_remote_packet_sizes): Delete function.
	(actual_register_packet_size, remote_packet_size): Moved to
	``struct remote_state''.
	(PBUFSIZE): Delete. Replaced by state->remote_packet_size.
	(free_remote_state): New function.
	(get_memory_packet_size, get_memory_read_packet_size)
	(set_thread, remote_unpack_thread_info_response)
	(remote_get_threadinfo, parse_threadlist_response)
	(remote_get_threadlist, remote_current_thread)
	(remote_threads_info, remote_threads_extra_info)
	(extended_remote_restart, get_offsets)
	(get_offsets, remote_check_symbols, remote_open_1)
	(remote_async_open_1, remote_detach, remote_async_detach)
	(remote_resume, remote_async_resume, remote_wait)
	(remote_async_wait, remote_fetch_registers)
	(store_register_using_P, remote_store_registers)
	(check_binary_download, putpkt_binary)
	(remote_insert_breakpoint, remote_remove_breakpoint)
	(remote_insert_watchpoint, remote_remove_watchpoint)
	(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint)
	(compare_sections_command, remote_query)
	(remote_rcmd, remote_rcmd, packet_command)
	(remote_info_process): Update.

Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.65
diff -p -r1.65 remote.c
*** remote.c	2001/11/15 02:56:29	1.65
--- remote.c	2001/11/15 04:55:21
*************** void open_remote_target (char *, int, st
*** 210,215 ****
--- 210,283 ----
  
  void _initialize_remote (void);
  
+ /* Description of the remote protocol.  Strictly speeking, when the
+    target is open()ed, remote.c should create a per-target description
+    of the remote protocol using that target's architecture.
+    Unfortunatly, the target stack doesn't include local state.  For
+    the moment keep the information in the target's architecture
+    object.  Sigh..  */
+ 
+ struct remote_state
+ {
+   /* This is the size (in chars) of the first response to the ``g''
+      packet.  It is used as a heuristic when determining the maximum
+      size of memory-read and memory-write packets.  A target will
+      typically only reserve a buffer large enough to hold the ``g''
+      packet.  The size does not include packet overhead (headers and
+      trailers). */
+   long actual_register_packet_size;
+ 
+   /* This is the maximum size (in chars) of a non read/write packet.
+      It is also used as a cap on the size of read/write packets. */
+   long remote_packet_size;
+ };
+ 
+ /* Handle for retreving the remote protocol data from gdbarch.  */
+ static struct gdbarch_data *remote_gdbarch_data_handle;
+ 
+ static struct remote_state *
+ get_remote_state ()
+ {
+   return gdbarch_data (remote_gdbarch_data_handle);
+ }
+ 
+ static void *
+ init_remote_state (struct gdbarch *gdbarch)
+ {
+   int regnum;
+   struct remote_state *rs = xmalloc (sizeof (struct remote_state));
+ 
+   /* Default maximum number of characters in a packet body. Many
+      remote stubs have a hardwired buffer size of 400 bytes
+      (c.f. BUFMAX in m68k-stub.c and i386-stub.c).  BUFMAX-1 is used
+      as the maximum packet-size to ensure that the packet and an extra
+      NUL character can always fit in the buffer.  This stops GDB
+      trashing stubs that try to squeeze an extra NUL into what is
+      already a full buffer (As of 1999-12-04 that was most stubs. */
+   rs->remote_packet_size = 400 - 1;
+ 
+   /* Should REGISTER_BYTES needs more space than the default, adjust
+      the size accordingly. Remember that each byte is encoded as two
+      characters. 32 is the overhead for the packet header /
+      footer. NOTE: cagney/1999-10-26: I suspect that 8
+      (``$NN:G...#NN'') is a better guess, the below has been padded a
+      little. */
+   if (REGISTER_BYTES > ((rs->remote_packet_size - 32) / 2))
+     rs->remote_packet_size = (REGISTER_BYTES * 2 + 32);
+   
+   /* This one is filled in when a ``g'' packet is received. */
+   rs->actual_register_packet_size = 0;
+ 
+   return rs;
+ }
+ 
+ static void
+ free_remote_state (struct gdbarch *gdbarch, void *pointer)
+ {
+   struct remote_state *state = pointer;
+   xfree (state);
+ }
+ 
  /* */
  
  static struct target_ops remote_ops;
*************** static int remote_address_size;
*** 267,290 ****
  static int remote_async_terminal_ours_p;
  
  
- /* This is the size (in chars) of the first response to the ``g''
-    packet.  It is used as a heuristic when determining the maximum
-    size of memory-read and memory-write packets.  A target will
-    typically only reserve a buffer large enough to hold the ``g''
-    packet.  The size does not include packet overhead (headers and
-    trailers). */
- 
- static long actual_register_packet_size;
- 
- /* This is the maximum size (in chars) of a non read/write packet.  It
-    is also used as a cap on the size of read/write packets. */
- 
- static long remote_packet_size;
- /* compatibility. */
- #define PBUFSIZ (remote_packet_size)
- 
  /* User configurable variables for the number of characters in a
!    memory read/write packet.  MIN (PBUFSIZ, g-packet-size) is the
     default.  Some targets need smaller values (fifo overruns, et.al.)
     and some users need larger values (speed up transfers).  The
     variables ``preferred_*'' (the user request), ``current_*'' (what
--- 335,342 ----
  static int remote_async_terminal_ours_p;
  
  
  /* User configurable variables for the number of characters in a
!    memory read/write packet.  MIN ((rs->remote_packet_size), g-packet-size) is the
     default.  Some targets need smaller values (fifo overruns, et.al.)
     and some users need larger values (speed up transfers).  The
     variables ``preferred_*'' (the user request), ``current_*'' (what
*************** struct memory_packet_config
*** 304,309 ****
--- 356,362 ----
  static long
  get_memory_packet_size (struct memory_packet_config *config)
  {
+   struct remote_state *rs = get_remote_state ();
    /* NOTE: The somewhat arbitrary 16k comes from the knowledge (folk
       law?) that some hosts don't cope very well with large alloca()
       calls.  Eventually the alloca() code will be replaced by calls to
*************** get_memory_packet_size (struct memory_pa
*** 326,340 ****
      }
    else
      {
!       what_they_get = remote_packet_size;
        /* Limit the packet to the size specified by the user. */
        if (config->size > 0
  	  && what_they_get > config->size)
  	what_they_get = config->size;
        /* Limit it to the size of the targets ``g'' response. */
!       if (actual_register_packet_size > 0
! 	  && what_they_get > actual_register_packet_size)
! 	what_they_get = actual_register_packet_size;
      }
    if (what_they_get > MAX_REMOTE_PACKET_SIZE)
      what_they_get = MAX_REMOTE_PACKET_SIZE;
--- 379,393 ----
      }
    else
      {
!       what_they_get = (rs->remote_packet_size);
        /* Limit the packet to the size specified by the user. */
        if (config->size > 0
  	  && what_they_get > config->size)
  	what_they_get = config->size;
        /* Limit it to the size of the targets ``g'' response. */
!       if ((rs->actual_register_packet_size) > 0
! 	  && what_they_get > (rs->actual_register_packet_size))
! 	what_they_get = (rs->actual_register_packet_size);
      }
    if (what_they_get > MAX_REMOTE_PACKET_SIZE)
      what_they_get = MAX_REMOTE_PACKET_SIZE;
*************** show_memory_read_packet_size (char *args
*** 442,490 ****
  static long
  get_memory_read_packet_size (void)
  {
    long size = get_memory_packet_size (&memory_read_packet_config);
    /* FIXME: cagney/1999-11-07: Functions like getpkt() need to get an
       extra buffer size argument before the memory read size can be
!      increased beyond PBUFSIZ. */
!   if (size > PBUFSIZ)
!     size = PBUFSIZ;
    return size;
  }
  
- /* Register packet size initialization. Since the bounds change when
-    the architecture changes (namely REGISTER_BYTES) this all needs to
-    be multi-arched.  */
- 
- static void
- register_remote_packet_sizes (void)
- {
-   REGISTER_GDBARCH_SWAP (remote_packet_size);
-   REGISTER_GDBARCH_SWAP (actual_register_packet_size);
- }
- 
- static void
- build_remote_packet_sizes (void)
- {
-   /* Default maximum number of characters in a packet body. Many
-      remote stubs have a hardwired buffer size of 400 bytes
-      (c.f. BUFMAX in m68k-stub.c and i386-stub.c).  BUFMAX-1 is used
-      as the maximum packet-size to ensure that the packet and an extra
-      NUL character can always fit in the buffer.  This stops GDB
-      trashing stubs that try to squeeze an extra NUL into what is
-      already a full buffer (As of 1999-12-04 that was most stubs. */
-   remote_packet_size = 400 - 1;
-   /* Should REGISTER_BYTES needs more space than the default, adjust
-      the size accordingly. Remember that each byte is encoded as two
-      characters. 32 is the overhead for the packet header /
-      footer. NOTE: cagney/1999-10-26: I suspect that 8
-      (``$NN:G...#NN'') is a better guess, the below has been padded a
-      little. */
-   if (REGISTER_BYTES > ((remote_packet_size - 32) / 2))
-     remote_packet_size = (REGISTER_BYTES * 2 + 32);
-   
-   /* This one is filled in when a ``g'' packet is received. */
-   actual_register_packet_size = 0;
- }
  
  /* Generic configuration support for packets the stub optionally
     supports. Allows the user to specify the use of the packet as well
--- 495,510 ----
  static long
  get_memory_read_packet_size (void)
  {
+   struct remote_state *rs = get_remote_state ();
    long size = get_memory_packet_size (&memory_read_packet_config);
    /* FIXME: cagney/1999-11-07: Functions like getpkt() need to get an
       extra buffer size argument before the memory read size can be
!      increased beyond (rs->remote_packet_size). */
!   if (size > (rs->remote_packet_size))
!     size = (rs->remote_packet_size);
    return size;
  }
  
  
  /* Generic configuration support for packets the stub optionally
     supports. Allows the user to specify the use of the packet as well
*************** record_currthread (int currthread)
*** 936,942 ****
  static void
  set_thread (int th, int gen)
  {
!   char *buf = alloca (PBUFSIZ);
    int state = gen ? general_thread : continue_thread;
  
    if (state == th)
--- 956,963 ----
  static void
  set_thread (int th, int gen)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    int state = gen ? general_thread : continue_thread;
  
    if (state == th)
*************** set_thread (int th, int gen)
*** 954,960 ****
    else
      sprintf (&buf[2], "%x", th);
    putpkt (buf);
!   getpkt (buf, PBUFSIZ, 0);
    if (gen)
      general_thread = th;
    else
--- 975,981 ----
    else
      sprintf (&buf[2], "%x", th);
    putpkt (buf);
!   getpkt (buf, (rs->remote_packet_size), 0);
    if (gen)
      general_thread = th;
    else
*************** static int
*** 1375,1384 ****
  remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
  				    struct gdb_ext_thread_info *info)
  {
    int mask, length;
    unsigned int tag;
    threadref ref;
!   char *limit = pkt + PBUFSIZ;	/* plausable parsing limit */
    int retval = 1;
  
    /* info->threadid = 0; FIXME: implement zero_threadref */
--- 1396,1406 ----
  remote_unpack_thread_info_response (char *pkt, threadref *expectedref,
  				    struct gdb_ext_thread_info *info)
  {
+   struct remote_state *rs = get_remote_state ();
    int mask, length;
    unsigned int tag;
    threadref ref;
!   char *limit = pkt + (rs->remote_packet_size);	/* plausable parsing limit */
    int retval = 1;
  
    /* info->threadid = 0; FIXME: implement zero_threadref */
*************** static int
*** 1465,1476 ****
  remote_get_threadinfo (threadref *threadid, int fieldset,	/* TAG mask */
  		       struct gdb_ext_thread_info *info)
  {
    int result;
!   char *threadinfo_pkt = alloca (PBUFSIZ);
  
    pack_threadinfo_request (threadinfo_pkt, fieldset, threadid);
    putpkt (threadinfo_pkt);
!   getpkt (threadinfo_pkt, PBUFSIZ, 0);
    result = remote_unpack_thread_info_response (threadinfo_pkt + 2, threadid,
  					       info);
    return result;
--- 1487,1499 ----
  remote_get_threadinfo (threadref *threadid, int fieldset,	/* TAG mask */
  		       struct gdb_ext_thread_info *info)
  {
+   struct remote_state *rs = get_remote_state ();
    int result;
!   char *threadinfo_pkt = alloca (rs->remote_packet_size);
  
    pack_threadinfo_request (threadinfo_pkt, fieldset, threadid);
    putpkt (threadinfo_pkt);
!   getpkt (threadinfo_pkt, (rs->remote_packet_size), 0);
    result = remote_unpack_thread_info_response (threadinfo_pkt + 2, threadid,
  					       info);
    return result;
*************** parse_threadlist_response (char *pkt, in
*** 1511,1522 ****
  			   threadref *original_echo, threadref *resultlist,
  			   int *doneflag)
  {
    char *limit;
    int count, resultcount, done;
  
    resultcount = 0;
    /* Assume the 'q' and 'M chars have been stripped.  */
!   limit = pkt + (PBUFSIZ - BUF_THREAD_ID_SIZE);		/* done parse past here */
    pkt = unpack_byte (pkt, &count);	/* count field */
    pkt = unpack_nibble (pkt, &done);
    /* The first threadid is the argument threadid.  */
--- 1534,1546 ----
  			   threadref *original_echo, threadref *resultlist,
  			   int *doneflag)
  {
+   struct remote_state *rs = get_remote_state ();
    char *limit;
    int count, resultcount, done;
  
    resultcount = 0;
    /* Assume the 'q' and 'M chars have been stripped.  */
!   limit = pkt + ((rs->remote_packet_size) - BUF_THREAD_ID_SIZE);		/* done parse past here */
    pkt = unpack_byte (pkt, &count);	/* count field */
    pkt = unpack_nibble (pkt, &done);
    /* The first threadid is the argument threadid.  */
*************** static int
*** 1536,1554 ****
  remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
  		       int *done, int *result_count, threadref *threadlist)
  {
    static threadref echo_nextthread;
!   char *threadlist_packet = alloca (PBUFSIZ);
!   char *t_response = alloca (PBUFSIZ);
    int result = 1;
  
    /* Trancate result limit to be smaller than the packet size */
!   if ((((result_limit + 1) * BUF_THREAD_ID_SIZE) + 10) >= PBUFSIZ)
!     result_limit = (PBUFSIZ / BUF_THREAD_ID_SIZE) - 2;
  
    pack_threadlist_request (threadlist_packet,
  			   startflag, result_limit, nextthread);
    putpkt (threadlist_packet);
!   getpkt (t_response, PBUFSIZ, 0);
  
    *result_count =
      parse_threadlist_response (t_response + 2, result_limit, &echo_nextthread,
--- 1560,1579 ----
  remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
  		       int *done, int *result_count, threadref *threadlist)
  {
+   struct remote_state *rs = get_remote_state ();
    static threadref echo_nextthread;
!   char *threadlist_packet = alloca (rs->remote_packet_size);
!   char *t_response = alloca (rs->remote_packet_size);
    int result = 1;
  
    /* Trancate result limit to be smaller than the packet size */
!   if ((((result_limit + 1) * BUF_THREAD_ID_SIZE) + 10) >= (rs->remote_packet_size))
!     result_limit = ((rs->remote_packet_size) / BUF_THREAD_ID_SIZE) - 2;
  
    pack_threadlist_request (threadlist_packet,
  			   startflag, result_limit, nextthread);
    putpkt (threadlist_packet);
!   getpkt (t_response, (rs->remote_packet_size), 0);
  
    *result_count =
      parse_threadlist_response (t_response + 2, result_limit, &echo_nextthread,
*************** remote_newthread_step (threadref *ref, v
*** 1654,1663 ****
  static ptid_t
  remote_current_thread (ptid_t oldpid)
  {
!   char *buf = alloca (PBUFSIZ);
  
    putpkt ("qC");
!   getpkt (buf, PBUFSIZ, 0);
    if (buf[0] == 'Q' && buf[1] == 'C')
      return pid_to_ptid (strtol (&buf[2], NULL, 16));
    else
--- 1679,1689 ----
  static ptid_t
  remote_current_thread (ptid_t oldpid)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
  
    putpkt ("qC");
!   getpkt (buf, (rs->remote_packet_size), 0);
    if (buf[0] == 'Q' && buf[1] == 'C')
      return pid_to_ptid (strtol (&buf[2], NULL, 16));
    else
*************** remote_find_new_threads (void)
*** 1687,1693 ****
  static void
  remote_threads_info (void)
  {
!   char *buf = alloca (PBUFSIZ);
    char *bufp;
    int tid;
  
--- 1713,1720 ----
  static void
  remote_threads_info (void)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    char *bufp;
    int tid;
  
*************** remote_threads_info (void)
*** 1698,1704 ****
      {
        putpkt ("qfThreadInfo");
        bufp = buf;
!       getpkt (bufp, PBUFSIZ, 0);
        if (bufp[0] != '\0')		/* q packet recognized */
  	{	
  	  while (*bufp++ == 'm')	/* reply contains one or more TID */
--- 1725,1731 ----
      {
        putpkt ("qfThreadInfo");
        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 */
*************** remote_threads_info (void)
*** 1712,1718 ****
  	      while (*bufp++ == ',');	/* comma-separated list */
  	      putpkt ("qsThreadInfo");
  	      bufp = buf;
! 	      getpkt (bufp, PBUFSIZ, 0);
  	    }
  	  return;	/* done */
  	}
--- 1739,1745 ----
  	      while (*bufp++ == ',');	/* comma-separated list */
  	      putpkt ("qsThreadInfo");
  	      bufp = buf;
! 	      getpkt (bufp, (rs->remote_packet_size), 0);
  	    }
  	  return;	/* done */
  	}
*************** remote_threads_info (void)
*** 1736,1747 ****
  static char *
  remote_threads_extra_info (struct thread_info *tp)
  {
    int result;
    int set;
    threadref id;
    struct gdb_ext_thread_info threadinfo;
    static char display_buf[100];	/* arbitrary... */
!   char *bufp = alloca (PBUFSIZ);
    int n = 0;                    /* position in display_buf */
  
    if (remote_desc == 0)		/* paranoia */
--- 1763,1775 ----
  static char *
  remote_threads_extra_info (struct thread_info *tp)
  {
+   struct remote_state *rs = get_remote_state ();
    int result;
    int set;
    threadref id;
    struct gdb_ext_thread_info threadinfo;
    static char display_buf[100];	/* arbitrary... */
!   char *bufp = alloca (rs->remote_packet_size);
    int n = 0;                    /* position in display_buf */
  
    if (remote_desc == 0)		/* paranoia */
*************** remote_threads_extra_info (struct thread
*** 1752,1758 ****
      {
        sprintf (bufp, "qThreadExtraInfo,%x", PIDGET (tp->ptid));
        putpkt (bufp);
!       getpkt (bufp, PBUFSIZ, 0);
        if (bufp[0] != 0)
  	{
  	  n = min (strlen (bufp) / 2, sizeof (display_buf));
--- 1780,1786 ----
      {
        sprintf (bufp, "qThreadExtraInfo,%x", PIDGET (tp->ptid));
        putpkt (bufp);
!       getpkt (bufp, (rs->remote_packet_size), 0);
        if (bufp[0] != 0)
  	{
  	  n = min (strlen (bufp) / 2, sizeof (display_buf));
*************** remote_threads_extra_info (struct thread
*** 1796,1802 ****
  static void
  extended_remote_restart (void)
  {
!   char *buf = alloca (PBUFSIZ);
  
    /* Send the restart command; for reasons I don't understand the
       remote side really expects a number after the "R".  */
--- 1824,1831 ----
  static void
  extended_remote_restart (void)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
  
    /* Send the restart command; for reasons I don't understand the
       remote side really expects a number after the "R".  */
*************** extended_remote_restart (void)
*** 1807,1813 ****
    /* Now query for status so this looks just like we restarted
       gdbserver from scratch.  */
    putpkt ("?");
!   getpkt (buf, PBUFSIZ, 0);
  }
  
  /* Clean up connection to a remote debugger.  */
--- 1836,1842 ----
    /* Now query for status so this looks just like we restarted
       gdbserver from scratch.  */
    putpkt ("?");
!   getpkt (buf, (rs->remote_packet_size), 0);
  }
  
  /* Clean up connection to a remote debugger.  */
*************** remote_close (int quitting)
*** 1826,1832 ****
  static void
  get_offsets (void)
  {
!   char *buf = alloca (PBUFSIZ);
    char *ptr;
    int lose;
    CORE_ADDR text_addr, data_addr, bss_addr;
--- 1855,1862 ----
  static void
  get_offsets (void)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    char *ptr;
    int lose;
    CORE_ADDR text_addr, data_addr, bss_addr;
*************** get_offsets (void)
*** 1834,1840 ****
  
    putpkt ("qOffsets");
  
!   getpkt (buf, PBUFSIZ, 0);
  
    if (buf[0] == '\000')
      return;			/* Return silently.  Stub doesn't support
--- 1864,1870 ----
  
    putpkt ("qOffsets");
  
!   getpkt (buf, (rs->remote_packet_size), 0);
  
    if (buf[0] == '\000')
      return;			/* Return silently.  Stub doesn't support
*************** init_all_packet_configs (void)
*** 2101,2106 ****
--- 2131,2137 ----
  static void
  remote_check_symbols (struct objfile *objfile)
  {
+   struct remote_state *rs = get_remote_state ();
    char *msg, *reply, *tmp;
    struct minimal_symbol *sym;
    int end;
*************** remote_check_symbols (struct objfile *ob
*** 2108,2120 ****
    if (remote_protocol_qSymbol.support == PACKET_DISABLE)
      return;
  
!   msg   = alloca (PBUFSIZ);
!   reply = alloca (PBUFSIZ);
  
    /* Invite target to request symbol lookups. */
  
    putpkt ("qSymbol::");
!   getpkt (reply, PBUFSIZ, 0);
    packet_ok (reply, &remote_protocol_qSymbol);
  
    while (strncmp (reply, "qSymbol:", 8) == 0)
--- 2139,2151 ----
    if (remote_protocol_qSymbol.support == PACKET_DISABLE)
      return;
  
!   msg   = alloca (rs->remote_packet_size);
!   reply = alloca (rs->remote_packet_size);
  
    /* Invite target to request symbol lookups. */
  
    putpkt ("qSymbol::");
!   getpkt (reply, (rs->remote_packet_size), 0);
    packet_ok (reply, &remote_protocol_qSymbol);
  
    while (strncmp (reply, "qSymbol:", 8) == 0)
*************** remote_check_symbols (struct objfile *ob
*** 2130,2136 ****
  		 paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
  		 &reply[8]);
        putpkt (msg);
!       getpkt (reply, PBUFSIZ, 0);
      }
  }
  
--- 2161,2167 ----
  		 paddr_nz (SYMBOL_VALUE_ADDRESS (sym)),
  		 &reply[8]);
        putpkt (msg);
!       getpkt (reply, (rs->remote_packet_size), 0);
      }
  }
  
*************** static void
*** 2138,2143 ****
--- 2169,2175 ----
  remote_open_1 (char *name, int from_tty, struct target_ops *target,
  	       int extended_p)
  {
+   struct remote_state *rs = get_remote_state ();
    if (name == 0)
      error ("To open a remote debug connection, you need to specify what\n\
  serial device is attached to the remote system\n\
*************** serial device is attached to the remote 
*** 2213,2221 ****
    if (extended_p)
      {
        /* Tell the remote that we are using the extended protocol.  */
!       char *buf = alloca (PBUFSIZ);
        putpkt ("!");
!       getpkt (buf, PBUFSIZ, 0);
      }
  #ifdef SOLIB_CREATE_INFERIOR_HOOK
    /* FIXME: need a master target_open vector from which all 
--- 2245,2253 ----
    if (extended_p)
      {
        /* Tell the remote that we are using the extended protocol.  */
!       char *buf = alloca (rs->remote_packet_size);
        putpkt ("!");
!       getpkt (buf, (rs->remote_packet_size), 0);
      }
  #ifdef SOLIB_CREATE_INFERIOR_HOOK
    /* FIXME: need a master target_open vector from which all 
*************** static void
*** 2238,2243 ****
--- 2270,2276 ----
  remote_async_open_1 (char *name, int from_tty, struct target_ops *target,
  		     int extended_p)
  {
+   struct remote_state *rs = get_remote_state ();
    if (name == 0)
      error ("To open a remote debug connection, you need to specify what\n\
  serial device is attached to the remote system\n\
*************** serial device is attached to the remote 
*** 2326,2334 ****
    if (extended_p)
      {
        /* Tell the remote that we are using the extended protocol.  */
!       char *buf = alloca (PBUFSIZ);
        putpkt ("!");
!       getpkt (buf, PBUFSIZ, 0);
      }
  #ifdef SOLIB_CREATE_INFERIOR_HOOK
    /* FIXME: need a master target_open vector from which all 
--- 2359,2367 ----
    if (extended_p)
      {
        /* Tell the remote that we are using the extended protocol.  */
!       char *buf = alloca (rs->remote_packet_size);
        putpkt ("!");
!       getpkt (buf, (rs->remote_packet_size), 0);
      }
  #ifdef SOLIB_CREATE_INFERIOR_HOOK
    /* FIXME: need a master target_open vector from which all 
*************** serial device is attached to the remote 
*** 2354,2367 ****
  static void
  remote_detach (char *args, int from_tty)
  {
!   char *buf = alloca (PBUFSIZ);
  
    if (args)
      error ("Argument given to \"detach\" when remotely debugging.");
  
    /* Tell the remote target to detach.  */
    strcpy (buf, "D");
!   remote_send (buf, PBUFSIZ);
  
    target_mourn_inferior ();
    if (from_tty)
--- 2387,2401 ----
  static void
  remote_detach (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.");
  
    /* Tell the remote target to detach.  */
    strcpy (buf, "D");
!   remote_send (buf, (rs->remote_packet_size));
  
    target_mourn_inferior ();
    if (from_tty)
*************** remote_detach (char *args, int from_tty)
*** 2373,2386 ****
  static void
  remote_async_detach (char *args, int from_tty)
  {
!   char *buf = alloca (PBUFSIZ);
  
    if (args)
      error ("Argument given to \"detach\" when remotely debugging.");
  
    /* Tell the remote target to detach.  */
    strcpy (buf, "D");
!   remote_send (buf, PBUFSIZ);
  
    /* Unregister the file descriptor from the event loop. */
    if (target_is_async_p ())
--- 2407,2421 ----
  static void
  remote_async_detach (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.");
  
    /* Tell the remote target to detach.  */
    strcpy (buf, "D");
!   remote_send (buf, (rs->remote_packet_size));
  
    /* Unregister the file descriptor from the event loop. */
    if (target_is_async_p ())
*************** static int last_sent_step;
*** 2462,2468 ****
  static void
  remote_resume (ptid_t ptid, int step, enum target_signal siggnal)
  {
!   char *buf = alloca (PBUFSIZ);
    int pid = PIDGET (ptid);
    char *p;
  
--- 2497,2504 ----
  static void
  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;
  
*************** remote_resume (ptid_t ptid, int step, en
*** 2508,2514 ****
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, PBUFSIZ, 0);
  
  	      if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
  		return;
--- 2544,2550 ----
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, (rs->remote_packet_size), 0);
  
  	      if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
  		return;
*************** remote_resume (ptid_t ptid, int step, en
*** 2526,2532 ****
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, PBUFSIZ, 0);
  
  	      if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
  		return;
--- 2562,2568 ----
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, (rs->remote_packet_size), 0);
  
  	      if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
  		return;
*************** remote_resume (ptid_t ptid, int step, en
*** 2551,2557 ****
  static void
  remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal)
  {
!   char *buf = alloca (PBUFSIZ);
    int pid = PIDGET (ptid);
    char *p;
  
--- 2587,2594 ----
  static void
  remote_async_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;
  
*************** remote_async_resume (ptid_t ptid, int st
*** 2596,2602 ****
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, PBUFSIZ, 0);
  
  	      if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
  		goto register_event_loop;
--- 2633,2639 ----
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, (rs->remote_packet_size), 0);
  
  	      if (packet_ok (buf, &remote_protocol_E) == PACKET_OK)
  		goto register_event_loop;
*************** remote_async_resume (ptid_t ptid, int st
*** 2614,2620 ****
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, PBUFSIZ, 0);
  
  	      if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
  		goto register_event_loop;
--- 2651,2657 ----
  	      *p++ = 0;
  
  	      putpkt (buf);
! 	      getpkt (buf, (rs->remote_packet_size), 0);
  
  	      if (packet_ok (buf, &remote_protocol_e) == PACKET_OK)
  		goto register_event_loop;
*************** remote_console_output (char *msg)
*** 2862,2868 ****
  static ptid_t
  remote_wait (ptid_t ptid, struct target_waitstatus *status)
  {
!   unsigned char *buf = alloca (PBUFSIZ);
    int thread_num = -1;
  
    status->kind = TARGET_WAITKIND_EXITED;
--- 2899,2906 ----
  static ptid_t
  remote_wait (ptid_t ptid, struct target_waitstatus *status)
  {
!   struct remote_state *rs = get_remote_state ();
!   unsigned char *buf = alloca (rs->remote_packet_size);
    int thread_num = -1;
  
    status->kind = TARGET_WAITKIND_EXITED;
*************** remote_wait (ptid_t ptid, struct target_
*** 2873,2879 ****
        unsigned char *p;
  
        ofunc = signal (SIGINT, remote_interrupt);
!       getpkt (buf, PBUFSIZ, 1);
        signal (SIGINT, ofunc);
  
        /* This is a hook for when we need to do something (perhaps the
--- 2911,2917 ----
        unsigned char *p;
  
        ofunc = signal (SIGINT, remote_interrupt);
!       getpkt (buf, (rs->remote_packet_size), 1);
        signal (SIGINT, ofunc);
  
        /* This is a hook for when we need to do something (perhaps the
*************** got_status:
*** 3075,3081 ****
  static ptid_t
  remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
  {
!   unsigned char *buf = alloca (PBUFSIZ);
    int thread_num = -1;
  
    status->kind = TARGET_WAITKIND_EXITED;
--- 3113,3120 ----
  static ptid_t
  remote_async_wait (ptid_t ptid, struct target_waitstatus *status)
  {
!   struct remote_state *rs = get_remote_state ();
!   unsigned char *buf = alloca (rs->remote_packet_size);
    int thread_num = -1;
  
    status->kind = TARGET_WAITKIND_EXITED;
*************** remote_async_wait (ptid_t ptid, struct t
*** 3091,3097 ****
           _never_ wait for ever -> test on target_is_async_p().
           However, before we do that we need to ensure that the caller
           knows how to take the target into/out of async mode. */
!       getpkt (buf, PBUFSIZ, wait_forever_enabled_p);
        if (!target_is_async_p ())
  	signal (SIGINT, ofunc);
  
--- 3130,3136 ----
           _never_ wait for ever -> test on target_is_async_p().
           However, before we do that we need to ensure that the caller
           knows how to take the target into/out of async mode. */
!       getpkt (buf, (rs->remote_packet_size), wait_forever_enabled_p);
        if (!target_is_async_p ())
  	signal (SIGINT, ofunc);
  
*************** static int register_bytes_found;
*** 3304,3310 ****
  static void
  remote_fetch_registers (int regno)
  {
!   char *buf = alloca (PBUFSIZ);
    int i;
    char *p;
    char *regs = alloca (REGISTER_BYTES);
--- 3343,3350 ----
  static void
  remote_fetch_registers (int regno)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    int i;
    char *p;
    char *regs = alloca (REGISTER_BYTES);
*************** remote_fetch_registers (int regno)
*** 3312,3324 ****
    set_thread (PIDGET (inferior_ptid), 1);
  
    sprintf (buf, "g");
!   remote_send (buf, PBUFSIZ);
  
    /* Save the size of the packet sent to us by the target.  Its used
       as a heuristic when determining the max size of packets that the
       target can safely receive. */
!   if (actual_register_packet_size == 0)
!     actual_register_packet_size = strlen (buf);
  
    /* Unimplemented registers read as all bits zero.  */
    memset (regs, 0, REGISTER_BYTES);
--- 3352,3364 ----
    set_thread (PIDGET (inferior_ptid), 1);
  
    sprintf (buf, "g");
!   remote_send (buf, (rs->remote_packet_size));
  
    /* Save the size of the packet sent to us by the target.  Its used
       as a heuristic when determining the max size of packets that the
       target can safely receive. */
!   if ((rs->actual_register_packet_size) == 0)
!     (rs->actual_register_packet_size) = strlen (buf);
  
    /* Unimplemented registers read as all bits zero.  */
    memset (regs, 0, REGISTER_BYTES);
*************** remote_fetch_registers (int regno)
*** 3333,3339 ****
        if (remote_debug)
  	fprintf_unfiltered (gdb_stdlog,
  			    "Bad register packet; fetching a new packet\n");
!       getpkt (buf, PBUFSIZ, 0);
      }
  
    /* Reply describes registers byte by byte, each byte encoded as two
--- 3373,3379 ----
        if (remote_debug)
  	fprintf_unfiltered (gdb_stdlog,
  			    "Bad register packet; fetching a new packet\n");
!       getpkt (buf, (rs->remote_packet_size), 0);
      }
  
    /* Reply describes registers byte by byte, each byte encoded as two
*************** remote_prepare_to_store (void)
*** 3401,3408 ****
  static int
  store_register_using_P (int regno)
  {
    /* Try storing a single register.  */
!   char *buf = alloca (PBUFSIZ);
    char *regp;
    char *p;
    int i;
--- 3441,3449 ----
  static int
  store_register_using_P (int regno)
  {
+   struct remote_state *rs = get_remote_state ();
    /* Try storing a single register.  */
!   char *buf = alloca (rs->remote_packet_size);
    char *regp;
    char *p;
    int i;
*************** store_register_using_P (int regno)
*** 3411,3417 ****
    p = buf + strlen (buf);
    regp = register_buffer (regno);
    bin2hex (regp, p, REGISTER_RAW_SIZE (regno));
!   remote_send (buf, PBUFSIZ);
  
    return buf[0] != '\0';
  }
--- 3452,3458 ----
    p = buf + strlen (buf);
    regp = register_buffer (regno);
    bin2hex (regp, p, REGISTER_RAW_SIZE (regno));
!   remote_send (buf, (rs->remote_packet_size));
  
    return buf[0] != '\0';
  }
*************** store_register_using_P (int regno)
*** 3423,3429 ****
  static void
  remote_store_registers (int regno)
  {
!   char *buf = alloca (PBUFSIZ);
    int i;
    char *p;
    char *regs;
--- 3464,3471 ----
  static void
  remote_store_registers (int regno)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    int i;
    char *p;
    char *regs;
*************** remote_store_registers (int regno)
*** 3468,3474 ****
    p = buf + 1;
    /* remote_prepare_to_store insures that register_bytes_found gets set.  */
    bin2hex (regs, p, register_bytes_found);
!   remote_send (buf, PBUFSIZ);
  }
  
  
--- 3510,3516 ----
    p = buf + 1;
    /* remote_prepare_to_store insures that register_bytes_found gets set.  */
    bin2hex (regs, p, register_bytes_found);
!   remote_send (buf, (rs->remote_packet_size));
  }
  
  
*************** remote_address_masked (CORE_ADDR addr)
*** 3543,3548 ****
--- 3585,3591 ----
  static void
  check_binary_download (CORE_ADDR addr)
  {
+   struct remote_state *rs = get_remote_state ();
    switch (remote_protocol_binary_download.support)
      {
      case PACKET_DISABLE:
*************** check_binary_download (CORE_ADDR addr)
*** 3551,3557 ****
        break;
      case PACKET_SUPPORT_UNKNOWN:
        {
! 	char *buf = alloca (PBUFSIZ);
  	char *p;
  	
  	p = buf;
--- 3594,3600 ----
        break;
      case PACKET_SUPPORT_UNKNOWN:
        {
! 	char *buf = alloca (rs->remote_packet_size);
  	char *p;
  	
  	p = buf;
*************** check_binary_download (CORE_ADDR addr)
*** 3563,3569 ****
  	*p = '\0';
  	
  	putpkt_binary (buf, (int) (p - buf));
! 	getpkt (buf, PBUFSIZ, 0);
  
  	if (buf[0] == '\0')
  	  {
--- 3606,3612 ----
  	*p = '\0';
  	
  	putpkt_binary (buf, (int) (p - buf));
! 	getpkt (buf, (rs->remote_packet_size), 0);
  
  	if (buf[0] == '\0')
  	  {
*************** remote_search (int len, char *data, char
*** 3841,3847 ****
        long mask_long, data_long;
        long data_found_long;
        CORE_ADDR addr_we_found;
!       char *buf = alloca (PBUFSIZ);
        long returned_long[2];
        char *p;
  
--- 3884,3890 ----
        long mask_long, data_long;
        long data_found_long;
        CORE_ADDR addr_we_found;
!       char *buf = alloca (rs->remote_packet_size);
        long returned_long[2];
        char *p;
  
*************** remote_search (int len, char *data, char
*** 3849,3855 ****
        data_long = extract_unsigned_integer (data, len);
        sprintf (buf, "t%x:%x,%x", startaddr, data_long, mask_long);
        putpkt (buf);
!       getpkt (buf, PBUFSIZ, 0);
        if (buf[0] == '\0')
  	{
  	  /* The stub doesn't support the 't' request.  We might want to
--- 3892,3898 ----
        data_long = extract_unsigned_integer (data, len);
        sprintf (buf, "t%x:%x,%x", startaddr, data_long, mask_long);
        putpkt (buf);
!       getpkt (buf, (rs->remote_packet_size), 0);
        if (buf[0] == '\0')
  	{
  	  /* The stub doesn't support the 't' request.  We might want to
*************** putpkt (char *buf)
*** 3962,3978 ****
  }
  
  /* Send a packet to the remote machine, with error checking.  The data
!    of the packet is in BUF.  The string in BUF can be at most  PBUFSIZ - 5
     to account for the $, # and checksum, and for a possible /0 if we are
     debugging (remote_debug) and want to print the sent packet as a string */
  
  static int
  putpkt_binary (char *buf, int cnt)
  {
    int i;
    unsigned char csum = 0;
    char *buf2 = alloca (cnt + 6);
!   long sizeof_junkbuf = PBUFSIZ;
    char *junkbuf = alloca (sizeof_junkbuf);
  
    int ch;
--- 4005,4022 ----
  }
  
  /* Send a packet to the remote machine, with error checking.  The data
!    of the packet is in BUF.  The string in BUF can be at most  (rs->remote_packet_size) - 5
     to account for the $, # and checksum, and for a possible /0 if we are
     debugging (remote_debug) and want to print the sent packet as a string */
  
  static int
  putpkt_binary (char *buf, int cnt)
  {
+   struct remote_state *rs = get_remote_state ();
    int i;
    unsigned char csum = 0;
    char *buf2 = alloca (cnt + 6);
!   long sizeof_junkbuf = (rs->remote_packet_size);
    char *junkbuf = alloca (sizeof_junkbuf);
  
    int ch;
*************** static unsigned char little_break_insn[]
*** 4501,4506 ****
--- 4545,4551 ----
  static int
  remote_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
  {
+   struct remote_state *rs = get_remote_state ();
  #ifdef REMOTE_BREAKPOINT
    int val;
  #endif  
*************** remote_insert_breakpoint (CORE_ADDR addr
*** 4513,4519 ****
    
    if (remote_protocol_Z[Z_PACKET_SOFTWARE_BP].support != PACKET_DISABLE)
      {
!       char *buf = alloca (PBUFSIZ);
        char *p = buf;
        
        addr = remote_address_masked (addr);
--- 4558,4564 ----
    
    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);
*************** remote_insert_breakpoint (CORE_ADDR addr
*** 4525,4531 ****
        sprintf (p, ",%d", bp_size);
        
        putpkt (buf);
!       getpkt (buf, PBUFSIZ, 0);
  
        switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_SOFTWARE_BP]))
  	{
--- 4570,4576 ----
        sprintf (p, ",%d", bp_size);
        
        putpkt (buf);
!       getpkt (buf, (rs->remote_packet_size), 0);
  
        switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_SOFTWARE_BP]))
  	{
*************** remote_insert_breakpoint (CORE_ADDR addr
*** 4560,4570 ****
  static int
  remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
  {
    int bp_size;
  
    if (remote_protocol_Z[Z_PACKET_SOFTWARE_BP].support != PACKET_DISABLE)
      {
!       char *buf = alloca (PBUFSIZ);
        char *p = buf;
        
        *(p++) = 'z';
--- 4605,4616 ----
  static int
  remote_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
  {
+   struct remote_state *rs = get_remote_state ();
    int bp_size;
  
    if (remote_protocol_Z[Z_PACKET_SOFTWARE_BP].support != PACKET_DISABLE)
      {
!       char *buf = alloca (rs->remote_packet_size);
        char *p = buf;
        
        *(p++) = 'z';
*************** remote_remove_breakpoint (CORE_ADDR addr
*** 4577,4583 ****
        sprintf (p, ",%d", bp_size);
        
        putpkt (buf);
!       getpkt (buf, PBUFSIZ, 0);
  
        return (buf[0] == 'E');
      }
--- 4623,4629 ----
        sprintf (p, ",%d", bp_size);
        
        putpkt (buf);
!       getpkt (buf, (rs->remote_packet_size), 0);
  
        return (buf[0] == 'E');
      }
*************** watchpoint_to_Z_packet (int type)
*** 4615,4621 ****
  int
  remote_insert_watchpoint (CORE_ADDR addr, int len, int type)
  {
!   char *buf = alloca (PBUFSIZ);
    char *p;
    enum Z_packet_type packet = watchpoint_to_Z_packet (type);
  
--- 4661,4668 ----
  int
  remote_insert_watchpoint (CORE_ADDR addr, int len, int type)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    char *p;
    enum Z_packet_type packet = watchpoint_to_Z_packet (type);
  
*************** remote_insert_watchpoint (CORE_ADDR addr
*** 4631,4637 ****
    sprintf (p, ",%x", len);
    
    putpkt (buf);
!   getpkt (buf, PBUFSIZ, 0);
  
    switch (packet_ok (buf, &remote_protocol_Z[packet]))
      {
--- 4678,4684 ----
    sprintf (p, ",%x", len);
    
    putpkt (buf);
!   getpkt (buf, (rs->remote_packet_size), 0);
  
    switch (packet_ok (buf, &remote_protocol_Z[packet]))
      {
*************** remote_insert_watchpoint (CORE_ADDR addr
*** 4651,4657 ****
  int
  remote_remove_watchpoint (CORE_ADDR addr, int len, int type)
  {
!   char *buf = alloca (PBUFSIZ);
    char *p;
    enum Z_packet_type packet = watchpoint_to_Z_packet (type);
  
--- 4698,4705 ----
  int
  remote_remove_watchpoint (CORE_ADDR addr, int len, int type)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    char *p;
    enum Z_packet_type packet = watchpoint_to_Z_packet (type);
  
*************** remote_remove_watchpoint (CORE_ADDR addr
*** 4666,4672 ****
    p += hexnumstr (p, (ULONGEST) addr);
    sprintf (p, ",%x", len);
    putpkt (buf);
!   getpkt (buf, PBUFSIZ, 0);
  
    switch (packet_ok (buf, &remote_protocol_Z[packet]))
      {
--- 4714,4720 ----
    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[packet]))
      {
*************** remote_remove_watchpoint (CORE_ADDR addr
*** 4686,4692 ****
  int
  remote_insert_hw_breakpoint (CORE_ADDR addr, int len)
  {
!   char *buf = alloca (PBUFSIZ);
    char *p = buf;
        
    if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
--- 4734,4741 ----
  int
  remote_insert_hw_breakpoint (CORE_ADDR addr, int len)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    char *p = buf;
        
    if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
*************** remote_insert_hw_breakpoint (CORE_ADDR a
*** 4703,4709 ****
    sprintf (p, ",%x", len);
  
    putpkt (buf);
!   getpkt (buf, PBUFSIZ, 0);
  
    switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP]))
      {
--- 4752,4758 ----
    sprintf (p, ",%x", len);
  
    putpkt (buf);
!   getpkt (buf, (rs->remote_packet_size), 0);
  
    switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP]))
      {
*************** remote_insert_hw_breakpoint (CORE_ADDR a
*** 4723,4729 ****
  int 
  remote_remove_hw_breakpoint (CORE_ADDR addr, int len)
  {
!   char *buf = alloca (PBUFSIZ);
    char *p = buf;
    
    if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
--- 4772,4779 ----
  int 
  remote_remove_hw_breakpoint (CORE_ADDR addr, int len)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
    char *p = buf;
    
    if (remote_protocol_Z[Z_PACKET_HARDWARE_BP].support == PACKET_DISABLE)
*************** remote_remove_hw_breakpoint (CORE_ADDR a
*** 4740,4746 ****
    sprintf (p, ",%x", len);
  
    putpkt(buf);
!   getpkt (buf, PBUFSIZ, 0);
    
    switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP]))
      {
--- 4790,4796 ----
    sprintf (p, ",%x", len);
  
    putpkt(buf);
!   getpkt (buf, (rs->remote_packet_size), 0);
    
    switch (packet_ok (buf, &remote_protocol_Z[Z_PACKET_HARDWARE_BP]))
      {
*************** crc32 (unsigned char *buf, int len, unsi
*** 4828,4833 ****
--- 4878,4884 ----
  static void
  compare_sections_command (char *args, int from_tty)
  {
+   struct remote_state *rs = get_remote_state ();
    asection *s;
    unsigned long host_crc, target_crc;
    extern bfd *exec_bfd;
*************** compare_sections_command (char *args, in
*** 4835,4841 ****
    char *tmp;
    char *sectdata;
    const char *sectname;
!   char *buf = alloca (PBUFSIZ);
    bfd_size_type size;
    bfd_vma lma;
    int matched = 0;
--- 4886,4892 ----
    char *tmp;
    char *sectdata;
    const char *sectname;
!   char *buf = alloca (rs->remote_packet_size);
    bfd_size_type size;
    bfd_vma lma;
    int matched = 0;
*************** compare_sections_command (char *args, in
*** 4872,4878 ****
        bfd_get_section_contents (exec_bfd, s, sectdata, 0, size);
        host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff);
  
!       getpkt (buf, PBUFSIZ, 0);
        if (buf[0] == 'E')
  	error ("target memory fault, section %s, range 0x%08x -- 0x%08x",
  	       sectname, lma, lma + size);
--- 4923,4929 ----
        bfd_get_section_contents (exec_bfd, s, sectdata, 0, size);
        host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff);
  
!       getpkt (buf, (rs->remote_packet_size), 0);
        if (buf[0] == 'E')
  	error ("target memory fault, section %s, range 0x%08x -- 0x%08x",
  	       sectname, lma, lma + size);
*************** the loaded file\n");
*** 4904,4922 ****
  static int
  remote_query (int query_type, char *buf, char *outbuf, int *bufsiz)
  {
    int i;
!   char *buf2 = alloca (PBUFSIZ);
    char *p2 = &buf2[0];
  
    if (!bufsiz)
      error ("null pointer to remote bufer size specified");
  
!   /* minimum outbuf size is PBUFSIZ - if bufsiz is not large enough let 
       the caller know and return what the minimum size is   */
    /* Note: a zero bufsiz can be used to query the minimum buffer size */
!   if (*bufsiz < PBUFSIZ)
      {
!       *bufsiz = PBUFSIZ;
        return -1;
      }
  
--- 4955,4974 ----
  static int
  remote_query (int query_type, char *buf, char *outbuf, int *bufsiz)
  {
+   struct remote_state *rs = get_remote_state ();
    int i;
!   char *buf2 = alloca (rs->remote_packet_size);
    char *p2 = &buf2[0];
  
    if (!bufsiz)
      error ("null pointer to remote bufer size specified");
  
!   /* minimum outbuf size is (rs->remote_packet_size) - if bufsiz is not large enough let 
       the caller know and return what the minimum size is   */
    /* Note: a zero bufsiz can be used to query the minimum buffer size */
!   if (*bufsiz < (rs->remote_packet_size))
      {
!       *bufsiz = (rs->remote_packet_size);
        return -1;
      }
  
*************** remote_query (int query_type, char *buf,
*** 4944,4950 ****
       plus one extra in case we are debugging (remote_debug),
       we have PBUFZIZ - 7 left to pack the query string */
    i = 0;
!   while (buf[i] && (i < (PBUFSIZ - 8)))
      {
        /* bad caller may have sent forbidden characters */
        if ((!isprint (buf[i])) || (buf[i] == '$') || (buf[i] == '#'))
--- 4996,5002 ----
       plus one extra in case we are debugging (remote_debug),
       we have PBUFZIZ - 7 left to pack the query string */
    i = 0;
!   while (buf[i] && (i < ((rs->remote_packet_size) - 8)))
      {
        /* bad caller may have sent forbidden characters */
        if ((!isprint (buf[i])) || (buf[i] == '$') || (buf[i] == '#'))
*************** static void
*** 4971,4978 ****
  remote_rcmd (char *command,
  	     struct ui_file *outbuf)
  {
    int i;
!   char *buf = alloca (PBUFSIZ);
    char *p = buf;
  
    if (!remote_desc)
--- 5023,5031 ----
  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)
*************** remote_rcmd (char *command,
*** 4986,4992 ****
    strcpy (buf, "qRcmd,");
    p = strchr (buf, '\0');
  
!   if ((strlen (buf) + strlen (command) * 2 + 8/*misc*/) > PBUFSIZ)
      error ("\"monitor\" command ``%s'' is too long\n", command);
  
    /* Encode the actual command */
--- 5039,5045 ----
    strcpy (buf, "qRcmd,");
    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);
  
    /* Encode the actual command */
*************** remote_rcmd (char *command,
*** 5000,5006 ****
      {
        /* XXX - see also tracepoint.c:remote_get_noisy_reply() */
        buf[0] = '\0';
!       getpkt (buf, PBUFSIZ, 0);
        if (buf[0] == '\0')
  	error ("Target does not support this command\n");
        if (buf[0] == 'O' && buf[1] != 'K')
--- 5053,5059 ----
      {
        /* XXX - see also tracepoint.c:remote_get_noisy_reply() */
        buf[0] = '\0';
!       getpkt (buf, (rs->remote_packet_size), 0);
        if (buf[0] == '\0')
  	error ("Target does not support this command\n");
        if (buf[0] == 'O' && buf[1] != 'K')
*************** remote_rcmd (char *command,
*** 5027,5033 ****
  static void
  packet_command (char *args, int from_tty)
  {
!   char *buf = alloca (PBUFSIZ);
  
    if (!remote_desc)
      error ("command can only be used with remote target");
--- 5080,5087 ----
  static void
  packet_command (char *args, int from_tty)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
  
    if (!remote_desc)
      error ("command can only be used with remote target");
*************** packet_command (char *args, int from_tty
*** 5040,5046 ****
    puts_filtered ("\n");
    putpkt (args);
  
!   getpkt (buf, PBUFSIZ, 0);
    puts_filtered ("received: ");
    print_packet (buf);
    puts_filtered ("\n");
--- 5094,5100 ----
    puts_filtered ("\n");
    putpkt (args);
  
!   getpkt (buf, (rs->remote_packet_size), 0);
    puts_filtered ("received: ");
    print_packet (buf);
    puts_filtered ("\n");
*************** Specify the serial device it is connecte
*** 5281,5293 ****
  static void
  remote_info_process (char *args, int from_tty)
  {
!   char *buf = alloca (PBUFSIZ);
  
    if (remote_desc == 0)
      error ("Command can only be used when connected to the remote target.");
  
    putpkt ("qfProcessInfo");
!   getpkt (buf, PBUFSIZ, 0);
    if (buf[0] == 0)
      return;			/* Silently: target does not support this feature. */
  
--- 5335,5348 ----
  static void
  remote_info_process (char *args, int from_tty)
  {
!   struct remote_state *rs = get_remote_state ();
!   char *buf = alloca (rs->remote_packet_size);
  
    if (remote_desc == 0)
      error ("Command can only be used when connected to the remote target.");
  
    putpkt ("qfProcessInfo");
!   getpkt (buf, (rs->remote_packet_size), 0);
    if (buf[0] == 0)
      return;			/* Silently: target does not support this feature. */
  
*************** remote_info_process (char *args, int fro
*** 5298,5304 ****
      {
        remote_console_output (&buf[1]);
        putpkt ("qsProcessInfo");
!       getpkt (buf, PBUFSIZ, 0);
      }
  }
  
--- 5353,5359 ----
      {
        remote_console_output (&buf[1]);
        putpkt ("qsProcessInfo");
!       getpkt (buf, (rs->remote_packet_size), 0);
      }
  }
  
*************** show_remote_cmd (char *args, int from_tt
*** 5789,5795 ****
  static void
  build_remote_gdbarch_data (void)
  {
-   build_remote_packet_sizes ();
    remote_address_size = TARGET_ADDR_BIT;
  }
  
--- 5844,5849 ----
*************** _initialize_remote (void)
*** 5818,5825 ****
    struct cmd_list_element *tmpcmd;
  
    /* architecture specific data */
!   build_remote_gdbarch_data ();
!   register_remote_packet_sizes ();
    register_gdbarch_swap (&remote_address_size, 
                           sizeof (&remote_address_size), NULL);
    register_gdbarch_swap (NULL, 0, build_remote_gdbarch_data);
--- 5872,5883 ----
    struct cmd_list_element *tmpcmd;
  
    /* architecture specific data */
!   remote_gdbarch_data_handle = register_gdbarch_data (init_remote_state,
! 						      free_remote_state);
! 
!   /* Old tacky stuff.  NOTE: This comes after the remote protocol so
!      that the remote protocol has been initialized.  */
!   register_gdbarch_swap (&tty_input, sizeof (&tty_input), NULL);
    register_gdbarch_swap (&remote_address_size, 
                           sizeof (&remote_address_size), NULL);
    register_gdbarch_swap (NULL, 0, build_remote_gdbarch_data);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]