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 16/16] move some static thread state into remote_state
Date: Fri, 21 Jun 2013 17:25:00 -0000	[thread overview]
Message-ID: <1371835506-15691-17-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1371835506-15691-1-git-send-email-tromey@redhat.com>

This moves a few static variables from thread-info functions into
remote_state.  Pedro said on irc that these functions implement the
ancient thread-discovery method and that he wouldn't be surprised if
they had rotted; nevertheless it seems safer to me to make them
explicitly per-remote.

This necessitated moving a couple of macros and a typedef earlier in
the file.

	* remote.c (struct remote_state) <echo_nextthread, nextthread,
	resultthreadlist>: New fields.
	(OPAQUETHREADBYTES, threadref, MAXTHREADLISTRESULTS): Move earlier.
	(remote_get_threadlist, remote_threadlist_iterator): Use
	new fields.  Remove static variables.
---
 gdb/remote.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 0210b9f..e69ed29 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -267,6 +267,13 @@ struct vCont_action_support
 
 static int use_range_stepping = 1;
 
+#define OPAQUETHREADBYTES 8
+
+/* a 64 bit opaque identifier */
+typedef unsigned char threadref[OPAQUETHREADBYTES];
+
+#define MAXTHREADLISTRESULTS 32
+
 /* Description of the remote protocol state for the currently
    connected target.  This is per-target state, and independent of the
    selected architecture.  */
@@ -420,6 +427,10 @@ struct remote_state
 
   /* This is non-zero if target stopped for a watchpoint.  */
   int remote_stopped_by_watchpoint_p;
+
+  threadref echo_nextthread;
+  threadref nextthread;
+  threadref resultthreadlist[MAXTHREADLISTRESULTS];
 };
 
 /* Private data that we'll store in (struct thread_info)->private.  */
@@ -1879,11 +1890,6 @@ remote_thread_alive (struct target_ops *ops, ptid_t ptid)
    remote protocol in general.  There is a matching unit test module
    in libstub.  */
 
-#define OPAQUETHREADBYTES 8
-
-/* a 64 bit opaque identifier */
-typedef unsigned char threadref[OPAQUETHREADBYTES];
-
 /* WARNING: This threadref data structure comes from the remote O.S.,
    libstub protocol encoding, and remote.c.  It is not particularly
    changable.  */
@@ -2499,7 +2505,6 @@ 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;
   int result = 1;
 
   /* Trancate result limit to be smaller than the packet size.  */
@@ -2515,10 +2520,10 @@ remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
     return 0;
   else
     *result_count =
-      parse_threadlist_response (rs->buf + 2, result_limit, &echo_nextthread,
-                                 threadlist, done);
+      parse_threadlist_response (rs->buf + 2, result_limit,
+				 &rs->echo_nextthread, threadlist, done);
 
-  if (!threadmatch (&echo_nextthread, nextthread))
+  if (!threadmatch (&rs->echo_nextthread, nextthread))
     {
       /* FIXME: This is a good reason to drop the packet.  */
       /* Possably, there is a duplicate response.  */
@@ -2561,18 +2566,15 @@ remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
 
 /* About this many threadisds fit in a packet.  */
 
-#define MAXTHREADLISTRESULTS 32
-
 static int
 remote_threadlist_iterator (rmt_thread_action stepfunction, void *context,
 			    int looplimit)
 {
+  struct remote_state *rs = get_remote_state ();
   int done, i, result_count;
   int startflag = 1;
   int result = 1;
   int loopcount = 0;
-  static threadref nextthread;
-  static threadref resultthreadlist[MAXTHREADLISTRESULTS];
 
   done = 0;
   while (!done)
@@ -2583,8 +2585,9 @@ remote_threadlist_iterator (rmt_thread_action stepfunction, void *context,
 	  warning (_("Remote fetch threadlist -infinite loop-."));
 	  break;
 	}
-      if (!remote_get_threadlist (startflag, &nextthread, MAXTHREADLISTRESULTS,
-				  &done, &result_count, resultthreadlist))
+      if (!remote_get_threadlist (startflag, &rs->nextthread,
+				  MAXTHREADLISTRESULTS,
+				  &done, &result_count, rs->resultthreadlist))
 	{
 	  result = 0;
 	  break;
@@ -2593,10 +2596,11 @@ remote_threadlist_iterator (rmt_thread_action stepfunction, void *context,
       startflag = 0;
       /* Setup to resume next batch of thread references, set nextthread.  */
       if (result_count >= 1)
-	copy_threadref (&nextthread, &resultthreadlist[result_count - 1]);
+	copy_threadref (&rs->nextthread,
+			&rs->resultthreadlist[result_count - 1]);
       i = 0;
       while (result_count--)
-	if (!(result = (*stepfunction) (&resultthreadlist[i++], context)))
+	if (!(result = (*stepfunction) (&rs->resultthreadlist[i++], context)))
 	  break;
     }
   return result;
-- 
1.8.1.4


  parent reply	other threads:[~2013-06-21 17:25 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21 17:25 [PATCH 00/16] clean up remote.c state Tom Tromey
2013-06-21 17:25 ` [PATCH 09/16] push last_sent_signal into struct remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 01/16] use the libiberty crc code Tom Tromey
2013-06-24 17:24   ` Pedro Alves
2013-06-27 20:12     ` Tom Tromey
2013-06-21 17:25 ` [PATCH 04/16] push remote_desc into struct remote_state Tom Tromey
2013-06-24 17:25   ` Pedro Alves
2013-06-27 20:29     ` Tom Tromey
2013-06-28 16:43       ` [PATCH] Make file transfer commands work with all (native) targets. (was: Re: [PATCH 04/16] push remote_desc into struct remote_state) Pedro Alves
2013-06-28 17:40         ` [PATCH] Make file transfer commands work with all (native) targets Tom Tromey
2013-06-28 17:46         ` [PATCH] Make file transfer commands work with all (native) targets. (was: Re: [PATCH 04/16] push remote_desc into struct remote_state) Eli Zaretskii
2013-06-28 19:05           ` [PATCH] Make file transfer commands work with all (native) targets Pedro Alves
2013-06-28 19:35             ` Eli Zaretskii
2013-07-01 14:28               ` Tom Tromey
2013-07-01 16:34                 ` Pedro Alves
2013-07-01 16:41                 ` Eli Zaretskii
2013-07-01 16:44                   ` Pedro Alves
2013-06-21 17:25 ` [PATCH 08/16] push last_program_signals_packet into struct remote_state Tom Tromey
2013-06-24 17:36   ` Pedro Alves
2013-06-27 20:13     ` Tom Tromey
2013-06-21 17:25 ` [PATCH 07/16] push last_pass_packet " Tom Tromey
2013-06-21 17:25 ` [PATCH 10/16] push last_sent_step " Tom Tromey
2013-06-21 17:25 ` [PATCH 14/16] move async_client_callback and async_client_context into remote_state Tom Tromey
2013-06-24 17:32   ` Pedro Alves
2013-06-24 18:44     ` Tom Tromey
2013-06-24 19:03       ` Pedro Alves
2013-06-21 17:25 ` Tom Tromey [this message]
2013-06-24 17:33   ` [PATCH 16/16] move some static thread state " Pedro Alves
2013-06-27 20:21     ` Tom Tromey
2013-06-21 17:25 ` [PATCH 06/16] push remote_traceframe_number into struct remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 05/16] push general_thread and continue_thread " Tom Tromey
2013-06-21 17:25 ` [PATCH 11/16] move some statics from remote_read_qxfer " Tom Tromey
2013-06-24 17:25   ` Pedro Alves
2013-06-21 17:25 ` [PATCH 03/16] Add new_remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 15/16] move remote_stopped_by_watchpoint_p and remote_watch_data_address into remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 12/16] move use_threadinfo_query and use_threadextra_query into struct remote_state Tom Tromey
2013-06-21 17:25 ` [PATCH 13/16] move sizeof_pkt into remote_trace_find Tom Tromey
2013-06-24  1:45   ` Yao Qi
2013-06-24 14:54     ` Tom Tromey
2013-06-24 17:32   ` Pedro Alves
2013-06-21 17:30 ` [PATCH 02/16] make remote_protocol_features "const" Tom Tromey
2013-06-24 18:35 ` [PATCH 00/16] clean up remote.c state Pedro Alves
2013-07-05  3:07 ` Yao Qi
2013-07-05 14:27   ` Pedro Alves
2013-08-14 17:53 ` Tom Tromey
2013-06-28 17:40 [PATCH v2 00/16] Tom Tromey
2013-06-28 17:40 ` [PATCH 16/16] move some static thread state into remote_state Tom Tromey

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=1371835506-15691-17-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