#include "symfile.h"
#include "gdbcore.h"
#include "inferior.h"
+#include "arch-utils.h"
+#include "gdb_string.h"
/* Functions declared and used only in this file */
void _initialize_mcore (void);
-void mcore_init_extra_frame_info (struct frame_info *fi);
+void mcore_init_extra_frame_info (int fromleaf, struct frame_info *fi);
CORE_ADDR mcore_frame_saved_pc (struct frame_info *fi);
CORE_ADDR mcore_push_return_address (CORE_ADDR pc, CORE_ADDR sp);
CORE_ADDR mcore_push_arguments (int nargs, struct value ** args, CORE_ADDR sp,
- unsigned char struct_return, CORE_ADDR struct_addr);
+ int struct_return, CORE_ADDR struct_addr);
-void mcore_pop_frame (struct frame_info *fi);
+void mcore_pop_frame ();
CORE_ADDR mcore_skip_prologue (CORE_ADDR pc);
#define MCORE_REG_SIZE 4
#define MCORE_NUM_REGS 65
+/* Some useful register numbers. */
+#define PR_REGNUM 15
+#define FIRST_ARGREG 2
+#define LAST_ARGREG 7
+#define RETVAL_REGNUM 2
+
/* Additional info that we use for managing frames */
struct frame_extra_info
return breakpoint;
}
+static CORE_ADDR
+mcore_saved_pc_after_call (struct frame_info *frame)
+{
+ return read_register (PR_REGNUM);
+}
+
+/* This is currently handled by init_extra_frame_info. */
+static void
+mcore_frame_init_saved_regs (struct frame_info *frame)
+{
+
+}
+
+/* This is currently handled by mcore_push_arguments */
+static void
+mcore_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
+{
+
+}
+
+static int
+mcore_reg_struct_has_addr (int gcc_p, struct type *type)
+{
+ return 0;
+}
+
+
/* Helper function for several routines below. This funtion simply
sets up a fake, aka dummy, frame (not a _call_ dummy frame) that
we can analyze with mcore_analyze_prologue. */
return addr;
}
-/* Given a GDB frame, determine the address of the calling function's frame.
- This will be used to create a new GDB frame struct, and then
- INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame. */
+/* Given a GDB frame, determine the address of the calling function's
+ frame. This will be used to create a new GDB frame struct, and
+ then INIT_EXTRA_FRAME_INFO and DEPRECATED_INIT_FRAME_PC will be
+ called for the new frame. */
CORE_ADDR
mcore_frame_chain (struct frame_info * fi)
{
for (; fi != NULL; fi = fi->next)
{
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
- return generic_read_register_dummy (fi->pc, fi->frame, regnum);
+ if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+ return deprecated_read_register_dummy (fi->pc, fi->frame, regnum);
else if (fi->saved_regs[regnum] != 0)
return read_memory_integer (fi->saved_regs[regnum],
REGISTER_SIZE);
mcore_frame_saved_pc (struct frame_info * fi)
{
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
- return generic_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
+ if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+ return deprecated_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
else
return mcore_find_callers_reg (fi, PR_REGNUM);
}
command, or the call dummy breakpoint gets hit. */
void
-mcore_pop_frame (struct frame_info *fi)
+mcore_pop_frame (void)
{
int rn;
+ struct frame_info *fi = get_current_frame ();
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+ if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
generic_pop_dummy_frame ();
else
{
}
/* Actually cut back the stack. */
- write_register (SP_REGNUM, FRAME_FP (fi));
+ write_register (SP_REGNUM, get_frame_base (fi));
}
/* Finally, throw away any cached frame information. */
CORE_ADDR
mcore_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
- unsigned char struct_return, CORE_ADDR struct_addr)
+ int struct_return, CORE_ADDR struct_addr)
{
int argreg;
int argnum;
zeros = alloca (return_size);
memset (zeros, 0, return_size);
- write_register_bytes (REGISTER_BYTE (RETVAL_REGNUM), zeros, return_size);
- write_register_bytes (offset, valbuf, value_size);
+ deprecated_write_register_bytes (REGISTER_BYTE (RETVAL_REGNUM), zeros,
+ return_size);
+ deprecated_write_register_bytes (offset, valbuf, value_size);
}
/* Initialize our target-dependent "stuff" for this newly created frame.
the prologue of this frame. */
void
-mcore_init_extra_frame_info (struct frame_info *fi)
+mcore_init_extra_frame_info (int fromleaf, struct frame_info *fi)
{
- if (fi->next)
+ if (fi && fi->next)
fi->pc = FRAME_SAVED_PC (fi->next);
frame_saved_regs_zalloc (fi);
fi->extra_info->status = 0;
fi->extra_info->framesize = 0;
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+ if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
{
/* We need to setup fi->frame here because run_stack_dummy gets it wrong
by assuming it's always FP. */
- fi->frame = generic_read_register_dummy (fi->pc, fi->frame, SP_REGNUM);
+ fi->frame = deprecated_read_register_dummy (fi->pc, fi->frame, SP_REGNUM);
}
else
mcore_analyze_prologue (fi, 0, 0);
gdbarch = gdbarch_alloc (&info, 0);
+ /* NOTE: cagney/2002-12-06: This can be deleted when this arch is
+ ready to unwind the PC first (see frame.c:get_prev_frame()). */
+ set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
+
+ /* Registers: */
+
/* All registers are 32 bits */
set_gdbarch_register_size (gdbarch, MCORE_REG_SIZE);
set_gdbarch_max_register_raw_size (gdbarch, MCORE_REG_SIZE);
set_gdbarch_max_register_virtual_size (gdbarch, MCORE_REG_SIZE);
-
set_gdbarch_register_name (gdbarch, mcore_register_name);
set_gdbarch_register_virtual_type (gdbarch, mcore_register_virtual_type);
set_gdbarch_register_virtual_size (gdbarch, mcore_register_size);
set_gdbarch_register_raw_size (gdbarch, mcore_register_size);
set_gdbarch_register_byte (gdbarch, mcore_register_byte);
+ set_gdbarch_register_bytes (gdbarch, MCORE_REG_SIZE * MCORE_NUM_REGS);
+ set_gdbarch_num_regs (gdbarch, MCORE_NUM_REGS);
+ set_gdbarch_pc_regnum (gdbarch, 64);
+ set_gdbarch_sp_regnum (gdbarch, 0);
+ set_gdbarch_fp_regnum (gdbarch, 0);
+
+ /* Call Dummies: */
set_gdbarch_call_dummy_p (gdbarch, 1);
- set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
set_gdbarch_call_dummy_words (gdbarch, call_dummy_words);
set_gdbarch_sizeof_call_dummy_words (gdbarch, 0);
set_gdbarch_call_dummy_start_offset (gdbarch, 0);
set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
- set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
- set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy);
set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
+ set_gdbarch_saved_pc_after_call (gdbarch, mcore_saved_pc_after_call);
+ set_gdbarch_function_start_offset (gdbarch, 0);
+ set_gdbarch_decr_pc_after_break (gdbarch, 0);
+ set_gdbarch_breakpoint_from_pc (gdbarch, mcore_breakpoint_from_pc);
+ set_gdbarch_push_return_address (gdbarch, mcore_push_return_address);
+ set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
+ set_gdbarch_push_arguments (gdbarch, mcore_push_arguments);
+ set_gdbarch_call_dummy_length (gdbarch, 0);
+
+ /* Frames: */
+
+ set_gdbarch_init_extra_frame_info (gdbarch, mcore_init_extra_frame_info);
+ set_gdbarch_frame_chain (gdbarch, mcore_frame_chain);
+ set_gdbarch_frame_chain_valid (gdbarch, generic_func_frame_chain_valid);
+ set_gdbarch_frame_init_saved_regs (gdbarch, mcore_frame_init_saved_regs);
+ set_gdbarch_frame_saved_pc (gdbarch, mcore_frame_saved_pc);
+ set_gdbarch_deprecated_store_return_value (gdbarch, mcore_store_return_value);
+ set_gdbarch_deprecated_extract_return_value (gdbarch,
+ mcore_extract_return_value);
+ set_gdbarch_store_struct_return (gdbarch, mcore_store_struct_return);
+ set_gdbarch_deprecated_extract_struct_value_address (gdbarch,
+ mcore_extract_struct_value_address);
+ set_gdbarch_skip_prologue (gdbarch, mcore_skip_prologue);
+ set_gdbarch_frame_args_skip (gdbarch, 0);
+ set_gdbarch_frame_args_address (gdbarch, mcore_frame_args_address);
+ set_gdbarch_frame_locals_address (gdbarch, mcore_frame_locals_address);
+ set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
+ set_gdbarch_pop_frame (gdbarch, mcore_pop_frame);
+ set_gdbarch_virtual_frame_pointer (gdbarch, mcore_virtual_frame_pointer);
+
+ /* Misc.: */
+
+ /* Stack grows down. */
+ set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
+ set_gdbarch_use_struct_convention (gdbarch, mcore_use_struct_convention);
+ set_gdbarch_believe_pcc_promotion (gdbarch, 1);
+ /* MCore will never pass a sturcture by reference. It will always be split
+ between registers and stack. */
+ set_gdbarch_reg_struct_has_addr (gdbarch, mcore_reg_struct_has_addr);
return gdbarch;
}