Remove usage of find_inferior in resume

Change find_inferior with find_thread.  Since we can now pass arguments
directly instead of through a void pointer, we don't need the
visit_actioned_threads_data structure anymore.

gdb/gdbserver/ChangeLog:

	* server.c (struct visit_actioned_threads_data): Remove.
	(visit_actioned_threads): Change prototype to take arguments
	directly.
	(resume): Use find_thread instead of find_inferior.
This commit is contained in:
Simon Marchi 2017-10-27 23:43:11 -04:00
parent 99078d344d
commit eaddb42592
2 changed files with 23 additions and 27 deletions

View File

@ -1,3 +1,10 @@
2017-10-27 Simon Marchi <simon.marchi@ericsson.com>
* server.c (struct visit_actioned_threads_data): Remove.
(visit_actioned_threads): Change prototype to take arguments
directly.
(resume): Use find_thread instead of find_inferior.
2017-10-27 Simon Marchi <simon.marchi@ericsson.com> 2017-10-27 Simon Marchi <simon.marchi@ericsson.com>
* server.c (queue_stop_reply_callback): Change prototype, return * server.c (queue_stop_reply_callback): Change prototype, return

View File

@ -2677,31 +2677,18 @@ static void resume (struct thread_resume *actions, size_t n);
typedef int (visit_actioned_threads_callback_ftype) typedef int (visit_actioned_threads_callback_ftype)
(const struct thread_resume *, struct thread_info *); (const struct thread_resume *, struct thread_info *);
/* Struct to pass data to visit_actioned_threads. */
struct visit_actioned_threads_data
{
const struct thread_resume *actions;
size_t num_actions;
visit_actioned_threads_callback_ftype *callback;
};
/* Call CALLBACK for any thread to which ACTIONS applies to. Returns /* Call CALLBACK for any thread to which ACTIONS applies to. Returns
true if CALLBACK returns true. Returns false if no matching thread true if CALLBACK returns true. Returns false if no matching thread
is found or CALLBACK results false. is found or CALLBACK results false.
Note: This function is itself a callback for find_inferior. */ Note: This function is itself a callback for find_thread. */
static int static bool
visit_actioned_threads (thread_info *thread, void *datap) visit_actioned_threads (thread_info *thread,
const struct thread_resume *actions,
size_t num_actions,
visit_actioned_threads_callback_ftype *callback)
{ {
struct visit_actioned_threads_data *data for (size_t i = 0; i < num_actions; i++)
= (struct visit_actioned_threads_data *) datap;
const struct thread_resume *actions = data->actions;
size_t num_actions = data->num_actions;
visit_actioned_threads_callback_ftype *callback = data->callback;
size_t i;
for (i = 0; i < num_actions; i++)
{ {
const struct thread_resume *action = &actions[i]; const struct thread_resume *action = &actions[i];
@ -2712,11 +2699,11 @@ visit_actioned_threads (thread_info *thread, void *datap)
&& ptid_get_lwp (action->thread) == -1)) && ptid_get_lwp (action->thread) == -1))
{ {
if ((*callback) (action, thread)) if ((*callback) (action, thread))
return 1; return true;
} }
} }
return 0; return false;
} }
/* Callback for visit_actioned_threads. If the thread has a pending /* Callback for visit_actioned_threads. If the thread has a pending
@ -2858,12 +2845,14 @@ resume (struct thread_resume *actions, size_t num_actions)
one with a pending status to report. If so, skip actually one with a pending status to report. If so, skip actually
resuming/stopping and report the pending event resuming/stopping and report the pending event
immediately. */ immediately. */
struct visit_actioned_threads_data data;
data.actions = actions; thread_info *thread_with_status = find_thread ([&] (thread_info *thread)
data.num_actions = num_actions; {
data.callback = handle_pending_status; return visit_actioned_threads (thread, actions, num_actions,
if (find_inferior (&all_threads, visit_actioned_threads, &data) != NULL) handle_pending_status);
});
if (thread_with_status != NULL)
return; return;
enable_async_io (); enable_async_io ();