Slightly improve CPU trace files

This commit is contained in:
Aaron Culliney 2014-10-31 16:32:34 -07:00
parent 6fdeee3896
commit 4ff57ab7dd
4 changed files with 23 additions and 1 deletions

View File

@ -674,6 +674,14 @@ void cpu65_trace_end(void) {
}
}
void cpu65_trace_toggle(const char *trace_file) {
if (cpu_trace_fp) {
cpu65_trace_end();
} else {
cpu65_trace_begin(trace_file);
}
}
GLUE_C_WRITE(cpu65_trace_prologue)
{
nargs = 0;
@ -739,7 +747,7 @@ GLUE_C_WRITE(cpu65_trace_epilogue)
case addr_j_indirect:
case addr_j_indirect_x: /* word arg */
sprintf(fmt, "%04X: %02X%02X%02X %s %s", current_pc, cpu65_opcode, (uint8_t)arg1, (uint8_t)arg2, opcodes_65c02[cpu65_opcode].mnemonic, disasm_templates[opcodes_65c02[cpu65_opcode].mode]);
sprintf(buf, fmt, (uint8_t)arg2, (uint8_t)arg1);
sprintf(buf, fmt, (uint8_t)arg1, (uint8_t)arg2);
break;
case addr_relative: /* offset */

View File

@ -60,6 +60,7 @@ extern int16_t cpu65_cycles_to_execute;
#if CPU_TRACING
void cpu65_trace_begin(const char *trace_file);
void cpu65_trace_end(void);
void cpu65_trace_toggle(const char *trace_file);
#endif
#endif /* !__ASSEMBLER__ */

View File

@ -850,6 +850,17 @@ ADDRS [0-9a-fA-F]+
return LOAD;
}
{BOS}cput?r?a?c?e?{EOS} {
#if CPU_TRACING
char *buf = NULL;
asprintf(&buf, "%s/%s", getenv("HOME"), "cputrace.txt");
cpu65_trace_toggle(buf);
free(buf);
#else
LOG("CPU tracing not enabled...");
#endif
}
{BOS}la?n?g?{EOS} {
/* display language card settings */
show_lc_info();

View File

@ -26,6 +26,7 @@
#if CPU_TRACING
# define TRACE_PROLOGUE \
movw PC_Reg, SN(cpu65_pc); \
callLQ CALL(cpu65_trace_prologue);
# define TRACE_ARG \
callLQ CALL(cpu65_trace_arg);
@ -34,6 +35,7 @@
# define TRACE_ARG2 \
callLQ CALL(cpu65_trace_arg2);
# define TRACE_EPILOGUE \
movw EffectiveAddr, DebugCurrEA; \
callLQ CALL(cpu65_trace_epilogue);
#else
# define TRACE_PROLOGUE