summaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2002-07-22 21:47:28 +0000
committerKeith Seitz <keiths@redhat.com>2002-07-22 21:47:28 +0000
commitf489974290164bb5eb6f9684fde2ea2ce301efa5 (patch)
tree12a27afbcef09f7ba809563d09ed5a99bb8cfdc8 /gdb/cli
parente24af8ba97e1baaff8c87d62cec7e681686b2d57 (diff)
downloadgdb-f489974290164bb5eb6f9684fde2ea2ce301efa5.tar.gz
Merge w/trunk (kseitz_interps-20020722-merge).
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-decode.c88
1 files changed, 68 insertions, 20 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index a6fadd91360..84e445ee980 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -329,16 +329,20 @@ add_set_or_show_cmd (char *name,
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. */
+ non-NULL). SET_DOC and SHOW_DOC are the documentation strings.
+ SET_RESULT and SHOW_RESULT, if not NULL, are set to the resulting
+ command structures. */
-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)
+void
+add_setshow_cmd_full (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_result,
+ struct cmd_list_element **show_result)
{
struct cmd_list_element *set;
struct cmd_list_element *show;
@@ -350,9 +354,31 @@ add_setshow_cmd (char *name,
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;
+
+ if (set_result != NULL)
+ *set_result = set;
+ if (show_result != NULL)
+ *show_result = show;
+}
+
+/* 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. */
+
+void
+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)
+{
+ add_setshow_cmd_full (name, class, var_type, var, set_doc, show_doc,
+ set_func, show_func, set_list, show_list,
+ NULL, NULL);
}
struct cmd_list_element *
@@ -405,9 +431,10 @@ add_setshow_auto_boolean_cmd (char *name,
{
static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL };
struct cmd_list_element *c;
- c = add_setshow_cmd (name, class, var_auto_boolean, var,
- set_doc, show_doc, set_func, show_func,
- set_list, show_list);
+ add_setshow_cmd_full (name, class, var_auto_boolean, var,
+ set_doc, show_doc, set_func, show_func,
+ set_list, show_list,
+ &c, NULL);
c->enums = auto_boolean_enums;
}
@@ -426,10 +453,11 @@ add_setshow_boolean_cmd (char *name,
{
static const char *boolean_enums[] = { "on", "off", NULL };
struct cmd_list_element *c;
- c = add_setshow_cmd (name, class, var_boolean, var,
- set_doc, show_doc,
- set_func, show_func,
- set_list, show_list);
+ add_setshow_cmd_full (name, class, var_boolean, var,
+ set_doc, show_doc,
+ set_func, show_func,
+ set_list, show_list,
+ &c, NULL);
c->enums = boolean_enums;
}
@@ -437,7 +465,7 @@ add_setshow_boolean_cmd (char *name,
command to LIST and return a pointer to the added command (not
necessarily the head of LIST). */
/* NOTE: cagney/2002-03-17: The original version of add_show_from_set
- used memcpy() to clone `set' into `show'. This ment that in
+ used memcpy() to clone `set' into `show'. This meant that in
addition to all the needed fields (var, name, et.al.) some
unnecessary fields were copied (namely the callback function). The
function explictly copies relevant fields. For a `set' and `show'
@@ -1477,3 +1505,23 @@ complete_on_enum (const char *enumlist[],
return matchlist;
}
+
+/* check function pointer */
+int
+cmd_func_p (struct cmd_list_element *cmd)
+{
+ return (cmd->func != NULL);
+}
+
+
+/* call the command function */
+void
+cmd_func (struct cmd_list_element *cmd, char *args, int from_tty)
+{
+ if (cmd_func_p (cmd))
+ (*cmd->func) (cmd, args, from_tty);
+ else
+ error ("Invalid command");
+}
+
+