Line 81... |
Line 81... |
#else /* no DEBUGMOD_OFF */
|
#else /* no DEBUGMOD_OFF */
|
#define GlobalMode 0
|
#define GlobalMode 0
|
#endif /* no DEBUGMOD_OFF */
|
#endif /* no DEBUGMOD_OFF */
|
|
|
/* CVS revision number. */
|
/* CVS revision number. */
|
const char rcsrev[] = "$Revision: 1.22 $";
|
const char rcsrev[] = "$Revision: 1.23 $";
|
|
|
/* Continuos run versus single step tracing switch. */
|
/* Continuos run versus single step tracing switch. */
|
int cont_run;
|
int cont_run;
|
|
|
/* History of execution */
|
/* History of execution */
|
Line 103... |
Line 103... |
"pc",
|
"pc",
|
"reset",
|
"reset",
|
"break",
|
"break",
|
"hist",
|
"hist",
|
"stats",
|
"stats",
|
|
"stall"
|
"info",
|
"info",
|
"r",
|
"r",
|
"dv",
|
"dv",
|
0
|
0
|
};
|
};
|
Line 169... |
Line 170... |
|
|
void
|
void
|
ctrl_c(signum)
|
ctrl_c(signum)
|
int signum;
|
int signum;
|
{
|
{
|
cont_run = 1;
|
extern int cpu_stalled; /* CZ from debug_interface */
|
|
cont_run = cpu_stalled ? 0 : 1;
|
config.iprompt = 1;
|
config.iprompt = 1;
|
|
cpu_stalled = 0;
|
signal(SIGINT, ctrl_c);
|
signal(SIGINT, ctrl_c);
|
}
|
}
|
|
|
void
|
void
|
version()
|
version()
|
Line 206... |
Line 209... |
printf("pm <addr> <value> - patch memory location <addr> with <value>\n");
|
printf("pm <addr> <value> - patch memory location <addr> with <value>\n");
|
printf("pc <value> - patch PC register with <value>\n");
|
printf("pc <value> - patch PC register with <value>\n");
|
printf("break <addr> - toggle breakpoint at address <addr>\n");
|
printf("break <addr> - toggle breakpoint at address <addr>\n");
|
printf("reset - simulator reset\n");
|
printf("reset - simulator reset\n");
|
printf("hist - execution history\n");
|
printf("hist - execution history\n");
|
|
printf("stall - stalls the processor and gives control to the debugger\n");
|
printf("stats <num|clear> - execution statistics num or clear it.\n");
|
printf("stats <num|clear> - execution statistics num or clear it.\n");
|
printf("info - configuration info (caches etc.)\n");
|
printf("info - configuration info (caches etc.)\n");
|
printf("dv <fromaddr> [<toaddr>] [<modname>] - dumps memory as verilog (use redirect)\n");
|
printf("dv <fromaddr> [<toaddr>] [<modname>] - dumps memory as verilog (use redirect)\n");
|
printf("dh <fromaddr> [<toaddr>] - dumps memory as hex code (use redirect)\n");
|
printf("dh <fromaddr> [<toaddr>] - dumps memory as hex code (use redirect)\n");
|
printf("<cmd> > <filename> - redirect simulator stdout to <filename> (and not emulated printf)\n");
|
printf("<cmd> > <filename> - redirect simulator stdout to <filename> (and not emulated printf)\n");
|
Line 227... |
Line 231... |
char item1[500], b2[500], prev_str[500] = "";
|
char item1[500], b2[500], prev_str[500] = "";
|
char *redirstr;
|
char *redirstr;
|
int hush;
|
int hush;
|
unsigned long endaddr = 0xFFFFFFFF;
|
unsigned long endaddr = 0xFFFFFFFF;
|
int first_prompt = 1;
|
int first_prompt = 1;
|
|
int trace_fd = 0;
|
|
|
srand(getpid());
|
srand(getpid());
|
init_defconfig();
|
init_defconfig();
|
if (parse_args(argc, argv)) {
|
if (parse_args(argc, argv)) {
|
printf("Usage: %s [options] <filename>\n", argv[0]);
|
printf("Usage: %s [options] <filename>\n", argv[0]);
|
Line 609... |
Line 614... |
hush = 1;
|
hush = 1;
|
else
|
else
|
hush = 0;
|
hush = 0;
|
cont_run = strtol(item2, NULL, 0);
|
cont_run = strtol(item2, NULL, 0);
|
} else
|
} else
|
|
if(!strcmp(item1, "stall")) { /* Added by CZ 210801 */
|
|
extern int cpu_stalled; /* CZ from debug_interface */
|
|
cpu_stalled = 1;
|
|
config.iprompt = 0;
|
|
cont_run = -1;
|
|
hush = 1;
|
|
} else
|
|
if (!strcmp(item1, "trace")) { /* Added by CZ 210801 */
|
|
char item2[256];
|
|
|
|
strtoken(linestr, item2, 2);
|
|
if(trace_fd)
|
|
{
|
|
close(trace_fd);
|
|
trace_fd = 0;
|
|
}
|
|
if(strcmp(item2,"off")) /* if we're not being turned off */
|
|
{
|
|
if(item2[0])
|
|
trace_fd = open(item2,O_CREAT | O_NOCTTY |
|
|
O_TRUNC | O_WRONLY, 0644);
|
|
else
|
|
trace_fd = dup(1);
|
|
if(trace_fd < 0)
|
|
{
|
|
perror(item2[0]?item2:"stdout");
|
|
trace_fd = 0;
|
|
}
|
|
}
|
|
} else
|
if (strcmp(item1, "stats") == 0) { /* stats */
|
if (strcmp(item1, "stats") == 0) { /* stats */
|
char item2[20];
|
char item2[20];
|
int i = 0;
|
int i = 0;
|
|
|
strtoken(linestr, item2, 2);
|
strtoken(linestr, item2, 2);
|
Line 650... |
Line 685... |
}
|
}
|
|
|
if (!testsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME)) {
|
if (!testsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME)) {
|
if(cycle_delay <= 0)
|
if(cycle_delay <= 0)
|
{
|
{
|
|
unsigned int addr;
|
if (cont_run > 0) cont_run--;
|
if (cont_run > 0) cont_run--;
|
if(fetch()) {
|
if(fetch()) {
|
cont_run = 0; /* memory breakpoint encountered */
|
cont_run = 0; /* memory breakpoint encountered */
|
break;
|
break;
|
}
|
}
|
decode_execute(&iqueue[0]);
|
addr = iqueue[0].insn_addr;
|
|
|
|
/* If trace_fd is non zero, we want
|
|
to make sure that disassemble is called */
|
|
|
|
decode_execute(&iqueue[0],trace_fd);
|
|
if(trace_fd)
|
|
{
|
|
char sTemp[256];
|
|
char sTemp2[256];
|
|
unsigned long value;
|
|
extern char *disassembled;
|
|
extern unsigned long reg[];
|
|
|
|
/* The objects passed to the
|
|
trace command should not be
|
|
hardcoded like this...instead
|
|
what to dump should be passed
|
|
on the command line.
|
|
|
|
FIX THIS LATER...
|
|
*/
|
|
value = (mem[0x306bc].data << 24) +
|
|
(mem[0x306bd].data << 16) +
|
|
(mem[0x306be].data << 8)
|
|
+ mem[0x306bf].data;
|
|
|
|
sprintf(sTemp,"0x%06x: %s",addr,disassembled);
|
|
memset(sTemp2,' ',sizeof(sTemp2));
|
|
strncpy(sTemp2,sTemp,strlen(sTemp));
|
|
sprintf(&sTemp2[40],"<0x%08x,0x%08x> [0x%08x]\n",
|
|
reg[3],reg[4],value);
|
|
write(trace_fd,sTemp2,strlen(sTemp2));
|
|
}
|
update_pc();
|
update_pc();
|
analysis();
|
analysis();
|
if (!hush)
|
if (!hush)
|
dumpreg();
|
dumpreg();
|
}
|
}
|