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: [commit] Don't internal error on user typos


> I typed "-var-create - & foo" several times today.  When I do this, I
> get a scary internal error instead of a slap on the knuckles.  And
> after the scary internal error GDB drops core.  Fixed as below,
> committed.
> 
> -- 
> Daniel Jacobowitz
> CodeSourcery
> 
> 2006-11-17  Daniel Jacobowitz  <dan@codesourcery.com>
> 
> 	* utils.c (string_to_core_addr): Use error instead of
> 	internal_error.
> 	* mi/mi-main.c (mi_execute_command): Check for a NULL message.

Any objection to including this patch in the branch? I think
the internal error is scarier than it should be, and might give
the wrong impression about the debugger quality.

The patch itself looks relatively low risk.

> Index: utils.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/utils.c,v
> retrieving revision 1.170
> diff -u -p -r1.170 utils.c
> --- utils.c	18 Oct 2006 22:16:52 -0000	1.170
> +++ utils.c	17 Nov 2006 19:24:34 -0000
> @@ -2865,7 +2865,7 @@ string_to_core_addr (const char *my_stri
>  	  else if (isxdigit (my_string[i]))
>  	    addr = (tolower (my_string[i]) - 'a' + 0xa) + (addr * 16);
>  	  else
> -	    internal_error (__FILE__, __LINE__, _("invalid hex"));
> +	    error (_("invalid hex \"%s\""), my_string);
>  	}
>      }
>    else
> @@ -2877,7 +2877,7 @@ string_to_core_addr (const char *my_stri
>  	  if (isdigit (my_string[i]))
>  	    addr = (my_string[i] - '0') + (addr * 10);
>  	  else
> -	    internal_error (__FILE__, __LINE__, _("invalid decimal"));
> +	    error (_("invalid decimal \"%s\""), my_string);
>  	}
>      }
>    return addr;
> Index: mi/mi-main.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
> retrieving revision 1.85
> diff -u -p -r1.85 mi-main.c
> --- mi/mi-main.c	15 Aug 2006 18:46:25 -0000	1.85
> +++ mi/mi-main.c	17 Nov 2006 19:29:34 -0000
> @@ -1183,7 +1183,10 @@ mi_execute_command (char *cmd, int from_
>  	     somewhere.  */
>  	  fputs_unfiltered (command->token, raw_stdout);
>  	  fputs_unfiltered ("^error,msg=\"", raw_stdout);
> -	  fputstr_unfiltered (result.message, '"', raw_stdout);
> +	  if (result.message == NULL)
> +	    fputs_unfiltered ("unknown error", raw_stdout);
> +	  else
> +	      fputstr_unfiltered (result.message, '"', raw_stdout);
>  	  fputs_unfiltered ("\"\n", raw_stdout);
>  	  mi_out_rewind (uiout);
>  	}

-- 
Joel


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