int regno;
{
unsigned short sval;
+ unsigned int ival;
unsigned long lval;
+ int size;
+
if (!register_valid[regno])
target_fetch_registers (regno);
- switch (REGISTER_RAW_SIZE(regno))
+ size = REGISTER_RAW_SIZE(regno);
+
+ if (size == sizeof (unsigned char))
+ return registers[REGISTER_BYTE (regno)];
+ else if (size == sizeof (sval))
{
- case sizeof (unsigned char):
- return registers[REGISTER_BYTE (regno)];
- case sizeof (sval):
memcpy (&sval, ®isters[REGISTER_BYTE (regno)], sizeof (sval));
SWAP_TARGET_AND_HOST (&sval, sizeof (sval));
return sval;
- case sizeof (lval):
+ }
+ else if (size == sizeof (ival))
+ {
+ memcpy (&ival, ®isters[REGISTER_BYTE (regno)], sizeof (ival));
+ SWAP_TARGET_AND_HOST (&ival, sizeof (ival));
+ return ival;
+ }
+ else if (size == sizeof (lval))
+ {
memcpy (&lval, ®isters[REGISTER_BYTE (regno)], sizeof (lval));
SWAP_TARGET_AND_HOST (&lval, sizeof (lval));
return lval;
- default:
+ }
+ else
+ {
error ("GDB Internal Error in read_register() for register %d, size %d",
- regno, RAW_REGISTER_SIZE(regno));
+ regno, REGISTER_RAW_SIZE(regno));
}
}
write_register (regno, val)
int regno, val;
{
+ unsigned char cval;
unsigned short sval;
+ unsigned int ival;
unsigned long lval;
-
+ int size;
+ PTR ptr;
+
/* On the sparc, writing %g0 is a no-op, so we don't even want to change
the registers array if something writes to this register. */
if (CANNOT_STORE_REGISTER (regno))
return;
- target_prepare_to_store ();
+ /* If we have a valid copy of the register, and new value == old value,
+ then don't bother doing the actual store. */
- register_valid [regno] = 1;
+ size = REGISTER_RAW_SIZE(regno);
- switch (REGISTER_RAW_SIZE(regno))
+ if (size == sizeof(cval))
{
- case sizeof (unsigned char):
- registers[REGISTER_BYTE (regno)] = val;
- break;
- case sizeof (sval):
+ ptr = (PTR) &cval;
+ cval = val;
+ }
+ else if (size == sizeof(sval))
+ {
+ ptr = (PTR) &sval;
sval = val;
- SWAP_TARGET_AND_HOST (&sval, sizeof (sval));
- memcpy (®isters[REGISTER_BYTE (regno)], &sval, sizeof (sval));
- break;
- case sizeof (lval):
+ }
+ else if (size == sizeof(ival))
+ {
+ ptr = (PTR) &ival;
+ ival = val;
+ }
+ else if (size == sizeof(lval))
+ {
+ ptr = (PTR) &lval;
lval = val;
- SWAP_TARGET_AND_HOST (&lval, sizeof (lval));
- memcpy (®isters[REGISTER_BYTE (regno)], &lval, sizeof (lval));
- break;
- default:
+ }
+ else
+ {
error ("GDB Internal Error in write_register() for register %d, size %d",
- regno, RAW_REGISTER_SIZE(regno));
+ regno, size);
}
+
+ if (register_valid [regno])
+ {
+ SWAP_TARGET_AND_HOST (ptr, size);
+ if (memcmp (®isters[REGISTER_BYTE (regno)],
+ ptr, size) == 0)
+ return;
+ }
+
+ target_prepare_to_store ();
+
+ memcpy (®isters[REGISTER_BYTE (regno)], ptr, size);
+
+ register_valid [regno] = 1;
target_store_registers (regno);
}
if (lval == lval_register)
reg_stor++;
else
- {
- mem_stor++;
- first_addr = addr;
- }
+ mem_stor++;
+ first_addr = addr;
last_addr = addr;
get_saved_register (value_bytes + 2,
frame,
local_regnum,
&lval);
+
+ if (regnum == local_regnum)
+ first_addr = addr;
if (lval == lval_register)
reg_stor++;
else
{
mem_stor++;
-
- if (regnum == local_regnum)
- first_addr = addr;
mem_tracking =
(mem_tracking
/* Copy into the contents section of the value. */
memcpy (VALUE_CONTENTS_RAW (v), value_bytes, len);
+ /* Finally do any conversion necessary when extracting this
+ type from more than one register. */
+#ifdef REGISTER_CONVERT_TO_TYPE
+ REGISTER_CONVERT_TO_TYPE(regnum, type, VALUE_CONTENTS_RAW(v));
+#endif
return v;
}
#include "frame.h"
#include "obstack.h"
#include "symtab.h"
+#include <dis-asm.h>
#undef NUM_REGS
#define NUM_REGS 11
{
short int w;
- w = read_memory_short (start_pc);
+ w = read_memory_unsigned_integer (start_pc, 2);
/* Skip past all push insns */
while (IS_PUSH_FP (w))
{
start_pc += 2;
- w = read_memory_short (start_pc);
+ w = read_memory_unsigned_integer (start_pc, 2);
}
/* Skip past a move to FP */
if (IS_MOVE_FP (w))
{
start_pc += 2;
- w = read_memory_short (start_pc);
+ w = read_memory_unsigned_integer (start_pc, 2);
}
/* Skip the stack adjust */
if (IS_MOVK_R5 (w))
{
start_pc += 2;
- w = read_memory_short (start_pc);
+ w = read_memory_unsigned_integer (start_pc, 2);
}
if (IS_SUB_R5SP (w))
{
start_pc += 2;
- w = read_memory_short (start_pc);
+ w = read_memory_unsigned_integer (start_pc, 2);
}
while (IS_SUB2_SP (w))
{
start_pc += 2;
- w = read_memory_short (start_pc);
+ w = read_memory_unsigned_integer (start_pc, 2);
}
return start_pc;
CORE_ADDR memaddr;
FILE *stream;
{
- /* Nothing is bigger than 8 bytes */
- char data[8];
-
- read_memory (memaddr, data, sizeof (data));
- return print_insn_h8300 (memaddr, data, stream);
+ disassemble_info info;
+ GDB_INIT_DISASSEMBLE_INFO(info, stream);
+ return print_insn_h8300 (memaddr, &info);
}
/* Given a GDB frame, determine the address of the calling function's frame.
/* Locals are always reffed based from the fp */
fi->locals_pointer = after_prolog_fp;
/* The PC is at a known place */
- fi->from_pc = read_memory_short (after_prolog_fp + 2);
+ fi->from_pc = read_memory_unsigned_integer (after_prolog_fp + 2, BINWORD);
/* Rememeber any others too */
in_frame[PC_REGNUM] = 0;
if (have_fp)
/* We keep the old FP in the SP spot */
- fsr->regs[SP_REGNUM] = (read_memory_short (fsr->regs[6]));
+ fsr->regs[SP_REGNUM] = (read_memory_unsigned_integer
+ (fsr->regs[6]), BINWORD);
else
fsr->regs[SP_REGNUM] = after_prolog_fp + auto_depth;
{
if (fsr.regs[regnum])
{
- write_register (regnum, read_memory_short (fsr.regs[regnum]));
+ write_register (regnum, read_memory_integer(fsr.regs[regnum]), BINWORD);
}
flush_cached_frames ();
#include "../opcodes/sh-opc.h"
+
+
/* Prologue looks like
[mov.l <regs>,@-r15]...
[sts.l pr,@-r15]
depth += -((char) (insn & 0xff));
insn = read_memory_integer (pc, 2);
}
- else break;
+ else
+ break;
}
/* Now we know how deep things are, we can work out their addresses */
if (have_fp)
{
-
fsr->regs[SP_REGNUM] = read_memory_integer (fsr->regs[FP_REGNUM], 4);
}
else
fsr->regs[SP_REGNUM] = fi->frame - 4;
}
- /* Remember the address of the frame pointer */
/* Work out the return pc - either from the saved pr or the pr
value */
set_current_frame (create_new_frame (read_register (FP_REGNUM),
read_pc ()));
}
+
+
+_initialize_sh_tdep ()
+{
+ extern int sim_memory_size;
+ /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
+ add_show_from_set
+ (add_set_cmd ("memory_size", class_support, var_uinteger,
+ (char *) &sim_memory_size,
+ "Set simulated memory size of simulator target.", &setlist),
+ &showlist);
+}