summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Thorpe <thorpej@netbsd.org>2002-05-26 20:31:06 +0000
committerJason Thorpe <thorpej@netbsd.org>2002-05-26 20:31:06 +0000
commitddcbc7c6acae54bbeda842a59dd06c474f57ebac (patch)
tree10d53ea068a90c433f2be760ca3972c5b155f39c
parent72e36ef519850c09b159d05cfb7dcc1fae1322b9 (diff)
downloadgdb-ddcbc7c6acae54bbeda842a59dd06c474f57ebac.tar.gz
* ns32k-tdep.c (ns32k_breakpoint_from_pc, ns32k_frame_chain,
ns32k_frame_saved_pc, ns32k_frame_args_address, ns32k_frame_locals_address, ns32k_frame_init_saved_regs, ns32k_push_dummy_frame, ns32k_pop_frame): New functions. * config/ns32k/tm-nbsd.h (FRAME_SAVED_PC): Remove. * config/ns32k/tm-umax.h (INNER_THAN): Define as core_addr_lessthan. (BREAKPOINT_FROM_PC): Define as ns32k_breakpoint_from_pc. (BREAKPOINT): Remove.. (FRAME_CHAIN): Define as ns32k_frame_chain. (FRAME_SAVED_PC): Define as ns32k_frame_saved_pc. (FRAME_ARGS_ADDRESS): Define as ns32k_frame_args_address. (FRAME_LOCALS_ADDRESS): Define as ns32k_frame_locals_address. (FRAME_FIND_SAVED_REGS): Remove. (FRAME_INIT_SAVED_REGS): Define as ns32k_frame_init_saved_regs. (PUSH_DUMMY_FRAME): Define as ns32k_push_dummy_frame. (POP_FRAME): Define as ns32k_pop_frame.
-rw-r--r--gdb/ChangeLog19
-rw-r--r--gdb/config/ns32k/tm-nbsd.h8
-rw-r--r--gdb/config/ns32k/tm-umax.h114
-rw-r--r--gdb/ns32k-tdep.c149
4 files changed, 173 insertions, 117 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index af11644b6da..dba149fa395 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,24 @@
2002-05-26 Jason Thorpe <thorpej@wasabisystems.com>
+ * ns32k-tdep.c (ns32k_breakpoint_from_pc, ns32k_frame_chain,
+ ns32k_frame_saved_pc, ns32k_frame_args_address,
+ ns32k_frame_locals_address, ns32k_frame_init_saved_regs,
+ ns32k_push_dummy_frame, ns32k_pop_frame): New functions.
+ * config/ns32k/tm-nbsd.h (FRAME_SAVED_PC): Remove.
+ * config/ns32k/tm-umax.h (INNER_THAN): Define as core_addr_lessthan.
+ (BREAKPOINT_FROM_PC): Define as ns32k_breakpoint_from_pc.
+ (BREAKPOINT): Remove..
+ (FRAME_CHAIN): Define as ns32k_frame_chain.
+ (FRAME_SAVED_PC): Define as ns32k_frame_saved_pc.
+ (FRAME_ARGS_ADDRESS): Define as ns32k_frame_args_address.
+ (FRAME_LOCALS_ADDRESS): Define as ns32k_frame_locals_address.
+ (FRAME_FIND_SAVED_REGS): Remove.
+ (FRAME_INIT_SAVED_REGS): Define as ns32k_frame_init_saved_regs.
+ (PUSH_DUMMY_FRAME): Define as ns32k_push_dummy_frame.
+ (POP_FRAME): Define as ns32k_pop_frame.
+
+2002-05-26 Jason Thorpe <thorpej@wasabisystems.com>
+
* ns32k-tdep.c (ns32k_register_byte_32082,
ns32k_register_byte_32382, ns32k_register_raw_size,
ns32k_register_virtual_size, ns32k_register_virtual_type): New
diff --git a/gdb/config/ns32k/tm-nbsd.h b/gdb/config/ns32k/tm-nbsd.h
index ae29bcfbfb0..5081c3587aa 100644
--- a/gdb/config/ns32k/tm-nbsd.h
+++ b/gdb/config/ns32k/tm-nbsd.h
@@ -38,14 +38,6 @@
/* Offset to saved PC in sigcontext, from <machine/signal.h>. */
#define SIGCONTEXT_PC_OFFSET 20
-#undef FRAME_SAVED_PC(FRAME)
-#define FRAME_SAVED_PC(FRAME) \
- (((FRAME)->signal_handler_caller \
- ? sigtramp_saved_pc (FRAME) \
- : read_memory_integer ((FRAME)->frame + 4, 4)) \
- )
-
-
/* tm-umax.h assumes a 32082 fpu. We have a 32382 fpu. */
#undef REGISTER_NAME
diff --git a/gdb/config/ns32k/tm-umax.h b/gdb/config/ns32k/tm-umax.h
index 85838668613..8496307d509 100644
--- a/gdb/config/ns32k/tm-umax.h
+++ b/gdb/config/ns32k/tm-umax.h
@@ -52,11 +52,10 @@ extern CORE_ADDR umax_skip_prologue (CORE_ADDR);
/* Stack grows downward. */
-#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
+#define INNER_THAN(lhs,rhs) core_addr_lessthan ((lhs), (rhs))
-/* Sequence of bytes for breakpoint instruction. */
-
-#define BREAKPOINT {0xf2}
+extern const unsigned char *ns32k_breakpoint_from_pc (CORE_ADDR *, int *);
+#define BREAKPOINT_FROM_PC(PCP, LENP) ns32k_breakpoint_from_pc ((PCP), (LENP))
/* Amount PC must be decremented by after a breakpoint.
This is often the number of bytes in BREAKPOINT
@@ -157,116 +156,41 @@ struct type *ns32k_register_virtual_type (int);
/* Describe the pointer in each stack frame to the previous stack frame
(its caller). */
-/* FRAME_CHAIN takes a frame's nominal address
- and produces the frame's chain-pointer. */
-
-/* In the case of the ns32000 series, the frame's nominal address is the FP
- value, and at that address is saved previous FP value as a 4-byte word. */
-
-#define FRAME_CHAIN(thisframe) \
- (!inside_entry_file ((thisframe)->pc) ? \
- read_memory_integer ((thisframe)->frame, 4) :\
- 0)
-
-/* Define other aspects of the stack frame. */
-
-#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
-
-/* Compute base of arguments. */
+CORE_ADDR ns32k_frame_chain (struct frame_info *);
+#define FRAME_CHAIN(thisframe) ns32k_frame_chain ((thisframe))
-#define FRAME_ARGS_ADDRESS(fi) \
- ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \
- ((fi)->frame) : (read_register (SP_REGNUM) - 4))
+CORE_ADDR ns32k_frame_saved_pc (struct frame_info *);
+#define FRAME_SAVED_PC(FRAME) ns32k_frame_saved_pc ((FRAME))
-#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
+CORE_ADDR ns32k_frame_args_address (struct frame_info *);
+#define FRAME_ARGS_ADDRESS(fi) ns32k_frame_args_address ((fi))
-/* Get the address of the enter opcode for this function, if it is active.
- Returns positive address > 1 if pc is between enter/exit,
- 1 if pc before enter or after exit, 0 otherwise. */
-
-extern CORE_ADDR ns32k_get_enter_addr (CORE_ADDR);
+CORE_ADDR ns32k_frame_locals_address (struct frame_info *);
+#define FRAME_LOCALS_ADDRESS(fi) ns32k_frame_locals_address ((fi))
/* Return number of args passed to a frame.
Can return -1, meaning no way to tell. */
-extern int umax_frame_num_args (struct frame_info *fi);
+extern int umax_frame_num_args (struct frame_info *);
#define FRAME_NUM_ARGS(fi) (umax_frame_num_args ((fi)))
/* Return number of bytes at start of arglist that are not really args. */
#define FRAME_ARGS_SKIP 8
-/* Put here the code to store, into a struct frame_saved_regs,
- the addresses of the saved registers of frame described by FRAME_INFO.
- This includes special registers such as pc and fp saved in special
- ways in the stack frame. sp is even more special:
- the address we return for it IS the sp for the next frame. */
-
-extern int ns32k_localcount (CORE_ADDR enter_pc);
-
-#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
-{ \
- register int regmask, regnum; \
- int localcount; \
- register CORE_ADDR enter_addr; \
- register CORE_ADDR next_addr; \
- \
- memset (&(frame_saved_regs), '\0', sizeof (frame_saved_regs)); \
- enter_addr = ns32k_get_enter_addr ((frame_info)->pc); \
- if (enter_addr > 1) \
- { \
- regmask = read_memory_integer (enter_addr+1, 1) & 0xff; \
- localcount = ns32k_localcount (enter_addr); \
- next_addr = (frame_info)->frame + localcount; \
- for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \
- (frame_saved_regs).regs[regnum] = (regmask & 1) ? \
- (next_addr -= 4) : 0; \
- (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\
- (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\
- (frame_saved_regs).regs[FP_REGNUM] = \
- (read_memory_integer ((frame_info)->frame, 4));\
- } \
- else if (enter_addr == 1) \
- { \
- CORE_ADDR sp = read_register (SP_REGNUM); \
- (frame_saved_regs).regs[PC_REGNUM] = sp; \
- (frame_saved_regs).regs[SP_REGNUM] = sp + 4; \
- } \
-}
+void ns32k_frame_init_saved_regs (struct frame_info *);
+#define FRAME_INIT_SAVED_REGS(FI) ns32k_frame_init_saved_regs ((FI))
+
/* Things needed for making the inferior call functions. */
-/* Push an empty stack frame, to record the current PC, etc. */
-
-#define PUSH_DUMMY_FRAME \
-{ register CORE_ADDR sp = read_register (SP_REGNUM);\
- register int regnum; \
- sp = push_word (sp, read_register (PC_REGNUM)); \
- sp = push_word (sp, read_register (FP_REGNUM)); \
- write_register (FP_REGNUM, sp); \
- for (regnum = 0; regnum < 8; regnum++) \
- sp = push_word (sp, read_register (regnum)); \
- write_register (SP_REGNUM, sp); \
-}
+extern void ns32k_push_dummy_frame (void);
+#define PUSH_DUMMY_FRAME ns32k_push_dummy_frame ()
/* Discard from the stack the innermost frame, restoring all registers. */
-#define POP_FRAME \
-{ register struct frame_info *frame = get_current_frame (); \
- register CORE_ADDR fp; \
- register int regnum; \
- struct frame_saved_regs fsr; \
- struct frame_info *fi; \
- fp = frame->frame; \
- get_frame_saved_regs (frame, &fsr); \
- for (regnum = 0; regnum < 8; regnum++) \
- if (fsr.regs[regnum]) \
- write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
- write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
- write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
- write_register (SP_REGNUM, fp + 8); \
- flush_cached_frames (); \
-}
+extern void ns32k_pop_frame (void);
+#define POP_FRAME ns32k_pop_frame ()
/* This sequence of words is the instructions
enter 0xff,0 82 ff 00
diff --git a/gdb/ns32k-tdep.c b/gdb/ns32k-tdep.c
index f6fb85fad2f..42c6456fabb 100644
--- a/gdb/ns32k-tdep.c
+++ b/gdb/ns32k-tdep.c
@@ -24,6 +24,8 @@
#include "gdbcore.h"
static int sign_extend (int value, int bits);
+static CORE_ADDR ns32k_get_enter_addr (CORE_ADDR);
+static int ns32k_localcount (CORE_ADDR enter_pc);
char *
ns32k_register_name_32082 (int regno)
@@ -136,6 +138,15 @@ umax_skip_prologue (CORE_ADDR pc)
}
return pc;
}
+
+const unsigned char *
+ns32k_breakpoint_from_pc (CORE_ADDR *pcp, int *lenp)
+{
+ static const unsigned char breakpoint_insn[] = { 0xf2 };
+
+ *lenp = sizeof (breakpoint_insn);
+ return breakpoint_insn;
+}
/* Return number of args passed to a frame.
Can return -1, meaning no way to tell.
@@ -208,11 +219,11 @@ flip_bytes (void *p, int count)
}
}
-/* Return the number of locals in the current frame given a pc
- pointing to the enter instruction. This is used in the macro
- FRAME_FIND_SAVED_REGS. */
+/* Return the number of locals in the current frame given a
+ pc pointing to the enter instruction. This is used by
+ ns32k_frame_init_saved_regs. */
-int
+static int
ns32k_localcount (CORE_ADDR enter_pc)
{
unsigned char localtype;
@@ -241,16 +252,10 @@ ns32k_about_to_return (CORE_ADDR pc)
return (read_memory_integer (pc, 1) == 0x12);
}
-
-/*
- * Get the address of the enter opcode for the function
- * containing PC, if there is an enter for the function,
- * and if the pc is between the enter and exit.
- * Returns positive address if pc is between enter/exit,
- * 1 if pc before enter or after exit, 0 otherwise.
- */
-
-CORE_ADDR
+/* Get the address of the enter opcode for this function, if it is active.
+ Returns positive address > 1 if pc is between enter/exit,
+ 1 if pc before enter or after exit, 0 otherwise. */
+static CORE_ADDR
ns32k_get_enter_addr (CORE_ADDR pc)
{
CORE_ADDR enter_addr;
@@ -275,6 +280,122 @@ ns32k_get_enter_addr (CORE_ADDR pc)
return enter_addr; /* pc is between enter and exit */
}
+CORE_ADDR
+ns32k_frame_chain (struct frame_info *frame)
+{
+ /* In the case of the NS32000 series, the frame's nominal address is the
+ FP value, and that address is saved at the previous FP value as a
+ 4-byte word. */
+
+ if (inside_entry_file (frame->pc))
+ return 0;
+
+ return (read_memory_integer (frame->frame, 4));
+}
+
+CORE_ADDR
+ns32k_frame_saved_pc (struct frame_info *frame)
+{
+ if (frame->signal_handler_caller)
+ return (sigtramp_saved_pc (frame)); /* XXXJRT */
+
+ return (read_memory_integer (frame->frame + 4, 4));
+}
+
+CORE_ADDR
+ns32k_frame_args_address (struct frame_info *frame)
+{
+ if (ns32k_get_enter_addr (frame->pc) > 1)
+ return (frame->frame);
+
+ return (read_register (SP_REGNUM) - 4);
+}
+
+CORE_ADDR
+ns32k_frame_locals_address (struct frame_info *frame)
+{
+ return (frame->frame);
+}
+
+/* Code to initialize the addresses of the saved registers of frame described
+ by FRAME_INFO. This includes special registers such as pc and fp saved in
+ special ways in the stack frame. sp is even more special: the address we
+ return for it IS the sp for the next frame. */
+
+void
+ns32k_frame_init_saved_regs (struct frame_info *frame)
+{
+ int regmask, regnum;
+ int localcount;
+ CORE_ADDR enter_addr, next_addr;
+
+ if (frame->saved_regs)
+ return;
+
+ frame_saved_regs_zalloc (frame);
+
+ enter_addr = ns32k_get_enter_addr (frame->pc);
+ if (enter_addr > 1)
+ {
+ regmask = read_memory_integer (enter_addr + 1, 1) & 0xff;
+ localcount = ns32k_localcount (enter_addr);
+ next_addr = frame->frame + localcount;
+
+ for (regnum = 0; regnum < 8; regnum++)
+ {
+ if (regmask & (1 << regnum))
+ frame->saved_regs[regnum] = next_addr -= 4;
+ }
+
+ frame->saved_regs[SP_REGNUM] = frame->frame + 4;
+ frame->saved_regs[PC_REGNUM] = frame->frame + 4;
+ frame->saved_regs[FP_REGNUM] = read_memory_integer (frame->frame, 4);
+ }
+ else if (enter_addr == 1)
+ {
+ CORE_ADDR sp = read_register (SP_REGNUM);
+ frame->saved_regs[PC_REGNUM] = sp;
+ frame->saved_regs[SP_REGNUM] = sp + 4;
+ }
+}
+
+void
+ns32k_push_dummy_frame (void)
+{
+ CORE_ADDR sp = read_register (SP_REGNUM);
+ int regnum;
+
+ sp = push_word (sp, read_register (PC_REGNUM));
+ sp = push_word (sp, read_register (FP_REGNUM));
+ write_register (FP_REGNUM, sp);
+
+ for (regnum = 0; regnum < 8; regnum++)
+ sp = push_word (sp, read_register (regnum));
+
+ write_register (SP_REGNUM, sp);
+}
+
+void
+ns32k_pop_frame (void)
+{
+ struct frame_info *frame = get_current_frame ();
+ CORE_ADDR fp;
+ int regnum;
+
+ fp = frame->frame;
+ FRAME_INIT_SAVED_REGS (frame);
+
+ for (regnum = 0; regnum < 8; regnum++)
+ if (frame->saved_regs[regnum])
+ write_register (regnum,
+ read_memory_integer (frame->saved_regs[regnum], 4));
+
+ write_register (FP_REGNUM, read_memory_integer (fp, 4));
+ write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));
+ write_register (SP_REGNUM, fp + 8);
+ flush_cached_frames ();
+}
+
void
_initialize_ns32k_tdep (void)
{