Get pending events in random
Nowadays, we select events to be reported to GDB in random, however that is not enough when many GDBserver internal events (not reported to GDB) are generated. GDBserver pulls all events out of kernel via waitpid, and leave them pending. When goes through threads which have pending events, GDBserver uses find_inferior to find the first thread which has pending event, and consumes it. Note that find_inferior always iterate threads in a fixed order. If multiple threads keep hitting GDBserver breakpoints, range stepping with single-step breakpoint for example, threads in the head of the thread list are more likely to be processed and threads in the tail are starved. This causes some timeout fails in gdb.threads/non-stop-fair-events.exp when range stepping is enabled on arm-linux. This patch fixes this issue by randomly selecting pending events. It adds a new function find_inferior_in_random, which iterates threads which have pending events randomly. gdb/gdbserver: 2016-10-27 Yao Qi <yao.qi@linaro.org> * inferiors.c (find_inferior_in_random): New function. * inferiors.h (find_inferior_in_random): Declare. * linux-low.c (linux_wait_for_event_filtered): Call find_inferior_in_random instead of find_inferior.
This commit is contained in:
parent
e3652c8460
commit
8934261877
4 changed files with 61 additions and 2 deletions
|
@ -2700,7 +2700,8 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
|
|||
if (ptid_equal (filter_ptid, minus_one_ptid) || ptid_is_pid (filter_ptid))
|
||||
{
|
||||
event_thread = (struct thread_info *)
|
||||
find_inferior (&all_threads, status_pending_p_callback, &filter_ptid);
|
||||
find_inferior_in_random (&all_threads, status_pending_p_callback,
|
||||
&filter_ptid);
|
||||
if (event_thread != NULL)
|
||||
event_child = get_thread_lwp (event_thread);
|
||||
if (debug_threads && event_thread)
|
||||
|
@ -2811,7 +2812,8 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
|
|||
/* ... and find an LWP with a status to report to the core, if
|
||||
any. */
|
||||
event_thread = (struct thread_info *)
|
||||
find_inferior (&all_threads, status_pending_p_callback, &filter_ptid);
|
||||
find_inferior_in_random (&all_threads, status_pending_p_callback,
|
||||
&filter_ptid);
|
||||
if (event_thread != NULL)
|
||||
{
|
||||
event_child = get_thread_lwp (event_thread);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue