Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [PATCH 11/16] move some statics from remote_read_qxfer into struct remote_state
Date: Fri, 28 Jun 2013 17:40:00 -0000	[thread overview]
Message-ID: <1372441229-305-12-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1372441229-305-1-git-send-email-tromey@redhat.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


  parent reply	other threads:[~2013-06-28 17:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-28 17:40 [PATCH v2 00/16] Tom Tromey
2013-06-28 17:40 ` [PATCH 06/16] push remote_traceframe_number into struct remote_state Tom Tromey
2013-06-28 17:40 ` Tom Tromey [this message]
2013-07-01 16:07   ` [PATCH 11/16] move some statics from remote_read_qxfer " Pedro Alves
2013-07-01 18:06     ` Tom Tromey
2013-06-28 17:40 ` [PATCH 16/16] move some static thread state into remote_state Tom Tromey
2013-06-28 17:40 ` [PATCH 01/16] use the libiberty crc code Tom Tromey
2013-06-28 17:40 ` [PATCH 04/16] push remote_desc into struct remote_state Tom Tromey
2013-06-28 17:40 ` [PATCH 12/16] move use_threadinfo_query and use_threadextra_query " Tom Tromey
2013-06-28 17:40 ` [PATCH 13/16] move sizeof_pkt into remote_trace_find Tom Tromey
2013-06-28 17:40 ` [PATCH 10/16] push last_sent_step into struct remote_state Tom Tromey
2013-06-28 17:40 ` [PATCH 05/16] push general_thread and continue_thread " Tom Tromey
2013-06-28 17:40 ` [PATCH 02/16] make remote_protocol_features "const" Tom Tromey
2013-06-28 17:40 ` [PATCH 14/16] move async_client_callback and async_client_context into remote_state Tom Tromey
2013-07-01 16:07   ` Pedro Alves
2013-07-01 18:06     ` Tom Tromey
2013-06-28 17:40 ` [PATCH 07/16] push last_pass_packet into struct remote_state Tom Tromey
2013-06-28 17:40 ` [PATCH 03/16] Add new_remote_state Tom Tromey
2013-07-01 16:05   ` Pedro Alves
2013-07-01 18:05     ` Tom Tromey
2013-06-28 17:40 ` [PATCH 08/16] push last_program_signals_packet into struct remote_state Tom Tromey
2013-06-28 17:40 ` [PATCH 15/16] move remote_stopped_by_watchpoint_p and remote_watch_data_address into remote_state Tom Tromey
2013-06-28 17:44 ` [PATCH 09/16] push last_sent_signal into struct remote_state Tom Tromey
2013-07-01 16:07 ` [PATCH v2 00/16] Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2013-06-21 17:25 [PATCH 00/16] clean up remote.c state Tom Tromey
2013-06-21 17:25 ` [PATCH 11/16] move some statics from remote_read_qxfer into struct remote_state Tom Tromey
2013-06-24 17:25   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372441229-305-12-git-send-email-tromey@redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox