diff options
author | Fernando Nasser <fnasser@redhat.com> | 2000-11-06 22:44:34 +0000 |
---|---|---|
committer | Fernando Nasser <fnasser@redhat.com> | 2000-11-06 22:44:34 +0000 |
commit | 73bc900df9bcfe3ce24453219d2303fafb1395de (patch) | |
tree | 907962cd2f5627b8eaa9fb92616a178ae33bf764 /gdb/command.c | |
parent | 7152f1dc4515cb14067fed4c5d5b5374f0d475b4 (diff) | |
download | gdb-73bc900df9bcfe3ce24453219d2303fafb1395de.zip gdb-73bc900df9bcfe3ce24453219d2303fafb1395de.tar.gz gdb-73bc900df9bcfe3ce24453219d2303fafb1395de.tar.bz2 |
2000-11-06 Fernando Nasser <fnasser@cygnus.com>
From Steven Johnson <sbjohnson@ozemail.com.au>:
This set of changes add "hookpost-" as an expansion on the original
hooking of commands to GDB. A Hook may now be run "AFTER" execution of
a command as well as before.
* command.h (struct cmd_list_element): Changed elements hook and hookee
to hook_pre and hookee_pre respectively. Added hook_post and hookee_post
for the post hook command operation. Added hook_in so that an executing
hook can be flagged to prevent recursion.
* command.c (add_cmd): Changed initilization of cmd_list_element to
reflect above changes.
(delete_cmd): Remove both pre and post hooks.
(help_cmd): Notify that the command has pre and/or post hooks.
* infrun.c (normal_stop): Change references to hook_pre from hook.
* top.c (execute_command): Run both pre and post hooks.
(define_command): Allow definition of both pre and post hooks.
The definition of pre-hooks is done as before, with the "hook-"
prefix for backward compatibility.
Diffstat (limited to 'gdb/command.c')
-rw-r--r-- | gdb/command.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/gdb/command.c b/gdb/command.c index 3b59d33..6e64de4 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -112,7 +112,9 @@ add_cmd (char *name, enum command_class class, void (*fun) (char *, int), c->doc = doc; c->flags = 0; c->replacement = NULL; - c->hook = NULL; + c->hook_pre = NULL; + c->hook_post = NULL; + c->hook_in = 0; c->prefixlist = NULL; c->prefixname = NULL; c->allow_unknown = 0; @@ -123,7 +125,8 @@ add_cmd (char *name, enum command_class class, void (*fun) (char *, int), c->var_type = var_boolean; c->enums = NULL; c->user_commands = NULL; - c->hookee = NULL; + c->hookee_pre = NULL; + c->hookee_post = NULL; c->cmd_pointer = NULL; return c; @@ -366,8 +369,10 @@ delete_cmd (char *name, struct cmd_list_element **list) while (*list && STREQ ((*list)->name, name)) { - if ((*list)->hookee) - (*list)->hookee->hook = 0; /* Hook slips out of its mouth */ + if ((*list)->hookee_pre) + (*list)->hookee_pre->hook_pre = 0; /* Hook slips out of its mouth */ + if ((*list)->hookee_post) + (*list)->hookee_post->hook_post = 0; /* Hook slips out of its bottom */ p = (*list)->next; free ((PTR) * list); *list = p; @@ -378,8 +383,11 @@ delete_cmd (char *name, struct cmd_list_element **list) { if (STREQ (c->next->name, name)) { - if (c->next->hookee) - c->next->hookee->hook = 0; /* hooked cmd gets away. */ + if (c->next->hookee_pre) + c->next->hookee_pre->hook_pre = 0; /* hooked cmd gets away. */ + if (c->next->hookee_post) + c->next->hookee_post->hook_post = 0; /* remove post hook */ + /* :( no fishing metaphore */ p = c->next->next; free ((PTR) c->next); c->next = p; @@ -531,9 +539,18 @@ help_cmd (char *command, struct ui_file *stream) if (c->function.cfunc == NULL) help_list (cmdlist, "", c->class, stream); - if (c->hook) - fprintf_filtered (stream, "\nThis command has a hook defined: %s\n", - c->hook->name); + if (c->hook_pre || c->hook_post) + fprintf_filtered (stream, + "\nThis command has a hook (or hooks) defined:\n"); + + if (c->hook_pre) + fprintf_filtered (stream, + "\tThis command is run after : %s (pre hook)\n", + c->hook_pre->name); + if (c->hook_post) + fprintf_filtered (stream, + "\tThis command is run before : %s (post hook)\n", + c->hook_post->name); } /* |