Enhance debug support
This commit is contained in:
parent
9811b59602
commit
87178dbdf7
4 changed files with 756 additions and 475 deletions
|
@ -1,3 +1,22 @@
|
|||
Wed Sep 4 11:35:17 1996 Michael Meissner <meissner@tiktok.cygnus.com>
|
||||
|
||||
* d10v_sim.h (DEBUG_*): Add bit flags for controlling debug
|
||||
output.
|
||||
(_ins_type): New enumeration to specify which container an
|
||||
instruction is in, and whether it is part of a parallel operation.
|
||||
(_state): Add ins_type field.
|
||||
|
||||
* simops.c: Change all #ifdef DEBUG code so that the input and
|
||||
output values can be traced, along with the instruction type.
|
||||
|
||||
* interp.c (_leftright): New enumeration to say whether 2 short
|
||||
instructions are done left first or right first.
|
||||
(do_{long,2_short,parallel}): Indicate in the machine state which
|
||||
type of instruction this is.
|
||||
(sim_size): Only print the memory sizes if DEBUG_MEMSIZE debug
|
||||
flag is set.
|
||||
(sim_resume): Pass left/right indication to do_2_short.
|
||||
|
||||
Wed Sep 04 04:45:34 1996 Mark Alexander <marka@cygnus.com>
|
||||
|
||||
* simops.c: Include correct syscall.h for d10v, not host's.
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "ansidecl.h"
|
||||
#include "callback.h"
|
||||
#include "opcode/d10v.h"
|
||||
|
||||
#define DEBUG_TRACE 0x00000001
|
||||
#define DEBUG_VALUES 0x00000002
|
||||
#define DEBUG_MEMSIZE 0x00000004
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
|
||||
/* FIXME: host defines */
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
|
@ -28,6 +37,16 @@ struct simops
|
|||
int operands[9];
|
||||
};
|
||||
|
||||
enum _ins_type
|
||||
{
|
||||
INS_UNKNOWN,
|
||||
INS_LEFT,
|
||||
INS_RIGHT,
|
||||
INS_LEFT_PARALLEL,
|
||||
INS_RIGHT_PARALLEL,
|
||||
INS_LONG
|
||||
};
|
||||
|
||||
struct _state
|
||||
{
|
||||
reg_t regs[16]; /* general-purpose registers */
|
||||
|
@ -48,8 +67,10 @@ struct _state
|
|||
uint8 *imem;
|
||||
uint8 *dmem;
|
||||
int exception;
|
||||
enum _ins_type ins_type;
|
||||
} State;
|
||||
|
||||
extern host_callback *d10v_callback;
|
||||
extern uint16 OP[4];
|
||||
extern struct simops Simops[];
|
||||
|
||||
|
@ -102,6 +123,7 @@ extern struct simops Simops[];
|
|||
#define RW(x) (*((uint16 *)((x)+State.imem)))
|
||||
#define RLW(x) (*((uint32 *)((x)+State.imem)))
|
||||
#define SW(addr,data) RW(addr)=data
|
||||
#define SLW(addr,data) RLW(addr)=data
|
||||
#define READ_16(x) (*((int16 *)(x)))
|
||||
#define WRITE_16(addr,data) (*(int16 *)(addr)=data)
|
||||
#define READ_64(x) (*((int64 *)(x)))
|
||||
|
@ -113,10 +135,12 @@ uint32 get_longword PARAMS ((uint8 *));
|
|||
uint16 get_word PARAMS ((uint8 *));
|
||||
int64 get_longlong PARAMS ((uint8 *));
|
||||
void write_word PARAMS ((uint8 *addr, uint16 data));
|
||||
void write_longword PARAMS ((uint8 *addr, uint32 data));
|
||||
void write_longlong PARAMS ((uint8 *addr, int64 data));
|
||||
|
||||
#define SW(addr,data) write_word((long)(addr)+State.imem,data)
|
||||
#define RW(x) get_word((long)(x)+State.imem)
|
||||
#define SLW(addr,data) write_longword((long)(addr)+State.imem,data)
|
||||
#define RLW(x) get_longword((long)(x)+State.imem)
|
||||
#define READ_16(x) get_word(x)
|
||||
#define WRITE_16(addr,data) write_word(addr,data)
|
||||
|
|
|
@ -2,13 +2,16 @@
|
|||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "remote-sim.h"
|
||||
#include "callback.h"
|
||||
|
||||
#include "d10v_sim.h"
|
||||
|
||||
#define IMEM_SIZE 18 /* D10V instruction memory size is 18 bits */
|
||||
#define DMEM_SIZE 16 /* Data memory */
|
||||
|
||||
enum _leftright { LEFT_FIRST, RIGHT_FIRST };
|
||||
|
||||
host_callback *d10v_callback;
|
||||
|
||||
uint16 OP[4];
|
||||
|
||||
static struct hash_entry *lookup_hash PARAMS ((uint32 ins, int size));
|
||||
|
@ -51,7 +54,7 @@ lookup_hash (ins, size)
|
|||
{
|
||||
if (h->next == NULL)
|
||||
{
|
||||
printf ("ERROR looking up hash for %x\n",ins);
|
||||
printf ("ERROR looking up hash for %x at PC %x\n",ins, PC);
|
||||
exit(1);
|
||||
}
|
||||
h = h->next;
|
||||
|
@ -84,6 +87,7 @@ get_word (x)
|
|||
return ((uint16)a[0]<<8) + a[1];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
write_word (addr, data)
|
||||
uint8 *addr;
|
||||
|
@ -94,6 +98,17 @@ write_word (addr, data)
|
|||
a[1] = data & 0xff;
|
||||
}
|
||||
|
||||
void
|
||||
write_longword (addr, data)
|
||||
uint8 *addr;
|
||||
uint32 data;
|
||||
{
|
||||
addr[0] = (data >> 24) & 0xff;
|
||||
addr[1] = (data >> 16) & 0xff;
|
||||
addr[2] = (data >> 8) & 0xff;
|
||||
addr[3] = data & 0xff;
|
||||
}
|
||||
|
||||
void
|
||||
write_longlong (addr, data)
|
||||
uint8 *addr;
|
||||
|
@ -110,7 +125,6 @@ write_longlong (addr, data)
|
|||
a[7] = data & 0xff;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
get_operands (struct simops *s, uint32 ins)
|
||||
{
|
||||
|
@ -134,19 +148,23 @@ do_long (ins)
|
|||
/* printf ("do_long %x\n",ins); */
|
||||
h = lookup_hash (ins, 1);
|
||||
get_operands (h->ops, ins);
|
||||
State.ins_type = INS_LONG;
|
||||
(h->ops->func)();
|
||||
}
|
||||
static void
|
||||
do_2_short (ins1, ins2)
|
||||
do_2_short (ins1, ins2, leftright)
|
||||
uint16 ins1, ins2;
|
||||
enum _leftright leftright;
|
||||
{
|
||||
struct hash_entry *h;
|
||||
/* printf ("do_2_short %x -> %x\n",ins1,ins2); */
|
||||
h = lookup_hash (ins1, 0);
|
||||
get_operands (h->ops, ins1);
|
||||
State.ins_type = (leftright == LEFT_FIRST) ? INS_LEFT : INS_RIGHT;
|
||||
(h->ops->func)();
|
||||
h = lookup_hash (ins2, 0);
|
||||
get_operands (h->ops, ins2);
|
||||
State.ins_type = (leftright == LEFT_FIRST) ? INS_RIGHT : INS_LEFT;
|
||||
(h->ops->func)();
|
||||
}
|
||||
static void
|
||||
|
@ -161,28 +179,34 @@ do_parallel (ins1, ins2)
|
|||
if (h1->ops->exec_type == PARONLY)
|
||||
{
|
||||
get_operands (h1->ops, ins1);
|
||||
State.ins_type = INS_LEFT;
|
||||
(h1->ops->func)();
|
||||
if (State.exe)
|
||||
{
|
||||
get_operands (h2->ops, ins2);
|
||||
State.ins_type = INS_RIGHT;
|
||||
(h2->ops->func)();
|
||||
}
|
||||
}
|
||||
else if (h2->ops->exec_type == PARONLY)
|
||||
{
|
||||
get_operands (h2->ops, ins2);
|
||||
State.ins_type = INS_RIGHT;
|
||||
(h2->ops->func)();
|
||||
if (State.exe)
|
||||
{
|
||||
get_operands (h1->ops, ins1);
|
||||
State.ins_type = INS_LEFT;
|
||||
(h1->ops->func)();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
get_operands (h1->ops, ins1);
|
||||
State.ins_type = INS_LEFT_PARALLEL;
|
||||
(h1->ops->func)();
|
||||
get_operands (h2->ops, ins2);
|
||||
State.ins_type = INS_RIGHT_PARALLEL;
|
||||
(h2->ops->func)();
|
||||
}
|
||||
}
|
||||
|
@ -206,8 +230,10 @@ sim_size (power)
|
|||
fprintf (stderr,"Memory allocation failed.\n");
|
||||
exit(1);
|
||||
}
|
||||
#if (DEBUG & DEBUG_MEMSIZE) != 0
|
||||
printf ("Allocated %d bytes instruction memory and\n",1<<IMEM_SIZE);
|
||||
printf (" %d bytes data memory.\n",1<<DMEM_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -312,11 +338,11 @@ sim_resume (step, siggnal)
|
|||
break;
|
||||
case 0x80000000:
|
||||
/* R -> L */
|
||||
do_2_short ( inst & 0x7FFF, (inst & 0x3FFF8000) >> 15);
|
||||
do_2_short ( inst & 0x7FFF, (inst & 0x3FFF8000) >> 15, 0);
|
||||
break;
|
||||
case 0x40000000:
|
||||
/* L -> R */
|
||||
do_2_short ((inst & 0x3FFF8000) >> 15, inst & 0x7FFF);
|
||||
do_2_short ((inst & 0x3FFF8000) >> 15, inst & 0x7FFF, 1);
|
||||
break;
|
||||
case 0:
|
||||
do_parallel ((inst & 0x3FFF8000) >> 15, inst & 0x7FFF);
|
||||
|
@ -374,8 +400,8 @@ void
|
|||
sim_set_callbacks(p)
|
||||
host_callback *p;
|
||||
{
|
||||
printf ("sim_set_callbacks\n");
|
||||
/* callback = p; */
|
||||
/* printf ("sim_set_callbacks\n"); */
|
||||
d10v_callback = p;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
1146
sim/d10v/simops.c
1146
sim/d10v/simops.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue