* findvar.c (read_register, write_register): Make these capable
of reading/writing registers that are shorter than REGISTER_TYPE. * (value_from_register): Install H8500 specific code to return proper value when register is being used as a pointer. * h8500-tdep.c: Remove extra defines of NUM_REGS. (h8500_skip_prologue): Use correct lengths for LINK instructions. (FRAME_CHAIN): Change name to h8500_frame_chain. Rewrite code to chain frames properly by combining frame pointer with T reg. (init_extra_frame_info): Delete. It's now a macro. (frame_args_address): Don't add PTR_SIZE. Stack args are already offset by the correct amount off of the frame pointer. (register_byte): Delete. It's now a macro. (register_raw_size, register_virtual_size): Delete. Replaced by common routine h8500_register_size, cuz there's no difference between the raw & virtual sizes on this machine. (register_convert_to_raw, register_convert_to_virtual): Delete, cuz there's no difference between the raw & virtual forms. Replaced by memcpy in tm file. (register_virtual_type): Rename to h8500_register_virtual_type. Get rid of pointer pseudo-regs, use _REGNUM with all reg names. (_initialize_h8500_tdep): Get rid of crock to ensure that GDB & emulator have same reg offsets. This is all handled in the simulator code now. (h8500_trapped_internalvar): New routine to detect references to convenience vars acting as pointer pseudo-regs. (h8500_value_trapped_internalvar): Conjure up value of pointer pseudo-regs. (h8500_set_trapped_internalvar): Convert set value in real register references. infcmd.c (read_pc, write_pc): Add h8500 specific code to handle code segment register. infrun.c (proceed): Simplify. Call write_pc instead of doing it by hand. (wait_for_inferior): Add h8500 specific code to add stack segment when reading SP register. remote-sim.c (fetch_register): Spacing. tm-h8500.h: #define GDB_TARGET_IS_H8500 to make it easier to detect cruft. Redo all register manipulation stuff. Get rid of pointer pseudo-regs. (INIT_EXTRA_FRAME_INFO): Adds stack segment to frame pointer. (IS_TRAPPED_INTERNALVAL, VALUE_OF_TRAPPED_INTERNALVAR, SET_TRAPPED_INTERNALVAR): Use these to create internal vars for pointer pseudo-regs.
This commit is contained in:
parent
61001d969d
commit
ccf1e898d7
4 changed files with 507 additions and 198 deletions
|
@ -1,3 +1,48 @@
|
||||||
|
Thu Mar 25 12:26:50 1993 Stu Grossman (grossman@cygnus.com)
|
||||||
|
|
||||||
|
* findvar.c (read_register, write_register): Make these capable
|
||||||
|
of reading/writing registers that are shorter than REGISTER_TYPE.
|
||||||
|
* (value_from_register): Install H8500 specific code to return
|
||||||
|
proper value when register is being used as a pointer.
|
||||||
|
* h8500-tdep.c: Remove extra defines of NUM_REGS.
|
||||||
|
(h8500_skip_prologue): Use correct lengths for LINK instructions.
|
||||||
|
(FRAME_CHAIN): Change name to h8500_frame_chain. Rewrite code to
|
||||||
|
chain frames properly by combining frame pointer with T reg.
|
||||||
|
(init_extra_frame_info): Delete. It's now a macro.
|
||||||
|
(frame_args_address): Don't add PTR_SIZE. Stack args are already
|
||||||
|
offset by the correct amount off of the frame pointer.
|
||||||
|
(register_byte): Delete. It's now a macro.
|
||||||
|
(register_raw_size, register_virtual_size): Delete. Replaced by
|
||||||
|
common routine h8500_register_size, cuz there's no difference
|
||||||
|
between the raw & virtual sizes on this machine.
|
||||||
|
(register_convert_to_raw, register_convert_to_virtual): Delete,
|
||||||
|
cuz there's no difference between the raw & virtual forms.
|
||||||
|
Replaced by memcpy in tm file.
|
||||||
|
(register_virtual_type): Rename to h8500_register_virtual_type.
|
||||||
|
Get rid of pointer pseudo-regs, use _REGNUM with all reg names.
|
||||||
|
(_initialize_h8500_tdep): Get rid of crock to ensure that GDB &
|
||||||
|
emulator have same reg offsets. This is all handled in the
|
||||||
|
simulator code now.
|
||||||
|
(h8500_trapped_internalvar): New routine to detect references to
|
||||||
|
convenience vars acting as pointer pseudo-regs.
|
||||||
|
(h8500_value_trapped_internalvar): Conjure up value of pointer
|
||||||
|
pseudo-regs.
|
||||||
|
(h8500_set_trapped_internalvar): Convert set value in real
|
||||||
|
register references.
|
||||||
|
infcmd.c (read_pc, write_pc): Add h8500 specific code to handle
|
||||||
|
code segment register.
|
||||||
|
infrun.c (proceed): Simplify. Call write_pc instead of doing it
|
||||||
|
by hand.
|
||||||
|
(wait_for_inferior): Add h8500 specific code to add stack segment
|
||||||
|
when reading SP register.
|
||||||
|
remote-sim.c (fetch_register): Spacing.
|
||||||
|
tm-h8500.h: #define GDB_TARGET_IS_H8500 to make it easier to
|
||||||
|
detect cruft. Redo all register manipulation stuff. Get rid of
|
||||||
|
pointer pseudo-regs. (INIT_EXTRA_FRAME_INFO): Adds stack segment
|
||||||
|
to frame pointer. (IS_TRAPPED_INTERNALVAL,
|
||||||
|
VALUE_OF_TRAPPED_INTERNALVAR, SET_TRAPPED_INTERNALVAR): Use these
|
||||||
|
to create internal vars for pointer pseudo-regs.
|
||||||
|
|
||||||
Thu Mar 25 10:10:28 1993 Fred Fish (fnf@cygnus.com)
|
Thu Mar 25 10:10:28 1993 Fred Fish (fnf@cygnus.com)
|
||||||
|
|
||||||
* Makefile.in: Numerous small changes to macro definitions
|
* Makefile.in: Numerous small changes to macro definitions
|
||||||
|
|
335
gdb/h8500-tdep.c
335
gdb/h8500-tdep.c
|
@ -28,15 +28,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "gdbtypes.h"
|
#include "gdbtypes.h"
|
||||||
#include "gdbcmd.h"
|
#include "gdbcmd.h"
|
||||||
|
#include "value.h"
|
||||||
#include "dis-asm.h"
|
#include "dis-asm.h"
|
||||||
#include "../opcodes/h8500-opc.h"
|
#include "../opcodes/h8500-opc.h"
|
||||||
;
|
;
|
||||||
#undef NUM_REGS
|
|
||||||
#define NUM_REGS 11
|
|
||||||
|
|
||||||
#define UNSIGNED_SHORT(X) ((X) & 0xffff)
|
#define UNSIGNED_SHORT(X) ((X) & 0xffff)
|
||||||
|
|
||||||
|
|
||||||
/* Shape of an H8/500 frame :
|
/* Shape of an H8/500 frame :
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,6 +77,11 @@ int minimum_mode = 1;
|
||||||
CORE_ADDR examine_prologue ();
|
CORE_ADDR examine_prologue ();
|
||||||
|
|
||||||
void frame_find_saved_regs ();
|
void frame_find_saved_regs ();
|
||||||
|
|
||||||
|
int regoff[NUM_REGS] = {0, 2, 4, 6, 8, 10, 12, 14, /* r0->r7 */
|
||||||
|
16, 18, /* ccr, pc */
|
||||||
|
20, 21, 22, 23}; /* cp, dp, ep, tp */
|
||||||
|
|
||||||
CORE_ADDR
|
CORE_ADDR
|
||||||
h8500_skip_prologue (start_pc)
|
h8500_skip_prologue (start_pc)
|
||||||
CORE_ADDR start_pc;
|
CORE_ADDR start_pc;
|
||||||
|
@ -86,47 +89,20 @@ h8500_skip_prologue (start_pc)
|
||||||
{
|
{
|
||||||
short int w;
|
short int w;
|
||||||
|
|
||||||
|
|
||||||
w = read_memory_integer (start_pc, 1);
|
w = read_memory_integer (start_pc, 1);
|
||||||
if (w == LINK_8)
|
if (w == LINK_8)
|
||||||
{
|
{
|
||||||
start_pc ++;
|
start_pc += 2;
|
||||||
w = read_memory_integer (start_pc,1);
|
w = read_memory_integer (start_pc,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w == LINK_16)
|
if (w == LINK_16)
|
||||||
{
|
{
|
||||||
start_pc +=2;
|
start_pc += 3;
|
||||||
w = read_memory_integer (start_pc,2);
|
w = read_memory_integer (start_pc,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip past a move to FP */
|
|
||||||
if (IS_MOVE_FP (w))
|
|
||||||
{
|
|
||||||
start_pc += 2;
|
|
||||||
w = read_memory_short (start_pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip the stack adjust */
|
|
||||||
|
|
||||||
if (IS_MOVK_R5 (w))
|
|
||||||
{
|
|
||||||
start_pc += 2;
|
|
||||||
w = read_memory_short (start_pc);
|
|
||||||
}
|
|
||||||
if (IS_SUB_R5SP (w))
|
|
||||||
{
|
|
||||||
start_pc += 2;
|
|
||||||
w = read_memory_short (start_pc);
|
|
||||||
}
|
|
||||||
while (IS_SUB2_SP (w))
|
|
||||||
{
|
|
||||||
start_pc += 2;
|
|
||||||
w = read_memory_short (start_pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return start_pc;
|
return start_pc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -150,22 +126,15 @@ print_insn (memaddr, stream)
|
||||||
the function prologue to determine the caller's sp value, and return it. */
|
the function prologue to determine the caller's sp value, and return it. */
|
||||||
|
|
||||||
FRAME_ADDR
|
FRAME_ADDR
|
||||||
FRAME_CHAIN (thisframe)
|
h8500_frame_chain (thisframe)
|
||||||
FRAME thisframe;
|
FRAME thisframe;
|
||||||
{
|
{
|
||||||
static int loopcount;
|
|
||||||
static int prevr;
|
|
||||||
if (!inside_entry_file ((thisframe)->pc))
|
|
||||||
{
|
|
||||||
int v = read_memory_integer ((thisframe)->frame, PTR_SIZE) ;
|
|
||||||
|
|
||||||
/* Detect loops in the stack */
|
if (!inside_entry_file (thisframe->pc))
|
||||||
if (v == prevr) loopcount++;
|
return read_memory_integer(thisframe->frame, 2)
|
||||||
else loopcount = 0;
|
| (read_register(SEG_T_REGNUM) << 16);
|
||||||
v = prevr;
|
else
|
||||||
if (loopcount > 5) return 0;
|
return 0;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put here the code to store, into a struct frame_saved_regs,
|
/* Put here the code to store, into a struct frame_saved_regs,
|
||||||
|
@ -361,19 +330,6 @@ examine_prologue (ip, limit, after_prolog_fp, fsr, fi)
|
||||||
return (ip);
|
return (ip);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
|
||||||
void
|
|
||||||
init_extra_frame_info (fromleaf, fi)
|
|
||||||
int fromleaf;
|
|
||||||
struct frame_info *fi;
|
|
||||||
{
|
|
||||||
fi->fsr = 0; /* Not yet allocated */
|
|
||||||
fi->args_pointer = 0; /* Unknown */
|
|
||||||
fi->locals_pointer = 0; /* Unknown */
|
|
||||||
fi->from_pc = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Return the saved PC from this frame. */
|
/* Return the saved PC from this frame. */
|
||||||
|
|
||||||
|
@ -381,7 +337,7 @@ CORE_ADDR
|
||||||
frame_saved_pc (frame)
|
frame_saved_pc (frame)
|
||||||
FRAME frame;
|
FRAME frame;
|
||||||
{
|
{
|
||||||
return read_memory_integer ((frame)->frame + 2, PTR_SIZE);
|
return read_memory_integer ((frame)->frame + 2, PTR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CORE_ADDR
|
CORE_ADDR
|
||||||
|
@ -398,7 +354,7 @@ CORE_ADDR
|
||||||
frame_args_address (fi)
|
frame_args_address (fi)
|
||||||
struct frame_info *fi;
|
struct frame_info *fi;
|
||||||
{
|
{
|
||||||
return fi->frame + PTR_SIZE; /* Skip the PC */
|
return fi->frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -474,127 +430,43 @@ print_register_hook (regno)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
h8500_register_size (regno)
|
||||||
#if 0
|
int regno;
|
||||||
register_byte (N)
|
|
||||||
{
|
{
|
||||||
return reginfo[N].offset;
|
if (regno <= PC_REGNUM)
|
||||||
}
|
return 2;
|
||||||
#endif
|
else
|
||||||
register_raw_size (N)
|
return 1;
|
||||||
{
|
|
||||||
if (N <= R7) return 2;
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
register_virtual_size (N)
|
|
||||||
{
|
|
||||||
if (N <= R7) return 2;
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
register_convert_to_raw (regnum, from, to)
|
|
||||||
int regnum;
|
|
||||||
char *from;
|
|
||||||
char *to;
|
|
||||||
{
|
|
||||||
switch (regnum)
|
|
||||||
{
|
|
||||||
case PR0:
|
|
||||||
case PR1:
|
|
||||||
case PR2:
|
|
||||||
case PR3:
|
|
||||||
case PR4:
|
|
||||||
case PR5:
|
|
||||||
case PR6:
|
|
||||||
case PR7:
|
|
||||||
case PC_REGNUM:
|
|
||||||
to[0] = 0;
|
|
||||||
to[1] = from[1];
|
|
||||||
to[2] = from[2];
|
|
||||||
to[3] = from[3];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
to[0] = from[0];
|
|
||||||
to[1] = from[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
register_convert_to_virtual (regnum, from, to)
|
|
||||||
int regnum;
|
|
||||||
char *from;
|
|
||||||
char *to;
|
|
||||||
{
|
|
||||||
switch (regnum)
|
|
||||||
{
|
|
||||||
case PR0:
|
|
||||||
case PR1:
|
|
||||||
case PR2:
|
|
||||||
case PR3:
|
|
||||||
case PR4:
|
|
||||||
case PR5:
|
|
||||||
case PR6:
|
|
||||||
case PR7:
|
|
||||||
case PC_REGNUM:
|
|
||||||
to[0] = 0;
|
|
||||||
to[1] = from[1];
|
|
||||||
to[2] = from[2];
|
|
||||||
to[3] = from[3];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
to[0] = from[0];
|
|
||||||
to[1] = from[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct type *
|
struct type *
|
||||||
register_virtual_type (N)
|
h8500_register_virtual_type (regno)
|
||||||
|
int regno;
|
||||||
{
|
{
|
||||||
switch (N)
|
switch (regno)
|
||||||
{
|
{
|
||||||
/* Although these are actually word size registers, we treat them
|
case SEG_C_REGNUM:
|
||||||
like longs so that we can deal with any implicit segmentation */
|
case SEG_E_REGNUM:
|
||||||
case PR0:
|
case SEG_D_REGNUM:
|
||||||
case PR1:
|
case SEG_T_REGNUM:
|
||||||
case PR2:
|
|
||||||
case PR3:
|
|
||||||
case PR4:
|
|
||||||
case PR5:
|
|
||||||
case PR6:
|
|
||||||
case PR7:
|
|
||||||
case PC_REGNUM:
|
|
||||||
return builtin_type_unsigned_long;
|
|
||||||
case SEG_C:
|
|
||||||
case SEG_E:
|
|
||||||
case SEG_D:
|
|
||||||
case SEG_T:
|
|
||||||
return builtin_type_unsigned_char;
|
return builtin_type_unsigned_char;
|
||||||
case R0:
|
case R0_REGNUM:
|
||||||
case R1:
|
case R1_REGNUM:
|
||||||
case R2:
|
case R2_REGNUM:
|
||||||
case R3:
|
case R3_REGNUM:
|
||||||
case R4:
|
case R4_REGNUM:
|
||||||
case R5:
|
case R5_REGNUM:
|
||||||
case R6:
|
case R6_REGNUM:
|
||||||
case R7:
|
case R7_REGNUM:
|
||||||
|
case PC_REGNUM:
|
||||||
case CCR_REGNUM:
|
case CCR_REGNUM:
|
||||||
return builtin_type_unsigned_short;
|
return builtin_type_unsigned_short;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Put here the code to store, into a struct frame_saved_regs,
|
/* Put here the code to store, into a struct frame_saved_regs,
|
||||||
the addresses of the saved registers of frame described by FRAME_INFO.
|
the addresses of the saved registers of frame described by FRAME_INFO.
|
||||||
This includes special registers such as pc and fp saved in special
|
This includes special registers such as pc and fp saved in special
|
||||||
|
@ -769,28 +641,119 @@ set_memory (args, from_tty)
|
||||||
help_list (setmemorylist, "set memory ", -1, stdout);
|
help_list (setmemorylist, "set memory ", -1, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See if variable name is ppc or pr[0-7] */
|
||||||
|
|
||||||
|
int
|
||||||
|
h8500_is_trapped_internalvar (name)
|
||||||
|
char *name;
|
||||||
|
{
|
||||||
|
if (name[0] != 'p')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (strcmp(name+1, "pc") == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (name[1] == 'r'
|
||||||
|
&& name[2] >= '0'
|
||||||
|
&& name[2] <= '7'
|
||||||
|
&& name[3] == '\000')
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PTR
|
||||||
|
h8500_value_of_trapped_internalvar (var)
|
||||||
|
struct internalvar *var;
|
||||||
|
{
|
||||||
|
LONGEST regval;
|
||||||
|
unsigned char regbuf[4];
|
||||||
|
int page_regnum, regnum;
|
||||||
|
|
||||||
|
regnum = var->name[2] == 'c' ? PC_REGNUM : var->name[2] - '0';
|
||||||
|
|
||||||
|
switch (var->name[2])
|
||||||
|
{
|
||||||
|
case 'c':
|
||||||
|
page_regnum = SEG_C_REGNUM;
|
||||||
|
break;
|
||||||
|
case '0': case '1': case '2': case '3':
|
||||||
|
page_regnum = SEG_D_REGNUM;
|
||||||
|
break;
|
||||||
|
case '4': case '5':
|
||||||
|
page_regnum = SEG_E_REGNUM;
|
||||||
|
break;
|
||||||
|
case '6': case '7':
|
||||||
|
page_regnum = SEG_T_REGNUM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
get_saved_register (regbuf, NULL, NULL, selected_frame, page_regnum, NULL);
|
||||||
|
regval = regbuf[0] << 16;
|
||||||
|
|
||||||
|
get_saved_register (regbuf, NULL, NULL, selected_frame, regnum, NULL);
|
||||||
|
regval |= regbuf[0] << 8 | regbuf[1]; /* XXX host/target byte order */
|
||||||
|
|
||||||
|
free (var->value); /* Free up old value */
|
||||||
|
|
||||||
|
var->value = value_from_longest (builtin_type_unsigned_long, regval);
|
||||||
|
release_value (var->value); /* Unchain new value */
|
||||||
|
|
||||||
|
VALUE_LVAL (var->value) = lval_internalvar;
|
||||||
|
VALUE_INTERNALVAR (var->value) = var;
|
||||||
|
return var->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
h8500_set_trapped_internalvar (var, newval, bitpos, bitsize, offset)
|
||||||
|
struct internalvar *var;
|
||||||
|
int offset, bitpos, bitsize;
|
||||||
|
value newval;
|
||||||
|
{
|
||||||
|
char *page_regnum, *regnum;
|
||||||
|
char expression[100];
|
||||||
|
unsigned new_regval;
|
||||||
|
struct type *type;
|
||||||
|
enum type_code newval_type_code;
|
||||||
|
|
||||||
|
type = VALUE_TYPE (newval);
|
||||||
|
newval_type_code = TYPE_CODE (type);
|
||||||
|
|
||||||
|
if ((newval_type_code != TYPE_CODE_INT
|
||||||
|
&& newval_type_code != TYPE_CODE_PTR)
|
||||||
|
|| TYPE_LENGTH (type) != sizeof(new_regval))
|
||||||
|
error("Illegal type (%s) for assignment to $%s\n",
|
||||||
|
TYPE_NAME (type), var->name);
|
||||||
|
|
||||||
|
new_regval = *(long *)VALUE_CONTENTS_RAW(newval);
|
||||||
|
|
||||||
|
regnum = var->name + 1;
|
||||||
|
|
||||||
|
switch (var->name[2])
|
||||||
|
{
|
||||||
|
case 'c':
|
||||||
|
page_regnum = "cp";
|
||||||
|
break;
|
||||||
|
case '0': case '1': case '2': case '3':
|
||||||
|
page_regnum = "dp";
|
||||||
|
break;
|
||||||
|
case '4': case '5':
|
||||||
|
page_regnum = "ep";
|
||||||
|
break;
|
||||||
|
case '6': case '7':
|
||||||
|
page_regnum = "tp";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf (expression, "$%s=%d", page_regnum, new_regval >> 16);
|
||||||
|
parse_and_eval(expression);
|
||||||
|
|
||||||
|
sprintf (expression, "$%s=%d", regnum, new_regval & 0xffff);
|
||||||
|
parse_and_eval(expression);
|
||||||
|
}
|
||||||
|
|
||||||
_initialize_h8500_tdep ()
|
_initialize_h8500_tdep ()
|
||||||
{
|
{
|
||||||
/* Sanitity check a few things */
|
|
||||||
if (FP_REGNUM != GPR6
|
|
||||||
|| SP_REGNUM != GPR7
|
|
||||||
|| CCR_REGNUM != GCCR
|
|
||||||
|| PC_REGNUM != GPC
|
|
||||||
|| SEG_C != GSEGC
|
|
||||||
|| SEG_D != GSEGD
|
|
||||||
|| SEG_E != GSEGE
|
|
||||||
|| SEG_T != GSEGT
|
|
||||||
|| PR0 != GPR0
|
|
||||||
|| PR1 != GPR1
|
|
||||||
|| PR2 != GPR2
|
|
||||||
|| PR3 != GPR3
|
|
||||||
|| PR4 != GPR4
|
|
||||||
|| PR5 != GPR5
|
|
||||||
|| PR6 != GPR6
|
|
||||||
|| PR7 != GPR7)
|
|
||||||
abort ();
|
|
||||||
|
|
||||||
add_prefix_cmd ("memory", no_class, set_memory,
|
add_prefix_cmd ("memory", no_class, set_memory,
|
||||||
"set the memory model", &setmemorylist, "set memory ", 0,
|
"set the memory model", &setmemorylist, "set memory ", 0,
|
||||||
&setlist);
|
&setlist);
|
||||||
|
|
|
@ -191,23 +191,22 @@ sim_wait (status)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fetch_register(regno)
|
fetch_register(regno)
|
||||||
int regno;
|
int regno;
|
||||||
{
|
{
|
||||||
if (regno == -1)
|
if (regno == -1)
|
||||||
{
|
{
|
||||||
for (regno = 0; regno < NUM_REGS; regno++)
|
for (regno = 0; regno < NUM_REGS; regno++)
|
||||||
fetch_register(regno);
|
fetch_register(regno);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buf[MAX_REGISTER_RAW_SIZE];
|
char buf[MAX_REGISTER_RAW_SIZE];
|
||||||
sim_fetch_register(regno, buf);
|
|
||||||
supply_register(regno, buf);
|
sim_fetch_register(regno, buf);
|
||||||
}
|
supply_register(regno, buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
302
gdb/tm-h8500.h
Normal file
302
gdb/tm-h8500.h
Normal file
|
@ -0,0 +1,302 @@
|
||||||
|
/* Parameters for execution on a H8/500 series machine.
|
||||||
|
Copyright (C) 1993 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GDB.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
/* Contributed by Steve Chamberlain sac@cygnus.com */
|
||||||
|
|
||||||
|
#define GDB_TARGET_IS_H8500
|
||||||
|
|
||||||
|
#define IEEE_FLOAT 1
|
||||||
|
|
||||||
|
/* Define the bit, byte, and word ordering of the machine. */
|
||||||
|
|
||||||
|
#define TARGET_BYTE_ORDER BIG_ENDIAN
|
||||||
|
|
||||||
|
#undef TARGET_INT_BIT
|
||||||
|
#define TARGET_INT_BIT 16
|
||||||
|
|
||||||
|
#undef TARGET_PTR_BIT
|
||||||
|
#define TARGET_PTR_BIT (minimum_mode ? 16 : 32)
|
||||||
|
|
||||||
|
|
||||||
|
/* Offset from address of function to start of its code.
|
||||||
|
Zero on most machines. */
|
||||||
|
|
||||||
|
#define FUNCTION_START_OFFSET 0
|
||||||
|
|
||||||
|
/* Advance PC across any function entry prologue instructions
|
||||||
|
to reach some "real" code. */
|
||||||
|
|
||||||
|
#define SKIP_PROLOGUE(ip) {(ip) = h8500_skip_prologue(ip);}
|
||||||
|
extern CORE_ADDR h8500_skip_prologue ();
|
||||||
|
|
||||||
|
|
||||||
|
/* Immediately after a function call, return the saved pc.
|
||||||
|
Can't always go through the frames for this because on some machines
|
||||||
|
the new frame is not set up until the new function executes
|
||||||
|
some instructions. */
|
||||||
|
|
||||||
|
#define SAVED_PC_AFTER_CALL(frame) saved_pc_after_call(frame)
|
||||||
|
|
||||||
|
|
||||||
|
/* Stack grows downward. */
|
||||||
|
|
||||||
|
#define INNER_THAN <
|
||||||
|
|
||||||
|
/* Illegal instruction - used by the simulator for breakpoint
|
||||||
|
detection */
|
||||||
|
#define BREAKPOINT {0x0b}
|
||||||
|
|
||||||
|
|
||||||
|
/* If your kernel resets the pc after the trap happens you may need to
|
||||||
|
define this before including this file. */
|
||||||
|
|
||||||
|
#define DECR_PC_AFTER_BREAK 0
|
||||||
|
|
||||||
|
|
||||||
|
/* Nonzero if instruction at PC is a return instruction. */
|
||||||
|
|
||||||
|
#define ABOUT_TO_RETURN(pc) about_to_return(pc)
|
||||||
|
|
||||||
|
/* Return 1 if P points to an invalid floating point value. */
|
||||||
|
|
||||||
|
#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
|
||||||
|
|
||||||
|
/* Say how long registers are. */
|
||||||
|
|
||||||
|
#define REGISTER_TYPE unsigned long
|
||||||
|
|
||||||
|
/* Say how much memory is needed to store a copy of the register set */
|
||||||
|
|
||||||
|
#define REGISTER_BYTES (24)
|
||||||
|
|
||||||
|
/* Index within `registers' of the first byte of the space for
|
||||||
|
register N. */
|
||||||
|
|
||||||
|
int regoff[];
|
||||||
|
#define REGISTER_BYTE(N) (regoff[N])
|
||||||
|
|
||||||
|
/* Number of bytes of storage in the actual machine representation
|
||||||
|
for register N. */
|
||||||
|
|
||||||
|
#define REGISTER_RAW_SIZE(N) h8500_register_size(N)
|
||||||
|
int h8500_register_size PARAMS ((int regno));
|
||||||
|
|
||||||
|
#define REGISTER_VIRTUAL_SIZE(N) h8500_register_size(N)
|
||||||
|
|
||||||
|
/* Largest value REGISTER_RAW_SIZE can have. */
|
||||||
|
|
||||||
|
#define MAX_REGISTER_RAW_SIZE 4
|
||||||
|
|
||||||
|
/* Largest value REGISTER_VIRTUAL_SIZE can have. */
|
||||||
|
|
||||||
|
#define MAX_REGISTER_VIRTUAL_SIZE 4
|
||||||
|
|
||||||
|
/* Nonzero if register N requires conversion
|
||||||
|
from raw format to virtual format. */
|
||||||
|
|
||||||
|
#define REGISTER_CONVERTIBLE(N) (0)
|
||||||
|
|
||||||
|
/* Convert data from raw format for register REGNUM
|
||||||
|
to virtual format for register REGNUM. */
|
||||||
|
|
||||||
|
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
|
||||||
|
{ memcpy ((TO), (FROM), 4); }
|
||||||
|
|
||||||
|
/* Convert data from virtual format for register REGNUM
|
||||||
|
to raw format for register REGNUM. */
|
||||||
|
|
||||||
|
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
|
||||||
|
{ memcpy ((TO), (FROM), 4); }
|
||||||
|
|
||||||
|
/* Return the GDB type object for the "standard" data type
|
||||||
|
of data in register N. */
|
||||||
|
|
||||||
|
#define REGISTER_VIRTUAL_TYPE(N) h8500_register_virtual_type(N)
|
||||||
|
struct type *h8500_register_virtual_type PARAMS ((int regno));
|
||||||
|
|
||||||
|
/* Initializer for an array of names of registers.
|
||||||
|
Entries beyond the first NUM_REGS are ignored. */
|
||||||
|
|
||||||
|
#define REGISTER_NAMES \
|
||||||
|
{"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
|
||||||
|
"ccr","pc", \
|
||||||
|
"cp","dp","ep","tp" }
|
||||||
|
|
||||||
|
/* Register numbers of various important registers.
|
||||||
|
Note that some of these values are "real" register numbers,
|
||||||
|
and correspond to the general registers of the machine,
|
||||||
|
and some are "phony" register numbers which are too large
|
||||||
|
to be actual register numbers as far as the user is concerned
|
||||||
|
but do serve to get the desired values when passed to read_register. */
|
||||||
|
|
||||||
|
|
||||||
|
#define R0_REGNUM 0
|
||||||
|
#define R1_REGNUM 1
|
||||||
|
#define R2_REGNUM 2
|
||||||
|
#define R3_REGNUM 3
|
||||||
|
#define R4_REGNUM 4
|
||||||
|
#define R5_REGNUM 5
|
||||||
|
#define R6_REGNUM 6
|
||||||
|
#define R7_REGNUM 7
|
||||||
|
|
||||||
|
#define SP_REGNUM R7_REGNUM /* Contains address of top of stack */
|
||||||
|
#define FP_REGNUM R6_REGNUM /* Contains address of executing stack frame */
|
||||||
|
|
||||||
|
#define CCR_REGNUM 8 /* Contains processor status */
|
||||||
|
#define PC_REGNUM 9 /* Contains program counter */
|
||||||
|
|
||||||
|
#define SEG_C_REGNUM 10 /* Segment registers */
|
||||||
|
#define SEG_D_REGNUM 11
|
||||||
|
#define SEG_E_REGNUM 12
|
||||||
|
#define SEG_T_REGNUM 13
|
||||||
|
|
||||||
|
#define NUM_REGS 14
|
||||||
|
|
||||||
|
#define PTR_SIZE (minimum_mode ? 2: 4)
|
||||||
|
#define PTR_MASK (minimum_mode ? 0x0000ffff : 0x00ffffff)
|
||||||
|
|
||||||
|
/* Store the address of the place in which to copy the structure the
|
||||||
|
subroutine will return. This is called from call_function. */
|
||||||
|
|
||||||
|
/*#define STORE_STRUCT_RETURN(ADDR, SP) \
|
||||||
|
{ write_register (0, (ADDR)); abort(); }*/
|
||||||
|
|
||||||
|
/* Extract from an array REGBUF containing the (raw) register state
|
||||||
|
a function return value of type TYPE, and copy that, in virtual format,
|
||||||
|
into VALBUF. */
|
||||||
|
|
||||||
|
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
|
||||||
|
bcopy ((char *)(REGBUF), VALBUF, TYPE_LENGTH(TYPE))
|
||||||
|
|
||||||
|
|
||||||
|
/* Write into appropriate registers a function return value
|
||||||
|
of type TYPE, given in virtual format. Assumes floats are passed
|
||||||
|
in d0/d1. */
|
||||||
|
|
||||||
|
|
||||||
|
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
|
||||||
|
write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
|
||||||
|
|
||||||
|
|
||||||
|
/* Extract from an array REGBUF containing the (raw) register state
|
||||||
|
the address in which a function should return its structure value,
|
||||||
|
as a CORE_ADDR (or an expression that can be used as one). */
|
||||||
|
|
||||||
|
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(CORE_ADDR *)(REGBUF))
|
||||||
|
|
||||||
|
|
||||||
|
/* Define other aspects of the stack frame. */
|
||||||
|
|
||||||
|
/* A macro that tells us whether the function invocation represented
|
||||||
|
by FI does not have a frame on the stack associated with it. If it
|
||||||
|
does not, FRAMELESS is set to 1, else 0. */
|
||||||
|
#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
|
||||||
|
(FRAMELESS) = frameless_look_for_prologue(FI)
|
||||||
|
|
||||||
|
/* Any function with a frame looks like this
|
||||||
|
SECOND ARG
|
||||||
|
FIRST ARG
|
||||||
|
RET PC
|
||||||
|
SAVED R2
|
||||||
|
SAVED R3
|
||||||
|
SAVED FP <-FP POINTS HERE
|
||||||
|
LOCALS0
|
||||||
|
LOCALS1 <-SP POINTS HERE
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
CORE_ADDR h8500_frame_chain PARAMS ((FRAME thisframe));
|
||||||
|
|
||||||
|
#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \
|
||||||
|
(fci)->frame |= read_register(SEG_T_REGNUM) << 16;
|
||||||
|
|
||||||
|
#define FRAME_CHAIN(FRAME) h8500_frame_chain(FRAME)
|
||||||
|
|
||||||
|
#define FRAME_SAVED_PC(FRAME) frame_saved_pc(FRAME)
|
||||||
|
|
||||||
|
#define FRAME_ARGS_ADDRESS(fi) frame_args_address(fi)
|
||||||
|
|
||||||
|
#define FRAME_LOCALS_ADDRESS(fi) frame_locals_address(fi);
|
||||||
|
|
||||||
|
/* Set VAL to the number of args passed to frame described by FI.
|
||||||
|
Can set VAL to -1, meaning no way to tell. */
|
||||||
|
|
||||||
|
/* We can't tell how many args there are
|
||||||
|
now that the C compiler delays popping them. */
|
||||||
|
|
||||||
|
#define FRAME_NUM_ARGS(val,fi) (val = -1)
|
||||||
|
|
||||||
|
/* Return number of bytes at start of arglist that are not really args. */
|
||||||
|
|
||||||
|
#define FRAME_ARGS_SKIP 0
|
||||||
|
|
||||||
|
/* Put here the code to store, into a struct frame_saved_regs,
|
||||||
|
the addresses of the saved registers of frame described by FRAME_INFO.
|
||||||
|
This includes special registers such as pc and fp saved in special
|
||||||
|
ways in the stack frame. sp is even more special:
|
||||||
|
the address we return for it IS the sp for the next frame. */
|
||||||
|
|
||||||
|
#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
|
||||||
|
frame_find_saved_regs(frame_info, &(frame_saved_regs))
|
||||||
|
|
||||||
|
|
||||||
|
/* Push an empty stack frame, to record the current PC, etc. */
|
||||||
|
|
||||||
|
/*#define PUSH_DUMMY_FRAME { h8300_push_dummy_frame (); }*/
|
||||||
|
|
||||||
|
/* Discard from the stack the innermost frame, restoring all registers. */
|
||||||
|
|
||||||
|
#define POP_FRAME { h8300_pop_frame (); }
|
||||||
|
|
||||||
|
#define SHORT_INT_MAX 32767
|
||||||
|
#define SHORT_INT_MIN -32768
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define BEFORE_MAIN_LOOP_HOOK \
|
||||||
|
hms_before_main_loop();
|
||||||
|
|
||||||
|
|
||||||
|
#define NAMES_HAVE_UNDERSCORE
|
||||||
|
|
||||||
|
typedef unsigned short INSN_WORD;
|
||||||
|
|
||||||
|
#define ADDR_BITS_REMOVE(addr) ((addr) & 0xffffff)
|
||||||
|
#define ADDR_BITS_SET(addr) (((addr)))
|
||||||
|
|
||||||
|
#define read_memory_short(x) (read_memory_integer(x,2) & 0xffff)
|
||||||
|
#define DONT_USE_REMOTE
|
||||||
|
|
||||||
|
|
||||||
|
#define PRINT_REGISTER_HOOK(regno) print_register_hook(regno)
|
||||||
|
|
||||||
|
int minimum_mode;
|
||||||
|
|
||||||
|
#define CALL_DUMMY_LENGTH 10
|
||||||
|
|
||||||
|
/* Fake variables to make it easy to use 24 bit register pointers */
|
||||||
|
|
||||||
|
int h8500_is_trapped_internalvar PARAMS ((char *name));
|
||||||
|
#define IS_TRAPPED_INTERNALVAR h8500_is_trapped_internalvar
|
||||||
|
|
||||||
|
PTR h8500_value_of_trapped_internalvar PARAMS ((struct internalvar *var));
|
||||||
|
#define VALUE_OF_TRAPPED_INTERNALVAR h8500_value_of_trapped_internalvar
|
||||||
|
|
||||||
|
void h8500_set_trapped_internalvar PARAMS ((struct internalvar *var, value newval, int bitpos, int bitsize, int offset));
|
||||||
|
#define SET_TRAPPED_INTERNALVAR h8500_set_trapped_internalvar
|
Loading…
Add table
Add a link
Reference in a new issue