This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cleanup mi error message handling


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]