aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-03-19 02:19:17 +0000
committerAndrew Cagney <cagney@redhat.com>2002-03-19 02:19:17 +0000
commit7d0766f3c30e00dd87a789de68e93eb1df8f24da (patch)
treefd21ec664c292791c16e3e6c57af4b2664c1d6d5
parent42aacdb61cdc52f380808edd95940d0502cb38bf (diff)
downloadgdb-7d0766f3c30e00dd87a789de68e93eb1df8f24da.zip
gdb-7d0766f3c30e00dd87a789de68e93eb1df8f24da.tar.gz
gdb-7d0766f3c30e00dd87a789de68e93eb1df8f24da.tar.bz2
* command.h (struct cmd_list_element): Add field context.
(set_cmd_context, get_cmd_context): Declare. * cli/cli-decode.h: Ditto. * cli/cli-decode.c (get_cmd_context): New function. (set_cmd_context): New function. (add_cmd): Initialize context. Part of fixing PR gdb/145 and PR gdb/146.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/cli/cli-decode.c13
-rw-r--r--gdb/cli/cli-decode.h7
-rw-r--r--gdb/command.h8
4 files changed, 38 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 682cc5c..90118cb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2002-03-18 Andrew Cagney <ac131313@redhat.com>
+
+ * command.h (struct cmd_list_element): Add field context.
+ (set_cmd_context, get_cmd_context): Declare.
+ * cli/cli-decode.h: Ditto.
+ * cli/cli-decode.c (get_cmd_context): New function.
+ (set_cmd_context): New function.
+ (add_cmd): Initialize context.
+ Part of fixing PR gdb/145 and PR gdb/146.
+
2002-03-17 Andrew Cagney <ac131313@redhat.com>
* cli/cli-decode.c (cmd_type): New function.
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 1568e31..28db5f9 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -86,6 +86,18 @@ cmd_cfunc_eq (struct cmd_list_element *cmd,
return cmd->func == do_cfunc && cmd->function.cfunc == cfunc;
}
+void
+set_cmd_context (struct cmd_list_element *cmd, void *context)
+{
+ cmd->context = context;
+}
+
+void *
+get_cmd_context (struct cmd_list_element *cmd)
+{
+ return cmd->context;
+}
+
enum cmd_types
cmd_type (struct cmd_list_element *cmd)
{
@@ -146,6 +158,7 @@ add_cmd (char *name, enum command_class class, void (*fun) (char *, int),
c->name = name;
c->class = class;
set_cmd_cfunc (c, fun);
+ set_cmd_context (c, NULL);
c->doc = doc;
c->flags = 0;
c->replacement = NULL;
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 51ca781..adb9feb 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -139,6 +139,9 @@ struct cmd_list_element
}
function;
+ /* Local state (context) for this command. This can be anything. */
+ void *context;
+
/* Documentation of this command (or help topic).
First line is brief documentation; remaining lines form, with it,
the full documentation. First line should end with a period.
@@ -294,6 +297,10 @@ extern void set_cmd_completer (struct cmd_list_element *cmd,
extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
void (*cfunc) (char *args, int from_tty));
+/* Access to the command's local context. */
+extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
+extern void *get_cmd_context (struct cmd_list_element *cmd);
+
extern struct cmd_list_element *lookup_cmd (char **,
struct cmd_list_element *, char *,
int, int);
diff --git a/gdb/command.h b/gdb/command.h
index fffa3be..5f7284e 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -145,6 +145,9 @@ struct cmd_list_element
}
function;
+ /* Local state (context) for this command. This can be anything. */
+ void *context;
+
/* Documentation of this command (or help topic).
First line is brief documentation; remaining lines form, with it,
the full documentation. First line should end with a period.
@@ -300,6 +303,11 @@ extern void set_cmd_completer (struct cmd_list_element *cmd,
extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
void (*cfunc) (char *args, int from_tty));
+/* Each command object has a local context attached to it. . */
+extern void set_cmd_context (struct cmd_list_element *cmd, void *context);
+extern void *get_cmd_context (struct cmd_list_element *cmd);
+
+
/* Execute CMD's pre/post hook. Throw an error if the command fails.
If already executing this pre/post hook, or there is no pre/post
hook, the call is silently ignored. */