Rename common to gdbsupport
[deliverable/binutils-gdb.git] / gdb / gdbserver / gdbthread.h
index b82d5b0e72ac8ca9673c24046dd62aa2ebb4517e..825a7f6b51007d890ba60e9cc74b61c93f79a1c3 100644 (file)
@@ -1,5 +1,5 @@
 /* Multi-thread control defs for remote server for GDB.
-   Copyright (C) 1993-2017 Free Software Foundation, Inc.
+   Copyright (C) 1993-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    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 GDB_THREAD_H
-#define GDB_THREAD_H
+#ifndef GDBSERVER_GDBTHREAD_H
+#define GDBSERVER_GDBTHREAD_H
 
-#include "common-gdbthread.h"
+#include "gdbsupport/common-gdbthread.h"
 #include "inferiors.h"
 
 #include <list>
@@ -123,6 +123,18 @@ find_thread (int pid, Func func)
     });
 }
 
+/* Find the first thread that matches FILTER for which FUNC returns true.
+   Return NULL if no thread satisfying these conditions is found.  */
+
+template <typename Func>
+static thread_info *
+find_thread (ptid_t filter, Func func)
+{
+  return find_thread ([&] (thread_info *thread) {
+    return thread->id.matches (filter) && func (thread);
+  });
+}
+
 /* Invoke FUNC for each thread.  */
 
 template <typename Func>
@@ -176,8 +188,8 @@ find_thread_in_random (Func func)
   random_selector = (int)
     ((count * (double) rand ()) / (RAND_MAX + 1.0));
 
-  thread_info *thread = find_thread ([&] (thread_info *thread) {
-    return func (thread) && (random_selector-- == 0);
+  thread_info *thread = find_thread ([&] (thread_info *thr_arg) {
+    return func (thr_arg) && (random_selector-- == 0);
   });
 
   gdb_assert (thread != NULL);
@@ -212,7 +224,4 @@ lwpid_of (const thread_info *thread)
   return thread->id.lwp ();
 }
 
-/* Create a cleanup to restore current_thread.  */
-struct cleanup *make_cleanup_restore_current_thread (void);
-
-#endif /* GDB_THREAD_H */
+#endif /* GDBSERVER_GDBTHREAD_H */
This page took 0.024509 seconds and 4 git commands to generate.