diff options
author | Vladimir Prus <vladimir@codesourcery.com> | 2008-06-10 09:35:09 +0000 |
---|---|---|
committer | Vladimir Prus <vladimir@codesourcery.com> | 2008-06-10 09:35:09 +0000 |
commit | f7f9a841a31878b377a60bfc7c793e6c8400fafe (patch) | |
tree | 1554ae753adf4a06eee7b5129ff71c937f5245ad /gdb/mi | |
parent | f5871ec07bfb6388317ec60513286c51ecd06733 (diff) | |
download | gdb-f7f9a841a31878b377a60bfc7c793e6c8400fafe.zip gdb-f7f9a841a31878b377a60bfc7c793e6c8400fafe.tar.gz gdb-f7f9a841a31878b377a60bfc7c793e6c8400fafe.tar.bz2 |
Use observers to report stop events in MI.
* mi/mi-interp.c (mi_on_normal_stop): New.
(mi_interpreter_init): Register mi_on_normal_stop.
(mi_interpreter_exec_continuation): Remove.
(mi_cmd_interpreter_exec): Don't register the above.
* mi/mi-main.c (captured_mi_execute_command): Don't care
about sync_execution.
(mi_execute_async_cli_command): Don't install continuation. Don't
print *stopped.
(mi_exec_async_cli_cmd_continuation): Remove.
Diffstat (limited to 'gdb/mi')
-rw-r--r-- | gdb/mi/mi-interp.c | 40 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 37 |
2 files changed, 21 insertions, 56 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 8b0d909..583c288 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -65,6 +65,7 @@ static void mi1_command_loop (void); static void mi_insert_notify_hooks (void); static void mi_remove_notify_hooks (void); +static void mi_on_normal_stop (struct bpstats *bs); static void mi_new_thread (struct thread_info *t); static void mi_thread_exit (struct thread_info *t); @@ -92,6 +93,7 @@ mi_interpreter_init (int top_level) { observer_attach_new_thread (mi_new_thread); observer_attach_thread_exit (mi_thread_exit); + observer_attach_normal_stop (mi_on_normal_stop); } return mi; @@ -171,26 +173,6 @@ mi_interpreter_prompt_p (void *data) return 0; } -static void -mi_interpreter_exec_continuation (struct continuation_arg *arg, int error_p) -{ - bpstat_do_actions (&stop_bpstat); - /* It's not clear what to do in the case of errror -- should we assume that - the target is stopped, or that it still runs? */ - if (!target_executing) - { - fputs_unfiltered ("*stopped", raw_stdout); - mi_out_put (uiout, raw_stdout); - fputs_unfiltered ("\n", raw_stdout); - fputs_unfiltered ("(gdb) \n", raw_stdout); - gdb_flush (raw_stdout); - } - else if (target_can_async_p ()) - { - add_continuation (mi_interpreter_exec_continuation, NULL); - } -} - enum mi_cmd_result mi_cmd_interpreter_exec (char *command, char **argv, int argc) { @@ -241,7 +223,6 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc) if (target_can_async_p () && target_executing) { fputs_unfiltered ("^running\n", raw_stdout); - add_continuation (mi_interpreter_exec_continuation, NULL); } if (mi_error_message != NULL) @@ -325,12 +306,27 @@ static void mi_thread_exit (struct thread_info *t) { struct mi_interp *mi = top_level_interpreter_data (); - target_terminal_ours (); fprintf_unfiltered (mi->event_channel, "thread-exited,id=\"%d\"", t->num); gdb_flush (mi->event_channel); } +static void +mi_on_normal_stop (struct bpstats *bs) +{ + /* Since this can be called when CLI command is executing, + using cli interpreter, be sure to use MI uiout for output, + not the current one. */ + struct ui_out *uiout = interp_ui_out (top_level_interpreter ()); + struct mi_interp *mi = top_level_interpreter_data (); + + fputs_unfiltered ("*stopped", raw_stdout); + mi_out_put (uiout, raw_stdout); + mi_out_rewind (uiout); + fputs_unfiltered ("\n", raw_stdout); + gdb_flush (raw_stdout); +} + extern initialize_file_ftype _initialize_mi_interp; /* -Wmissing-prototypes */ void diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 4ae509e..6dc7609 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -103,10 +103,6 @@ static void mi_execute_cli_command (const char *cmd, int args_p, const char *args); static enum mi_cmd_result mi_execute_async_cli_command (char *cli_command, char **argv, int argc); - -static void mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg, - int error_p); - static int register_changed_p (int regnum, struct regcache *, struct regcache *); static void get_register (int regnum, int format); @@ -1087,15 +1083,11 @@ captured_mi_execute_command (struct ui_out *uiout, void *data) fputs_unfiltered ("\n", raw_stdout); } else + /* The command does not want anything to be printed. In that + case, the command probably should not have written anything + to uiout, but in case it has written something, discard it. */ mi_out_rewind (uiout); } - else if (sync_execution) - { - /* Don't print the prompt. We are executing the target in - synchronous mode. */ - args->action = EXECUTE_COMMAND_SUPPRESS_PROMPT; - return; - } break; case CLI_COMMAND: @@ -1311,12 +1303,6 @@ mi_execute_async_cli_command (char *cli_command, char **argv, int argc) fputs_unfiltered (current_token, raw_stdout); fputs_unfiltered ("^running\n", raw_stdout); - /* Ideally, we should be intalling continuation only when - the target is already running. However, this will break right now, - because continuation installed by the 'finish' command must be after - the continuation that prints *stopped. This issue will be - fixed soon. */ - add_continuation (mi_exec_async_cli_cmd_continuation, NULL); } execute_command ( /*ui */ run, 0 /*from_tty */ ); @@ -1332,31 +1318,14 @@ mi_execute_async_cli_command (char *cli_command, char **argv, int argc) /* Do this before doing any printing. It would appear that some print code leaves garbage around in the buffer. */ do_cleanups (old_cleanups); - /* If the target was doing the operation synchronously we fake - the stopped message. */ - fputs_unfiltered ("*stopped", raw_stdout); - mi_out_put (uiout, raw_stdout); - mi_out_rewind (uiout); if (do_timings) print_diff_now (current_command_ts); - fputs_unfiltered ("\n", raw_stdout); return MI_CMD_QUIET; } return MI_CMD_DONE; } void -mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg, int error_p) -{ - /* Assume 'error' means that target is stopped, too. */ - fputs_unfiltered ("*stopped", raw_stdout); - mi_out_put (uiout, raw_stdout); - fputs_unfiltered ("\n", raw_stdout); - fputs_unfiltered ("(gdb) \n", raw_stdout); - gdb_flush (raw_stdout); -} - -void mi_load_progress (const char *section_name, unsigned long sent_so_far, unsigned long total_section, |