From b4a14fd09b84468e7d28a2889d99a27008781fb1 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 2 Sep 2011 16:56:30 +0000 Subject: 2011-09-02 Pedro Alves * top.c: Include interps.h. (execute_command): If the target can async, but the interpreter is in sync mode, synchronously wait for the command to finish before returning. (execute_command_to_string): Force the interpreter to sync mode. * infrun.c: Include interps.h. (fetch_inferior_event): Don't restore the prompt yet if the interpreter is in sync mode. * interps.c (interpreter_async): New global. * interps.h (interpreter_async): Declare. * inf-loop.c: Include interps.h. (inferior_event_handler): Don't print the language change or run breakpoint commands yet if the interpreter in is sync mode. * main.c (captured_command_loop): Flip the interpreter to async mode. * cli/cli-script.c: Include interps.h. (execute_user_command, while_command, if_command): Force the interpreter to sync mode. * python/python.c: Include interps.h. (python_command, execute_gdb_command): Force the interpreter to sync mode. --- gdb/top.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'gdb/top.c') diff --git a/gdb/top.c b/gdb/top.c index 3112d393203..ac371763dc6 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -48,6 +48,7 @@ #include "event-loop.h" #include "gdbthread.h" #include "python/python.h" +#include "interps.h" /* readline include files. */ #include "readline/readline.h" @@ -441,7 +442,18 @@ execute_command (char *p, int from_tty) deprecated_call_command_hook (c, arg, from_tty & caution); else cmd_func (c, arg, from_tty & caution); - + + /* If the interpreter is in sync mode (we're running a user + command's list, running command hooks or similars), and we + just ran a synchronous command that started the target, wait + for that command to end. */ + if (!interpreter_async && sync_execution && is_running (inferior_ptid)) + { + while (gdb_do_one_event () >= 0) + if (!sync_execution) + break; + } + /* If this command has been post-hooked, run the hook last. */ execute_cmd_post_hook (c); @@ -497,6 +509,9 @@ execute_command_to_string (char *p, int from_tty) restoration callbacks. */ cleanup = set_batch_flag_and_make_cleanup_restore_page_info (); + make_cleanup_restore_integer (&interpreter_async); + interpreter_async = 0; + str_file = mem_fileopen (); make_cleanup_ui_file_delete (str_file); -- cgit v1.2.1