Share parts of gdb/gdbthread.h with gdbserver
authorSergio Durigan Junior <sergiodj@redhat.com>
Thu, 22 Dec 2016 18:30:42 +0000 (13:30 -0500)
committerSergio Durigan Junior <sergiodj@redhat.com>
Wed, 7 Jun 2017 23:56:01 +0000 (19:56 -0400)
GDB and gdbserver now share 'switch_to_thread' because of
fork_inferior.  To make things clear, I created a new file name
common/common-gdbthread.h, and left the implementation specific to
each part.

gdb/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>

* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-gdbthread.h".
* common/common-gdbthread.h: New file, with parts from
"gdb/gdbthread.h".
* gdbthread.h: Include "common-gdbthread.h".
(switch_to_thread): Moved to "common/common-gdbthread.h".

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

* inferiors.c (switch_to_thread): New function.

gdb/ChangeLog
gdb/Makefile.in
gdb/common/common-gdbthread.h [new file with mode: 0644]
gdb/gdbserver/ChangeLog
gdb/gdbserver/inferiors.c
gdb/gdbthread.h

index 4bd70e516dd8d5a9777b993dad7438b8e933c13e..a3c406c121ebb64bb59eee0d0709f005b8d7aa63 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * Makefile.in (HFILES_NO_SRCDIR): Add "common/common-gdbthread.h".
+       * common/common-gdbthread.h: New file, with parts from
+       "gdb/gdbthread.h".
+       * gdbthread.h: Include "common-gdbthread.h".
+       (switch_to_thread): Moved to "common/common-gdbthread.h".
+
 2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        * Makefile.in (SFILES): Add "common/job-control.c".
index 4cefd847fa340c83b7ce6ae39fa14280a21448db..2b47d298217ab5911fe8aebe9bcde6699762b6b3 100644 (file)
@@ -1508,6 +1508,7 @@ HFILES_NO_SRCDIR = \
        common/common-debug.h \
        common/common-defs.h \
        common/common-exceptions.h \
+       common/common-gdbthread.h \
        common/common-regcache.h \
        common/common-types.h \
        common/common-utils.h \
diff --git a/gdb/common/common-gdbthread.h b/gdb/common/common-gdbthread.h
new file mode 100644 (file)
index 0000000..d8635e7
--- /dev/null
@@ -0,0 +1,25 @@
+/* Common multi-process/thread control defs for GDB and gdbserver.
+   Copyright (C) 1987-2017 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef COMMON_GDBTHREAD_H
+#define COMMON_GDBTHREAD_H
+
+/* Switch from one thread to another.  */
+extern void switch_to_thread (ptid_t ptid);
+
+#endif /* ! COMMON_GDBTHREAD_H */
index ae458e22b0e465ba1875a98c934be9cf39ae662f..840cf79b35f9a8e2b3e5af40b2e33116808a2f40 100644 (file)
@@ -1,3 +1,7 @@
+2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * inferiors.c (switch_to_thread): New function.
+
 2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        * Makefile.in (SFILE): Add "common/job-control.c".
index b65a7266e3f4085330149cf465c146cc00a882f4..5a4a0d1c23bc95b4ba46e0df6b143ef988727ccf 100644 (file)
@@ -468,3 +468,12 @@ make_cleanup_restore_current_thread (void)
 {
   return make_cleanup (do_restore_current_thread_cleanup, current_thread);
 }
+
+/* See common/common-gdbthread.h.  */
+
+void
+switch_to_thread (ptid_t ptid)
+{
+  if (!ptid_equal (ptid, minus_one_ptid))
+    current_thread = find_thread_ptid (ptid);
+}
index 7bf2070338b06611fbe09e282f34354fefafacd5..046bf95cf6fc7e07460dc60aa9c236d025539736 100644 (file)
@@ -32,6 +32,7 @@ struct symtab;
 #include "target/waitstatus.h"
 #include "cli/cli-utils.h"
 #include "common/refcounted-object.h"
+#include "common-gdbthread.h"
 
 /* Frontend view of the thread state.  Possible extensions: stepping,
    finishing, until(ling),...  */
@@ -493,10 +494,6 @@ extern struct thread_info *iterate_over_threads (thread_callback_func, void *);
 
 extern int thread_count (void);
 
-/* Switch from one thread to another.  Also sets the STOP_PC
-   global.  */
-extern void switch_to_thread (ptid_t ptid);
-
 /* Switch from one thread to another.  Does not read registers and
    sets STOP_PC to -1.  */
 extern void switch_to_thread_no_regs (struct thread_info *thread);