Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Use "switch_to_thread" more thoroughly on gdbserver
@ 2017-09-15  4:34 Sergio Durigan Junior
  2017-09-15 11:14 ` Pedro Alves
  2017-09-26  4:23 ` [PATCH v2] " Sergio Durigan Junior
  0 siblings, 2 replies; 8+ messages in thread
From: Sergio Durigan Junior @ 2017-09-15  4:34 UTC (permalink / raw)
  To: GDB Patches; +Cc: Sergio Durigan Junior

This is a technical debt that I left when I ported "switch_to_thread"
to gdbserver.  It's a simple patch that converts occurences of:

  current_thread = find_thread_ptid (ptid);

to:

  switch_to_thread (ptid);

It helps to leave things more uniform across the code.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
yyyy-mm-dd  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdbthread.h: Include "common-gdbthread.h".
	* remote-utils.c: Include "gdbthread.h".
	(prepare_resume_reply): Use "switch_to_thread".
	* target.c (set_desired_thread): Likewise.
	(done_accessing_memory): Likewise.
---
 gdb/gdbserver/gdbthread.h    | 1 +
 gdb/gdbserver/remote-utils.c | 3 ++-
 gdb/gdbserver/target.c       | 9 +++------
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h
index 04cc47ba71..a864f95884 100644
--- a/gdb/gdbserver/gdbthread.h
+++ b/gdb/gdbserver/gdbthread.h
@@ -19,6 +19,7 @@
 #ifndef GDB_THREAD_H
 #define GDB_THREAD_H
 
+#include "common-gdbthread.h"
 #include "inferiors.h"
 
 struct btrace_target_info;
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 25b7e41a91..761604683c 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -23,6 +23,7 @@
 #include "tdesc.h"
 #include "dll.h"
 #include "rsp-low.h"
+#include "gdbthread.h"
 #include <ctype.h>
 #if HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
@@ -1188,7 +1189,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 
 	saved_thread = current_thread;
 
-	current_thread = find_thread_ptid (ptid);
+	switch_to_thread (ptid);
 
 	regp = current_target_desc ()->expedite_regs;
 
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
index 752646310a..2226dc802d 100644
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -26,14 +26,11 @@ struct target_ops *the_target;
 int
 set_desired_thread (int use_general)
 {
-  struct thread_info *found;
-
   if (use_general == 1)
-    found = find_thread_ptid (general_thread);
+    switch_to_thread (general_thread);
   else
-    found = find_thread_ptid (cont_thread);
+    switch_to_thread (cont_thread);
 
-  current_thread = found;
   return (current_thread != NULL);
 }
 
@@ -143,7 +140,7 @@ done_accessing_memory (void)
 
   /* Restore the previous selected thread.  */
   general_thread = prev_general_thread;
-  current_thread = find_thread_ptid (general_thread);
+  switch_to_thread (general_thread);
 }
 
 int
-- 
2.13.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-26 16:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-15  4:34 [PATCH] Use "switch_to_thread" more thoroughly on gdbserver Sergio Durigan Junior
2017-09-15 11:14 ` Pedro Alves
2017-09-15 18:25   ` Sergio Durigan Junior
2017-09-21 15:11     ` Pedro Alves
2017-09-21 15:42       ` Sergio Durigan Junior
2017-09-26  4:23 ` [PATCH v2] " Sergio Durigan Junior
2017-09-26 12:28   ` Pedro Alves
2017-09-26 16:52     ` Sergio Durigan Junior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox