From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 08/11] Remove usage of find_inferior when calling linux_set_resume_request
Date: Fri, 17 Nov 2017 18:34:00 -0000 [thread overview]
Message-ID: <1510943613-18598-9-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1510943613-18598-1-git-send-email-simon.marchi@ericsson.com>
Replace it with for_each_thread.
gdb/gdbserver/ChangeLog:
* linux-low.c (struct thread_resume_array): Remove.
(linux_set_resume_request): Return void, take arguments
directly.
(linux_resume): Use for_each_thread.
---
gdb/gdbserver/linux-low.c | 41 +++++++++++++++--------------------------
1 file changed, 15 insertions(+), 26 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index b4c716c..c1d17f1 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4569,33 +4569,22 @@ linux_resume_one_lwp (struct lwp_info *lwp,
END_CATCH
}
-struct thread_resume_array
-{
- struct thread_resume *resume;
- size_t n;
-};
-
-/* This function is called once per thread via find_inferior.
- ARG is a pointer to a thread_resume_array struct.
- We look up the thread specified by ENTRY in ARG, and mark the thread
- with a pointer to the appropriate resume request.
+/* This function is called once per thread via for_each_thread.
+ We look up which resume request applies to THREAD and mark it with a
+ pointer to the appropriate resume request.
This algorithm is O(threads * resume elements), but resume elements
is small (and will remain small at least until GDB supports thread
suspension). */
-static int
-linux_set_resume_request (thread_info *thread, void *arg)
+static void
+linux_set_resume_request (thread_info *thread, thread_resume *resume, size_t n)
{
struct lwp_info *lwp = get_thread_lwp (thread);
- int ndx;
- struct thread_resume_array *r;
-
- r = (struct thread_resume_array *) arg;
- for (ndx = 0; ndx < r->n; ndx++)
+ for (int ndx = 0; ndx < n; ndx++)
{
- ptid_t ptid = r->resume[ndx].thread;
+ ptid_t ptid = resume[ndx].thread;
if (ptid_equal (ptid, minus_one_ptid)
|| ptid == thread->id
/* Handle both 'pPID' and 'pPID.-1' as meaning 'all threads
@@ -4604,7 +4593,7 @@ linux_set_resume_request (thread_info *thread, void *arg)
&& (ptid_is_pid (ptid)
|| ptid_get_lwp (ptid) == -1)))
{
- if (r->resume[ndx].kind == resume_stop
+ if (resume[ndx].kind == resume_stop
&& thread->last_resume_kind == resume_stop)
{
if (debug_threads)
@@ -4620,7 +4609,7 @@ linux_set_resume_request (thread_info *thread, void *arg)
/* Ignore (wildcard) resume requests for already-resumed
threads. */
- if (r->resume[ndx].kind != resume_stop
+ if (resume[ndx].kind != resume_stop
&& thread->last_resume_kind != resume_stop)
{
if (debug_threads)
@@ -4662,7 +4651,7 @@ linux_set_resume_request (thread_info *thread, void *arg)
continue;
}
- lwp->resume = &r->resume[ndx];
+ lwp->resume = &resume[ndx];
thread->last_resume_kind = lwp->resume->kind;
lwp->step_range_start = lwp->resume->step_range_start;
@@ -4684,14 +4673,12 @@ linux_set_resume_request (thread_info *thread, void *arg)
lwpid_of (thread));
}
- return 0;
+ return;
}
}
/* No resume action for this thread. */
lwp->resume = NULL;
-
- return 0;
}
/* find_inferior callback for linux_resume.
@@ -5104,7 +5091,6 @@ linux_resume_one_thread (thread_info *thread, void *arg)
static void
linux_resume (struct thread_resume *resume_info, size_t n)
{
- struct thread_resume_array array = { resume_info, n };
struct thread_info *need_step_over = NULL;
int any_pending;
int leave_all_stopped;
@@ -5115,7 +5101,10 @@ linux_resume (struct thread_resume *resume_info, size_t n)
debug_printf ("linux_resume:\n");
}
- find_inferior (&all_threads, linux_set_resume_request, &array);
+ for_each_thread ([&] (thread_info *thread)
+ {
+ linux_set_resume_request (thread, resume_info, n);
+ });
/* If there is a thread which would otherwise be resumed, which has
a pending status, then don't resume any threads - we can just
--
2.7.4
next prev parent reply other threads:[~2017-11-17 18:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 18:33 [PATCH 00/11] Remove some usages of find_inferior Simon Marchi
2017-11-17 18:34 ` Simon Marchi [this message]
2017-11-17 18:34 ` [PATCH 07/11] Remove usage of find_inferior in linux_stabilize_threads Simon Marchi
2017-11-17 18:34 ` [PATCH 06/11] Remove usage of find_inferior in unsuspend_all_lwps Simon Marchi
2017-11-17 18:34 ` [PATCH 04/11] Remove usage of find_inferior in reset_lwp_ptrace_options_callback Simon Marchi
2017-11-17 18:34 ` [PATCH 03/11] Remove usages of find_inferior in linux-arm-low.c Simon Marchi
2017-11-17 18:34 ` [PATCH 02/11] Remove usage of find_inferior in win32-low.c Simon Marchi
2017-11-17 18:34 ` [PATCH 05/11] Remove usage of find_inferior in iterate_over_lwps Simon Marchi
2017-11-17 18:34 ` [PATCH 11/11] Remove usage of find_inferior when calling kill_one_lwp_callback Simon Marchi
2017-11-17 18:34 ` [PATCH 10/11] Remove usages of find_thread when calling need_step_over_p Simon Marchi
2017-11-17 18:34 ` [PATCH 09/11] Remove usage of find_thread when calling resume_status_pending_p Simon Marchi
2017-11-17 18:34 ` [PATCH 01/11] Remove usage of find_inferior in win32-i386-low.c Simon Marchi
2017-11-19 19:21 ` [PATCH 00/11] Remove some usages of find_inferior Sergio Durigan Junior
2017-11-20 3:24 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1510943613-18598-9-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).