diff options
author | Mark Alexander <marka@cygnus> | 1996-04-22 22:31:10 +0000 |
---|---|---|
committer | Mark Alexander <marka@cygnus> | 1996-04-22 22:31:10 +0000 |
commit | f9fedc48d1d676bbcc6afd2187052d9b4ff804dc (patch) | |
tree | 668d3626af7120334ae0c6a9a583a9f76bb79561 /gdb/corefile.c | |
parent | 6799c638e59e6861940dd4eec6c59f6466db1f69 (diff) | |
download | gdb-f9fedc48d1d676bbcc6afd2187052d9b4ff804dc.zip gdb-f9fedc48d1d676bbcc6afd2187052d9b4ff804dc.tar.gz gdb-f9fedc48d1d676bbcc6afd2187052d9b4ff804dc.tar.bz2 |
* corefile.c (specify_exec_file_hook): Allow arbitrary number of
hooks.
(call_extra_exec_file_hooks): New function.
* h8300-tdep.c: Lint; add .h files to provide missing declarations,
remove unused variables.
(set_machine_hook): New function.
(_initialize_h8300m): Initialize it.
PR 8849.
Diffstat (limited to 'gdb/corefile.c')
-rw-r--r-- | gdb/corefile.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/gdb/corefile.c b/gdb/corefile.c index a916bf8..65ea357 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -36,9 +36,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ extern char registers[]; -/* Hook for `exec_file_command' command to call. */ +/* Local function declarations. */ -void (*exec_file_display_hook) PARAMS ((char *)) = NULL; +static void call_extra_exec_file_hooks PARAMS ((char *filename)); + +/* You can have any number of hooks for `exec_file_command' command to call. + If there's only one hook, it is set in exec_file_display hook. + If there are two or more hooks, they are set in exec_file_extra_hooks[], + and exec_file_display_hook is set to a function that calls all of them. + This extra complexity is needed to preserve compatibility with + old code that assumed that only one hook could be set, and which called + exec_file_display_hook directly. */ + +typedef void (*hook_type) PARAMS ((char *)); + +hook_type exec_file_display_hook; /* the original hook */ +static hook_type *exec_file_extra_hooks; /* array of additional hooks */ +static int exec_file_hook_count = 0; /* size of array */ /* Binary file diddling handle for the core file. */ @@ -67,6 +81,19 @@ core_file_command (filename, from_tty) } +/* If there are two or more functions that wish to hook into exec_file_command, + * this function will call all of the hook functions. */ + +static void +call_extra_exec_file_hooks (filename) + char *filename; +{ + int i; + + for (i = 0; i < exec_file_hook_count; i++) + (*exec_file_extra_hooks[i])(filename); +} + /* Call this to specify the hook for exec_file_command to call back. This is called from the x-window display code. */ @@ -74,7 +101,33 @@ void specify_exec_file_hook (hook) void (*hook) PARAMS ((char *)); { - exec_file_display_hook = hook; + hook_type *new_array; + + if (exec_file_display_hook != NULL) + { + /* There's already a hook installed. Arrange to have both it + * and the subsequent hooks called. */ + if (exec_file_hook_count == 0) + { + /* If this is the first extra hook, initialize the hook array. */ + exec_file_extra_hooks = (hook_type *) xmalloc (sizeof(hook_type)); + exec_file_extra_hooks[0] = exec_file_display_hook; + exec_file_display_hook = call_extra_exec_file_hooks; + exec_file_hook_count = 1; + } + + /* Grow the hook array by one and add the new hook to the end. + Yes, it's inefficient to grow it by one each time but since + this is hardly ever called it's not a big deal. */ + exec_file_hook_count++; + new_array = + (hook_type *) xrealloc (exec_file_extra_hooks, + exec_file_hook_count * sizeof(hook_type)); + exec_file_extra_hooks = new_array; + exec_file_extra_hooks[exec_file_hook_count - 1] = hook; + } + else + exec_file_display_hook = hook; } /* The exec file must be closed before running an inferior. |