diff options
Diffstat (limited to 'gdb/mi/mi-main.c')
-rw-r--r-- | gdb/mi/mi-main.c | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index d53bcc7..8e51edc 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -72,8 +72,6 @@ enum int mi_debug_p; -struct ui_file *raw_stdout; - /* This is used to pass the current command timestamp down to continuation routines. */ static struct mi_timestamp *current_command_ts; @@ -149,18 +147,21 @@ mi_async_p (void) static void timestamp (struct mi_timestamp *tv); -static void print_diff_now (struct mi_timestamp *start); -static void print_diff (struct mi_timestamp *start, struct mi_timestamp *end); +static void print_diff (struct ui_file *file, struct mi_timestamp *start, + struct mi_timestamp *end); void mi_cmd_gdb_exit (char *command, char **argv, int argc) { + struct mi_interp *mi + = (struct mi_interp *) interp_data (current_interpreter ()); + /* We have to print everything right here because we never return. */ if (current_token) - fputs_unfiltered (current_token, raw_stdout); - fputs_unfiltered ("^exit\n", raw_stdout); - mi_out_put (current_uiout, raw_stdout); - gdb_flush (raw_stdout); + fputs_unfiltered (current_token, mi->raw_stdout); + fputs_unfiltered ("^exit\n", mi->raw_stdout); + mi_out_put (current_uiout, mi->raw_stdout); + gdb_flush (mi->raw_stdout); /* FIXME: The function called is not yet a formal libgdb function. */ quit_force (NULL, FROM_TTY); } @@ -1983,6 +1984,7 @@ mi_cmd_remove_inferior (char *command, char **argv, int argc) static void captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) { + struct mi_interp *mi = (struct mi_interp *) interp_data (command_interp ()); struct cleanup *cleanup; if (do_timings) @@ -1999,7 +2001,8 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) /* A MI command was read from the input stream. */ if (mi_debug_p) /* FIXME: gdb_???? */ - fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n", + fprintf_unfiltered (mi->raw_stdout, + " token=`%s' command=`%s' args=`%s'\n", context->token, context->command, context->args); mi_cmd_execute (context); @@ -2012,15 +2015,15 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) uiout will most likely crash in the mi_out_* routines. */ if (!running_result_record_printed) { - fputs_unfiltered (context->token, raw_stdout); + fputs_unfiltered (context->token, mi->raw_stdout); /* There's no particularly good reason why target-connect results in not ^done. Should kill ^connected for MI3. */ fputs_unfiltered (strcmp (context->command, "target-select") == 0 - ? "^connected" : "^done", raw_stdout); - mi_out_put (uiout, raw_stdout); + ? "^connected" : "^done", mi->raw_stdout); + mi_out_put (uiout, mi->raw_stdout); mi_out_rewind (uiout); - mi_print_timing_maybe (); - fputs_unfiltered ("\n", raw_stdout); + mi_print_timing_maybe (mi->raw_stdout); + fputs_unfiltered ("\n", mi->raw_stdout); } else /* The command does not want anything to be printed. In that @@ -2051,12 +2054,12 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) { if (!running_result_record_printed) { - fputs_unfiltered (context->token, raw_stdout); - fputs_unfiltered ("^done", raw_stdout); - mi_out_put (uiout, raw_stdout); + fputs_unfiltered (context->token, mi->raw_stdout); + fputs_unfiltered ("^done", mi->raw_stdout); + mi_out_put (uiout, mi->raw_stdout); mi_out_rewind (uiout); - mi_print_timing_maybe (); - fputs_unfiltered ("\n", raw_stdout); + mi_print_timing_maybe (mi->raw_stdout); + fputs_unfiltered ("\n", mi->raw_stdout); } else mi_out_rewind (uiout); @@ -2073,22 +2076,25 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context) static void mi_print_exception (const char *token, struct gdb_exception exception) { - fputs_unfiltered (token, raw_stdout); - fputs_unfiltered ("^error,msg=\"", raw_stdout); + struct mi_interp *mi + = (struct mi_interp *) interp_data (current_interpreter ()); + + fputs_unfiltered (token, mi->raw_stdout); + fputs_unfiltered ("^error,msg=\"", mi->raw_stdout); if (exception.message == NULL) - fputs_unfiltered ("unknown error", raw_stdout); + fputs_unfiltered ("unknown error", mi->raw_stdout); else - fputstr_unfiltered (exception.message, '"', raw_stdout); - fputs_unfiltered ("\"", raw_stdout); + fputstr_unfiltered (exception.message, '"', mi->raw_stdout); + fputs_unfiltered ("\"", mi->raw_stdout); switch (exception.error) { case UNDEFINED_COMMAND_ERROR: - fputs_unfiltered (",code=\"undefined-command\"", raw_stdout); + fputs_unfiltered (",code=\"undefined-command\"", mi->raw_stdout); break; } - fputs_unfiltered ("\n", raw_stdout); + fputs_unfiltered ("\n", mi->raw_stdout); } void @@ -2358,6 +2364,8 @@ mi_load_progress (const char *section_name, int new_section; struct ui_out *saved_uiout; struct ui_out *uiout; + struct mi_interp *mi + = (struct mi_interp *) interp_data (current_interpreter ()); /* This function is called through deprecated_show_load_progress which means uiout may not be correct. Fix it for the duration @@ -2399,16 +2407,16 @@ mi_load_progress (const char *section_name, previous_sect_name = xstrdup (section_name); if (current_token) - fputs_unfiltered (current_token, raw_stdout); - fputs_unfiltered ("+download", raw_stdout); + fputs_unfiltered (current_token, mi->raw_stdout); + fputs_unfiltered ("+download", mi->raw_stdout); cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "section", section_name); ui_out_field_int (uiout, "section-size", total_section); ui_out_field_int (uiout, "total-size", grand_total); do_cleanups (cleanup_tuple); - mi_out_put (uiout, raw_stdout); - fputs_unfiltered ("\n", raw_stdout); - gdb_flush (raw_stdout); + mi_out_put (uiout, mi->raw_stdout); + fputs_unfiltered ("\n", mi->raw_stdout); + gdb_flush (mi->raw_stdout); } if (delta.tv_sec >= update_threshold.tv_sec && @@ -2419,8 +2427,8 @@ mi_load_progress (const char *section_name, last_update.tv_sec = time_now.tv_sec; last_update.tv_usec = time_now.tv_usec; if (current_token) - fputs_unfiltered (current_token, raw_stdout); - fputs_unfiltered ("+download", raw_stdout); + fputs_unfiltered (current_token, mi->raw_stdout); + fputs_unfiltered ("+download", mi->raw_stdout); cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "section", section_name); ui_out_field_int (uiout, "section-sent", sent_so_far); @@ -2428,9 +2436,9 @@ mi_load_progress (const char *section_name, ui_out_field_int (uiout, "total-sent", total_sent); ui_out_field_int (uiout, "total-size", grand_total); do_cleanups (cleanup_tuple); - mi_out_put (uiout, raw_stdout); - fputs_unfiltered ("\n", raw_stdout); - gdb_flush (raw_stdout); + mi_out_put (uiout, mi->raw_stdout); + fputs_unfiltered ("\n", mi->raw_stdout); + gdb_flush (mi->raw_stdout); } xfree (uiout); @@ -2460,21 +2468,21 @@ timestamp (struct mi_timestamp *tv) } static void -print_diff_now (struct mi_timestamp *start) +print_diff_now (struct ui_file *file, struct mi_timestamp *start) { struct mi_timestamp now; timestamp (&now); - print_diff (start, &now); + print_diff (file, start, &now); } void -mi_print_timing_maybe (void) +mi_print_timing_maybe (struct ui_file *file) { /* If the command is -enable-timing then do_timings may be true whilst current_command_ts is not initialized. */ if (do_timings && current_command_ts) - print_diff_now (current_command_ts); + print_diff_now (file, current_command_ts); } static long @@ -2485,10 +2493,11 @@ timeval_diff (struct timeval start, struct timeval end) } static void -print_diff (struct mi_timestamp *start, struct mi_timestamp *end) +print_diff (struct ui_file *file, struct mi_timestamp *start, + struct mi_timestamp *end) { fprintf_unfiltered - (raw_stdout, + (file, ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}", timeval_diff (start->wallclock, end->wallclock) / 1000000.0, timeval_diff (start->utime, end->utime) / 1000000.0, |