+2009-03-12 Vladimir Prus <vladimir@codesourcery.com>
+
+ Fix MI timings.
+
+ * mi/mi-main.c (mi_print_timing_maybe): New.
+ (captured_mi_execute_command): Simplify. Output timings to
+ CLI commands, too.
+ (mi_execute_async_cli_command): Do not print timings.
+ * mi/mi-main.h (mi_print_timing_maybe): Declare.
+ * mi/mi-interp.c (mi_on_normal_stop): Call mi_print_timing_maybe.
+
2009-03-12 Jerome Guitton <guitton@adacore.com>
* xcoffread.c (process_linenos): Check if the line in the
{
struct mi_parse *context = (struct mi_parse *) data;
- struct mi_timestamp cmd_finished;
+ if (do_timings)
+ current_command_ts = context->cmd_start;
running_result_record_printed = 0;
switch (context->op)
fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n",
context->token, context->command, context->args);
- if (do_timings)
- current_command_ts = context->cmd_start;
mi_cmd_execute (context);
- if (do_timings)
- timestamp (&cmd_finished);
-
/* Print the result if there were no errors.
Remember that on the way out of executing a command, you have
? "^connected" : "^done", raw_stdout);
mi_out_put (uiout, raw_stdout);
mi_out_rewind (uiout);
- /* Have to check cmd_start, since the command could be
- -enable-timings. */
- if (do_timings && context->cmd_start)
- print_diff (context->cmd_start, &cmd_finished);
+ mi_print_timing_maybe ();
fputs_unfiltered ("\n", raw_stdout);
}
else
fputs_unfiltered ("^done", raw_stdout);
mi_out_put (uiout, raw_stdout);
mi_out_rewind (uiout);
- fputs_unfiltered ("\n", raw_stdout);
+ mi_print_timing_maybe ();
+ fputs_unfiltered ("\n", raw_stdout);
}
else
mi_out_rewind (uiout);
/* Do this before doing any printing. It would appear that some
print code leaves garbage around in the buffer. */
do_cleanups (old_cleanups);
- if (do_timings)
- print_diff_now (current_command_ts);
}
}
print_diff (start, &now);
}
+void
+mi_print_timing_maybe (void)
+{
+ /* 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);
+}
+
static long
timeval_diff (struct timeval start, struct timeval end)
{