diff options
author | Keith Seitz <keiths@redhat.com> | 2002-06-20 01:41:32 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2002-06-20 01:41:32 +0000 |
commit | e7355adcaa079a48b581c93fcbde062447527dfc (patch) | |
tree | c358953cf88f97caa6be50366a3f934027ed98a5 /gdb/cli | |
parent | f429694a7fe0fd8837a3a28b4fbf4e558fcb9351 (diff) | |
download | gdb-e7355adcaa079a48b581c93fcbde062447527dfc.tar.gz |
Merge with mainline, kseitz_interps-20020619-merge.
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-decode.c | 94 | ||||
-rw-r--r-- | gdb/cli/cli-decode.h | 23 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.c | 21 |
3 files changed, 78 insertions, 60 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 3f510ac87d1..a6fadd91360 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -53,8 +53,7 @@ do_cfunc (struct cmd_list_element *c, char *args, int from_tty) } void -set_cmd_cfunc (struct cmd_list_element *cmd, - void (*cfunc) (char *args, int from_tty)) +set_cmd_cfunc (struct cmd_list_element *cmd, cmd_cfunc_ftype *cfunc) { if (cfunc == NULL) cmd->func = NULL; @@ -70,9 +69,7 @@ do_sfunc (struct cmd_list_element *c, char *args, int from_tty) } void -set_cmd_sfunc (struct cmd_list_element *cmd, - void (*sfunc) (char *args, int from_tty, - struct cmd_list_element * c)) +set_cmd_sfunc (struct cmd_list_element *cmd, cmd_sfunc_ftype *sfunc) { if (sfunc == NULL) cmd->func = NULL; @@ -328,6 +325,35 @@ add_set_or_show_cmd (char *name, return c; } +/* Add element named NAME to both the command SET_LIST and SHOW_LIST. + CLASS is as in add_cmd. VAR_TYPE is the kind of thing we are + setting. VAR is address of the variable being controlled by this + command. SET_FUNC and SHOW_FUNC are the callback functions (if + non-NULL). SET_DOC and SHOW_DOC are the documentation strings. */ + +static struct cmd_list_element * +add_setshow_cmd (char *name, + enum command_class class, + var_types var_type, void *var, + char *set_doc, char *show_doc, + cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list) +{ + struct cmd_list_element *set; + struct cmd_list_element *show; + set = add_set_or_show_cmd (name, set_cmd, class, var_type, var, + set_doc, set_list); + if (set_func != NULL) + set_cmd_sfunc (set, set_func); + show = add_set_or_show_cmd (name, show_cmd, class, var_type, var, + show_doc, show_list); + if (show_func != NULL) + set_cmd_sfunc (show, show_func); + /* The caller often wants to modify set to include info like an + enumeration. */ + return set; +} struct cmd_list_element * add_set_cmd (char *name, @@ -363,42 +389,48 @@ add_set_enum_cmd (char *name, return c; } -/* Add element named NAME to command list LIST (the list for set - or some sublist thereof). - CLASS is as in add_cmd. - VAR is address of the variable which will contain the value. - DOC is the documentation string. */ -struct cmd_list_element * -add_set_auto_boolean_cmd (char *name, - enum command_class class, - enum cmd_auto_boolean *var, - char *doc, - struct cmd_list_element **list) +/* Add an auto-boolean command named NAME to both the set and show + command list lists. CLASS is as in add_cmd. VAR is address of the + variable which will contain the value. DOC is the documentation + string. FUNC is the corresponding callback. */ +void +add_setshow_auto_boolean_cmd (char *name, + enum command_class class, + enum auto_boolean *var, + char *set_doc, char *show_doc, + cmd_sfunc_ftype *set_func, + cmd_sfunc_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list) { static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL }; struct cmd_list_element *c; - c = add_set_cmd (name, class, var_auto_boolean, var, doc, list); + c = add_setshow_cmd (name, class, var_auto_boolean, var, + set_doc, show_doc, set_func, show_func, + set_list, show_list); c->enums = auto_boolean_enums; - return c; } -/* Add element named NAME to command list LIST (the list for set - or some sublist thereof). - CLASS is as in add_cmd. - VAR is address of the variable which will contain the value. - DOC is the documentation string. */ -struct cmd_list_element * -add_set_boolean_cmd (char *name, - enum command_class class, - int *var, - char *doc, - struct cmd_list_element **list) +/* Add element named NAME to both the set and show command LISTs (the + list for set/show or some sublist thereof). CLASS is as in + add_cmd. VAR is address of the variable which will contain the + value. SET_DOC and SHOW_DOR are the documentation strings. */ +void +add_setshow_boolean_cmd (char *name, + enum command_class class, + int *var, char *set_doc, char *show_doc, + cmd_sfunc_ftype *set_func, + cmd_sfunc_ftype *show_func, + struct cmd_list_element **set_list, + struct cmd_list_element **show_list) { static const char *boolean_enums[] = { "on", "off", NULL }; struct cmd_list_element *c; - c = add_set_cmd (name, class, var_boolean, var, doc, list); + c = add_setshow_cmd (name, class, var_boolean, var, + set_doc, show_doc, + set_func, show_func, + set_list, show_list); c->enums = boolean_enums; - return c; } /* Where SETCMD has already been added, add the corresponding show diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 72436f04657..e8563ff5c59 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -69,12 +69,11 @@ struct cmd_list_element to one of the below. */ union { - /* If type is not_set_cmd, call it like this: */ - void (*cfunc) (char *args, int from_tty); - - /* If type is set_cmd or show_cmd, first set the variables, and - then call this. */ - void (*sfunc) (char *args, int from_tty, struct cmd_list_element * c); + /* If type is not_set_cmd, call it like this: */ + cmd_cfunc_ftype *cfunc; + /* If type is set_cmd or show_cmd, first set the variables, + and then call this: */ + cmd_sfunc_ftype *sfunc; } function; @@ -294,18 +293,6 @@ extern struct cmd_list_element *add_set_enum_cmd (char *name, char *doc, struct cmd_list_element **list); -extern struct cmd_list_element *add_set_auto_boolean_cmd (char *name, - enum command_class class, - enum cmd_auto_boolean *var, - char *doc, - struct cmd_list_element **list); - -extern struct cmd_list_element *add_set_boolean_cmd (char *name, - enum command_class class, - int *var, - char *doc, - struct cmd_list_element **list); - extern struct cmd_list_element *add_show_from_set (struct cmd_list_element *, struct cmd_list_element **); diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index f967b0c3eba..94ba94e16dd 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -34,9 +34,8 @@ static int parse_binary_operation (char *); -static enum cmd_auto_boolean parse_auto_binary_operation (const char *arg); -static enum cmd_auto_boolean +static enum auto_boolean parse_auto_binary_operation (const char *arg) { if (arg != NULL && *arg != '\0') @@ -48,18 +47,18 @@ parse_auto_binary_operation (const char *arg) || strncmp (arg, "1", length) == 0 || strncmp (arg, "yes", length) == 0 || strncmp (arg, "enable", length) == 0) - return CMD_AUTO_BOOLEAN_TRUE; + return AUTO_BOOLEAN_TRUE; else if (strncmp (arg, "off", length) == 0 || strncmp (arg, "0", length) == 0 || strncmp (arg, "no", length) == 0 || strncmp (arg, "disable", length) == 0) - return CMD_AUTO_BOOLEAN_FALSE; + return AUTO_BOOLEAN_FALSE; else if (strncmp (arg, "auto", length) == 0 || (strncmp (arg, "-1", length) == 0 && length > 1)) - return CMD_AUTO_BOOLEAN_AUTO; + return AUTO_BOOLEAN_AUTO; } error ("\"on\", \"off\" or \"auto\" expected."); - return CMD_AUTO_BOOLEAN_AUTO; /* pacify GCC */ + return AUTO_BOOLEAN_AUTO; /* pacify GCC */ } static int @@ -167,7 +166,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c) *(int *) c->var = parse_binary_operation (arg); break; case var_auto_boolean: - *(enum cmd_auto_boolean *) c->var = parse_auto_binary_operation (arg); + *(enum auto_boolean *) c->var = parse_auto_binary_operation (arg); break; case var_uinteger: if (arg == NULL) @@ -296,15 +295,15 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c) fputs_filtered (*(int *) c->var ? "on" : "off", stb->stream); break; case var_auto_boolean: - switch (*(enum cmd_auto_boolean*) c->var) + switch (*(enum auto_boolean*) c->var) { - case CMD_AUTO_BOOLEAN_TRUE: + case AUTO_BOOLEAN_TRUE: fputs_filtered ("on", stb->stream); break; - case CMD_AUTO_BOOLEAN_FALSE: + case AUTO_BOOLEAN_FALSE: fputs_filtered ("off", stb->stream); break; - case CMD_AUTO_BOOLEAN_AUTO: + case AUTO_BOOLEAN_AUTO: fputs_filtered ("auto", stb->stream); break; default: |