From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9529 invoked by alias); 21 Jun 2013 17:25:25 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9169 invoked by uid 89); 21 Jun 2013 17:25:23 -0000 X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 21 Jun 2013 17:25:22 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5LHPLF1032088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Jun 2013 13:25:21 -0400 Received: from barimba.redhat.com (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5LHPBT8021447; Fri, 21 Jun 2013 13:25:20 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 16/16] move some static thread state into remote_state Date: Fri, 21 Jun 2013 17:25:00 -0000 Message-Id: <1371835506-15691-17-git-send-email-tromey@redhat.com> In-Reply-To: <1371835506-15691-1-git-send-email-tromey@redhat.com> References: <1371835506-15691-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-06/txt/msg00607.txt.bz2 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) : 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