[PATCH] MI error messages

Nick Roberts
2005-06-20T21:48:32Z

> I like this idea; in fact, this is the style I was going to recommend
> to you (until I went through and noticed that it is only used for
> functions with arguments, not without, at the moment).

Here's a patch for mi-cmd-stack.c and mi-cmd-var.c to start with. Only the
word "Usage" should be translated so e.g

error (_("Usage: -stack-list-locals PRINT_VALUES"));

should be something like:

error (_("Usage")(": -stack-list-locals PRINT_VALUES"));

but I don't what the correct way to do this is.

Also, in mi-cmd-stack.c, I've given get_selected_frame the message string
"No stack." but presumably this also gets translated so should it be:

get_selected_frame (_("No stack.")) ?

Some error messages are terminated with a period, others aren't. I don't
know which style is preferred but clearly it would be best to just use
one.

I'll go through the rest, but I thought I'd try to get these right first.

Nick

2005-06-21 Nick Roberts <nickrob@snap.net.nz>

* mi/mi-cmd-stack.c, mi/mi-cmd-var.c: Re-style error strings for
usage of MI commands.

Index: mi/mi-cmd-stack.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-stack.c,v
retrieving revision 1.27
diff -c -r1.27 mi-cmd-stack.c
*** mi/mi-cmd-stack.c 19 Jun 2005 03:11:47 -0000 1.27
--- mi/mi-cmd-stack.c 20 Jun 2005 21:30:28 -0000
***************
*** 48,54 ****
struct frame_info *fi;

if (argc > 2 || argc == 1)
! error (_("mi_cmd_stack_list_frames: Usage: [FRAME_LOW FRAME_HIGH]"));

if (argc == 2)
{
--- 48,54 ----
struct frame_info *fi;

if (argc > 2 || argc == 1)
! error (_("Usage: -stack-list-frames [FRAME_LOW FRAME_HIGH]"));

if (argc == 2)
{
***************
*** 102,108 ****
struct frame_info *fi;

if (argc > 1)
! error (_("mi_cmd_stack_info_depth: Usage: [MAX_DEPTH]"));

if (argc == 1)
frame_high = atoi (argv[0]);
--- 102,108 ----
struct frame_info *fi;

if (argc > 1)
! error (_("Usage: -stack-info-depth [MAX_DEPTH]"));

if (argc == 1)
frame_high = atoi (argv[0]);
***************
*** 131,139 ****
enum print_values print_values;

if (argc != 1)
! error (_("mi_cmd_stack_list_locals: Usage: PRINT_VALUES"));

! frame = get_selected_frame (NULL);

if (strcmp (argv[0], "0") == 0
|| strcmp (argv[0], "--no-values") == 0)
--- 131,139 ----
enum print_values print_values;

if (argc != 1)
! error (_("Usage: -stack-list-locals PRINT_VALUES"));

! frame = get_selected_frame ("No stack.");

if (strcmp (argv[0], "0") == 0
|| strcmp (argv[0], "--no-values") == 0)
***************
*** 163,169 ****
struct cleanup *cleanup_stack_args;

if (argc < 1 || argc > 3 || argc == 2)
! error (_("mi_cmd_stack_list_args: Usage: PRINT_VALUES [FRAME_LOW FRAME_HIGH]"));

if (argc == 3)
{
--- 163,169 ----
struct cleanup *cleanup_stack_args;

if (argc < 1 || argc > 3 || argc == 2)
! error (_("Usage: -stack-list-arguments PRINT_VALUES [FRAME_LOW FRAME_HIGH]"));

if (argc == 3)
{
***************
*** 324,330 ****
mi_cmd_stack_select_frame (char *command, char **argv, int argc)
{
if (argc == 0 || argc > 1)
! error (_("mi_cmd_stack_select_frame: Usage: FRAME_SPEC"));

select_frame_command (argv[0], 1 /* not used */ );
return MI_CMD_DONE;
--- 324,330 ----
mi_cmd_stack_select_frame (char *command, char **argv, int argc)
{
if (argc == 0 || argc > 1)
! error (_("Usage: -stack-select-frame FRAME_SPEC"));

select_frame_command (argv[0], 1 /* not used */ );
return MI_CMD_DONE;
***************
*** 334,341 ****
mi_cmd_stack_info_frame (char *command, char **argv, int argc)
{
if (argc > 0)
! error (_("mi_cmd_stack_info_frame: No arguments required"));

! print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0);
return MI_CMD_DONE;
}
--- 334,341 ----
mi_cmd_stack_info_frame (char *command, char **argv, int argc)
{
if (argc > 0)
! error (_("Usage: -stack-info-frame"));

! print_frame_info (get_selected_frame ("No stack."), 1, LOC_AND_ADDRESS, 0);
return MI_CMD_DONE;
}

Index: mi/mi-cmd-var.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-var.c,v
retrieving revision 1.21
diff -c -r1.21 mi-cmd-var.c
*** mi/mi-cmd-var.c 11 Feb 2005 04:06:11 -0000 1.21
--- mi/mi-cmd-var.c 20 Jun 2005 21:31:08 -0000
***************
*** 52,58 ****
{
/* mi_error_message = xstrprintf ("mi_cmd_var_create: Usage:
...."); return MI_CMD_ERROR; */
! error (_("mi_cmd_var_create: Usage: NAME FRAME EXPRESSION."));
}

name = xstrdup (argv[0]);
--- 52,58 ----
{
/* mi_error_message = xstrprintf ("mi_cmd_var_create: Usage:
...."); return MI_CMD_ERROR; */
! error (_("Usage: -var-create NAME FRAME EXPRESSION."));
}

name = xstrdup (argv[0]);
***************
*** 119,125 ****
struct cleanup *old_cleanups;

if (argc < 1 || argc > 2)
! error (_("mi_cmd_var_delete: Usage: [-c] EXPRESSION."));

name = xstrdup (argv[0]);
/* Add cleanup for name. Must be free_current_contents as
--- 119,125 ----
struct cleanup *old_cleanups;

if (argc < 1 || argc > 2)
! error (_("Usage: -var-delete [-c] EXPRESSION."));

name = xstrdup (argv[0]);
/* Add cleanup for name. Must be free_current_contents as
***************
*** 174,180 ****
char *formspec;

if (argc != 2)
! error (_("mi_cmd_var_set_format: Usage: NAME FORMAT."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 174,180 ----
char *formspec;

if (argc != 2)
! error (_("Usage: -var-set-format NAME FORMAT."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 216,222 ****
struct varobj *var;

if (argc != 1)
! error (_("mi_cmd_var_show_format: Usage: NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 216,222 ----
struct varobj *var;

if (argc != 1)
! error (_("Usage: -var-show-format NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 236,242 ****
struct varobj *var;

if (argc != 1)
! error (_("mi_cmd_var_info_num_children: Usage: NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 236,242 ----
struct varobj *var;

if (argc != 1)
! error (_("Usage: -var-info-num-children NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 259,265 ****
enum print_values print_values;

if (argc != 1 && argc != 2)
! error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));

/* Get varobj handle, if a valid var obj name was specified */
if (argc == 1) var = varobj_get_handle (argv[0]);
--- 259,265 ----
enum print_values print_values;

if (argc != 1 && argc != 2)
! error (_("Usage: -var-list-children [PRINT_VALUES] NAME"));

/* Get varobj handle, if a valid var obj name was specified */
if (argc == 1) var = varobj_get_handle (argv[0]);
***************
*** 315,321 ****
struct varobj *var;

if (argc != 1)
! error (_("mi_cmd_var_info_type: Usage: NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 315,321 ----
struct varobj *var;

if (argc != 1)
! error (_("Usage: -var-info-type NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 333,339 ****
struct varobj *var;

if (argc != 1)
! error (_("mi_cmd_var_info_expression: Usage: NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 333,339 ----
struct varobj *var;

if (argc != 1)
! error (_("Usage: -var-info-expression NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 355,361 ****
struct varobj *var;

if (argc != 1)
! error (_("mi_cmd_var_show_attributes: Usage: NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 355,361 ----
struct varobj *var;

if (argc != 1)
! error (_("Usage: -var-show-attributes NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 379,385 ****
struct varobj *var;

if (argc != 1)
! error (_("mi_cmd_var_evaluate_expression: Usage: NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 379,385 ----
struct varobj *var;

if (argc != 1)
! error (_("Usage: -var-evaluate-expression NAME."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 397,403 ****
char *expression;

if (argc != 2)
! error (_("mi_cmd_var_assign: Usage: NAME EXPRESSION."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
--- 397,403 ----
char *expression;

if (argc != 2)
! error (_("Usage: -var-assign NAME EXPRESSION."));

/* Get varobj handle, if a valid var obj name was specified */
var = varobj_get_handle (argv[0]);
***************
*** 428,434 ****
int nv;

if (argc != 1)
! error (_("mi_cmd_var_update: Usage: NAME."));

name = argv[0];

--- 428,434 ----
int nv;

if (argc != 1)
! error (_("Usage: -var-update NAME."));

name = argv[0];