* coffread.c (init_stringtab): Fix bug where sizeof(long) != 4.

* gdbcore.h, core.c (read_memory_unsigned_integer): New function.
	* findvar.c (read_register, write_register): Fix thinko where
	sizeof(host long) != sizeof(target int).
	* h8300-tdep.c: Use new read_memory_unsigned_integer call.
	* sh-tdep.c (_initialize_sh_tdep): Add memory_size command.
This commit is contained in:
Steve Chamberlain 1993-06-09 00:47:13 +00:00
parent bf3b8abd19
commit df14b38baf
4 changed files with 116 additions and 52 deletions

View File

@ -1,3 +1,12 @@
Tue Jun 8 17:39:12 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
* coffread.c (init_stringtab): Fix bug where sizeof(long) != 4.
* gdbcore.h, core.c (read_memory_unsigned_integer): New function.
* findvar.c (read_register, write_register): Fix thinko where
sizeof(host long) != sizeof(target int).
* h8300-tdep.c: Use new read_memory_unsigned_integer call.
* sh-tdep.c (_initialize_sh_tdep): Add memory_size command.
Tue Jun 8 14:42:10 1993 Jim Kingdon (kingdon@rtl.cygnus.com) Tue Jun 8 14:42:10 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
* Move config/m68k/tm-m68k.h (FRAME_FIND_SAVED_REGS) to * Move config/m68k/tm-m68k.h (FRAME_FIND_SAVED_REGS) to

View File

@ -304,26 +304,40 @@ read_register (regno)
int regno; int regno;
{ {
unsigned short sval; unsigned short sval;
unsigned int ival;
unsigned long lval; unsigned long lval;
int size;
if (!register_valid[regno]) if (!register_valid[regno])
target_fetch_registers (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, &registers[REGISTER_BYTE (regno)], sizeof (sval)); memcpy (&sval, &registers[REGISTER_BYTE (regno)], sizeof (sval));
SWAP_TARGET_AND_HOST (&sval, sizeof (sval)); SWAP_TARGET_AND_HOST (&sval, sizeof (sval));
return sval; return sval;
case sizeof (lval): }
else if (size == sizeof (ival))
{
memcpy (&ival, &registers[REGISTER_BYTE (regno)], sizeof (ival));
SWAP_TARGET_AND_HOST (&ival, sizeof (ival));
return ival;
}
else if (size == sizeof (lval))
{
memcpy (&lval, &registers[REGISTER_BYTE (regno)], sizeof (lval)); memcpy (&lval, &registers[REGISTER_BYTE (regno)], sizeof (lval));
SWAP_TARGET_AND_HOST (&lval, sizeof (lval)); SWAP_TARGET_AND_HOST (&lval, sizeof (lval));
return lval; return lval;
default: }
else
{
error ("GDB Internal Error in read_register() for register %d, size %d", error ("GDB Internal Error in read_register() for register %d, size %d",
regno, RAW_REGISTER_SIZE(regno)); regno, REGISTER_RAW_SIZE(regno));
} }
} }
@ -340,37 +354,62 @@ void
write_register (regno, val) write_register (regno, val)
int regno, val; int regno, val;
{ {
unsigned char cval;
unsigned short sval; unsigned short sval;
unsigned int ival;
unsigned long lval; unsigned long lval;
int size;
PTR ptr;
/* On the sparc, writing %g0 is a no-op, so we don't even want to change /* 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. */ the registers array if something writes to this register. */
if (CANNOT_STORE_REGISTER (regno)) if (CANNOT_STORE_REGISTER (regno))
return; return;
/* If we have a valid copy of the register, and new value == old value,
then don't bother doing the actual store. */
size = REGISTER_RAW_SIZE(regno);
if (size == sizeof(cval))
{
ptr = (PTR) &cval;
cval = val;
}
else if (size == sizeof(sval))
{
ptr = (PTR) &sval;
sval = val;
}
else if (size == sizeof(ival))
{
ptr = (PTR) &ival;
ival = val;
}
else if (size == sizeof(lval))
{
ptr = (PTR) &lval;
lval = val;
}
else
{
error ("GDB Internal Error in write_register() for register %d, size %d",
regno, size);
}
if (register_valid [regno])
{
SWAP_TARGET_AND_HOST (ptr, size);
if (memcmp (&registers[REGISTER_BYTE (regno)],
ptr, size) == 0)
return;
}
target_prepare_to_store (); target_prepare_to_store ();
register_valid [regno] = 1; memcpy (&registers[REGISTER_BYTE (regno)], ptr, size);
switch (REGISTER_RAW_SIZE(regno)) register_valid [regno] = 1;
{
case sizeof (unsigned char):
registers[REGISTER_BYTE (regno)] = val;
break;
case sizeof (sval):
sval = val;
SWAP_TARGET_AND_HOST (&sval, sizeof (sval));
memcpy (&registers[REGISTER_BYTE (regno)], &sval, sizeof (sval));
break;
case sizeof (lval):
lval = val;
SWAP_TARGET_AND_HOST (&lval, sizeof (lval));
memcpy (&registers[REGISTER_BYTE (regno)], &lval, sizeof (lval));
break;
default:
error ("GDB Internal Error in write_register() for register %d, size %d",
regno, RAW_REGISTER_SIZE(regno));
}
target_store_registers (regno); target_store_registers (regno);
} }
@ -626,10 +665,8 @@ value_from_register (type, regnum, frame)
if (lval == lval_register) if (lval == lval_register)
reg_stor++; reg_stor++;
else else
{ mem_stor++;
mem_stor++; first_addr = addr;
first_addr = addr;
}
last_addr = addr; last_addr = addr;
get_saved_register (value_bytes + 2, get_saved_register (value_bytes + 2,
@ -661,14 +698,14 @@ value_from_register (type, regnum, frame)
frame, frame,
local_regnum, local_regnum,
&lval); &lval);
if (regnum == local_regnum)
first_addr = addr;
if (lval == lval_register) if (lval == lval_register)
reg_stor++; reg_stor++;
else else
{ {
mem_stor++; mem_stor++;
if (regnum == local_regnum)
first_addr = addr;
mem_tracking = mem_tracking =
(mem_tracking (mem_tracking
@ -710,6 +747,11 @@ value_from_register (type, regnum, frame)
/* Copy into the contents section of the value. */ /* Copy into the contents section of the value. */
memcpy (VALUE_CONTENTS_RAW (v), value_bytes, len); 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; return v;
} }

View File

@ -26,6 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "frame.h" #include "frame.h"
#include "obstack.h" #include "obstack.h"
#include "symtab.h" #include "symtab.h"
#include <dis-asm.h>
#undef NUM_REGS #undef NUM_REGS
#define NUM_REGS 11 #define NUM_REGS 11
@ -57,19 +58,19 @@ h8300_skip_prologue (start_pc)
{ {
short int w; short int w;
w = read_memory_short (start_pc); w = read_memory_unsigned_integer (start_pc, 2);
/* Skip past all push insns */ /* Skip past all push insns */
while (IS_PUSH_FP (w)) while (IS_PUSH_FP (w))
{ {
start_pc += 2; start_pc += 2;
w = read_memory_short (start_pc); w = read_memory_unsigned_integer (start_pc, 2);
} }
/* Skip past a move to FP */ /* Skip past a move to FP */
if (IS_MOVE_FP (w)) if (IS_MOVE_FP (w))
{ {
start_pc += 2; start_pc += 2;
w = read_memory_short (start_pc); w = read_memory_unsigned_integer (start_pc, 2);
} }
/* Skip the stack adjust */ /* Skip the stack adjust */
@ -77,17 +78,17 @@ h8300_skip_prologue (start_pc)
if (IS_MOVK_R5 (w)) if (IS_MOVK_R5 (w))
{ {
start_pc += 2; start_pc += 2;
w = read_memory_short (start_pc); w = read_memory_unsigned_integer (start_pc, 2);
} }
if (IS_SUB_R5SP (w)) if (IS_SUB_R5SP (w))
{ {
start_pc += 2; start_pc += 2;
w = read_memory_short (start_pc); w = read_memory_unsigned_integer (start_pc, 2);
} }
while (IS_SUB2_SP (w)) while (IS_SUB2_SP (w))
{ {
start_pc += 2; start_pc += 2;
w = read_memory_short (start_pc); w = read_memory_unsigned_integer (start_pc, 2);
} }
return start_pc; return start_pc;
@ -99,11 +100,9 @@ print_insn (memaddr, stream)
CORE_ADDR memaddr; CORE_ADDR memaddr;
FILE *stream; FILE *stream;
{ {
/* Nothing is bigger than 8 bytes */ disassemble_info info;
char data[8]; GDB_INIT_DISASSEMBLE_INFO(info, stream);
return print_insn_h8300 (memaddr, &info);
read_memory (memaddr, data, sizeof (data));
return print_insn_h8300 (memaddr, data, stream);
} }
/* Given a GDB frame, determine the address of the calling function's frame. /* Given a GDB frame, determine the address of the calling function's frame.
@ -297,14 +296,15 @@ examine_prologue (ip, limit, after_prolog_fp, fsr, fi)
/* Locals are always reffed based from the fp */ /* Locals are always reffed based from the fp */
fi->locals_pointer = after_prolog_fp; fi->locals_pointer = after_prolog_fp;
/* The PC is at a known place */ /* 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 */ /* Rememeber any others too */
in_frame[PC_REGNUM] = 0; in_frame[PC_REGNUM] = 0;
if (have_fp) if (have_fp)
/* We keep the old FP in the SP spot */ /* 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 else
fsr->regs[SP_REGNUM] = after_prolog_fp + auto_depth; fsr->regs[SP_REGNUM] = after_prolog_fp + auto_depth;
@ -384,7 +384,7 @@ h8300_pop_frame ()
{ {
if (fsr.regs[regnum]) 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 (); flush_cached_frames ();

View File

@ -33,6 +33,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "../opcodes/sh-opc.h" #include "../opcodes/sh-opc.h"
/* Prologue looks like /* Prologue looks like
[mov.l <regs>,@-r15]... [mov.l <regs>,@-r15]...
[sts.l pr,@-r15] [sts.l pr,@-r15]
@ -152,7 +154,8 @@ frame_find_saved_regs (fi, fsr)
depth += -((char) (insn & 0xff)); depth += -((char) (insn & 0xff));
insn = read_memory_integer (pc, 2); insn = read_memory_integer (pc, 2);
} }
else break; else
break;
} }
/* Now we know how deep things are, we can work out their addresses */ /* Now we know how deep things are, we can work out their addresses */
@ -174,7 +177,6 @@ frame_find_saved_regs (fi, fsr)
if (have_fp) if (have_fp)
{ {
fsr->regs[SP_REGNUM] = read_memory_integer (fsr->regs[FP_REGNUM], 4); fsr->regs[SP_REGNUM] = read_memory_integer (fsr->regs[FP_REGNUM], 4);
} }
else else
@ -182,7 +184,6 @@ frame_find_saved_regs (fi, fsr)
fsr->regs[SP_REGNUM] = fi->frame - 4; 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 /* Work out the return pc - either from the saved pr or the pr
value */ value */
@ -240,3 +241,15 @@ pop_frame ()
set_current_frame (create_new_frame (read_register (FP_REGNUM), set_current_frame (create_new_frame (read_register (FP_REGNUM),
read_pc ())); 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);
}