Adjust CPU trace file format

- CPU_TRACING now records IRQ check timeout and total cycles
This commit is contained in:
Aaron Culliney 2016-10-05 20:34:41 -07:00
parent c80e16de3b
commit bb93b5c243
2 changed files with 87 additions and 11 deletions

View File

@ -878,9 +878,16 @@ GLUE_C_WRITE(cpu65_trace_epilogue)
}
flags_buf[8] = '\0';
fprintf(cpu_trace_fp, " %s CYC:%u EA:%04X", flags_buf, cpu65_opcycles, cpu65_ea);
char fmt[64];
if (UNLIKELY(cpu65_opcycles >= 10)) {
// occurs rarely for interrupt + opcode
snprintf(fmt, 64, "%s", " %s CY:%u irqChk:%d totCyc:%d EA:%04X");
} else {
snprintf(fmt, 64, "%s", " %s CYC:%u irqChk:%d totCyc:%d EA:%04X");
}
extern int32_t irqCheckTimeout;
fprintf(cpu_trace_fp, fmt, flags_buf, cpu65_opcycles, (irqCheckTimeout - cpu65_opcycles), (cycles_count_total + cpu65_opcycles), cpu65_ea);
sprintf(fmt, " %s %s", opcodes_65c02[cpu65_opcode].mnemonic, disasm_templates[opcodes_65c02[cpu65_opcode].mode]);
switch (opcodes_65c02[cpu65_opcode].mode) {

View File

@ -124,8 +124,8 @@ TEST test_boot_sound() {
// Mockingboard tracing
#define NSCT_DSK "NSCT.dsk.gz"
#define NSCT_TRACE_SHA "FA2FE78A273405E2B129E46FD13F1CB0C56F8D53"
#define NSCT_SAMPS_SHA "DF9686D4835B0E55480BE25CB0A065C85A6963DE"
#define NSCT_TRACE_SHA "B280BBCDC3C8475E53213D0DC78BD20D0E83D133"
#define NSCT_SAMPS_SHA "A534CFDCD3A99468793E4D50E7F651E27964FD75"
#define NSCT_TRACE_TARGET_SIZ (512 * 65536) // 2^25
#define NSCT_SAMPS_TARGET_SIZ (2048 * 65536) // 2^27
TEST test_mockingboard_1() {
@ -214,11 +214,11 @@ TEST test_mockingboard_1() {
// ----------------------------------------------------------------------------
// CPU tracing
// This test is majorly abusive ... it creates an ~900MB file in $HOME
// This test is majorly abusive ... it creates an ~1GB file in $HOME
// ... but if it's correct, you're fairly assured the cpu/vm is working =)
#if ABUSIVE_TESTS
#define EXPECTED_CPU_TRACE_FILE_SIZE 889495699
#define EXPECTED_CPU_TRACE_SHA "ADFF915FF3B8F15428DD89580DBE21CDF71B7E39"
#define EXPECTED_CPU_TRACE_FILE_SIZE 1233878608
#define EXPECTED_CPU_TRACE_SHA "36E399BEC3A4671A9AE4145B7F01A9AD1F1CDE3B"
TEST test_boot_disk_cputrace() {
const char *homedir = HOMEDIR;
char *output = NULL;
@ -260,10 +260,75 @@ TEST test_boot_disk_cputrace() {
PASS();
}
#define EXPECTED_BOOT_SIZ2 555444333
#define EXPECTED_BOOT_SHA2 "A5F4114D404FDBE84691412ED85DB18E3B06EEE5"
TEST test_boot_disk_cputrace2() {
test_setup_boot_disk(NSCT_DSK, 0);
const char *homedir = HOMEDIR;
char *output = NULL;
ASPRINTF(&output, "%s/a2_cputrace.txt", homedir);
if (output) {
unlink(output);
cpu65_trace_begin(output);
}
srandom(0);
// Poll for trace file of particular size
c_debugger_clear_watchpoints();
c_debugger_set_timeout(1);
do {
c_debugger_go();
FILE *fpTrace = fopen(output, "r");
fseek(fpTrace, 0, SEEK_END);
long minSizeTrace = ftell(fpTrace);
if (minSizeTrace < EXPECTED_BOOT_SIZ2) {
fclose(fpTrace);
continue;
}
// trace has generated files of sufficient length
uint8_t md[SHA_DIGEST_LENGTH];
char mdstr0[(SHA_DIGEST_LENGTH*2)+1];
cpu65_trace_end();
truncate(output, EXPECTED_BOOT_SIZ2);
// verify trace file
do {
unsigned char *buf = MALLOC(EXPECTED_BOOT_SIZ2);
fseek(fpTrace, 0, SEEK_SET);
ASSERT(fread(buf, 1, EXPECTED_BOOT_SIZ2, fpTrace) == EXPECTED_BOOT_SIZ2);
fclose(fpTrace); fpTrace = NULL;
SHA1(buf, EXPECTED_BOOT_SIZ2, md);
FREE(buf);
sha1_to_str(md, mdstr0);
ASSERT(strcmp(mdstr0, EXPECTED_BOOT_SHA2) == 0);
} while (0);
break;
} while (1);
c_debugger_set_timeout(0);
disk6_eject(0);
unlink(output);
FREE(output);
PASS();
}
#endif
#define EXPECTED_CPUTRACE_HELLO_FILE_SIZE 118170437
#define EXPECTED_CPUTRACE_HELLO_SHA "D5BF7650E51404F3358C9C4CBBEBAA191E53AD72"
#define EXPECTED_CPUTRACE_HELLO_FILE_SIZE 164542693
#define EXPECTED_CPUTRACE_HELLO_SHA "46A3CAE4BB3D7F0A73465DFF6EAD9181D2F958CF"
TEST test_cputrace_hello_dsk() {
test_setup_boot_disk(BLANK_DSK, 0);
@ -312,8 +377,8 @@ TEST test_cputrace_hello_dsk() {
PASS();
}
#define EXPECTED_CPUTRACE_HELLO_NIB_FILE_SIZE 14153921
#define EXPECTED_CPUTRACE_HELLO_NIB_SHA "B09F85206E964487378C5B62EA26626A6E8159F1"
#define EXPECTED_CPUTRACE_HELLO_NIB_FILE_SIZE 19455366
#define EXPECTED_CPUTRACE_HELLO_NIB_SHA "F0D3B25E98037E82422787DD950D4F959426F258"
TEST test_cputrace_hello_nib() {
test_setup_boot_disk(BLANK_NIB, 0);
@ -578,14 +643,18 @@ GREATEST_SUITE(test_suite_trace) {
#if ABUSIVE_TESTS
RUN_TESTp(test_boot_disk_cputrace);
RUN_TESTp(test_boot_disk_cputrace2);
#endif
RUN_TESTp(test_cputrace_hello_dsk);
RUN_TESTp(test_cputrace_hello_nib);
RUN_TESTp(test_cputrace_hello_po);
#if VM_TRACING_FIXED
// 2016/10/01 : VM tracing is undergoing upheaval
RUN_TESTp(test_boot_disk_vmtrace);
RUN_TESTp(test_boot_disk_vmtrace_nib);
RUN_TESTp(test_boot_disk_vmtrace_po);
#endif
// ...
disk6_eject(0);