Improved VM_TRACING syntax

This commit is contained in:
Aaron Culliney 2014-11-23 14:28:00 -08:00
parent 88b7db0387
commit 0ad98602fe
4 changed files with 37 additions and 18 deletions

View File

@ -26,11 +26,12 @@
#define GLUE_C_WRITE(func) \
void c__##func(uint16_t ea, uint8_t b); \
void c_##func(uint16_t ea, uint8_t b) { \
extern FILE *test_vm_fp; \
if (test_vm_fp && ((ea >= 0xC000) && (ea < 0xD000)) ) { \
fprintf(test_vm_fp, "%04X w:%02X %s (%s:%d)\n", ea, b, __FUNCTION__, __FILE__, __LINE__); \
} \
c__##func(ea, b); \
extern FILE *test_vm_fp; \
if (test_vm_fp && !vm_trace_is_ignored(ea)) { \
fprintf(test_vm_fp, "%04X w:%02X %s (%s:%d)\n", ea, b, __FUNCTION__, __FILE__, __LINE__); \
fflush(test_vm_fp); \
} \
} \
void c__##func(uint16_t ea, uint8_t b)
@ -39,8 +40,9 @@
uint8_t c_##func(uint16_t ea) { \
uint8_t b = c__##func(ea); \
extern FILE *test_vm_fp; \
if (test_vm_fp && ((ea >= 0xC000) && (ea < 0xD000)) ) { \
if (test_vm_fp && !vm_trace_is_ignored(ea)) { \
fprintf(test_vm_fp, "%04X r:%02X %s (%s:%d)\n", ea, b, __FUNCTION__, __FILE__, __LINE__); \
fflush(test_vm_fp); \
} \
return b; \
} \

View File

@ -124,9 +124,10 @@ void reinitialize();
/* vm hooks */
#if VM_TRACING
void vm_begin_trace(const char *vm_file);
void vm_end_trace(void);
void vm_toggle_trace(const char *vm_file);
void vm_trace_begin(const char *vm_file);
void vm_trace_end(void);
void vm_trace_toggle(const char *vm_file);
bool vm_trace_is_ignored(uint16_t ea);
#endif
void ram_nop(),

View File

@ -144,20 +144,20 @@ TEST test_boot_disk_cputrace() {
PASS();
}
#define EXPECTED_VM_TRACE_FILE_SIZE 3688453
#define EXPECTED_VM_TRACE_SHA "9946B0C5288228535A37475CDAB5C9E685EEDDE9"
#define EXPECTED_VM_TRACE_FILE_SIZE 2670370
#define EXPECTED_VM_TRACE_SHA "E808CFF531554AC825A6A2D9E49170887AC9594C"
TEST test_boot_disk_vmtrace() {
char *homedir = getenv("HOME");
char *disk = NULL;
asprintf(&disk, "%s/a2_vmtrace.txt", homedir);
if (disk) {
unlink(disk);
vm_begin_trace(disk);
vm_trace_begin(disk);
}
BOOT_TO_DOS();
vm_end_trace();
vm_trace_end();
c_eject_6(0);
do {

View File

@ -115,6 +115,11 @@
#if VM_TRACING
FILE *test_vm_fp = NULL;
typedef struct vm_trace_range_t {
uint16_t lo;
uint16_t hi;
} vm_trace_range_t;
#endif
GLUE_C_READ(ram_nop)
@ -1044,16 +1049,16 @@ void debug_print_softwitches(void) {
}
#if VM_TRACING
void vm_begin_trace(const char *vm_file) {
void vm_trace_begin(const char *vm_file) {
if (vm_file) {
if (test_vm_fp) {
vm_end_trace();
vm_trace_end();
}
test_vm_fp = fopen(vm_file, "w");
}
}
void vm_end_trace(void) {
void vm_trace_end(void) {
if (test_vm_fp) {
fflush(test_vm_fp);
fclose(test_vm_fp);
@ -1061,12 +1066,23 @@ void vm_end_trace(void) {
}
}
void vm_toggle_trace(const char *vm_file) {
void vm_trace_toggle(const char *vm_file) {
if (test_vm_fp) {
vm_end_trace();
vm_trace_end();
} else {
vm_begin_trace(vm_file);
vm_trace_begin(vm_file);
}
}
void vm_trace_ignore(vm_trace_range_t range) {
// TODO ...
}
bool vm_trace_is_ignored(uint16_t ea) {
if ((ea < 0xC000) || (ea > 0xCFFF)) {
return true;
}
}
#endif