From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9196 invoked by alias); 21 Jun 2013 17:25:23 -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 8303 invoked by uid 89); 21 Jun 2013 17:25:19 -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:19 +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 r5LHPIP8019793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Jun 2013 13:25:18 -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 r5LHPBT3021447; Fri, 21 Jun 2013 13:25:17 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 11/16] move some statics from remote_read_qxfer into struct remote_state Date: Fri, 21 Jun 2013 17:25:00 -0000 Message-Id: <1371835506-15691-12-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/msg00604.txt.bz2 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) : 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 1c5b27d..c77cdaf 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -394,6 +394,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. */ @@ -8703,10 +8707,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; @@ -8715,19 +8715,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 @@ -8766,9 +8766,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