This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 09/19] Remove usage of find_inferior in find_lwp_pid
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: <gdb-patches at sourceware dot org>
- Cc: Simon Marchi <simon dot marchi at polymtl dot ca>
- Date: Mon, 20 Nov 2017 11:34:33 -0500
- Subject: [PATCH 09/19] Remove usage of find_inferior in find_lwp_pid
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon dot marchi at ericsson dot com;
- References: <1511195683-2055-1-git-send-email-simon.marchi@ericsson.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
From: Simon Marchi <simon.marchi@polymtl.ca>
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/linux-low.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 6ec9a16..08f7f90 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1807,27 +1807,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;
--
2.7.4