1999-05-12 04:29:07 +08:00
|
|
|
|
/* Event loop machinery for GDB, the GNU debugger.
|
2015-01-01 17:32:14 +08:00
|
|
|
|
Copyright (C) 1999-2015 Free Software Foundation, Inc.
|
1999-05-12 04:29:07 +08:00
|
|
|
|
Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
|
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-05-12 04:29:07 +08:00
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2010-12-29 08:58:14 +08:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
1999-06-21 21:27:42 +08:00
|
|
|
|
#include "event-loop.h"
|
1999-09-22 11:28:34 +08:00
|
|
|
|
#include "event-top.h"
|
2013-01-25 22:17:10 +08:00
|
|
|
|
#include "queue.h"
|
2000-07-05 18:25:43 +08:00
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2000-07-05 18:25:43 +08:00
|
|
|
|
#if defined (HAVE_POLL_H)
|
1999-06-21 21:27:42 +08:00
|
|
|
|
#include <poll.h>
|
2000-07-05 18:25:43 +08:00
|
|
|
|
#elif defined (HAVE_SYS_POLL_H)
|
|
|
|
|
#include <sys/poll.h>
|
|
|
|
|
#endif
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif
|
2000-07-05 18:25:43 +08:00
|
|
|
|
|
1999-06-21 21:27:42 +08:00
|
|
|
|
#include <sys/types.h>
|
1999-09-22 11:28:34 +08:00
|
|
|
|
#include <sys/time.h>
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
|
#include "gdb_select.h"
|
Make display_gdb_prompt CLI-only.
Enabling target-async by default will require implementing sync
execution on top of an async target, much like foreground command are
implemented on the CLI in async mode.
In order to do that, we will need better control of when to print the
MI prompt. Currently the interp->display_prompt_p hook is all we
have, and MI just always returns false, meaning, make
display_gdb_prompt a no-op. We'll need to be able to know to print
the MI prompt in some of the conditions that display_gdb_prompt is
called from the core, but not all.
This is all a litte twisted currently. As we can see,
display_gdb_prompt is really CLI specific, so make the console
interpreters (console/tui) themselves call it. To be able to do that,
and add a few different observers that the interpreters can use to
distinguish when or why the the prompt is being printed:
#1 - one called whenever a command is cancelled due to an error.
#2 - another for when a foreground command just finished.
In both cases, CLI wants to print the prompt, while MI doesn't.
MI will want to print the prompt in the second case when in a special
MI mode.
The display_gdb_prompt call in interp_set made me pause. The comment
there reads:
/* Finally, put up the new prompt to show that we are indeed here.
Also, display_gdb_prompt for the console does some readline magic
which is needed for the console interpreter, at least... */
But, that looks very much like a no-op to me currently:
- the MI interpreter always return false in the prompt hook, meaning
actually display no prompt.
- the interpreter used at that point is still quiet. And the
console/tui interpreters return false in the prompt hook if they're
quiet, meaning actually display no prompt.
The only remaining possible use would then be the readline magic. But
whatever that might have been, it's not reacheable today either,
because display_gdb_prompt returns early, before touching readline if
the interpreter returns false in the display_prompt_p hook.
Tested on x86_64 Fedora 20, sync and async modes.
gdb/
2014-05-29 Pedro Alves <palves@redhat.com>
* cli/cli-interp.c (cli_interpreter_display_prompt_p): Delete.
(_initialize_cli_interp): Adjust.
* event-loop.c: Include "observer.h".
(start_event_loop): Notify 'command_error' observers instead of
calling display_gdb_prompt. Remove FIXME comment.
* event-top.c (display_gdb_prompt): Remove call into the
interpreters.
* inf-loop.c: Include "observer.h".
(inferior_event_handler): Notify 'command_error' observers instead
of calling display_gdb_prompt.
* infrun.c (fetch_inferior_event): Notify 'sync_execution_done'
observers instead of calling display_gdb_prompt.
* interps.c (interp_set): Don't call display_gdb_prompt.
(current_interp_display_prompt_p): Delete.
* interps.h (interp_prompt_p): Delete declaration.
(interp_prompt_p_ftype): Delete.
(struct interp_procs) <prompt_proc_p>: Delete field.
(current_interp_display_prompt_p): Delete declaration.
* mi-interp.c (mi_interpreter_prompt_p): Delete.
(_initialize_mi_interp): Adjust.
* tui-interp.c (tui_init): Install 'sync_execution_done' and
'command_error' observers.
(tui_on_sync_execution_done, tui_on_command_error): New
functions.
(tui_display_prompt_p): Delete.
(_initialize_tui_interp): Adjust.
gdb/doc/
2014-05-29 Pedro Alves <palves@redhat.com>
* observer.texi (sync_execution_done, command_error): New
subjects.
2014-05-23 18:37:12 +08:00
|
|
|
|
#include "observer.h"
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Tell create_file_handler what events we are interested in.
|
|
|
|
|
This is used by the select version of the event loop. */
|
2010-05-25 23:48:44 +08:00
|
|
|
|
|
|
|
|
|
#define GDB_READABLE (1<<1)
|
|
|
|
|
#define GDB_WRITABLE (1<<2)
|
|
|
|
|
#define GDB_EXCEPTION (1<<3)
|
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* Data point to pass to the event handler. */
|
|
|
|
|
typedef union event_data
|
|
|
|
|
{
|
|
|
|
|
void *ptr;
|
|
|
|
|
int integer;
|
|
|
|
|
} event_data;
|
|
|
|
|
|
1999-09-22 11:28:34 +08:00
|
|
|
|
typedef struct gdb_event gdb_event;
|
2008-10-25 03:33:39 +08:00
|
|
|
|
typedef void (event_handler_func) (event_data);
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
|
|
|
|
/* Event for the GDB event system. Events are queued by calling
|
2010-12-29 08:58:14 +08:00
|
|
|
|
async_queue_event and serviced later on by gdb_do_one_event. An
|
1999-09-22 11:28:34 +08:00
|
|
|
|
event can be, for instance, a file descriptor becoming ready to be
|
2008-10-25 03:33:39 +08:00
|
|
|
|
read. Servicing an event simply means that the procedure PROC will
|
1999-09-22 11:28:34 +08:00
|
|
|
|
be called. We have 2 queues, one for file handlers that we listen
|
|
|
|
|
to in the event loop, and one for the file handlers+events that are
|
2010-12-29 08:58:14 +08:00
|
|
|
|
ready. The procedure PROC associated with each event is dependant
|
2008-10-25 03:33:39 +08:00
|
|
|
|
of the event source. In the case of monitored file descriptors, it
|
|
|
|
|
is always the same (handle_file_event). Its duty is to invoke the
|
|
|
|
|
handler associated with the file descriptor whose state change
|
|
|
|
|
generated the event, plus doing other cleanups and such. In the
|
|
|
|
|
case of async signal handlers, it is
|
|
|
|
|
invoke_async_signal_handler. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
2013-01-25 22:17:10 +08:00
|
|
|
|
typedef struct gdb_event
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* Procedure to call to service this event. */
|
|
|
|
|
event_handler_func *proc;
|
|
|
|
|
|
|
|
|
|
/* Data to pass to the event handler. */
|
|
|
|
|
event_data data;
|
2013-01-25 22:17:10 +08:00
|
|
|
|
} *gdb_event_p;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
|
|
|
|
/* Information about each file descriptor we register with the event
|
2010-12-29 08:58:14 +08:00
|
|
|
|
loop. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
|
|
|
|
typedef struct file_handler
|
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
|
int fd; /* File descriptor. */
|
|
|
|
|
int mask; /* Events we want to monitor: POLLIN, etc. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
int ready_mask; /* Events that have been seen since
|
2010-12-29 08:58:14 +08:00
|
|
|
|
the last time. */
|
|
|
|
|
handler_func *proc; /* Procedure to call when fd is ready. */
|
|
|
|
|
gdb_client_data client_data; /* Argument to pass to proc. */
|
|
|
|
|
int error; /* Was an error detected on this fd? */
|
|
|
|
|
struct file_handler *next_file; /* Next registered file descriptor. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
}
|
|
|
|
|
file_handler;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* PROC is a function to be invoked when the READY flag is set. This
|
1999-09-22 11:28:34 +08:00
|
|
|
|
happens when there has been a signal and the corresponding signal
|
2010-12-29 08:58:14 +08:00
|
|
|
|
handler has 'triggered' this async_signal_handler for execution.
|
|
|
|
|
The actual work to be done in response to a signal will be carried
|
|
|
|
|
out by PROC at a later time, within process_event. This provides a
|
|
|
|
|
deferred execution of signal handlers.
|
|
|
|
|
|
1999-09-22 11:28:34 +08:00
|
|
|
|
Async_init_signals takes care of setting up such an
|
2010-12-29 08:58:14 +08:00
|
|
|
|
async_signal_handler for each interesting signal. */
|
|
|
|
|
|
1999-09-22 11:28:34 +08:00
|
|
|
|
typedef struct async_signal_handler
|
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
|
int ready; /* If ready, call this handler
|
|
|
|
|
from the main event loop, using
|
|
|
|
|
invoke_async_handler. */
|
|
|
|
|
struct async_signal_handler *next_handler; /* Ptr to next handler. */
|
|
|
|
|
sig_handler_func *proc; /* Function to call to do the work. */
|
|
|
|
|
gdb_client_data client_data; /* Argument to async_handler_func. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
}
|
|
|
|
|
async_signal_handler;
|
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* PROC is a function to be invoked when the READY flag is set. This
|
|
|
|
|
happens when the event has been marked with
|
|
|
|
|
MARK_ASYNC_EVENT_HANDLER. The actual work to be done in response
|
|
|
|
|
to an event will be carried out by PROC at a later time, within
|
|
|
|
|
process_event. This provides a deferred execution of event
|
|
|
|
|
handlers. */
|
|
|
|
|
typedef struct async_event_handler
|
|
|
|
|
{
|
|
|
|
|
/* If ready, call this handler from the main event loop, using
|
|
|
|
|
invoke_event_handler. */
|
|
|
|
|
int ready;
|
|
|
|
|
|
|
|
|
|
/* Point to next handler. */
|
|
|
|
|
struct async_event_handler *next_handler;
|
|
|
|
|
|
|
|
|
|
/* Function to call to do the work. */
|
|
|
|
|
async_event_handler_func *proc;
|
|
|
|
|
|
|
|
|
|
/* Argument to PROC. */
|
|
|
|
|
gdb_client_data client_data;
|
|
|
|
|
}
|
|
|
|
|
async_event_handler;
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
/* Gdb_notifier is just a list of file descriptors gdb is interested in.
|
|
|
|
|
These are the input file descriptor, and the target file
|
2010-12-29 08:58:14 +08:00
|
|
|
|
descriptor. We have two flavors of the notifier, one for platforms
|
1999-05-12 04:29:07 +08:00
|
|
|
|
that have the POLL function, the other for those that don't, and
|
2010-12-29 08:58:14 +08:00
|
|
|
|
only support SELECT. Each of the elements in the gdb_notifier list is
|
1999-05-12 04:29:07 +08:00
|
|
|
|
basically a description of what kind of events gdb is interested
|
2010-12-29 08:58:14 +08:00
|
|
|
|
in, for each fd. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
1999-05-26 02:09:09 +08:00
|
|
|
|
/* As of 1999-04-30 only the input file descriptor is registered with the
|
2010-12-29 08:58:14 +08:00
|
|
|
|
event loop. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
/* Do we use poll or select ? */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#define USE_POLL 1
|
|
|
|
|
#else
|
|
|
|
|
#define USE_POLL 0
|
|
|
|
|
#endif /* HAVE_POLL */
|
|
|
|
|
|
|
|
|
|
static unsigned char use_poll = USE_POLL;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2005-04-26 05:45:56 +08:00
|
|
|
|
#ifdef USE_WIN32API
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
static struct
|
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Ptr to head of file handler list. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
file_handler *first_file_handler;
|
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
/* Next file handler to handle, for the select variant. To level
|
|
|
|
|
the fairness across event sources, we serve file handlers in a
|
|
|
|
|
round-robin-like fashion. The number and order of the polled
|
|
|
|
|
file handlers may change between invocations, but this is good
|
|
|
|
|
enough. */
|
|
|
|
|
file_handler *next_file_handler;
|
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Ptr to array of pollfd structures. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
struct pollfd *poll_fds;
|
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
/* Next file descriptor to handle, for the poll variant. To level
|
|
|
|
|
the fairness across event sources, we poll the file descriptors
|
|
|
|
|
in a round-robin-like fashion. The number and order of the
|
|
|
|
|
polled file descriptors may change between invocations, but
|
|
|
|
|
this is good enough. */
|
|
|
|
|
int next_poll_fds_index;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Timeout in milliseconds for calls to poll(). */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
int poll_timeout;
|
|
|
|
|
#endif
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
/* Masks to be used in the next call to select.
|
2010-12-29 08:58:14 +08:00
|
|
|
|
Bits are set in response to calls to create_file_handler. */
|
2000-03-21 03:59:38 +08:00
|
|
|
|
fd_set check_masks[3];
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* What file descriptors were found ready by select. */
|
2000-03-21 03:59:38 +08:00
|
|
|
|
fd_set ready_masks[3];
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Number of file descriptors to monitor (for poll). */
|
|
|
|
|
/* Number of valid bits (highest fd value + 1) (for select). */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
int num_fds;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Time structure for calls to select(). */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
struct timeval select_timeout;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Flag to tell whether the timeout should be used. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
int timeout_valid;
|
1999-09-29 05:55:21 +08:00
|
|
|
|
}
|
1999-05-12 04:29:07 +08:00
|
|
|
|
gdb_notifier;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Structure associated with a timer. PROC will be executed at the
|
|
|
|
|
first occasion after WHEN. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
struct gdb_timer
|
|
|
|
|
{
|
|
|
|
|
struct timeval when;
|
|
|
|
|
int timer_id;
|
|
|
|
|
struct gdb_timer *next;
|
2010-12-29 08:58:14 +08:00
|
|
|
|
timer_handler_func *proc; /* Function to call to do the work. */
|
|
|
|
|
gdb_client_data client_data; /* Argument to async_handler_func. */
|
2010-05-04 04:58:21 +08:00
|
|
|
|
};
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* List of currently active timers. It is sorted in order of
|
|
|
|
|
increasing timers. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
static struct
|
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Pointer to first in timer list. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
struct gdb_timer *first_timer;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Id of the last timer created. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
int num_timers;
|
|
|
|
|
}
|
|
|
|
|
timer_list;
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
/* All the async_signal_handlers gdb is interested in are kept onto
|
2010-12-29 08:58:14 +08:00
|
|
|
|
this list. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
static struct
|
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Pointer to first in handler list. */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
async_signal_handler *first_handler;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Pointer to last in handler list. */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
async_signal_handler *last_handler;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
sighandler_list;
|
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* All the async_event_handlers gdb is interested in are kept onto
|
2010-12-29 08:58:14 +08:00
|
|
|
|
this list. */
|
2008-10-25 03:33:39 +08:00
|
|
|
|
static struct
|
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Pointer to first in handler list. */
|
2008-10-25 03:33:39 +08:00
|
|
|
|
async_event_handler *first_handler;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Pointer to last in handler list. */
|
2008-10-25 03:33:39 +08:00
|
|
|
|
async_event_handler *last_handler;
|
|
|
|
|
}
|
|
|
|
|
async_event_handler_list;
|
|
|
|
|
|
|
|
|
|
static int invoke_async_signal_handlers (void);
|
|
|
|
|
static void create_file_handler (int fd, int mask, handler_func *proc,
|
|
|
|
|
gdb_client_data client_data);
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
static int check_async_event_handlers (void);
|
2008-10-25 03:33:39 +08:00
|
|
|
|
static int gdb_wait_for_event (int);
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
static int update_wait_timeout (void);
|
|
|
|
|
static int poll_timers (void);
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Process one high level event. If nothing is ready at this time,
|
|
|
|
|
wait for something to happen (via gdb_wait_for_event), then process
|
1999-11-09 09:23:30 +08:00
|
|
|
|
it. Returns >0 if something was done otherwise returns <0 (this
|
2011-08-05 04:09:46 +08:00
|
|
|
|
can happen if there are no event sources to wait for). */
|
1999-11-09 09:23:30 +08:00
|
|
|
|
|
2002-09-11 03:53:24 +08:00
|
|
|
|
int
|
2011-08-05 04:09:46 +08:00
|
|
|
|
gdb_do_one_event (void)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
2008-10-25 03:33:39 +08:00
|
|
|
|
static int event_source_head = 0;
|
|
|
|
|
const int number_of_sources = 3;
|
|
|
|
|
int current = 0;
|
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* First let's see if there are any asynchronous signal handlers
|
|
|
|
|
that are ready. These would be the result of invoking any of the
|
|
|
|
|
signal handlers. */
|
|
|
|
|
if (invoke_async_signal_handlers ())
|
2008-10-25 03:33:39 +08:00
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
/* To level the fairness across event sources, we poll them in a
|
|
|
|
|
round-robin fashion. */
|
|
|
|
|
for (current = 0; current < number_of_sources; current++)
|
1999-11-09 09:23:30 +08:00
|
|
|
|
{
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
int res;
|
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
switch (event_source_head)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* Are any timers that are ready? */
|
|
|
|
|
res = poll_timers ();
|
2008-10-25 03:33:39 +08:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
/* Are there events already waiting to be collected on the
|
|
|
|
|
monitored file descriptors? */
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
res = gdb_wait_for_event (0);
|
2008-10-25 03:33:39 +08:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
/* Are there any asynchronous event handlers ready? */
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
res = check_async_event_handlers ();
|
2008-10-25 03:33:39 +08:00
|
|
|
|
break;
|
2015-02-04 18:05:58 +08:00
|
|
|
|
default:
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
"unexpected event_source_head %d",
|
|
|
|
|
event_source_head);
|
2008-10-25 03:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event_source_head++;
|
|
|
|
|
if (event_source_head == number_of_sources)
|
|
|
|
|
event_source_head = 0;
|
2000-03-23 11:48:13 +08:00
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
if (res > 0)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2000-03-23 11:48:13 +08:00
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* Block waiting for a new event. If gdb_wait_for_event returns -1,
|
|
|
|
|
we should get out because this means that there are no event
|
|
|
|
|
sources left. This will make the event loop stop, and the
|
|
|
|
|
application exit. */
|
2000-03-23 11:48:13 +08:00
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
if (gdb_wait_for_event (1) < 0)
|
|
|
|
|
return -1;
|
2000-03-23 11:48:13 +08:00
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* If gdb_wait_for_event has returned 1, it means that one event has
|
|
|
|
|
been handled. We break out of the loop. */
|
1999-11-09 09:23:30 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Start up the event loop. This is the entry point to the event loop
|
|
|
|
|
from the command loop. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
1999-11-09 09:23:30 +08:00
|
|
|
|
void
|
|
|
|
|
start_event_loop (void)
|
|
|
|
|
{
|
2011-08-05 04:09:46 +08:00
|
|
|
|
/* Loop until there is nothing to do. This is the entry point to
|
|
|
|
|
the event loop engine. gdb_do_one_event will process one event
|
|
|
|
|
for each invocation. It blocks waiting for an event and then
|
|
|
|
|
processes it. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
2011-08-05 04:09:46 +08:00
|
|
|
|
int result = 0;
|
2002-10-01 05:25:47 +08:00
|
|
|
|
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 23:14:14 +08:00
|
|
|
|
TRY
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
2011-08-05 04:09:46 +08:00
|
|
|
|
result = gdb_do_one_event ();
|
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 23:14:14 +08:00
|
|
|
|
CATCH (ex, RETURN_MASK_ALL)
|
2011-08-05 04:09:46 +08:00
|
|
|
|
{
|
|
|
|
|
exception_print (gdb_stderr, ex);
|
|
|
|
|
|
2008-03-15 02:57:44 +08:00
|
|
|
|
/* If any exception escaped to here, we better enable
|
|
|
|
|
stdin. Otherwise, any command that calls async_disable_stdin,
|
|
|
|
|
and then throws, will leave stdin inoperable. */
|
2008-03-15 03:55:51 +08:00
|
|
|
|
async_enable_stdin ();
|
2011-08-05 04:09:46 +08:00
|
|
|
|
/* If we long-jumped out of do_one_event, we probably didn't
|
|
|
|
|
get around to resetting the prompt, which leaves readline
|
|
|
|
|
in a messed-up state. Reset it here. */
|
Make display_gdb_prompt CLI-only.
Enabling target-async by default will require implementing sync
execution on top of an async target, much like foreground command are
implemented on the CLI in async mode.
In order to do that, we will need better control of when to print the
MI prompt. Currently the interp->display_prompt_p hook is all we
have, and MI just always returns false, meaning, make
display_gdb_prompt a no-op. We'll need to be able to know to print
the MI prompt in some of the conditions that display_gdb_prompt is
called from the core, but not all.
This is all a litte twisted currently. As we can see,
display_gdb_prompt is really CLI specific, so make the console
interpreters (console/tui) themselves call it. To be able to do that,
and add a few different observers that the interpreters can use to
distinguish when or why the the prompt is being printed:
#1 - one called whenever a command is cancelled due to an error.
#2 - another for when a foreground command just finished.
In both cases, CLI wants to print the prompt, while MI doesn't.
MI will want to print the prompt in the second case when in a special
MI mode.
The display_gdb_prompt call in interp_set made me pause. The comment
there reads:
/* Finally, put up the new prompt to show that we are indeed here.
Also, display_gdb_prompt for the console does some readline magic
which is needed for the console interpreter, at least... */
But, that looks very much like a no-op to me currently:
- the MI interpreter always return false in the prompt hook, meaning
actually display no prompt.
- the interpreter used at that point is still quiet. And the
console/tui interpreters return false in the prompt hook if they're
quiet, meaning actually display no prompt.
The only remaining possible use would then be the readline magic. But
whatever that might have been, it's not reacheable today either,
because display_gdb_prompt returns early, before touching readline if
the interpreter returns false in the display_prompt_p hook.
Tested on x86_64 Fedora 20, sync and async modes.
gdb/
2014-05-29 Pedro Alves <palves@redhat.com>
* cli/cli-interp.c (cli_interpreter_display_prompt_p): Delete.
(_initialize_cli_interp): Adjust.
* event-loop.c: Include "observer.h".
(start_event_loop): Notify 'command_error' observers instead of
calling display_gdb_prompt. Remove FIXME comment.
* event-top.c (display_gdb_prompt): Remove call into the
interpreters.
* inf-loop.c: Include "observer.h".
(inferior_event_handler): Notify 'command_error' observers instead
of calling display_gdb_prompt.
* infrun.c (fetch_inferior_event): Notify 'sync_execution_done'
observers instead of calling display_gdb_prompt.
* interps.c (interp_set): Don't call display_gdb_prompt.
(current_interp_display_prompt_p): Delete.
* interps.h (interp_prompt_p): Delete declaration.
(interp_prompt_p_ftype): Delete.
(struct interp_procs) <prompt_proc_p>: Delete field.
(current_interp_display_prompt_p): Delete declaration.
* mi-interp.c (mi_interpreter_prompt_p): Delete.
(_initialize_mi_interp): Adjust.
* tui-interp.c (tui_init): Install 'sync_execution_done' and
'command_error' observers.
(tui_on_sync_execution_done, tui_on_command_error): New
functions.
(tui_display_prompt_p): Delete.
(_initialize_tui_interp): Adjust.
gdb/doc/
2014-05-29 Pedro Alves <palves@redhat.com>
* observer.texi (sync_execution_done, command_error): New
subjects.
2014-05-23 18:37:12 +08:00
|
|
|
|
observer_notify_command_error ();
|
2001-11-27 12:15:09 +08:00
|
|
|
|
/* This call looks bizarre, but it is required. If the user
|
|
|
|
|
entered a command that caused an error,
|
|
|
|
|
after_char_processing_hook won't be called from
|
|
|
|
|
rl_callback_read_char_wrapper. Using a cleanup there
|
|
|
|
|
won't work, since we want this function to be called
|
|
|
|
|
after a new prompt is printed. */
|
|
|
|
|
if (after_char_processing_hook)
|
|
|
|
|
(*after_char_processing_hook) ();
|
1999-05-12 04:29:07 +08:00
|
|
|
|
/* Maybe better to set a flag to be checked somewhere as to
|
2010-12-29 08:58:14 +08:00
|
|
|
|
whether display the prompt or not. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 23:14:14 +08:00
|
|
|
|
END_CATCH
|
|
|
|
|
|
2011-08-05 04:09:46 +08:00
|
|
|
|
if (result < 0)
|
|
|
|
|
break;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
1999-06-29 00:06:02 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* We are done with the event loop. There are no more event sources
|
|
|
|
|
to listen to. So we exit GDB. */
|
1999-06-29 00:06:02 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
|
1999-06-29 00:06:02 +08:00
|
|
|
|
/* Wrapper function for create_file_handler, so that the caller
|
|
|
|
|
doesn't have to know implementation details about the use of poll
|
2010-12-29 08:58:14 +08:00
|
|
|
|
vs. select. */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
void
|
1999-09-29 05:55:21 +08:00
|
|
|
|
add_file_handler (int fd, handler_func * proc, gdb_client_data client_data)
|
1999-06-29 00:06:02 +08:00
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_POLL
|
2000-03-23 11:45:13 +08:00
|
|
|
|
struct pollfd fds;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (use_poll)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_POLL
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Check to see if poll () is usable. If not, we'll switch to
|
|
|
|
|
use select. This can happen on systems like
|
2000-03-23 11:48:13 +08:00
|
|
|
|
m68k-motorola-sys, `poll' cannot be used to wait for `stdin'.
|
|
|
|
|
On m68k-motorola-sysv, tty's are not stream-based and not
|
2010-12-29 08:58:14 +08:00
|
|
|
|
`poll'able. */
|
2000-03-23 11:48:13 +08:00
|
|
|
|
fds.fd = fd;
|
|
|
|
|
fds.events = POLLIN;
|
|
|
|
|
if (poll (&fds, 1, 0) == 1 && (fds.revents & POLLNVAL))
|
|
|
|
|
use_poll = 0;
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#else
|
2001-02-08 14:03:54 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif /* HAVE_POLL */
|
|
|
|
|
}
|
|
|
|
|
if (use_poll)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
|
create_file_handler (fd, POLLIN, proc, client_data);
|
1999-06-29 00:06:02 +08:00
|
|
|
|
#else
|
2001-02-08 14:03:54 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
1999-06-29 00:06:02 +08:00
|
|
|
|
#endif
|
2000-03-23 11:45:13 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
2010-12-29 08:58:14 +08:00
|
|
|
|
create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION,
|
|
|
|
|
proc, client_data);
|
1999-06-29 00:06:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
/* Add a file handler/descriptor to the list of descriptors we are
|
2010-12-29 08:58:14 +08:00
|
|
|
|
interested in.
|
|
|
|
|
|
|
|
|
|
FD is the file descriptor for the file/stream to be listened to.
|
|
|
|
|
|
|
|
|
|
For the poll case, MASK is a combination (OR) of POLLIN,
|
|
|
|
|
POLLRDNORM, POLLRDBAND, POLLPRI, POLLOUT, POLLWRNORM, POLLWRBAND:
|
|
|
|
|
these are the events we are interested in. If any of them occurs,
|
|
|
|
|
proc should be called.
|
|
|
|
|
|
|
|
|
|
For the select case, MASK is a combination of READABLE, WRITABLE,
|
|
|
|
|
EXCEPTION. PROC is the procedure that will be called when an event
|
|
|
|
|
occurs for FD. CLIENT_DATA is the argument to pass to PROC. */
|
|
|
|
|
|
1999-06-29 00:06:02 +08:00
|
|
|
|
static void
|
2010-12-29 08:58:14 +08:00
|
|
|
|
create_file_handler (int fd, int mask, handler_func * proc,
|
|
|
|
|
gdb_client_data client_data)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
|
|
|
|
file_handler *file_ptr;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Do we already have a file handler for this file? (We may be
|
|
|
|
|
changing its associated procedure). */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
for (file_ptr = gdb_notifier.first_file_handler; file_ptr != NULL;
|
|
|
|
|
file_ptr = file_ptr->next_file)
|
|
|
|
|
{
|
|
|
|
|
if (file_ptr->fd == fd)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* It is a new file descriptor. Add it to the list. Otherwise, just
|
|
|
|
|
change the data associated with it. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
if (file_ptr == NULL)
|
|
|
|
|
{
|
|
|
|
|
file_ptr = (file_handler *) xmalloc (sizeof (file_handler));
|
|
|
|
|
file_ptr->fd = fd;
|
|
|
|
|
file_ptr->ready_mask = 0;
|
|
|
|
|
file_ptr->next_file = gdb_notifier.first_file_handler;
|
|
|
|
|
gdb_notifier.first_file_handler = file_ptr;
|
|
|
|
|
|
2002-05-14 23:21:10 +08:00
|
|
|
|
if (use_poll)
|
|
|
|
|
{
|
1999-05-12 04:29:07 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2002-05-14 23:21:10 +08:00
|
|
|
|
gdb_notifier.num_fds++;
|
|
|
|
|
if (gdb_notifier.poll_fds)
|
|
|
|
|
gdb_notifier.poll_fds =
|
|
|
|
|
(struct pollfd *) xrealloc (gdb_notifier.poll_fds,
|
|
|
|
|
(gdb_notifier.num_fds
|
|
|
|
|
* sizeof (struct pollfd)));
|
|
|
|
|
else
|
|
|
|
|
gdb_notifier.poll_fds =
|
|
|
|
|
(struct pollfd *) xmalloc (sizeof (struct pollfd));
|
|
|
|
|
(gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
|
|
|
|
|
(gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
|
|
|
|
|
(gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#else
|
2002-05-14 23:21:10 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif /* HAVE_POLL */
|
2002-05-14 23:21:10 +08:00
|
|
|
|
}
|
2000-03-23 11:45:13 +08:00
|
|
|
|
else
|
2002-05-14 23:21:10 +08:00
|
|
|
|
{
|
|
|
|
|
if (mask & GDB_READABLE)
|
|
|
|
|
FD_SET (fd, &gdb_notifier.check_masks[0]);
|
|
|
|
|
else
|
|
|
|
|
FD_CLR (fd, &gdb_notifier.check_masks[0]);
|
|
|
|
|
|
|
|
|
|
if (mask & GDB_WRITABLE)
|
|
|
|
|
FD_SET (fd, &gdb_notifier.check_masks[1]);
|
|
|
|
|
else
|
|
|
|
|
FD_CLR (fd, &gdb_notifier.check_masks[1]);
|
|
|
|
|
|
|
|
|
|
if (mask & GDB_EXCEPTION)
|
|
|
|
|
FD_SET (fd, &gdb_notifier.check_masks[2]);
|
|
|
|
|
else
|
|
|
|
|
FD_CLR (fd, &gdb_notifier.check_masks[2]);
|
|
|
|
|
|
|
|
|
|
if (gdb_notifier.num_fds <= fd)
|
|
|
|
|
gdb_notifier.num_fds = fd + 1;
|
|
|
|
|
}
|
2000-03-23 11:45:13 +08:00
|
|
|
|
}
|
2002-05-14 23:21:10 +08:00
|
|
|
|
|
|
|
|
|
file_ptr->proc = proc;
|
|
|
|
|
file_ptr->client_data = client_data;
|
|
|
|
|
file_ptr->mask = mask;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
/* Return the next file handler to handle, and advance to the next
|
|
|
|
|
file handler, wrapping around if the end of the list is
|
|
|
|
|
reached. */
|
|
|
|
|
|
|
|
|
|
static file_handler *
|
|
|
|
|
get_next_file_handler_to_handle_and_advance (void)
|
|
|
|
|
{
|
|
|
|
|
file_handler *curr_next;
|
|
|
|
|
|
|
|
|
|
/* The first time around, this is still NULL. */
|
|
|
|
|
if (gdb_notifier.next_file_handler == NULL)
|
|
|
|
|
gdb_notifier.next_file_handler = gdb_notifier.first_file_handler;
|
|
|
|
|
|
|
|
|
|
curr_next = gdb_notifier.next_file_handler;
|
|
|
|
|
gdb_assert (curr_next != NULL);
|
|
|
|
|
|
|
|
|
|
/* Advance. */
|
|
|
|
|
gdb_notifier.next_file_handler = curr_next->next_file;
|
|
|
|
|
/* Wrap around, if necessary. */
|
|
|
|
|
if (gdb_notifier.next_file_handler == NULL)
|
|
|
|
|
gdb_notifier.next_file_handler = gdb_notifier.first_file_handler;
|
|
|
|
|
|
|
|
|
|
return curr_next;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
/* Remove the file descriptor FD from the list of monitored fd's:
|
2010-12-29 08:58:14 +08:00
|
|
|
|
i.e. we don't care anymore about events on the FD. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
void
|
1999-09-22 11:28:34 +08:00
|
|
|
|
delete_file_handler (int fd)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
|
|
|
|
file_handler *file_ptr, *prev_ptr = NULL;
|
2000-03-21 03:59:38 +08:00
|
|
|
|
int i;
|
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
|
int j;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
struct pollfd *new_poll_fds;
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Find the entry for the given file. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
for (file_ptr = gdb_notifier.first_file_handler; file_ptr != NULL;
|
|
|
|
|
file_ptr = file_ptr->next_file)
|
|
|
|
|
{
|
|
|
|
|
if (file_ptr->fd == fd)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file_ptr == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (use_poll)
|
|
|
|
|
{
|
1999-05-12 04:29:07 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Create a new poll_fds array by copying every fd's information
|
|
|
|
|
but the one we want to get rid of. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
new_poll_fds = (struct pollfd *)
|
|
|
|
|
xmalloc ((gdb_notifier.num_fds - 1) * sizeof (struct pollfd));
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
for (i = 0, j = 0; i < gdb_notifier.num_fds; i++)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if ((gdb_notifier.poll_fds + i)->fd != fd)
|
|
|
|
|
{
|
|
|
|
|
(new_poll_fds + j)->fd = (gdb_notifier.poll_fds + i)->fd;
|
|
|
|
|
(new_poll_fds + j)->events = (gdb_notifier.poll_fds + i)->events;
|
2011-01-06 06:22:53 +08:00
|
|
|
|
(new_poll_fds + j)->revents
|
|
|
|
|
= (gdb_notifier.poll_fds + i)->revents;
|
2000-03-23 11:45:13 +08:00
|
|
|
|
j++;
|
|
|
|
|
}
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
2000-12-15 09:01:51 +08:00
|
|
|
|
xfree (gdb_notifier.poll_fds);
|
2000-03-23 11:45:13 +08:00
|
|
|
|
gdb_notifier.poll_fds = new_poll_fds;
|
|
|
|
|
gdb_notifier.num_fds--;
|
|
|
|
|
#else
|
2001-02-08 14:03:54 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif /* HAVE_POLL */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
2000-03-23 11:45:13 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (file_ptr->mask & GDB_READABLE)
|
|
|
|
|
FD_CLR (fd, &gdb_notifier.check_masks[0]);
|
|
|
|
|
if (file_ptr->mask & GDB_WRITABLE)
|
|
|
|
|
FD_CLR (fd, &gdb_notifier.check_masks[1]);
|
|
|
|
|
if (file_ptr->mask & GDB_EXCEPTION)
|
|
|
|
|
FD_CLR (fd, &gdb_notifier.check_masks[2]);
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Find current max fd. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if ((fd + 1) == gdb_notifier.num_fds)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
2000-03-23 11:45:13 +08:00
|
|
|
|
gdb_notifier.num_fds--;
|
|
|
|
|
for (i = gdb_notifier.num_fds; i; i--)
|
|
|
|
|
{
|
|
|
|
|
if (FD_ISSET (i - 1, &gdb_notifier.check_masks[0])
|
|
|
|
|
|| FD_ISSET (i - 1, &gdb_notifier.check_masks[1])
|
|
|
|
|
|| FD_ISSET (i - 1, &gdb_notifier.check_masks[2]))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
gdb_notifier.num_fds = i;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-14 05:40:00 +08:00
|
|
|
|
/* Deactivate the file descriptor, by clearing its mask,
|
2010-12-29 08:58:14 +08:00
|
|
|
|
so that it will not fire again. */
|
1999-09-14 05:40:00 +08:00
|
|
|
|
|
|
|
|
|
file_ptr->mask = 0;
|
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
/* If this file handler was going to be the next one to be handled,
|
|
|
|
|
advance to the next's next, if any. */
|
|
|
|
|
if (gdb_notifier.next_file_handler == file_ptr)
|
|
|
|
|
{
|
|
|
|
|
if (file_ptr->next_file == NULL
|
|
|
|
|
&& file_ptr == gdb_notifier.first_file_handler)
|
|
|
|
|
gdb_notifier.next_file_handler = NULL;
|
|
|
|
|
else
|
|
|
|
|
get_next_file_handler_to_handle_and_advance ();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Get rid of the file handler in the file handler list. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
if (file_ptr == gdb_notifier.first_file_handler)
|
|
|
|
|
gdb_notifier.first_file_handler = file_ptr->next_file;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (prev_ptr = gdb_notifier.first_file_handler;
|
1999-06-21 21:27:42 +08:00
|
|
|
|
prev_ptr->next_file != file_ptr;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
prev_ptr = prev_ptr->next_file)
|
|
|
|
|
;
|
|
|
|
|
prev_ptr->next_file = file_ptr->next_file;
|
|
|
|
|
}
|
2000-12-15 09:01:51 +08:00
|
|
|
|
xfree (file_ptr);
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle the given event by calling the procedure associated to the
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
corresponding file handler. */
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
static void
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
handle_file_event (file_handler *file_ptr, int ready_mask)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
1999-09-22 11:28:34 +08:00
|
|
|
|
int mask;
|
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
|
int error_mask;
|
|
|
|
|
#endif
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
/* With poll, the ready_mask could have any of three events
|
2010-12-29 08:58:14 +08:00
|
|
|
|
set to 1: POLLHUP, POLLERR, POLLNVAL. These events
|
|
|
|
|
cannot be used in the requested event mask (events), but
|
|
|
|
|
they can be returned in the return mask (revents). We
|
|
|
|
|
need to check for those event too, and add them to the
|
|
|
|
|
mask which will be passed to the handler. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
/* See if the desired events (mask) match the received
|
2010-12-29 08:58:14 +08:00
|
|
|
|
events (ready_mask). */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (use_poll)
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2011-05-25 15:59:04 +08:00
|
|
|
|
/* POLLHUP means EOF, but can be combined with POLLIN to
|
|
|
|
|
signal more data to read. */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
error_mask = POLLHUP | POLLERR | POLLNVAL;
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
mask = ready_mask & (file_ptr->mask | error_mask);
|
2000-03-23 11:45:13 +08:00
|
|
|
|
|
2011-05-25 15:59:04 +08:00
|
|
|
|
if ((mask & (POLLERR | POLLNVAL)) != 0)
|
2000-03-23 11:45:13 +08:00
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Work in progress. We may need to tell somebody
|
|
|
|
|
what kind of error we had. */
|
2011-05-25 15:59:04 +08:00
|
|
|
|
if (mask & POLLERR)
|
2011-01-06 06:22:53 +08:00
|
|
|
|
printf_unfiltered (_("Error detected on fd %d\n"),
|
|
|
|
|
file_ptr->fd);
|
2011-05-25 15:59:04 +08:00
|
|
|
|
if (mask & POLLNVAL)
|
2011-01-06 06:22:53 +08:00
|
|
|
|
printf_unfiltered (_("Invalid or non-`poll'able fd %d\n"),
|
|
|
|
|
file_ptr->fd);
|
2000-03-23 11:45:13 +08:00
|
|
|
|
file_ptr->error = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
file_ptr->error = 0;
|
|
|
|
|
#else
|
2001-02-08 14:03:54 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif /* HAVE_POLL */
|
1999-09-29 05:55:21 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
if (ready_mask & GDB_EXCEPTION)
|
2000-03-23 11:45:13 +08:00
|
|
|
|
{
|
2011-01-06 06:22:53 +08:00
|
|
|
|
printf_unfiltered (_("Exception condition detected "
|
|
|
|
|
"on fd %d\n"), file_ptr->fd);
|
2000-03-23 11:45:13 +08:00
|
|
|
|
file_ptr->error = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
file_ptr->error = 0;
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
mask = ready_mask & file_ptr->mask;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
}
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* If there was a match, then call the handler. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
if (mask != 0)
|
1999-10-06 07:13:56 +08:00
|
|
|
|
(*file_ptr->proc) (file_ptr->error, file_ptr->client_data);
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* Wait for new events on the monitored file descriptors. Run the
|
|
|
|
|
event handler if the first descriptor that is detected by the poll.
|
|
|
|
|
If BLOCK and if there are no events, this function will block in
|
|
|
|
|
the call to poll. Return 1 if an event was handled. Return -1 if
|
|
|
|
|
there are no file descriptors to monitor. Return 1 if an event was
|
|
|
|
|
handled, otherwise returns 0. */
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
static int
|
2008-10-25 03:33:39 +08:00
|
|
|
|
gdb_wait_for_event (int block)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
|
|
|
|
file_handler *file_ptr;
|
1999-06-15 02:08:47 +08:00
|
|
|
|
int num_found = 0;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Make sure all output is done before getting another event. */
|
1999-08-17 03:57:19 +08:00
|
|
|
|
gdb_flush (gdb_stdout);
|
|
|
|
|
gdb_flush (gdb_stderr);
|
|
|
|
|
|
1999-05-12 04:29:07 +08:00
|
|
|
|
if (gdb_notifier.num_fds == 0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
if (block)
|
|
|
|
|
update_wait_timeout ();
|
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (use_poll)
|
|
|
|
|
{
|
1999-05-12 04:29:07 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2008-10-25 03:33:39 +08:00
|
|
|
|
int timeout;
|
|
|
|
|
|
|
|
|
|
if (block)
|
|
|
|
|
timeout = gdb_notifier.timeout_valid ? gdb_notifier.poll_timeout : -1;
|
|
|
|
|
else
|
|
|
|
|
timeout = 0;
|
|
|
|
|
|
|
|
|
|
num_found = poll (gdb_notifier.poll_fds,
|
|
|
|
|
(unsigned long) gdb_notifier.num_fds, timeout);
|
2000-03-23 11:45:13 +08:00
|
|
|
|
|
|
|
|
|
/* Don't print anything if we get out of poll because of a
|
2008-10-25 03:33:39 +08:00
|
|
|
|
signal. */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (num_found == -1 && errno != EINTR)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
perror_with_name (("poll"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#else
|
2001-02-08 14:03:54 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif /* HAVE_POLL */
|
|
|
|
|
}
|
|
|
|
|
else
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
2008-10-25 03:33:39 +08:00
|
|
|
|
struct timeval select_timeout;
|
|
|
|
|
struct timeval *timeout_p;
|
2010-05-15 02:35:11 +08:00
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
if (block)
|
|
|
|
|
timeout_p = gdb_notifier.timeout_valid
|
|
|
|
|
? &gdb_notifier.select_timeout : NULL;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
memset (&select_timeout, 0, sizeof (select_timeout));
|
|
|
|
|
timeout_p = &select_timeout;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-23 11:45:13 +08:00
|
|
|
|
gdb_notifier.ready_masks[0] = gdb_notifier.check_masks[0];
|
|
|
|
|
gdb_notifier.ready_masks[1] = gdb_notifier.check_masks[1];
|
|
|
|
|
gdb_notifier.ready_masks[2] = gdb_notifier.check_masks[2];
|
2005-04-26 05:45:56 +08:00
|
|
|
|
num_found = gdb_select (gdb_notifier.num_fds,
|
|
|
|
|
&gdb_notifier.ready_masks[0],
|
|
|
|
|
&gdb_notifier.ready_masks[1],
|
|
|
|
|
&gdb_notifier.ready_masks[2],
|
2008-10-25 03:33:39 +08:00
|
|
|
|
timeout_p);
|
2000-03-23 11:45:13 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Clear the masks after an error from select. */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (num_found == -1)
|
|
|
|
|
{
|
|
|
|
|
FD_ZERO (&gdb_notifier.ready_masks[0]);
|
|
|
|
|
FD_ZERO (&gdb_notifier.ready_masks[1]);
|
|
|
|
|
FD_ZERO (&gdb_notifier.ready_masks[2]);
|
2008-10-25 03:33:39 +08:00
|
|
|
|
|
|
|
|
|
/* Dont print anything if we got a signal, let gdb handle
|
|
|
|
|
it. */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (errno != EINTR)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
perror_with_name (("select"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
}
|
1999-09-22 11:28:34 +08:00
|
|
|
|
}
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
/* Avoid looking at poll_fds[i]->revents if no event fired. */
|
|
|
|
|
if (num_found <= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* Run event handlers. We always run just one handler and go back
|
|
|
|
|
to polling, in case a handler changes the notifier list. Since
|
|
|
|
|
events for sources we haven't consumed yet wake poll/select
|
|
|
|
|
immediately, no event is lost. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
/* To level the fairness across event descriptors, we handle them in
|
|
|
|
|
a round-robin-like fashion. The number and order of descriptors
|
|
|
|
|
may change between invocations, but this is good enough. */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (use_poll)
|
|
|
|
|
{
|
1999-05-12 04:29:07 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
int i;
|
|
|
|
|
int mask;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (gdb_notifier.next_poll_fds_index >= gdb_notifier.num_fds)
|
|
|
|
|
gdb_notifier.next_poll_fds_index = 0;
|
|
|
|
|
i = gdb_notifier.next_poll_fds_index++;
|
2000-03-23 11:45:13 +08:00
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
gdb_assert (i < gdb_notifier.num_fds);
|
|
|
|
|
if ((gdb_notifier.poll_fds + i)->revents)
|
|
|
|
|
break;
|
|
|
|
|
}
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
for (file_ptr = gdb_notifier.first_file_handler;
|
|
|
|
|
file_ptr != NULL;
|
|
|
|
|
file_ptr = file_ptr->next_file)
|
|
|
|
|
{
|
|
|
|
|
if (file_ptr->fd == (gdb_notifier.poll_fds + i)->fd)
|
|
|
|
|
break;
|
2000-03-23 11:45:13 +08:00
|
|
|
|
}
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
gdb_assert (file_ptr != NULL);
|
|
|
|
|
|
|
|
|
|
mask = (gdb_notifier.poll_fds + i)->revents;
|
|
|
|
|
handle_file_event (file_ptr, mask);
|
|
|
|
|
return 1;
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#else
|
2001-02-08 14:03:54 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif /* HAVE_POLL */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
/* See comment about even source fairness above. */
|
|
|
|
|
int mask = 0;
|
|
|
|
|
|
|
|
|
|
do
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
file_ptr = get_next_file_handler_to_handle_and_advance ();
|
2000-03-23 11:45:13 +08:00
|
|
|
|
|
|
|
|
|
if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[0]))
|
|
|
|
|
mask |= GDB_READABLE;
|
|
|
|
|
if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[1]))
|
|
|
|
|
mask |= GDB_WRITABLE;
|
|
|
|
|
if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[2]))
|
|
|
|
|
mask |= GDB_EXCEPTION;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
Fix gdb.mi/mi-nsmoribund.exp timeouts
The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:
(...)
-thread-info
FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)
... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.
That is, the test sends "-thread-info" to GDB, but GDB never replies
back.
The problem is that these machines are too fast for gdb. :-)
That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over. If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.
Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.
Unfortunately, the poll and the select variants each need their own
fixing.
Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18. Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.
(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue. That is, it hasn't
had 70b66289 merged yet. We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)
gdb/ChangeLog:
2015-05-15 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired. Poll file
handlers in round-robin fashion.
2015-05-15 23:26:53 +08:00
|
|
|
|
while (mask == 0);
|
|
|
|
|
|
|
|
|
|
handle_file_event (file_ptr, mask);
|
|
|
|
|
return 1;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Create an asynchronous handler, allocating memory for it.
|
1999-05-12 04:29:07 +08:00
|
|
|
|
Return a pointer to the newly created handler.
|
|
|
|
|
This pointer will be used to invoke the handler by
|
|
|
|
|
invoke_async_signal_handler.
|
|
|
|
|
PROC is the function to call with CLIENT_DATA argument
|
2010-12-29 08:58:14 +08:00
|
|
|
|
whenever the handler is invoked. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
async_signal_handler *
|
2011-01-06 06:22:53 +08:00
|
|
|
|
create_async_signal_handler (sig_handler_func * proc,
|
|
|
|
|
gdb_client_data client_data)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
|
|
|
|
async_signal_handler *async_handler_ptr;
|
|
|
|
|
|
|
|
|
|
async_handler_ptr =
|
|
|
|
|
(async_signal_handler *) xmalloc (sizeof (async_signal_handler));
|
|
|
|
|
async_handler_ptr->ready = 0;
|
|
|
|
|
async_handler_ptr->next_handler = NULL;
|
|
|
|
|
async_handler_ptr->proc = proc;
|
|
|
|
|
async_handler_ptr->client_data = client_data;
|
|
|
|
|
if (sighandler_list.first_handler == NULL)
|
|
|
|
|
sighandler_list.first_handler = async_handler_ptr;
|
|
|
|
|
else
|
|
|
|
|
sighandler_list.last_handler->next_handler = async_handler_ptr;
|
|
|
|
|
sighandler_list.last_handler = async_handler_ptr;
|
|
|
|
|
return async_handler_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-06 01:21:10 +08:00
|
|
|
|
/* Call the handler from HANDLER immediately. This function runs
|
|
|
|
|
signal handlers when returning to the event loop would be too
|
|
|
|
|
slow. */
|
|
|
|
|
void
|
|
|
|
|
call_async_signal_handler (struct async_signal_handler *handler)
|
|
|
|
|
{
|
|
|
|
|
(*handler->proc) (handler->client_data);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Mark the handler (ASYNC_HANDLER_PTR) as ready. This information
|
|
|
|
|
will be used when the handlers are invoked, after we have waited
|
|
|
|
|
for some event. The caller of this function is the interrupt
|
|
|
|
|
handler associated with a signal. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
void
|
1999-09-29 05:55:21 +08:00
|
|
|
|
mark_async_signal_handler (async_signal_handler * async_handler_ptr)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
2008-10-25 03:33:39 +08:00
|
|
|
|
async_handler_ptr->ready = 1;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* Call all the handlers that are ready. Returns true if any was
|
|
|
|
|
indeed ready. */
|
|
|
|
|
static int
|
|
|
|
|
invoke_async_signal_handlers (void)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
|
|
|
|
async_signal_handler *async_handler_ptr;
|
2008-10-25 03:33:39 +08:00
|
|
|
|
int any_ready = 0;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* Invoke ready handlers. */
|
1999-05-12 04:29:07 +08:00
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
for (async_handler_ptr = sighandler_list.first_handler;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
async_handler_ptr != NULL;
|
|
|
|
|
async_handler_ptr = async_handler_ptr->next_handler)
|
|
|
|
|
{
|
|
|
|
|
if (async_handler_ptr->ready)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (async_handler_ptr == NULL)
|
|
|
|
|
break;
|
2008-10-25 03:33:39 +08:00
|
|
|
|
any_ready = 1;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
async_handler_ptr->ready = 0;
|
|
|
|
|
(*async_handler_ptr->proc) (async_handler_ptr->client_data);
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
return any_ready;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Delete an asynchronous handler (ASYNC_HANDLER_PTR).
|
1999-05-12 04:29:07 +08:00
|
|
|
|
Free the space allocated for it. */
|
|
|
|
|
void
|
1999-09-29 05:55:21 +08:00
|
|
|
|
delete_async_signal_handler (async_signal_handler ** async_handler_ptr)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
|
|
|
|
async_signal_handler *prev_ptr;
|
|
|
|
|
|
1999-07-06 01:58:44 +08:00
|
|
|
|
if (sighandler_list.first_handler == (*async_handler_ptr))
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
1999-07-06 01:58:44 +08:00
|
|
|
|
sighandler_list.first_handler = (*async_handler_ptr)->next_handler;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
if (sighandler_list.first_handler == NULL)
|
|
|
|
|
sighandler_list.last_handler = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
prev_ptr = sighandler_list.first_handler;
|
2007-08-19 04:05:48 +08:00
|
|
|
|
while (prev_ptr && prev_ptr->next_handler != (*async_handler_ptr))
|
1999-05-12 04:29:07 +08:00
|
|
|
|
prev_ptr = prev_ptr->next_handler;
|
2011-03-12 06:31:44 +08:00
|
|
|
|
gdb_assert (prev_ptr);
|
1999-07-06 01:58:44 +08:00
|
|
|
|
prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
|
|
|
|
|
if (sighandler_list.last_handler == (*async_handler_ptr))
|
1999-05-12 04:29:07 +08:00
|
|
|
|
sighandler_list.last_handler = prev_ptr;
|
|
|
|
|
}
|
2000-12-15 09:01:51 +08:00
|
|
|
|
xfree ((*async_handler_ptr));
|
1999-07-06 01:58:44 +08:00
|
|
|
|
(*async_handler_ptr) = NULL;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-25 03:33:39 +08:00
|
|
|
|
/* Create an asynchronous event handler, allocating memory for it.
|
|
|
|
|
Return a pointer to the newly created handler. PROC is the
|
|
|
|
|
function to call with CLIENT_DATA argument whenever the handler is
|
|
|
|
|
invoked. */
|
|
|
|
|
async_event_handler *
|
|
|
|
|
create_async_event_handler (async_event_handler_func *proc,
|
|
|
|
|
gdb_client_data client_data)
|
|
|
|
|
{
|
|
|
|
|
async_event_handler *h;
|
|
|
|
|
|
|
|
|
|
h = xmalloc (sizeof (*h));
|
|
|
|
|
h->ready = 0;
|
|
|
|
|
h->next_handler = NULL;
|
|
|
|
|
h->proc = proc;
|
|
|
|
|
h->client_data = client_data;
|
|
|
|
|
if (async_event_handler_list.first_handler == NULL)
|
|
|
|
|
async_event_handler_list.first_handler = h;
|
|
|
|
|
else
|
|
|
|
|
async_event_handler_list.last_handler->next_handler = h;
|
|
|
|
|
async_event_handler_list.last_handler = h;
|
|
|
|
|
return h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Mark the handler (ASYNC_HANDLER_PTR) as ready. This information
|
|
|
|
|
will be used by gdb_do_one_event. The caller will be whoever
|
|
|
|
|
created the event source, and wants to signal that the event is
|
|
|
|
|
ready to be handled. */
|
|
|
|
|
void
|
|
|
|
|
mark_async_event_handler (async_event_handler *async_handler_ptr)
|
|
|
|
|
{
|
|
|
|
|
async_handler_ptr->ready = 1;
|
|
|
|
|
}
|
|
|
|
|
|
When disabling target async, remove all target event sources from the event loop
The sigall-reverse.exp test occasionally fails with something like this:
(gdb) PASS: gdb.reverse/sigall-reverse.exp: send signal TERM
continue
Continuing.
The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) FAIL: gdb.reverse/sigall-reverse.exp: continue to signal exit (timeout)
FAIL: gdb.reverse/sigall-reverse.exp: reverse to handler of TERM (timeout)
FAIL: gdb.reverse/sigall-reverse.exp: reverse to gen_TERM (timeout)
This is another event-loop/async related problem exposed by the patch
that made 'query' use gdb_readline_wrapper (588dcc3edbde19f9).
The problem is that even though gdb_readline_wrapper disables
target-async while the secondary prompt is in progress, the record
target's async event source is left marked. So when
gdb_readline_wrapper nests an event loop to process input, it may
happen that that event loop ends up processing a target event while
GDB is not really ready for it. Here's the relevant part of the
backtrace showing the root issue in action:
...
#14 0x000000000061cb48 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:4158
#15 0x0000000000642917 in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:57
#16 0x000000000077ca5c in record_full_async_inferior_event_handler (data=0x0) at src/gdb/record-full.c:791
#17 0x0000000000640fdf in invoke_async_event_handler (data=...) at src/gdb/event-loop.c:1067
#18 0x000000000063fb01 in process_event () at src/gdb/event-loop.c:339
#19 0x000000000063fb2a in gdb_do_one_event () at src/gdb/event-loop.c:360
#20 0x000000000074d607 in gdb_readline_wrapper (prompt=0x3588f40 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) ") at src/gdb/top.c:842
#21 0x0000000000750bd9 in defaulted_query (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?", defchar=121 'y', args=0x7fff70524410) at src/gdb/utils.c:1279
#22 0x0000000000750e4c in yquery (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?") at src/gdb/utils.c:1358
#23 0x00000000004b020e in record_linux_system_call (syscall=gdb_sys_exit_group, regcache=0x3529450, tdep=0xd6c840 <amd64_linux_record_tdep>) at src/gdb/linux-record.c:1933
With my all-stop-on-top-of-non-stop series, I'm also seeing
gdb.server/ext-attach.exp fail occasionally due to the same issue.
The first part of the fix is for target_async implementations to make
sure to remove/unmark all target-related event sources from the event
loop.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c (clear_async_event_handler): New function.
* event-loop.h (clear_async_event_handler): New declaration.
* record-btrace.c (record_btrace_async): New function.
(init_record_btrace_ops): Install record_btrace_async.
* record-full.c (record_full_async): New function.
(record_full_resume): Don't mark the async event source here.
(init_record_full_ops): Install record_full_async.
(record_full_core_resume): Don't mark the async event source here.
(init_record_full_core_ops): Install record_full_async.
* remote.c (remote_async): Mark and clear the async stop reply
queue event-loop token as appropriate.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* See event-loop.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
clear_async_event_handler (async_event_handler *async_handler_ptr)
|
|
|
|
|
{
|
|
|
|
|
async_handler_ptr->ready = 0;
|
|
|
|
|
}
|
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* Check if asynchronous event handlers are ready, and call the
|
|
|
|
|
handler function for one that is. */
|
2008-10-25 03:33:39 +08:00
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
static int
|
2008-10-25 03:33:39 +08:00
|
|
|
|
check_async_event_handlers (void)
|
|
|
|
|
{
|
|
|
|
|
async_event_handler *async_handler_ptr;
|
|
|
|
|
|
|
|
|
|
for (async_handler_ptr = async_event_handler_list.first_handler;
|
|
|
|
|
async_handler_ptr != NULL;
|
|
|
|
|
async_handler_ptr = async_handler_ptr->next_handler)
|
|
|
|
|
{
|
|
|
|
|
if (async_handler_ptr->ready)
|
|
|
|
|
{
|
|
|
|
|
async_handler_ptr->ready = 0;
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
(*async_handler_ptr->proc) (async_handler_ptr->client_data);
|
|
|
|
|
return 1;
|
2008-10-25 03:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
2008-10-25 03:33:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Delete an asynchronous handler (ASYNC_HANDLER_PTR).
|
|
|
|
|
Free the space allocated for it. */
|
|
|
|
|
void
|
|
|
|
|
delete_async_event_handler (async_event_handler **async_handler_ptr)
|
1999-05-12 04:29:07 +08:00
|
|
|
|
{
|
2008-10-25 03:33:39 +08:00
|
|
|
|
async_event_handler *prev_ptr;
|
|
|
|
|
|
|
|
|
|
if (async_event_handler_list.first_handler == *async_handler_ptr)
|
|
|
|
|
{
|
2011-01-06 06:22:53 +08:00
|
|
|
|
async_event_handler_list.first_handler
|
|
|
|
|
= (*async_handler_ptr)->next_handler;
|
2008-10-25 03:33:39 +08:00
|
|
|
|
if (async_event_handler_list.first_handler == NULL)
|
|
|
|
|
async_event_handler_list.last_handler = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
prev_ptr = async_event_handler_list.first_handler;
|
|
|
|
|
while (prev_ptr && prev_ptr->next_handler != *async_handler_ptr)
|
|
|
|
|
prev_ptr = prev_ptr->next_handler;
|
2011-03-12 06:31:44 +08:00
|
|
|
|
gdb_assert (prev_ptr);
|
2008-10-25 03:33:39 +08:00
|
|
|
|
prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
|
|
|
|
|
if (async_event_handler_list.last_handler == (*async_handler_ptr))
|
|
|
|
|
async_event_handler_list.last_handler = prev_ptr;
|
|
|
|
|
}
|
|
|
|
|
xfree (*async_handler_ptr);
|
|
|
|
|
*async_handler_ptr = NULL;
|
1999-05-12 04:29:07 +08:00
|
|
|
|
}
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Create a timer that will expire in MILLISECONDS from now. When the
|
|
|
|
|
timer is ready, PROC will be executed. At creation, the timer is
|
1999-09-22 11:28:34 +08:00
|
|
|
|
aded to the timers queue. This queue is kept sorted in order of
|
2010-12-29 08:58:14 +08:00
|
|
|
|
increasing timers. Return a handle to the timer struct. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
int
|
2010-12-29 08:58:14 +08:00
|
|
|
|
create_timer (int milliseconds, timer_handler_func * proc,
|
|
|
|
|
gdb_client_data client_data)
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
|
|
|
|
struct gdb_timer *timer_ptr, *timer_index, *prev_timer;
|
|
|
|
|
struct timeval time_now, delta;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Compute seconds. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
delta.tv_sec = milliseconds / 1000;
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Compute microseconds. */
|
1999-09-29 05:55:21 +08:00
|
|
|
|
delta.tv_usec = (milliseconds % 1000) * 1000;
|
|
|
|
|
|
1999-09-22 11:28:34 +08:00
|
|
|
|
gettimeofday (&time_now, NULL);
|
|
|
|
|
|
2010-05-04 04:58:21 +08:00
|
|
|
|
timer_ptr = (struct gdb_timer *) xmalloc (sizeof (*timer_ptr));
|
1999-09-22 11:28:34 +08:00
|
|
|
|
timer_ptr->when.tv_sec = time_now.tv_sec + delta.tv_sec;
|
|
|
|
|
timer_ptr->when.tv_usec = time_now.tv_usec + delta.tv_usec;
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Carry? */
|
1999-09-29 05:55:21 +08:00
|
|
|
|
if (timer_ptr->when.tv_usec >= 1000000)
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
|
|
|
|
timer_ptr->when.tv_sec += 1;
|
|
|
|
|
timer_ptr->when.tv_usec -= 1000000;
|
|
|
|
|
}
|
|
|
|
|
timer_ptr->proc = proc;
|
|
|
|
|
timer_ptr->client_data = client_data;
|
1999-09-29 05:55:21 +08:00
|
|
|
|
timer_list.num_timers++;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
timer_ptr->timer_id = timer_list.num_timers;
|
|
|
|
|
|
|
|
|
|
/* Now add the timer to the timer queue, making sure it is sorted in
|
2010-12-29 08:58:14 +08:00
|
|
|
|
increasing order of expiration. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
1999-09-29 05:55:21 +08:00
|
|
|
|
for (timer_index = timer_list.first_timer;
|
|
|
|
|
timer_index != NULL;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
timer_index = timer_index->next)
|
|
|
|
|
{
|
|
|
|
|
/* If the seconds field is greater or if it is the same, but the
|
2010-12-29 08:58:14 +08:00
|
|
|
|
microsecond field is greater. */
|
2009-10-07 07:27:05 +08:00
|
|
|
|
if ((timer_index->when.tv_sec > timer_ptr->when.tv_sec)
|
|
|
|
|
|| ((timer_index->when.tv_sec == timer_ptr->when.tv_sec)
|
|
|
|
|
&& (timer_index->when.tv_usec > timer_ptr->when.tv_usec)))
|
1999-09-22 11:28:34 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
1999-09-29 05:55:21 +08:00
|
|
|
|
|
1999-09-22 11:28:34 +08:00
|
|
|
|
if (timer_index == timer_list.first_timer)
|
|
|
|
|
{
|
|
|
|
|
timer_ptr->next = timer_list.first_timer;
|
|
|
|
|
timer_list.first_timer = timer_ptr;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-09-29 05:55:21 +08:00
|
|
|
|
for (prev_timer = timer_list.first_timer;
|
|
|
|
|
prev_timer->next != timer_index;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
prev_timer = prev_timer->next)
|
|
|
|
|
;
|
1999-09-29 05:55:21 +08:00
|
|
|
|
|
1999-09-22 11:28:34 +08:00
|
|
|
|
prev_timer->next = timer_ptr;
|
|
|
|
|
timer_ptr->next = timer_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gdb_notifier.timeout_valid = 0;
|
|
|
|
|
return timer_ptr->timer_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There is a chance that the creator of the timer wants to get rid of
|
2010-12-29 08:58:14 +08:00
|
|
|
|
it before it expires. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
void
|
|
|
|
|
delete_timer (int id)
|
|
|
|
|
{
|
|
|
|
|
struct gdb_timer *timer_ptr, *prev_timer = NULL;
|
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Find the entry for the given timer. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
|
|
|
|
for (timer_ptr = timer_list.first_timer; timer_ptr != NULL;
|
|
|
|
|
timer_ptr = timer_ptr->next)
|
|
|
|
|
{
|
|
|
|
|
if (timer_ptr->timer_id == id)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (timer_ptr == NULL)
|
|
|
|
|
return;
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Get rid of the timer in the timer list. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
if (timer_ptr == timer_list.first_timer)
|
|
|
|
|
timer_list.first_timer = timer_ptr->next;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (prev_timer = timer_list.first_timer;
|
|
|
|
|
prev_timer->next != timer_ptr;
|
|
|
|
|
prev_timer = prev_timer->next)
|
|
|
|
|
;
|
|
|
|
|
prev_timer->next = timer_ptr->next;
|
|
|
|
|
}
|
2000-12-15 09:01:51 +08:00
|
|
|
|
xfree (timer_ptr);
|
1999-09-22 11:28:34 +08:00
|
|
|
|
|
|
|
|
|
gdb_notifier.timeout_valid = 0;
|
|
|
|
|
}
|
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* Update the timeout for the select() or poll(). Returns true if the
|
|
|
|
|
timer has already expired, false otherwise. */
|
1999-09-29 05:55:21 +08:00
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
static int
|
|
|
|
|
update_wait_timeout (void)
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
|
|
|
|
struct timeval time_now, delta;
|
1999-09-29 05:55:21 +08:00
|
|
|
|
|
1999-10-06 07:13:56 +08:00
|
|
|
|
if (timer_list.first_timer != NULL)
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
|
|
|
|
gettimeofday (&time_now, NULL);
|
|
|
|
|
delta.tv_sec = timer_list.first_timer->when.tv_sec - time_now.tv_sec;
|
|
|
|
|
delta.tv_usec = timer_list.first_timer->when.tv_usec - time_now.tv_usec;
|
2010-12-29 08:58:14 +08:00
|
|
|
|
/* Borrow? */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
if (delta.tv_usec < 0)
|
|
|
|
|
{
|
|
|
|
|
delta.tv_sec -= 1;
|
|
|
|
|
delta.tv_usec += 1000000;
|
|
|
|
|
}
|
1999-09-29 05:55:21 +08:00
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* Cannot simply test if delta.tv_sec is negative because time_t
|
|
|
|
|
might be unsigned. */
|
2000-03-07 01:07:03 +08:00
|
|
|
|
if (timer_list.first_timer->when.tv_sec < time_now.tv_sec
|
|
|
|
|
|| (timer_list.first_timer->when.tv_sec == time_now.tv_sec
|
|
|
|
|
&& timer_list.first_timer->when.tv_usec < time_now.tv_usec))
|
1999-09-22 11:28:34 +08:00
|
|
|
|
{
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* It expired already. */
|
1999-09-22 11:28:34 +08:00
|
|
|
|
delta.tv_sec = 0;
|
|
|
|
|
delta.tv_usec = 0;
|
|
|
|
|
}
|
|
|
|
|
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
/* Update the timeout for select/ poll. */
|
2000-03-23 11:45:13 +08:00
|
|
|
|
if (use_poll)
|
|
|
|
|
{
|
1999-09-22 11:28:34 +08:00
|
|
|
|
#ifdef HAVE_POLL
|
2000-03-23 11:45:13 +08:00
|
|
|
|
gdb_notifier.poll_timeout = delta.tv_sec * 1000;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
#else
|
2001-02-08 14:03:54 +08:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
|
_("use_poll without HAVE_POLL"));
|
2000-03-23 11:45:13 +08:00
|
|
|
|
#endif /* HAVE_POLL */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gdb_notifier.select_timeout.tv_sec = delta.tv_sec;
|
|
|
|
|
gdb_notifier.select_timeout.tv_usec = delta.tv_usec;
|
|
|
|
|
}
|
1999-09-22 11:28:34 +08:00
|
|
|
|
gdb_notifier.timeout_valid = 1;
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
|
|
|
|
|
if (delta.tv_sec == 0 && delta.tv_usec == 0)
|
|
|
|
|
return 1;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
}
|
1999-09-29 05:55:21 +08:00
|
|
|
|
else
|
1999-09-22 11:28:34 +08:00
|
|
|
|
gdb_notifier.timeout_valid = 0;
|
Simplify event-loop core, remove two-step event processing
Even with the previous patch installed, we'll still see
sigall-reverse.exp occasionally fail. The problem is that the event
loop's event handling processing is done in two steps:
#1 - poll all event sources, and push new event objects to the event
queue, until all event sources are drained.
#2 - go through the event queue, processing each event object at a
time. For each event, call the associated callback, and deletes the
event object from the queue.
and then bad things happen if between #1 and #2 something decides that
events from an event source that has already queued events shouldn't
be processed yet. To do that, we either remove the event source from
the list of event sources, or clear its "have events" flag. However,
if an event for that source has meanwhile already been pushed in the
event queue, #2 will still process it and call the associated
callback...
One way to fix it that I considered was to do something to the event
objects already in the event queue when an event source is no longer
interesting. But then I couldn't find any good reason for the
two-step process in the first place. It's much simpler (and less
code) to call the event source callbacks as we poll the sources and
find events.
Tested on x86-64 Fedora 20, native and gdbserver.
gdb/
2015-02-03 Pedro Alves <palves@redhat.com>
* event-loop.c: Don't declare nor define a queue type for
gdb_event_p.
(event_queue): Delete.
(create_event, create_file_event, gdb_event_xfree)
(initialize_event_loop, process_event): Delete.
(gdb_do_one_event): Return as soon as one event is handled.
(handle_file_event): Change prototype. Used the passed in
file_handler pointer and ready_mask instead of looping over all
file handlers.
(gdb_wait_for_event): Update the poll/select timeouts before
blocking. Run event handlers directly instead of queueing events.
Return as soon as one event is handled.
(struct async_event_handler_data): Delete.
(invoke_async_event_handler): Delete.
(check_async_event_handlers): Change return type to int. Run
event handlers directly instead of queueing events. Return as
soon as one event is handled.
(handle_timer_event): Delete.
(update_wait_timeout): New function, factored out from
poll_timers.
(poll_timers): Reimplement.
* event-loop.h (initialize_event_loop): Delete declaration.
* top.c (gdb_init): Don't call initialize_event_loop.
2015-02-03 23:07:54 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check whether a timer in the timers queue is ready. If a timer is
|
|
|
|
|
ready, call its handler and return. Update the timeout for the
|
|
|
|
|
select() or poll() as well. Return 1 if an event was handled,
|
|
|
|
|
otherwise returns 0.*/
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
poll_timers (void)
|
|
|
|
|
{
|
|
|
|
|
if (update_wait_timeout ())
|
|
|
|
|
{
|
|
|
|
|
struct gdb_timer *timer_ptr = timer_list.first_timer;
|
|
|
|
|
timer_handler_func *proc = timer_ptr->proc;
|
|
|
|
|
gdb_client_data client_data = timer_ptr->client_data;
|
|
|
|
|
|
|
|
|
|
/* Get rid of the timer from the beginning of the list. */
|
|
|
|
|
timer_list.first_timer = timer_ptr->next;
|
|
|
|
|
|
|
|
|
|
/* Delete the timer before calling the callback, not after, in
|
|
|
|
|
case the callback itself decides to try deleting the timer
|
|
|
|
|
too. */
|
|
|
|
|
xfree (timer_ptr);
|
|
|
|
|
|
|
|
|
|
/* Call the procedure associated with that timer. */
|
|
|
|
|
(proc) (client_data);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
1999-09-22 11:28:34 +08:00
|
|
|
|
}
|