* 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:
parent
bf3b8abd19
commit
df14b38baf
@ -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)
|
||||
|
||||
* Move config/m68k/tm-m68k.h (FRAME_FIND_SAVED_REGS) to
|
||||
|
112
gdb/findvar.c
112
gdb/findvar.c
@ -304,26 +304,40 @@ read_register (regno)
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,37 +354,62 @@ void
|
||||
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;
|
||||
|
||||
/* 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 (®isters[REGISTER_BYTE (regno)],
|
||||
ptr, size) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
target_prepare_to_store ();
|
||||
|
||||
register_valid [regno] = 1;
|
||||
memcpy (®isters[REGISTER_BYTE (regno)], ptr, size);
|
||||
|
||||
switch (REGISTER_RAW_SIZE(regno))
|
||||
{
|
||||
case sizeof (unsigned char):
|
||||
registers[REGISTER_BYTE (regno)] = val;
|
||||
break;
|
||||
case sizeof (sval):
|
||||
sval = val;
|
||||
SWAP_TARGET_AND_HOST (&sval, sizeof (sval));
|
||||
memcpy (®isters[REGISTER_BYTE (regno)], &sval, sizeof (sval));
|
||||
break;
|
||||
case sizeof (lval):
|
||||
lval = val;
|
||||
SWAP_TARGET_AND_HOST (&lval, sizeof (lval));
|
||||
memcpy (®isters[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));
|
||||
}
|
||||
register_valid [regno] = 1;
|
||||
|
||||
target_store_registers (regno);
|
||||
}
|
||||
@ -626,10 +665,8 @@ value_from_register (type, regnum, frame)
|
||||
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,
|
||||
@ -661,14 +698,14 @@ value_from_register (type, regnum, frame)
|
||||
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
|
||||
@ -710,6 +747,11 @@ value_from_register (type, regnum, frame)
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include "frame.h"
|
||||
#include "obstack.h"
|
||||
#include "symtab.h"
|
||||
#include <dis-asm.h>
|
||||
#undef NUM_REGS
|
||||
#define NUM_REGS 11
|
||||
|
||||
@ -57,19 +58,19 @@ h8300_skip_prologue (start_pc)
|
||||
{
|
||||
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 */
|
||||
@ -77,17 +78,17 @@ h8300_skip_prologue (start_pc)
|
||||
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;
|
||||
@ -99,11 +100,9 @@ print_insn (memaddr, stream)
|
||||
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.
|
||||
@ -297,14 +296,15 @@ examine_prologue (ip, limit, after_prolog_fp, fsr, fi)
|
||||
/* 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;
|
||||
|
||||
@ -384,7 +384,7 @@ h8300_pop_frame ()
|
||||
{
|
||||
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 ();
|
||||
|
@ -33,6 +33,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include "../opcodes/sh-opc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/* Prologue looks like
|
||||
[mov.l <regs>,@-r15]...
|
||||
[sts.l pr,@-r15]
|
||||
@ -152,7 +154,8 @@ frame_find_saved_regs (fi, fsr)
|
||||
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 */
|
||||
@ -174,7 +177,6 @@ frame_find_saved_regs (fi, fsr)
|
||||
|
||||
if (have_fp)
|
||||
{
|
||||
|
||||
fsr->regs[SP_REGNUM] = read_memory_integer (fsr->regs[FP_REGNUM], 4);
|
||||
}
|
||||
else
|
||||
@ -182,7 +184,6 @@ frame_find_saved_regs (fi, fsr)
|
||||
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 */
|
||||
@ -240,3 +241,15 @@ pop_frame ()
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user