From 0b83947edd8774f1b1b8e0ea0441e1ab62d7daab Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Thu, 5 Oct 2006 19:20:52 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 6 ++++++ gdb/remote.c | 21 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7f0a0dc89a1..b431592821a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2006-10-05 Daniel Jacobowitz + + * 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 * vec.c: Include defs.h first. This pulls in config.h which can diff --git a/gdb/remote.c b/gdb/remote.c index 409aa83721d..9a9e94d86f0 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -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); -- 2.30.2