]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove usage of find_inferior in find_lwp_pid
authorSimon Marchi <simon.marchi@polymtl.ca>
Sun, 3 Dec 2017 01:36:38 +0000 (20:36 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sun, 3 Dec 2017 01:36:38 +0000 (20:36 -0500)
Replace with find_thread.  We could almost use find_thread_ptid, except
that find_lwp_pid uses the pid of the input ptid of the lwp is 0, so the
behavior is not quite the same.

gdb/gdbserver/ChangeLog:

* linux-low.c (same_lwp): Remove.
(find_lwp_pid): Use find_thread.

gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c

index faee0c6496e70760d2450130049c1f9a0764213d..81694105603a0a7aa600d73054c7ca1f2598b3f9 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-02  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * linux-low.c (same_lwp): Remove.
+       (find_lwp_pid): Use find_thread.
+
 2017-12-02  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * linux-low.c (delete_lwp_callback): Remove.
index 498af11a79107654f5ea00d96d46fe9d537ec7aa..dd05a9f6bd8b0bb4596622a92cd58a7c61d35998 100644 (file)
@@ -1808,27 +1808,14 @@ status_pending_p_callback (thread_info *thread, ptid_t ptid)
   return lp->status_pending_p;
 }
 
-static int
-same_lwp (thread_info *thread, void *data)
-{
-  ptid_t ptid = *(ptid_t *) data;
-  int lwp;
-
-  if (ptid_get_lwp (ptid) != 0)
-    lwp = ptid_get_lwp (ptid);
-  else
-    lwp = ptid_get_pid (ptid);
-
-  if (thread->id.lwp () == lwp)
-    return 1;
-
-  return 0;
-}
-
 struct lwp_info *
 find_lwp_pid (ptid_t ptid)
 {
-  thread_info *thread = find_inferior (&all_threads, same_lwp, &ptid);
+  thread_info *thread = find_thread ([&] (thread_info *thread)
+    {
+      int lwp = ptid.lwp () != 0 ? ptid.lwp () : ptid.pid ();
+      return thread->id.lwp () == lwp;
+    });
 
   if (thread == NULL)
     return NULL;