#include "defs.h"
#include "frame.h"
-#include "obstack.h"
#include "symtab.h"
#include "symfile.h"
#include "gdbtypes.h"
#include "regcache.h"
#include "doublest.h"
-#include "elf-bfd.h"
+#include "sh-tdep.h"
+#include "elf-bfd.h"
#include "solib-svr4.h"
-#include "elf-bfd.h"
/* sh64 flags */
#include "elf/sh.h"
/* registers numbers shared with the simulator */
-#include "gdb/sim-sh64.h"
-
-#undef XMALLOC
-#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
+#include "gdb/sim-sh.h"
void (*sh_show_regs) (void);
CORE_ADDR (*skip_prologue_hard_way) (CORE_ADDR);
int f_offset;
};
-static char *
+static const char *
sh_generic_register_name (int reg_nr)
{
static char *register_names[] =
return register_names[reg_nr];
}
-static char *
+static const char *
sh_sh_register_name (int reg_nr)
{
static char *register_names[] =
return register_names[reg_nr];
}
-static char *
+static const char *
sh_sh3_register_name (int reg_nr)
{
static char *register_names[] =
return register_names[reg_nr];
}
-static char *
+static const char *
sh_sh3e_register_name (int reg_nr)
{
static char *register_names[] =
return register_names[reg_nr];
}
-static char *
+static const char *
sh_sh_dsp_register_name (int reg_nr)
{
static char *register_names[] =
return register_names[reg_nr];
}
-static char *
+static const char *
sh_sh3_dsp_register_name (int reg_nr)
{
static char *register_names[] =
return register_names[reg_nr];
}
-static char *
+static const char *
sh_sh4_register_name (int reg_nr)
{
static char *register_names[] =
return register_names[reg_nr];
}
-static char *
+static const char *
sh_sh64_register_name (int reg_nr)
{
static char *register_names[] =
static int
sh_use_struct_convention (int gcc_p, struct type *type)
{
+#if 0
return (TYPE_LENGTH (type) > 1);
+#else
+ int len = TYPE_LENGTH (type);
+ int nelem = TYPE_NFIELDS (type);
+ return ((len != 1 && len != 2 && len != 4 && len != 8) || nelem != 1) &&
+ (len != 8 || TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) != 4);
+#endif
}
static int
static int
gdb_print_insn_sh (bfd_vma memaddr, disassemble_info *info)
{
- if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
- return print_insn_sh (memaddr, info);
- else
- return print_insn_shl (memaddr, info);
-}
-
-/* Disassemble an instruction. */
-static int
-gdb_print_insn_sh64 (bfd_vma memaddr, disassemble_info *info)
-{
- if (pc_is_isa32 (memaddr))
- {
- /* Round down the instruction address to the appropriate boundary
- before disassembling it. */
- return print_insn_sh64x_media (UNMAKE_ISA32_ADDR (memaddr), info);
- }
- else
- {
- if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
- return print_insn_sh (memaddr, info);
- else
- return print_insn_shl (memaddr, info);
- }
+ info->endian = TARGET_BYTE_ORDER;
+ return print_insn_sh (memaddr, info);
}
/* Given a GDB frame, determine the address of the calling function's frame.
if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
/* When the caller requests PR from the dummy frame, we return PC because
that's where the previous routine appears to have done a call from. */
- return generic_read_register_dummy (fi->pc, fi->frame, regnum);
+ return deprecated_read_register_dummy (fi->pc, fi->frame, regnum);
else
{
FRAME_INIT_SAVED_REGS (fi);
if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
/* When the caller requests PR from the dummy frame, we return PC because
that's where the previous routine appears to have done a call from. */
- return generic_read_register_dummy (fi->pc, fi->frame, pr_regnum);
+ return deprecated_read_register_dummy (fi->pc, fi->frame, pr_regnum);
else
{
FRAME_INIT_SAVED_REGS (fi);
int opc;
int insn;
int r3_val = 0;
- char *dummy_regs = generic_find_dummy_frame (fi->pc, fi->frame);
+ char *dummy_regs = deprecated_generic_find_dummy_frame (fi->pc, fi->frame);
if (fi->saved_regs == NULL)
frame_saved_regs_zalloc (fi);
static void
sh64_nofp_frame_init_saved_regs (struct frame_info *fi)
{
- int *where = (int *) alloca ((NUM_REGS + NUM_PSEUDO_REGS) * sizeof(int));
+ int *where = (int *) alloca ((NUM_REGS + NUM_PSEUDO_REGS) * sizeof (int));
int rn;
int have_fp = 0;
int fp_regnum;
int insn_size;
int gdb_register_number;
int register_number;
- char *dummy_regs = generic_find_dummy_frame (fi->pc, fi->frame);
+ char *dummy_regs = deprecated_generic_find_dummy_frame (fi->pc, fi->frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
if (fi->saved_regs == NULL)
static void
sh_fp_frame_init_saved_regs (struct frame_info *fi)
{
- int where[NUM_REGS + NUM_PSEUDO_REGS];
+ int *where = (int *) alloca ((NUM_REGS + NUM_PSEUDO_REGS) * sizeof (int));
int rn;
int have_fp = 0;
int depth;
int opc;
int insn;
int r3_val = 0;
- char *dummy_regs = generic_find_dummy_frame (fi->pc, fi->frame);
+ char *dummy_regs = deprecated_generic_find_dummy_frame (fi->pc, fi->frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
if (fi->saved_regs == NULL)
{
/* 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->extra_info->return_pc = generic_read_register_dummy (fi->pc,
- fi->frame,
- PC_REGNUM);
+ fi->frame = deprecated_read_register_dummy (fi->pc, fi->frame,
+ SP_REGNUM);
+ fi->extra_info->return_pc = deprecated_read_register_dummy (fi->pc,
+ fi->frame,
+ PC_REGNUM);
fi->extra_info->f_offset = -(CALL_DUMMY_LENGTH + 4);
fi->extra_info->leaf_function = 0;
return;
{
/* 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);
fi->extra_info->return_pc =
- generic_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
+ deprecated_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
fi->extra_info->f_offset = -(CALL_DUMMY_LENGTH + 4);
fi->extra_info->leaf_function = 0;
return;
*lval = not_lval;
if (raw_buffer)
memcpy (raw_buffer,
- generic_find_dummy_frame (frame->pc, frame->frame) +
- REGISTER_BYTE (regnum),
+ (deprecated_generic_find_dummy_frame (frame->pc, frame->frame)
+ + REGISTER_BYTE (regnum)),
REGISTER_RAW_SIZE (regnum));
return;
}
if (addrp)
*addrp = REGISTER_BYTE (live_regnum);
if (raw_buffer)
- read_register_gen (live_regnum, raw_buffer);
+ deprecated_read_register_gen (live_regnum, raw_buffer);
}
/* Extract from an array REGBUF containing the (raw) register state
if (len < 4)
{
/* value gets right-justified in the register or stack word */
- memcpy (valbuf + (4 - len),
- (char *) VALUE_CONTENTS (args[argnum]), len);
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+ memcpy (valbuf + (4 - len),
+ (char *) VALUE_CONTENTS (args[argnum]), len);
+ else
+ memcpy (valbuf, (char *) VALUE_CONTENTS (args[argnum]), len);
val = valbuf;
}
else
if (float_arg_index <= tdep->FLOAT_ARGLAST_REGNUM)
{
/* Goes in FR0...FR11 */
- write_register_gen (FP0_REGNUM + float_arg_index, val);
+ deprecated_write_register_gen (FP0_REGNUM + float_arg_index,
+ val);
fp_args[float_arg_index] = 1;
/* Skip the corresponding general argument register. */
int_argreg ++;
}
#endif
/* Note: must use write_register_gen here instead
- of regcache_write, because regcache_write works
- only for real registers, not pseudo.
- write_register_gen will call the gdbarch
- function to do register writes, and that will
- properly know how to deal with pseudoregs. */
- write_register_gen (regnum, val);
+ of regcache_raw_write, because
+ regcache_raw_write works only for real
+ registers, not pseudo. write_register_gen will
+ call the gdbarch function to do register
+ writes, and that will properly know how to deal
+ with pseudoregs. */
+ deprecated_write_register_gen (regnum, val);
fp_args[double_arg_index] = 1;
fp_args[double_arg_index + 1] = 1;
/* Skip the corresponding general argument register. */
{
/* Add leading zeros to the value. */
memset (buf, 0, REGISTER_RAW_SIZE (R0_REGNUM));
- memcpy (buf + REGISTER_RAW_SIZE (R0_REGNUM) - TYPE_LENGTH (type),
- valbuf, TYPE_LENGTH (type));
- write_register_bytes (REGISTER_BYTE (R0_REGNUM), buf,
- REGISTER_RAW_SIZE (R0_REGNUM));
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+ memcpy (buf + REGISTER_RAW_SIZE (R0_REGNUM) - TYPE_LENGTH (type),
+ valbuf, TYPE_LENGTH (type));
+ else
+ memcpy (buf, valbuf, TYPE_LENGTH (type));
+ deprecated_write_register_bytes (REGISTER_BYTE (R0_REGNUM), buf,
+ REGISTER_RAW_SIZE (R0_REGNUM));
}
else
- write_register_bytes (REGISTER_BYTE (R0_REGNUM), valbuf,
- TYPE_LENGTH (type));
+ deprecated_write_register_bytes (REGISTER_BYTE (R0_REGNUM), valbuf,
+ TYPE_LENGTH (type));
}
static void
sh3e_sh4_store_return_value (struct type *type, char *valbuf)
{
if (TYPE_CODE (type) == TYPE_CODE_FLT)
- write_register_bytes (REGISTER_BYTE (FP0_REGNUM),
- valbuf, TYPE_LENGTH (type));
+ deprecated_write_register_bytes (REGISTER_BYTE (FP0_REGNUM),
+ valbuf, TYPE_LENGTH (type));
else
sh_default_store_return_value (type, valbuf);
}
if (len == 4)
{
/* Return value stored in FP0_REGNUM */
- write_register_gen (FP0_REGNUM, valbuf);
+ deprecated_write_register_gen (FP0_REGNUM, valbuf);
}
if (len == 8)
{
offset = REGISTER_RAW_SIZE (return_register) - len;
memcpy (buf + offset, valbuf, len);
- write_register_gen (return_register, buf);
+ deprecated_write_register_gen (return_register, buf);
}
else
- write_register_gen (return_register, valbuf);
+ deprecated_write_register_gen (return_register, valbuf);
}
}
The other pseudo registers (the FVs) also don't pose a problem
because they are stored as 4 individual FP elements. */
-int
-sh_sh4_register_convertible (int nr)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
- if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
- return (tdep->DR0_REGNUM <= nr
- && nr <= tdep->DR_LAST_REGNUM);
- else
- return 0;
-}
-
static void
sh_sh4_register_convert_to_virtual (int regnum, struct type *type,
char *from, char *to)
static void
sh_sh4_register_convert_to_raw (struct type *type, int regnum,
- char *from, char *to)
+ const void *from, void *to)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
void
sh_sh64_register_convert_to_raw (struct type *type, int regnum,
- char *from, char *to)
+ const void *from, void *to)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
}
void
-sh_pseudo_register_read (int reg_nr, char *buffer)
+sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, void *buffer)
{
int base_regnum, portion;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
/* Build the value in the provided buffer. */
/* Read the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_read (base_regnum + portion,
- temp_buffer
- + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ (temp_buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
/* We must pay attention to the endiannes. */
sh_sh4_register_convert_to_virtual (reg_nr,
REGISTER_VIRTUAL_TYPE (reg_nr),
/* Read the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
- regcache_read (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
}
static void
-sh4_register_read (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_read (reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh_pseudo_register_read (reg_nr, buffer);
-}
-
-static void
-sh64_pseudo_register_read (int reg_nr, char *buffer)
+sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, void *buffer)
{
int base_regnum;
int portion;
int offset = 0;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
/* DR regs are double precision registers obtained by
concatenating 2 single precision floating point registers. */
for (portion = 0; portion < 2; portion++)
- regcache_read (base_regnum + portion,
- temp_buffer
- + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ (temp_buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
/* We must pay attention to the endiannes. */
sh_sh64_register_convert_to_virtual (reg_nr, REGISTER_VIRTUAL_TYPE (reg_nr),
/* FPP regs are pairs of single precision registers obtained by
concatenating 2 single precision floating point registers. */
for (portion = 0; portion < 2; portion++)
- regcache_read (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
else if (reg_nr >= tdep->FV0_REGNUM
/* FV regs are vectors of single precision registers obtained by
concatenating 4 single precision floating point registers. */
for (portion = 0; portion < 4; portion++)
- regcache_read (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
/* sh compact pseudo registers. 1-to-1 with a shmedia register */
base_regnum = sh64_compact_reg_base_num (reg_nr);
/* Build the value in the provided buffer. */
- regcache_read (base_regnum, temp_buffer);
+ regcache_raw_read (regcache, base_regnum, temp_buffer);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
offset = 4;
memcpy (buffer, temp_buffer + offset, 4); /* get LOWER 32 bits only????*/
/* Build the value in the provided buffer. */
/* Floating point registers map 1-1 to the media fp regs,
they have the same size and endienness. */
- regcache_read (base_regnum, buffer);
+ regcache_raw_read (regcache, base_regnum, buffer);
}
else if (reg_nr >= tdep->DR0_C_REGNUM
/* DR_C regs are double precision registers obtained by
concatenating 2 single precision floating point registers. */
for (portion = 0; portion < 2; portion++)
- regcache_read (base_regnum + portion,
- temp_buffer
- + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ (temp_buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
/* We must pay attention to the endiannes. */
sh_sh64_register_convert_to_virtual (reg_nr, REGISTER_VIRTUAL_TYPE (reg_nr),
/* FV_C regs are vectors of single precision registers obtained by
concatenating 4 single precision floating point registers. */
for (portion = 0; portion < 4; portion++)
- regcache_read (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
else if (reg_nr == tdep->FPSCR_C_REGNUM)
*/
/* *INDENT-ON* */
/* Get FPSCR into a local buffer */
- regcache_read (fpscr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
/* Get value as an int. */
fpscr_value = extract_unsigned_integer (temp_buffer, 4);
/* Get SR into a local buffer */
- regcache_read (sr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
/* Get value as an int. */
sr_value = extract_unsigned_integer (temp_buffer, 4);
/* Build the new value. */
/* FPUL_C register is floating point register 32,
same size, same endianness. */
- regcache_read (base_regnum, buffer);
+ regcache_raw_read (regcache, base_regnum, buffer);
}
}
-static void
-sh64_register_read (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
-
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_read (reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh64_pseudo_register_read (reg_nr, buffer);
-}
-
void
-sh_pseudo_register_write (int reg_nr, char *buffer)
+sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, const void *buffer)
{
int base_regnum, portion;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_write (base_regnum + portion,
- temp_buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_write (regcache, base_regnum + portion,
+ (temp_buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
else if (reg_nr >= tdep->FV0_REGNUM
&& reg_nr <= tdep->FV_LAST_REGNUM)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
- regcache_write (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
}
-static void
-sh4_register_write (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_write (reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh_pseudo_register_write (reg_nr, buffer);
-}
-
void
-sh64_pseudo_register_write (int reg_nr, char *buffer)
+sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, const void *buffer)
{
int base_regnum, portion;
int offset;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_write (base_regnum + portion,
- temp_buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_write (regcache, base_regnum + portion,
+ (temp_buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
else if (reg_nr >= tdep->FPP0_REGNUM
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_write (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
else if (reg_nr >= tdep->FV0_REGNUM
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
- regcache_write (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
/* sh compact general pseudo registers. 1-to-1 with a shmedia
/* Let's read the value of the base register into a temporary
buffer, so that overwriting the last four bytes with the new
value of the pseudo will leave the upper 4 bytes unchanged. */
- regcache_read (base_regnum, temp_buffer);
+ regcache_raw_read (regcache, base_regnum, temp_buffer);
/* Write as an 8 byte quantity */
memcpy (temp_buffer + offset, buffer, 4);
- regcache_write (base_regnum, temp_buffer);
+ regcache_raw_write (regcache, base_regnum, temp_buffer);
}
/* sh floating point compact pseudo registers. 1-to-1 with a shmedia
&& reg_nr <= tdep->FP_LAST_C_REGNUM)
{
base_regnum = sh64_compact_reg_base_num (reg_nr);
- regcache_write (base_regnum, buffer);
+ regcache_raw_write (regcache, base_regnum, buffer);
}
else if (reg_nr >= tdep->DR0_C_REGNUM
sh_sh64_register_convert_to_raw (REGISTER_VIRTUAL_TYPE (reg_nr), reg_nr,
buffer, temp_buffer);
- regcache_write (base_regnum + portion,
- temp_buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_write (regcache, base_regnum + portion,
+ (temp_buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
}
for (portion = 0; portion < 4; portion++)
{
- regcache_write (base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
}
fpscr_value = fpscr_c_value & fpscr_mask;
sr_value = (fpscr_value & sr_mask) >> 6;
- regcache_read (fpscr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
old_fpscr_value = extract_unsigned_integer (temp_buffer, 4);
old_fpscr_value &= 0xfffc0002;
fpscr_value |= old_fpscr_value;
store_unsigned_integer (temp_buffer, 4, fpscr_value);
- regcache_write (fpscr_base_regnum, temp_buffer);
+ regcache_raw_write (regcache, fpscr_base_regnum, temp_buffer);
- regcache_read (sr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
old_sr_value = extract_unsigned_integer (temp_buffer, 4);
old_sr_value &= 0xffff8fff;
sr_value |= old_sr_value;
store_unsigned_integer (temp_buffer, 4, sr_value);
- regcache_write (sr_base_regnum, temp_buffer);
+ regcache_raw_write (regcache, sr_base_regnum, temp_buffer);
}
else if (reg_nr == tdep->FPUL_C_REGNUM)
{
base_regnum = sh64_compact_reg_base_num (reg_nr);
- regcache_write (base_regnum, buffer);
+ regcache_raw_write (regcache, base_regnum, buffer);
}
}
-static void
-sh64_register_write (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_write (reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh64_pseudo_register_write (reg_nr, buffer);
-}
-
/* Floating point vector of 4 float registers. */
static void
do_fv_register_info (int fv_regnum)
#endif /* SVR4_SHARED_LIBS */
\f
-/* This table matches the indices assigned to enum sh_osabi. Keep
- them in sync. */
-static const char * const sh_osabi_names[] =
+enum
{
- "<unknown>",
- "GNU/Linux",
- "NetBSD ELF",
- NULL
+ DSP_DSR_REGNUM = 24,
+ DSP_A0G_REGNUM,
+ DSP_A0_REGNUM,
+ DSP_A1G_REGNUM,
+ DSP_A1_REGNUM,
+ DSP_M0_REGNUM,
+ DSP_M1_REGNUM,
+ DSP_X0_REGNUM,
+ DSP_X1_REGNUM,
+ DSP_Y0_REGNUM,
+ DSP_Y1_REGNUM,
+
+ DSP_MOD_REGNUM = 40,
+
+ DSP_RS_REGNUM = 43,
+ DSP_RE_REGNUM,
+
+ DSP_R0_BANK_REGNUM = 51,
+ DSP_R7_BANK_REGNUM = DSP_R0_BANK_REGNUM + 7
};
-static void
-process_note_abi_tag_sections (bfd *abfd, asection *sect, void *obj)
-{
- enum sh_osabi *os_ident_ptr = obj;
- const char *name;
- unsigned int sectsize;
-
- name = bfd_get_section_name (abfd, sect);
- sectsize = bfd_section_size (abfd, sect);
-
- if (strcmp (name, ".note.ABI-tag") == 0 && sectsize > 0)
- {
- unsigned int name_length, data_length, note_type;
- char *note;
-
- /* If the section is larger than this, it's probably not what we are
- looking for. */
- if (sectsize > 128)
- sectsize = 128;
-
- note = alloca (sectsize);
-
- bfd_get_section_contents (abfd, sect, note,
- (file_ptr) 0, (bfd_size_type) sectsize);
-
- name_length = bfd_h_get_32 (abfd, note);
- data_length = bfd_h_get_32 (abfd, note + 4);
- note_type = bfd_h_get_32 (abfd, note + 8);
-
- if (name_length == 4 && data_length == 16 && note_type == NT_GNU_ABI_TAG
- && strcmp (note + 12, "GNU") == 0)
- {
- int os_number = bfd_h_get_32 (abfd, note + 16);
-
- /* The case numbers are from abi-tags in glibc. */
- switch (os_number)
- {
- case GNU_ABI_TAG_LINUX:
- *os_ident_ptr = SH_OSABI_LINUX;
- break;
-
- case GNU_ABI_TAG_HURD:
- internal_error
- (__FILE__, __LINE__,
- "process_note_abi_sections: Hurd objects not supported");
- break;
-
- case GNU_ABI_TAG_SOLARIS:
- internal_error
- (__FILE__, __LINE__,
- "process_note_abi_sections: Solaris objects not supported");
- break;
-
- default:
- internal_error
- (__FILE__, __LINE__,
- "process_note_abi_sections: unknown OS number %d",
- os_number);
- }
- }
- }
- /* NetBSD uses a similar trick. */
- else if (strcmp (name, ".note.netbsd.ident") == 0 && sectsize > 0)
- {
- unsigned int name_length, desc_length, note_type;
- char *note;
-
- /* If the section is larger than this, it's probably not what we are
- looking for. */
- if (sectsize > 128)
- sectsize = 128;
-
- note = alloca (sectsize);
-
- bfd_get_section_contents (abfd, sect, note,
- (file_ptr) 0, (bfd_size_type) sectsize);
-
- name_length = bfd_h_get_32 (abfd, note);
- desc_length = bfd_h_get_32 (abfd, note + 4);
- note_type = bfd_h_get_32 (abfd, note + 8);
-
- if (name_length == 7 && desc_length == 4 && note_type == NT_NETBSD_IDENT
- && strcmp (note + 12, "NetBSD") == 0)
- /* XXX Should we check the version here?
- Probably not necessary yet. */
- *os_ident_ptr = SH_OSABI_NETBSD_ELF;
- }
-}
-
static int
-get_elfosabi (bfd *abfd)
-{
- int elfosabi;
- enum sh_osabi sh_osabi = SH_OSABI_UNKNOWN;
-
- elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
-
- switch (elfosabi)
- {
- case ELFOSABI_NONE:
- /* When elfosabi is 0 (ELFOSABI_NONE), this is supposed to indicate
- that we're on a SYSV system. However, some systems use note sections
- to record OS/ABI info, but leave e_ident[EI_OSABI] zero. So we
- have to check the note sections too. */
- bfd_map_over_sections (abfd,
- process_note_abi_tag_sections,
- &sh_osabi);
- break;
-
- case ELFOSABI_NETBSD:
- sh_osabi = SH_OSABI_NETBSD_ELF;
- break;
-
- case ELFOSABI_LINUX:
- sh_osabi = SH_OSABI_LINUX;
- break;
- }
-
- return (sh_osabi);
-}
-
-struct sh_osabi_handler
-{
- struct sh_osabi_handler *next;
- enum sh_osabi abi;
- void (*init_osabi)(struct gdbarch_info, struct gdbarch *);
-};
-
-struct sh_osabi_handler *sh_osabi_handler_list = NULL;
-
-void
-sh_gdbarch_register_os_abi (enum sh_osabi abi,
- void (*init_osabi)(struct gdbarch_info,
- struct gdbarch *))
+sh_dsp_register_sim_regno (int nr)
{
- struct sh_osabi_handler **handler_p;
-
- for (handler_p = &sh_osabi_handler_list; *handler_p != NULL;
- handler_p = &(*handler_p)->next)
- {
- if ((*handler_p)->abi == abi)
- {
- internal_error
- (__FILE__, __LINE__,
- "sh_gdbarch_register_os_abi: A handler for this ABI variant "
- "(%d) has already been registered", (int) abi);
- /* If user wants to continue, override previous definition. */
- (*handler_p)->init_osabi = init_osabi;
- return;
- }
- }
-
- (*handler_p)
- = (struct sh_osabi_handler *) xmalloc (sizeof (struct sh_osabi_handler));
- (*handler_p)->next = NULL;
- (*handler_p)->abi = abi;
- (*handler_p)->init_osabi = init_osabi;
+ if (legacy_register_sim_regno (nr) < 0)
+ return legacy_register_sim_regno (nr);
+ if (nr >= DSP_DSR_REGNUM && nr < DSP_Y1_REGNUM)
+ return nr - DSP_DSR_REGNUM + SIM_SH_DSR_REGNUM;
+ if (nr == DSP_MOD_REGNUM)
+ return SIM_SH_MOD_REGNUM;
+ if (nr == DSP_RS_REGNUM)
+ return SIM_SH_RS_REGNUM;
+ if (nr == DSP_RE_REGNUM)
+ return SIM_SH_RE_REGNUM;
+ if (nr >= DSP_R0_BANK_REGNUM && nr <= DSP_R7_BANK_REGNUM)
+ return nr - DSP_R0_BANK_REGNUM + SIM_SH_R0_BANK_REGNUM;
+ return nr;
}
-
+\f
static gdbarch_init_ftype sh_gdbarch_init;
static struct gdbarch *
struct gdbarch *gdbarch;
struct gdbarch_tdep *tdep;
gdbarch_register_name_ftype *sh_register_name;
- gdbarch_store_return_value_ftype *sh_store_return_value;
+ gdbarch_deprecated_store_return_value_ftype *sh_store_return_value;
gdbarch_register_virtual_type_ftype *sh_register_virtual_type;
- enum sh_osabi sh_osabi = SH_OSABI_UNKNOWN;
- struct sh_osabi_handler *osabi_handler;
+ enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
/* Try to determine the ABI of the object we are loading. */
if (info.abfd != NULL)
{
- switch (bfd_get_flavour (info.abfd))
- {
- case bfd_target_elf_flavour:
- sh_osabi = get_elfosabi (info.abfd);
- break;
-
- default:
- /* Just leave it as "unkown". */
- break;
- }
+ osabi = gdbarch_lookup_osabi (info.abfd);
+ /* If we get "unknown" back, just leave it that way. */
}
/* Find a candidate among the list of pre-declared architectures. */
{
/* Make sure the ABI selection matches. */
tdep = gdbarch_tdep (arches->gdbarch);
- if (tdep && tdep->sh_osabi == sh_osabi)
+ if (tdep && tdep->osabi == osabi)
return arches->gdbarch;
}
tdep = XMALLOC (struct gdbarch_tdep);
gdbarch = gdbarch_alloc (&info, tdep);
- tdep->sh_osabi = sh_osabi;
- if (sh_osabi < SH_OSABI_INVALID)
- tdep->osabi_name = sh_osabi_names[sh_osabi];
- else
- {
- internal_error (__FILE__, __LINE__, "Invalid setting of sh_osabi %d",
- (int) sh_osabi);
- tdep->osabi_name = "<invalid>";
- }
+ tdep->osabi = osabi;
/* Initialize the register numbers that are not common to all the
variants to -1, if necessary thse will be overwritten in the case
set_gdbarch_pc_regnum (gdbarch, 16);
set_gdbarch_register_size (gdbarch, 4);
set_gdbarch_register_bytes (gdbarch, SH_DEFAULT_NUM_REGS * 4);
- set_gdbarch_do_registers_info (gdbarch, sh_do_registers_info);
+ set_gdbarch_deprecated_do_registers_info (gdbarch, sh_do_registers_info);
set_gdbarch_breakpoint_from_pc (gdbarch, sh_breakpoint_from_pc);
set_gdbarch_frame_chain (gdbarch, sh_frame_chain);
- set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
+ set_gdbarch_get_saved_register (gdbarch, deprecated_generic_get_saved_register);
set_gdbarch_init_extra_frame_info (gdbarch, sh_init_extra_frame_info);
- set_gdbarch_extract_return_value (gdbarch, sh_extract_return_value);
+ set_gdbarch_deprecated_extract_return_value (gdbarch, sh_extract_return_value);
set_gdbarch_push_arguments (gdbarch, sh_push_arguments);
set_gdbarch_store_struct_return (gdbarch, sh_store_struct_return);
set_gdbarch_use_struct_convention (gdbarch, sh_use_struct_convention);
- set_gdbarch_extract_struct_value_address (gdbarch, sh_extract_struct_value_address);
+ set_gdbarch_deprecated_extract_struct_value_address (gdbarch, sh_extract_struct_value_address);
set_gdbarch_pop_frame (gdbarch, sh_pop_frame);
set_gdbarch_print_insn (gdbarch, gdb_print_insn_sh);
+ set_gdbarch_register_sim_regno (gdbarch, legacy_register_sim_regno);
skip_prologue_hard_way = sh_skip_prologue_hard_way;
do_pseudo_register = sh_do_pseudo_register;
set_gdbarch_register_raw_size (gdbarch, sh_default_register_raw_size);
set_gdbarch_register_virtual_size (gdbarch, sh_default_register_raw_size);
set_gdbarch_register_byte (gdbarch, sh_default_register_byte);
+ set_gdbarch_register_sim_regno (gdbarch, sh_dsp_register_sim_regno);
tdep->DSR_REGNUM = 24;
tdep->A0G_REGNUM = 25;
tdep->A0_REGNUM = 26;
set_gdbarch_register_raw_size (gdbarch, sh_default_register_raw_size);
set_gdbarch_register_virtual_size (gdbarch, sh_default_register_raw_size);
set_gdbarch_register_byte (gdbarch, sh_default_register_byte);
- set_gdbarch_extract_return_value (gdbarch, sh3e_sh4_extract_return_value);
+ set_gdbarch_deprecated_extract_return_value (gdbarch, sh3e_sh4_extract_return_value);
set_gdbarch_fp0_regnum (gdbarch, 25);
tdep->FPUL_REGNUM = 23;
tdep->FPSCR_REGNUM = 24;
sh_store_return_value = sh3e_sh4_store_return_value;
sh_register_virtual_type = sh_sh4_register_virtual_type;
set_gdbarch_frame_init_saved_regs (gdbarch, sh_fp_frame_init_saved_regs);
- set_gdbarch_extract_return_value (gdbarch, sh3e_sh4_extract_return_value);
+ set_gdbarch_deprecated_extract_return_value (gdbarch, sh3e_sh4_extract_return_value);
set_gdbarch_fp0_regnum (gdbarch, 25);
set_gdbarch_register_raw_size (gdbarch, sh_sh4_register_raw_size);
set_gdbarch_register_virtual_size (gdbarch, sh_sh4_register_raw_size);
set_gdbarch_num_pseudo_regs (gdbarch, 12);
set_gdbarch_max_register_raw_size (gdbarch, 4 * 4);
set_gdbarch_max_register_virtual_size (gdbarch, 4 * 4);
- set_gdbarch_register_read (gdbarch, sh4_register_read);
- set_gdbarch_register_write (gdbarch, sh4_register_write);
+ set_gdbarch_pseudo_register_read (gdbarch, sh_pseudo_register_read);
+ set_gdbarch_pseudo_register_write (gdbarch, sh_pseudo_register_write);
tdep->FPUL_REGNUM = 23;
tdep->FPSCR_REGNUM = 24;
tdep->FP_LAST_REGNUM = 40;
sh_store_return_value = sh64_store_return_value;
skip_prologue_hard_way = sh64_skip_prologue_hard_way;
do_pseudo_register = sh64_do_pseudo_register;
- set_gdbarch_print_insn (gdbarch, gdb_print_insn_sh64);
set_gdbarch_register_raw_size (gdbarch, sh_sh64_register_raw_size);
set_gdbarch_register_virtual_size (gdbarch, sh_sh64_register_raw_size);
set_gdbarch_register_byte (gdbarch, sh_sh64_register_byte);
/* Or should that go in the virtual_size? */
/*set_gdbarch_max_register_virtual_size (gdbarch, 8);*/
set_gdbarch_max_register_virtual_size (gdbarch, 4 * 4);
- set_gdbarch_register_read (gdbarch, sh64_register_read);
- set_gdbarch_register_write (gdbarch, sh64_register_write);
+ set_gdbarch_pseudo_register_read (gdbarch, sh64_pseudo_register_read);
+ set_gdbarch_pseudo_register_write (gdbarch, sh64_pseudo_register_write);
- set_gdbarch_do_registers_info (gdbarch, sh64_do_registers_info);
+ set_gdbarch_deprecated_do_registers_info (gdbarch, sh64_do_registers_info);
set_gdbarch_frame_init_saved_regs (gdbarch, sh64_nofp_frame_init_saved_regs);
set_gdbarch_breakpoint_from_pc (gdbarch, sh_sh64_breakpoint_from_pc);
set_gdbarch_init_extra_frame_info (gdbarch, sh64_init_extra_frame_info);
set_gdbarch_frame_chain (gdbarch, sh64_frame_chain);
set_gdbarch_get_saved_register (gdbarch, sh64_get_saved_register);
- set_gdbarch_extract_return_value (gdbarch, sh64_extract_return_value);
+ set_gdbarch_deprecated_extract_return_value (gdbarch, sh64_extract_return_value);
set_gdbarch_push_arguments (gdbarch, sh64_push_arguments);
/*set_gdbarch_store_struct_return (gdbarch, sh64_store_struct_return);*/
- set_gdbarch_extract_struct_value_address (gdbarch, sh64_extract_struct_value_address);
+ set_gdbarch_deprecated_extract_struct_value_address (gdbarch, sh64_extract_struct_value_address);
set_gdbarch_use_struct_convention (gdbarch, sh64_use_struct_convention);
set_gdbarch_pop_frame (gdbarch, sh64_pop_frame);
set_gdbarch_elf_make_msymbol_special (gdbarch,
set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
- set_gdbarch_long_double_bit (gdbarch, 16 * TARGET_CHAR_BIT);/*??should be 8?*/
+ set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
set_gdbarch_call_dummy_length (gdbarch, 0);
set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
set_gdbarch_push_return_address (gdbarch, sh_push_return_address);
- set_gdbarch_store_return_value (gdbarch, sh_store_return_value);
+ set_gdbarch_deprecated_store_return_value (gdbarch, sh_store_return_value);
set_gdbarch_skip_prologue (gdbarch, sh_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_decr_pc_after_break (gdbarch, 0);
set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
set_gdbarch_believe_pcc_promotion (gdbarch, 1);
- /* Hook in ABI-specific overrides, if they have been registered. If
- the ABI is unknown, this is probably an embedded target, so we
- should not warn about this situation. */
- if (sh_osabi != SH_OSABI_UNKNOWN)
- {
- for (osabi_handler = sh_osabi_handler_list; osabi_handler != NULL;
- osabi_handler = osabi_handler->next)
- if (osabi_handler->abi == sh_osabi)
- break;
+ /* Hook in ABI-specific overrides, if they have been registered.
- if (osabi_handler)
- osabi_handler->init_osabi (info, gdbarch);
- else
- {
- /* We assume that if GDB_MULTI_ARCH is less than
- GDB_MULTI_ARCH_TM that an ABI variant can be supported by
- overriding definitions in this file. */
- if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
- fprintf_filtered
- (gdb_stderr,
- "A handler for the ABI variant \"%s\" is not built into this "
- "configuration of GDB. "
- "Attempting to continue with the default SuperH settings",
- sh_osabi_names[sh_osabi]);
- }
- }
+ FIXME: if the ABI is unknown, this is probably an embedded target,
+ so we should not warn about this situation. */
+ gdbarch_init_osabi (info, gdbarch, osabi);
return gdbarch;
}
if (tdep == NULL)
return;
- if (tdep->osabi_name != NULL)
- fprintf_unfiltered (file, "sh_dump_tdep: OS ABI = %s\n", tdep->osabi_name);
- else
- internal_error (__FILE__, __LINE__,
- "sh_dump_tdep: illegal setting of tdep->sh_osabi (%d)",
- (int) tdep->sh_osabi);
+ fprintf_unfiltered (file, "sh_dump_tdep: OS ABI = %s\n",
+ gdbarch_osabi_name (tdep->osabi));
}
void