Use "switch_to_thread" more thoroughly on gdbserver
authorSergio Durigan Junior <sergiodj@redhat.com>
Fri, 15 Sep 2017 04:27:53 +0000 (00:27 -0400)
committerSergio Durigan Junior <sergiodj@redhat.com>
Tue, 26 Sep 2017 16:50:25 +0000 (12:50 -0400)
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);

This patch also converts a simple "if" to a "gdb_assert" on
gdbserver's version of "switch_to_thread":

  gdb_assert (ptid != minus_one_ptid);

This change makes the code more similar to what GDB already does.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
2017-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>

* gdbthread.h: Include "common-gdbthread.h".
* inferiors.c (switch_to_thread): Use "gdb_assert" instead of
"if" when validating the ptid.
* remote-utils.c: Include "gdbthread.h".
(prepare_resume_reply): Use "switch_to_thread".
* target.c (done_accessing_memory): Likewise.

gdb/gdbserver/ChangeLog
gdb/gdbserver/gdbthread.h
gdb/gdbserver/inferiors.c
gdb/gdbserver/remote-utils.c
gdb/gdbserver/target.c

index a628b966e77fb7e93de54a37b6f407da023bb8a6..63fb653a7b1e37880dc3f1df2185dea50b193727 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-26  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * gdbthread.h: Include "common-gdbthread.h".
+       * inferiors.c (switch_to_thread): Use "gdb_assert" instead of
+       "if" when validating the ptid.
+       * remote-utils.c: Include "gdbthread.h".
+       (prepare_resume_reply): Use "switch_to_thread".
+       * target.c (done_accessing_memory): Likewise.
+
 2017-09-25  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        * configure.srv (s390*-*-linux*): Add s390-gs-linux64.o and
index 04cc47ba7199d46e036b79235f7f33d15365e663..a864f958848c801c5b4388f0ca8eb2d54c494a8f 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef GDB_THREAD_H
 #define GDB_THREAD_H
 
+#include "common-gdbthread.h"
 #include "inferiors.h"
 
 struct btrace_target_info;
index 72f0412757340f63a0029ac75a6dd5f477515368..3a45959000a6a949ff6a7a5fefe7bf6826ebbd28 100644 (file)
@@ -442,6 +442,6 @@ make_cleanup_restore_current_thread (void)
 void
 switch_to_thread (ptid_t ptid)
 {
-  if (!ptid_equal (ptid, minus_one_ptid))
-    current_thread = find_thread_ptid (ptid);
+  gdb_assert (ptid != minus_one_ptid);
+  current_thread = find_thread_ptid (ptid);
 }
index 25b7e41a91b18b97bb63ab473bc3d10a960bbb80..761604683cbc21732bb1fac592112780471948fd 100644 (file)
@@ -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;
 
index 7f5bed7ec7adb297dfc5d26736404f694037c5a2..94224a8a7ca99c4a8f0610416d0bc741e70144db 100644 (file)
@@ -138,7 +138,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
This page took 0.036608 seconds and 4 git commands to generate.