This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 11/16] move some statics from remote_read_qxfer into struct remote_state
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Fri, 28 Jun 2013 11:40:24 -0600
- Subject: [PATCH 11/16] move some statics from remote_read_qxfer into struct remote_state
- References: <1372441229-305-1-git-send-email-tromey at redhat dot com>
This moves a few static variables out of remote_read_qxfer and into
remote_state. It is unclear to me if this data can ever be required
to be kept around across a potential target switch, but it is
definitely safe to move it into the remote state object.
* remote.c (struct remote_state) <finished_object,
finished_annex, finished_offset>: New fields.
(remote_read_qxfer): Use remote_state fields; remove static
variables.
---
gdb/remote.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index e87f7e8..6c71ac1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -392,6 +392,10 @@ struct remote_state
enum gdb_signal last_sent_signal;
int last_sent_step;
+
+ char *finished_object;
+ char *finished_annex;
+ ULONGEST finished_offset;
};
/* Private data that we'll store in (struct thread_info)->private. */
@@ -8704,10 +8708,6 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
gdb_byte *readbuf, ULONGEST offset, LONGEST len,
struct packet_config *packet)
{
- static char *finished_object;
- static char *finished_annex;
- static ULONGEST finished_offset;
-
struct remote_state *rs = get_remote_state ();
LONGEST i, n, packet_len;
@@ -8716,19 +8716,19 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
/* Check whether we've cached an end-of-object packet that matches
this request. */
- if (finished_object)
+ if (rs->finished_object)
{
- if (strcmp (object_name, finished_object) == 0
- && strcmp (annex ? annex : "", finished_annex) == 0
- && offset == finished_offset)
+ if (strcmp (object_name, rs->finished_object) == 0
+ && strcmp (annex ? annex : "", rs->finished_annex) == 0
+ && offset == rs->finished_offset)
return 0;
/* Otherwise, we're now reading something different. Discard
the cache. */
- xfree (finished_object);
- xfree (finished_annex);
- finished_object = NULL;
- finished_annex = NULL;
+ xfree (rs->finished_object);
+ xfree (rs->finished_annex);
+ rs->finished_object = NULL;
+ rs->finished_annex = NULL;
}
/* Request only enough to fit in a single packet. The actual data
@@ -8767,9 +8767,9 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
object, record this fact to bypass a subsequent partial read. */
if (rs->buf[0] == 'l' && offset + i > 0)
{
- finished_object = xstrdup (object_name);
- finished_annex = xstrdup (annex ? annex : "");
- finished_offset = offset + i;
+ rs->finished_object = xstrdup (object_name);
+ rs->finished_annex = xstrdup (annex ? annex : "");
+ rs->finished_offset = offset + i;
}
return i;
--
1.8.1.4