This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Remove usage of find_inferior in find_lwp_pid


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=454296a2c1f3afe163e49730b9b396ffdd985e1f

commit 454296a2c1f3afe163e49730b9b396ffdd985e1f
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Sat Dec 2 20:36:38 2017 -0500

    Remove usage of find_inferior in find_lwp_pid
    
    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.

Diff:
---
 gdb/gdbserver/ChangeLog   |  5 +++++
 gdb/gdbserver/linux-low.c | 23 +++++------------------
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index faee0c6..81694105 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
 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.
 	(linux_mourn): Use for_each_thread.
 
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 498af11..dd05a9f 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]