aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMark Alexander <marka@cygnus>1996-04-22 22:31:10 +0000
committerMark Alexander <marka@cygnus>1996-04-22 22:31:10 +0000
commitf9fedc48d1d676bbcc6afd2187052d9b4ff804dc (patch)
tree668d3626af7120334ae0c6a9a583a9f76bb79561 /gdb
parent6799c638e59e6861940dd4eec6c59f6466db1f69 (diff)
downloadgdb-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')
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/corefile.c59
-rw-r--r--gdb/h8300-tdep.c33
3 files changed, 91 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1c1899b..1765eaa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+Mon Apr 22 14:54:45 1996 Mark Alexander <marka@superball.cygnus.com>
+
+ * 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.
+
Fri Apr 19 15:03:49 1996 Ian Lance Taylor <ian@cygnus.com>
* remote-mips.c (encoding): Don't specify size, to avoid bug in
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.
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 954e258..32581e9 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -29,6 +29,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "dis-asm.h"
#include "gdbcmd.h"
#include "gdbtypes.h"
+#include "gdbcore.h"
+#include "gdb_string.h"
+#include "value.h"
+
#undef NUM_REGS
#define NUM_REGS 11
@@ -52,7 +56,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define IS_MOVK_R5(x) (x==0x7905)
#define IS_SUB_R5SP(x) (x==0x1957)
+/* Local function declarations. */
+
static CORE_ADDR examine_prologue ();
+static void set_machine_hook PARAMS ((char *filename));
void frame_find_saved_regs ();
CORE_ADDR
@@ -137,9 +144,6 @@ frame_find_saved_regs (fi, fsr)
struct frame_info *fi;
struct frame_saved_regs *fsr;
{
- register CORE_ADDR next_addr;
- register CORE_ADDR *saved_regs;
- register int regnum;
register struct frame_saved_regs *cache_fsr;
extern struct obstack frame_cache_obstack;
CORE_ADDR ip;
@@ -212,12 +216,8 @@ examine_prologue (ip, limit, after_prolog_fp, fsr, fi)
{
register CORE_ADDR next_ip;
int r;
- int i;
int have_fp = 0;
- register int src;
- register struct pic_prologue_code *pcode;
INSN_WORD insn_word;
- int size, offset;
/* Number of things pushed onto stack, starts at 2/4, 'cause the
PC is already there */
unsigned int reg_save_depth = h8300hmode ? 4 : 2;
@@ -378,7 +378,7 @@ h8300_pop_frame ()
for (regnum = 0; regnum < 8; regnum++)
{
if (fsr.regs[regnum])
- write_register (regnum, read_memory_integer(fsr.regs[regnum]), BINWORD);
+ write_register (regnum, read_memory_integer(fsr.regs[regnum], BINWORD));
flush_cached_frames ();
}
@@ -410,6 +410,19 @@ set_machine (args, from_tty)
help_list (setmemorylist, "set memory ", -1, gdb_stdout);
}
+/* set_machine_hook is called as the exec file is being opened, but
+ before the symbol file is opened. This allows us to set the
+ h8300hmode flag based on the machine type specified in the exec
+ file. This in turn will cause subsequently defined pointer types
+ to be 16 or 32 bits as appropriate for the machine. */
+
+static void
+set_machine_hook (filename)
+ char *filename;
+{
+ h8300hmode = (bfd_get_mach (exec_bfd) == bfd_mach_h8300h);
+}
+
void
_initialize_h8300m ()
{
@@ -422,6 +435,10 @@ _initialize_h8300m ()
add_cmd ("h8300h", class_support, h8300h_command,
"Set machine to be H8/300H.", &setmemorylist);
+
+ /* Add a hook to set the machine type when we're loading a file. */
+
+ specify_exec_file_hook(set_machine_hook);
}