Re: async patch (no. 4)

Nick Roberts
2007-06-17T20:50:48Z

> > I'm not sure if this was the last message in the thread but I'd like to
> > see if we can get something committed after GDB 6.7 goes out.
>
> Neither of us understands what parts of the patch do; in fact, I
> understand almost none of it. I think it would be a very bad decision
> for us to commit structural changes to GDB that we do not understand
> (even if they are disabled by default), and I think we have no hope of
> keeping the code working and improving it unless it is clearer. These
> are the same requirements we apply to other changes.

I don't know how you can claim to uderstand almost none of it after you
suggested to me to use SIGCHLD to interrupt the call to select instead of using
threads. I think some of these comments are based on looking at the previous
(eponymous) patch (no. 4).

> I'd be happy to help you merge this, if you can break it down into
> well-understood and necessary pieces. I can help with making the
> native wait case asynchronous, since I know how that works. I also
> have a patch lying around that makes target async-remote work a bit
> better.

This is made harder by the fact that some of the event loop is quite obscure
and I suspect has a level of abstraction that is currently unused. Perhaps a
good starting point would be to simplify this first.

I posted a ChangeLog last time which I divided roughly into my changes and
Apple's which I post below again. Perhaps you can help me by telling me which
parts you think are unintelligible. I concede that some of my changes might
fit in that category and don't pretend that understand I them completely.

--
Nick http://www.inet.net.nz/~nickrob

2006-11-21 Nick Roberts <nickrob@snap.net.nz>

* defs.h (async_signal_hook): Declare.
(event_loop_p): New extern.
(deprecated_command_loop_hook): Make argument type void*.

* main.c (captured_main, print_gdb_help): Add and describe --async
option conditional on macro ASYNC.
(event_loop_p): New global variable.

* event-loop.c (async_signal_hook): New function pointer.
(gdb_wait_for_event): Use it.

* linux-nat.c: Include inf-loop.h. Include poll.h conditionally.
(gdb_post_startup): New extern.
(gdb_status, gdb_file_event): New variables.
(async_mask, old_mask, async_action, old_action): New variables.
(linux_nat_attach, linux_nat_detach): Condition on
target_can_async_p.
(linux_nat_resume): Add async file handler if necessary.
(linux_nat_fetch_event): New function.
(linux_nat_wait): Use it when asynchronous.
(async_sigchld_handler, linux_nat_signal_hook): New functions.
(_initialize_linux_nat): Set up signal handling and pipe for
asynchronous behaviour.

* infrun.c: Include event-top.h.
(sync_execution): Set sync_execution to 1 initially.
(proceed): Set target_executing to 0 if synchronous.
(handle_inferior_event): Print process switching for MI(?).
Don't call context_switch (ecs) or flush_cached_frames ().
Use local variable was_sync_execution.

* inf-ptrace.c: Include inf-loop.h, event-loop.h and event-top.h.
(standard_is_async_p, standard_can_async_p)
(initialize_sigint_signal_handler): New externs.
(async_client_context, async_terminal_ours_p): New variables.
(async_file_handler, inf_ptrace_async): New functions.
(inf_ptrace_him): Use gdb_post_startup as a flag.
(inf_ptrace_mourn_inferior): Don't call waitpid if asynchronous.
(inf_ptrace_attach): Set gdb_post_startup. Call wait_for_inferior
if asynchronous.
(async_terminal_inferior): New function.
(inf_ptrace_target): Add methods if asynchronous.

* exec.c (standard_async, standard_is_async_p, standard_can_async_p):
New functions.
(init_exec_ops): Initialise above methods if GDB is invoked
with --async.

* infcmd.c (jump_command): Call async_disable_stdin if necessary
before decode_line_spec_1.
(attach_command): Make attach work asynchronously.

(copied verbatim)
* event-top.h (cli_command_loop): Make argument type void*.

(copied verbatim)
* event-top.c (cli_command_loop): Make argument void*.
(display_gdb_prompt, async_enable_stdin)
(async_disable_stdin, handle_sigint, async_request_quit)
(gdb_setup_readline, _initialize_event_loop):
Changes for asynchronous operation.

(copied verbatim)
* interps.c (interp_set): Make type struct interp *.
Don't do_all_continuations or call clear_interpreter_hooks.
(current_interp_command_loop): Call command_loop with NULL argument.
(interp_set_quiet): Don't make static.

(copied verbatim)
* interps.h (interp_set, interp_set_quiet): New externs.

(copied verbatim)
* inf-loop.c (inferior_event_handler, complete_execution):
Changes for asynchronous operation.

(copied verbatim)
* cli/cli-interp.c (cli_interpreter_resume): Set sync_execution.
(safe_execute_command): Don't make it static.
(_initialize_cli_interp): Add cli_command_loop to interp_procs
structure.

(copied verbatim)
* wrapper.h (safe_execute_command): Declare here.

(copied verbatim)
* remote.c (cleanup_sigint_signal_handler)
(initialize_sigint_signal_handler): Don't make static.

(copied verbatim)
* top.c (deprecated_command_loop_hook): Make argument type void*.

(copied verbatim)
* mi/mi-interp.c (mi1_command_loop, mi2_command_loop)
(mi3_command_loop): Make argument type void*.

* config/i386/nm-linux.h: Add ASYNC macro definition.

* Makefile.in (inf-ptrace.o, infrun.o, linux-nat.o)
(cli-interp.o): Add new header dependencies.

ChangeLog | 102 +++++++++++++++++++++++++++
Makefile.in | 9 !!
cli/cli-interp.c | 11 -!
config/i386/nm-linux.h | 3
defs.h | 6 +
event-loop.c | 15 ++++
event-top.c | 93 ++++++++++++++!!!!!!!!!!!
event-top.h | 2
exec.c | 26 ++++++-
inf-loop.c | 46 ++++++!!!!!!
inf-ptrace.c | 101 ++++++++++++++++++++++++++!
infcmd.c | 25 ++--!!
infrun.c | 34 ++++---!
interps.c | 40 +++!!!!!!!
interps.h | 3
linux-nat.c | 181 +++++++++++++++++++++++++++++!!!!!!!!!!!!!!!!!!!
main.c | 15 ++++
mi/mi-interp.c | 12 !!!
remote.c | 8 !!
top.c | 2
wrapper.h | 2
21 files changed, 490 insertions(+), 25 deletions(-), 221 modifications(!)