cleanup mi error message handling
Vladimir Prus
ghost@cs.msu.su
Fri Apr 4 13:33:00 GMT 2008
Pedro Alves wrote:
> Index: src/gdb/mi/mi-main.c
> ===================================================================
> --- src.orig/gdb/mi/mi-main.c   2008-03-23 19:56:34.000000000 +0000
> +++ src/gdb/mi/mi-main.c        2008-03-23 20:00:02.000000000 +0000
> @@ -96,7 +96,6 @@ static int do_timings = 0;
> Â /* The token of the last asynchronous command. Â */
> Â static char *last_async_command;
> Â static char *previous_async_command;
> -char *mi_error_message;
> Â
> Â extern void _initialize_mi_main (void);
> Â static enum mi_cmd_result mi_cmd_execute (struct mi_parse *parse);
> @@ -109,7 +108,7 @@ static void mi_exec_async_cli_cmd_contin
> Â
> Â static int register_changed_p (int regnum, struct regcache *,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct regcache *);
> -static int get_register (int regnum, int format);
> +static void get_register (int regnum, int format);
> Â
> Â /* Command implementations. Â FIXME: Is this libgdb? Â No. Â This is the MI
> Â Â layer that calls libgdb. Â Any operation used in the below should be
> @@ -219,10 +218,8 @@ enum mi_cmd_result
> Â mi_cmd_exec_interrupt (char *args, int from_tty)
> Â {
> Â Â if (!target_executing)
> - Â Â {
> - Â Â Â mi_error_message = xstrprintf ("mi_cmd_exec_interrupt: Inferior not executing.");
> - Â Â Â return MI_CMD_ERROR;
> - Â Â }
> + Â Â error ("mi_cmd_exec_interrupt: Inferior not executing.");
> +
> Â Â interrupt_target_command (args, from_tty);
> Â Â if (last_async_command)
> Â Â Â fputs_unfiltered (last_async_command, raw_stdout);
> @@ -242,38 +239,40 @@ enum mi_cmd_result
> Â mi_cmd_thread_select (char *command, char **argv, int argc)
> Â {
> Â Â enum gdb_rc rc;
> + Â char *mi_error_message;
> Â
> Â Â if (argc != 1)
> + Â Â error ("mi_cmd_thread_select: USAGE: threadnum.");
> +
> + Â rc = gdb_thread_select (uiout, argv[0], &mi_error_message);
> +
> + Â if (rc == GDB_RC_FAIL)
> Â Â Â {
> - Â Â Â mi_error_message = xstrprintf ("mi_cmd_thread_select: USAGE: threadnum.");
> - Â Â Â return MI_CMD_ERROR;
> + Â Â Â make_cleanup (xfree, mi_error_message);
> + Â Â Â error ("%s", mi_error_message);
Oh, so first gdb_thread_select catches exception and converts it to string,
and then we throw that string again? Eek, but guess we can fix that with
a separate patch.
This patch is OK. Please be sure to re-run the MI testsuite before checking in,
though, as there were various testsuite changes recently.
Thanks,
Volodya
More information about the Gdb-patches
mailing list