aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-08-14 18:17:50 +0000
committerTom Tromey <tromey@redhat.com>2013-08-14 18:17:50 +0000
commit0d031856d82030c8bc52fc2d794b116eae88a92c (patch)
tree4fb7323f014fc2bc64ac73c2d5541f6ff6615ffc /gdb
parentee154beebfe8b88abc7c6b12960b0493151c0e33 (diff)
downloadgdb-0d031856d82030c8bc52fc2d794b116eae88a92c.zip
gdb-0d031856d82030c8bc52fc2d794b116eae88a92c.tar.gz
gdb-0d031856d82030c8bc52fc2d794b116eae88a92c.tar.bz2
move some static thread state into remote_state
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/remote.c42
2 files changed, 31 insertions, 19 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f81f9be..13bc9b4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2013-08-14 Tom Tromey <tromey@redhat.com>
+ * 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.
+
+2013-08-14 Tom Tromey <tromey@redhat.com>
+
* remote.c (struct remote_state) <remote_stopped_by_watchpoint_p,
remote_watch_data_address>: New fields.
(remote_stopped_by_watchpoint_p, remote_watch_data_address): Remove.
diff --git a/gdb/remote.c b/gdb/remote.c
index 28223c0..5028451 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -262,6 +262,15 @@ struct vCont_action_support
static int use_range_stepping = 1;
+#define OPAQUETHREADBYTES 8
+
+/* a 64 bit opaque identifier */
+typedef unsigned char threadref[OPAQUETHREADBYTES];
+
+/* About this many threadisds fit in a packet. */
+
+#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. */
@@ -412,6 +421,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. */
@@ -1873,11 +1886,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. */
@@ -2493,7 +2501,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. */
@@ -2509,10 +2516,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. */
@@ -2553,20 +2560,15 @@ remote_get_threadlist (int startflag, threadref *nextthread, int result_limit,
quit_flag is required. */
-/* 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)
@@ -2577,8 +2579,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;
@@ -2587,10 +2590,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;