* remote.c (get_remote_state_raw): Renamed from get_remote_state.
authorDaniel Jacobowitz <drow@false.org>
Thu, 5 Oct 2006 19:20:52 +0000 (19:20 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 5 Oct 2006 19:20:52 +0000 (19:20 +0000)
(get_remote_state): New function.
(init_remote_state, _initialize_remote): Use get_remote_state_raw.

gdb/ChangeLog
gdb/remote.c

index 7f0a0dc..b431592 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-05  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * remote.c (get_remote_state_raw): Renamed from get_remote_state.
+       (get_remote_state): New function.
+       (init_remote_state, _initialize_remote): Use get_remote_state_raw.
+
 2006-10-04  Fred Fish  <fnf@specifix.com>
 
        * vec.c: Include defs.h first.  This pulls in config.h which can
index 409aa83..9a9e94d 100644 (file)
@@ -244,7 +244,7 @@ struct remote_state
 static struct remote_state remote_state;
 
 static struct remote_state *
-get_remote_state (void)
+get_remote_state_raw (void)
 {
   return &remote_state;
 }
@@ -294,11 +294,26 @@ get_remote_arch_state (void)
   return gdbarch_data (current_gdbarch, remote_gdbarch_data_handle);
 }
 
+/* Fetch the global remote target state.  */
+
+static struct remote_state *
+get_remote_state (void)
+{
+  /* Make sure that the remote architecture state has been
+     initialized, because doing so might reallocate rs->buf.  Any
+     function which calls getpkt also needs to be mindful of changes
+     to rs->buf, but this call limits the number of places which run
+     into trouble.  */
+  get_remote_arch_state ();
+
+  return get_remote_state_raw ();
+}
+
 static void *
 init_remote_state (struct gdbarch *gdbarch)
 {
   int regnum;
-  struct remote_state *rs = get_remote_state ();
+  struct remote_state *rs = get_remote_state_raw ();
   struct remote_arch_state *rsa;
 
   rsa = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_arch_state);
@@ -6141,7 +6156,7 @@ _initialize_remote (void)
      of these, not one per target.  Only one target is active at a
      time.  The default buffer size is unimportant; it will be expanded
      whenever a larger buffer is needed.  */
-  rs = get_remote_state ();
+  rs = get_remote_state_raw ();
   rs->buf_size = 400;
   rs->buf = xmalloc (rs->buf_size);