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