mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 22:48:57 +08:00
Remove usages of find_inferior calling not_stopped_callback
Replace with find_thread. Writing a lambda inline in directly in the if conditions would be a bit messy, so I chose to assign them to variables instead. gdb/gdbserver/ChangeLog: * linux-low.c (not_stopped_callback): Return bool, take filter argument directly. (linux_wait_for_event_filtered): Use find_thread. (linux_wait_1): Likewise.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2017-12-02 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
|
* linux-low.c (not_stopped_callback): Return bool, take filter
|
||||||
|
argument directly.
|
||||||
|
(linux_wait_for_event_filtered): Use find_thread.
|
||||||
|
(linux_wait_1): Likewise.
|
||||||
|
|
||||||
2017-12-02 Simon Marchi <simon.marchi@polymtl.ca>
|
2017-12-02 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* linux-low.c (same_lwp): Remove.
|
* linux-low.c (same_lwp): Remove.
|
||||||
|
@ -1920,23 +1920,18 @@ check_zombie_leaders (void)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for `find_inferior'. Returns the first LWP that is not
|
/* Callback for `find_thread'. Returns the first LWP that is not
|
||||||
stopped. ARG is a PTID filter. */
|
stopped. */
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
not_stopped_callback (thread_info *thread, void *arg)
|
not_stopped_callback (thread_info *thread, ptid_t filter)
|
||||||
{
|
{
|
||||||
struct lwp_info *lwp;
|
if (!thread->id.matches (filter))
|
||||||
ptid_t filter = *(ptid_t *) arg;
|
return false;
|
||||||
|
|
||||||
if (!ptid_match (ptid_of (thread), filter))
|
lwp_info *lwp = get_thread_lwp (thread);
|
||||||
return 0;
|
|
||||||
|
|
||||||
lwp = get_thread_lwp (thread);
|
return !lwp->stopped;
|
||||||
if (!lwp->stopped)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment LWP's suspend count. */
|
/* Increment LWP's suspend count. */
|
||||||
@ -2763,6 +2758,11 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
|
|||||||
until all other threads in the thread group are. */
|
until all other threads in the thread group are. */
|
||||||
check_zombie_leaders ();
|
check_zombie_leaders ();
|
||||||
|
|
||||||
|
auto not_stopped = [&] (thread_info *thread)
|
||||||
|
{
|
||||||
|
return not_stopped_callback (thread, wait_ptid);
|
||||||
|
};
|
||||||
|
|
||||||
/* If there are no resumed children left in the set of LWPs we
|
/* If there are no resumed children left in the set of LWPs we
|
||||||
want to wait for, bail. We can't just block in
|
want to wait for, bail. We can't just block in
|
||||||
waitpid/sigsuspend, because lwps might have been left stopped
|
waitpid/sigsuspend, because lwps might have been left stopped
|
||||||
@ -2770,9 +2770,7 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
|
|||||||
their status to change (which would only happen if we resumed
|
their status to change (which would only happen if we resumed
|
||||||
them). Even if WNOHANG is set, this return code is preferred
|
them). Even if WNOHANG is set, this return code is preferred
|
||||||
over 0 (below), as it is more detailed. */
|
over 0 (below), as it is more detailed. */
|
||||||
if ((find_inferior (&all_threads,
|
if (find_thread (not_stopped) == NULL)
|
||||||
not_stopped_callback,
|
|
||||||
&wait_ptid) == NULL))
|
|
||||||
{
|
{
|
||||||
if (debug_threads)
|
if (debug_threads)
|
||||||
debug_printf ("LLW: exit (no unwaited-for LWP)\n");
|
debug_printf ("LLW: exit (no unwaited-for LWP)\n");
|
||||||
@ -3165,12 +3163,15 @@ linux_wait_1 (ptid_t ptid,
|
|||||||
return status_pending_p_callback (thread, minus_one_ptid);
|
return status_pending_p_callback (thread, minus_one_ptid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto not_stopped = [&] (thread_info *thread)
|
||||||
|
{
|
||||||
|
return not_stopped_callback (thread, minus_one_ptid);
|
||||||
|
};
|
||||||
|
|
||||||
/* Find a resumed LWP, if any. */
|
/* Find a resumed LWP, if any. */
|
||||||
if (find_thread (status_pending_p_any) != NULL)
|
if (find_thread (status_pending_p_any) != NULL)
|
||||||
any_resumed = 1;
|
any_resumed = 1;
|
||||||
else if ((find_inferior (&all_threads,
|
else if (find_thread (not_stopped) != NULL)
|
||||||
not_stopped_callback,
|
|
||||||
&minus_one_ptid) != NULL))
|
|
||||||
any_resumed = 1;
|
any_resumed = 1;
|
||||||
else
|
else
|
||||||
any_resumed = 0;
|
any_resumed = 0;
|
||||||
|
Reference in New Issue
Block a user