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 05/16] push general_thread and continue_thread into struct remote_state
Date: Fri, 28 Jun 2013 17:40:00 -0000	[thread overview]
Message-ID: <1372441229-305-6-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1372441229-305-1-git-send-email-tromey@redhat.com>

This moves the globals general_thread and continue_thread into
remote_state.

	* remote.c (struct remote_state) <general_thread, continue_thread>:
	New fields.
	(general_thread, continue_thread): Remove.
	(record_currthread, set_thread, set_general_process)
	(remote_open_1, extended_remote_attach_1, remote_wait_as)
	(extended_remote_mourn_1): Update.
---
 gdb/remote.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 9dfc73b..6d9478f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -183,8 +183,6 @@ static ptid_t remote_current_thread (ptid_t oldptid);
 
 static void remote_find_new_threads (void);
 
-static void record_currthread (ptid_t currthread);
-
 static int fromhex (int a);
 
 static int putpkt_binary (char *buf, int cnt);
@@ -373,6 +371,11 @@ struct remote_state
      remote_open knows that we don't have a file open when the program
      starts.  */
   struct serial *remote_desc;
+
+  /* These are the threads which we last sent to the remote system.  The
+     TID member will be -1 for all or -2 for not sent yet.  */
+  ptid_t general_thread;
+  ptid_t continue_thread;
 };
 
 /* Private data that we'll store in (struct thread_info)->private.  */
@@ -1439,12 +1442,6 @@ static ptid_t magic_null_ptid;
 static ptid_t not_sent_ptid;
 static ptid_t any_thread_ptid;
 
-/* These are the threads which we last sent to the remote system.  The
-   TID member will be -1 for all or -2 for not sent yet.  */
-
-static ptid_t general_thread;
-static ptid_t continue_thread;
-
 /* This is the traceframe which we last selected on the remote system.
    It will be -1 if no traceframe is selected.  */
 static int remote_traceframe_number = -1;
@@ -1649,9 +1646,9 @@ demand_private_info (ptid_t ptid)
    3) Successful execution of set thread */
 
 static void
-record_currthread (ptid_t currthread)
+record_currthread (struct remote_state *rs, ptid_t currthread)
 {
-  general_thread = currthread;
+  rs->general_thread = currthread;
 }
 
 static char *last_pass_packet;
@@ -1775,7 +1772,7 @@ static void
 set_thread (struct ptid ptid, int gen)
 {
   struct remote_state *rs = get_remote_state ();
-  ptid_t state = gen ? general_thread : continue_thread;
+  ptid_t state = gen ? rs->general_thread : rs->continue_thread;
   char *buf = rs->buf;
   char *endbuf = rs->buf + get_remote_packet_size ();
 
@@ -1795,9 +1792,9 @@ set_thread (struct ptid ptid, int gen)
   putpkt (rs->buf);
   getpkt (&rs->buf, &rs->buf_size, 0);
   if (gen)
-    general_thread = ptid;
+    rs->general_thread = ptid;
   else
-    continue_thread = ptid;
+    rs->continue_thread = ptid;
 }
 
 static void
@@ -1832,7 +1829,7 @@ set_general_process (void)
 
   /* We only need to change the remote current thread if it's pointing
      at some other process.  */
-  if (ptid_get_pid (general_thread) != ptid_get_pid (inferior_ptid))
+  if (ptid_get_pid (rs->general_thread) != ptid_get_pid (inferior_ptid))
     set_general_thread (inferior_ptid);
 }
 
@@ -4347,8 +4344,8 @@ remote_open_1 (char *name, int from_tty,
   rs->waiting_for_stop_reply = 0;
   rs->ctrlc_pending_p = 0;
 
-  general_thread = not_sent_ptid;
-  continue_thread = not_sent_ptid;
+  rs->general_thread = not_sent_ptid;
+  rs->continue_thread = not_sent_ptid;
   remote_traceframe_number = -1;
 
   /* Probe for ability to use "ThreadInfo" query, as required.  */
@@ -4566,7 +4563,7 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
 	inferior_ptid = pid_to_ptid (pid);
 
       /* Invalidate our notion of the remote current thread.  */
-      record_currthread (minus_one_ptid);
+      record_currthread (rs, minus_one_ptid);
     }
   else
     {
@@ -6065,13 +6062,13 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
 	   && status->kind != TARGET_WAITKIND_SIGNALLED)
     {
       if (!ptid_equal (event_ptid, null_ptid))
-	record_currthread (event_ptid);
+	record_currthread (rs, event_ptid);
       else
 	event_ptid = inferior_ptid;
     }
   else
     /* A process exit.  Invalidate our notion of current thread.  */
-    record_currthread (minus_one_ptid);
+    record_currthread (rs, minus_one_ptid);
 
   return event_ptid;
 }
@@ -7922,7 +7919,7 @@ extended_remote_mourn_1 (struct target_ops *target)
 
      To keep things simple, we always invalidate our notion of the
      current thread.  */
-  record_currthread (minus_one_ptid);
+  record_currthread (rs, minus_one_ptid);
 
   /* Unlike "target remote", we do not want to unpush the target; then
      the next time the user says "run", we won't be connected.  */
-- 
1.8.1.4


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

Thread overview: 25+ 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 15/16] move remote_stopped_by_watchpoint_p and remote_watch_data_address into remote_state 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 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 07/16] push last_pass_packet into struct remote_state 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 ` Tom Tromey [this message]
2013-06-28 17:40 ` [PATCH 10/16] push last_sent_step into struct remote_state 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 12/16] move use_threadinfo_query and use_threadextra_query into struct remote_state Tom Tromey
2013-06-28 17:40 ` [PATCH 04/16] push remote_desc " Tom Tromey
2013-06-28 17:40 ` [PATCH 01/16] use the libiberty crc code 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 11/16] move some statics from remote_read_qxfer into struct remote_state Tom Tromey
2013-07-01 16:07   ` Pedro Alves
2013-07-01 18:06     ` Tom Tromey
2013-06-28 17:40 ` [PATCH 06/16] push remote_traceframe_number " Tom Tromey
2013-06-28 17:44 ` [PATCH 09/16] push last_sent_signal " 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 05/16] push general_thread and continue_thread into struct 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=1372441229-305-6-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