aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotaz2010-12-06 01:50:14 +0200
committernotaz2010-12-06 19:21:54 +0200
commit3eb78778d86512b8811be2e3e469690c2171641a (patch)
tree81dcca17cdf8d0c75c17c71c59fc4fb62bdd1013
parent0d464c772e9a22e02818c309b79f8cc724ebb891 (diff)
downloadpcsx_rearmed-3eb78778d86512b8811be2e3e469690c2171641a.tar.gz
pcsx_rearmed-3eb78778d86512b8811be2e3e469690c2171641a.tar.bz2
pcsx_rearmed-3eb78778d86512b8811be2e3e469690c2171641a.zip
drc: small debug improvement
-rw-r--r--Makefile8
-rw-r--r--libpcsxcore/new_dynarec/emu_if.c40
2 files changed, 41 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 88972b6..2716f8d 100644
--- a/Makefile
+++ b/Makefile
@@ -11,9 +11,7 @@ endif
ifndef DEBUG
CFLAGS += -O2
endif
-ifdef DRC_DBG
-CFLAGS += -DDRC_DBG
-endif
+#DRC_DBG = 1
TARGET = pcsx
all: $(TARGET)
@@ -31,6 +29,10 @@ OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_ar
endif
OBJS += libpcsxcore/new_dynarec/emu_if.o
libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c
+ifdef DRC_DBG
+libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
+CFLAGS += -DDRC_DBG
+endif
# spu
OBJS += plugins/dfsound/adsr.o plugins/dfsound/dma.o plugins/dfsound/oss.o plugins/dfsound/reverb.o \
diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c
index d9d753d..2560eb3 100644
--- a/libpcsxcore/new_dynarec/emu_if.c
+++ b/libpcsxcore/new_dynarec/emu_if.c
@@ -187,7 +187,7 @@ unsigned char byte;
int pending_exception;
unsigned int next_interupt;
void new_dynarec_init() {}
-int new_dyna_start() {}
+void new_dyna_start() {}
void new_dynarec_cleanup() {}
#endif
@@ -200,6 +200,8 @@ extern u32 last_io_addr;
static void dump_mem(const char *fname, void *mem, size_t size)
{
FILE *f1 = fopen(fname, "wb");
+ if (f1 == NULL)
+ f1 = fopen(strrchr(fname, '/') + 1, "wb");
fwrite(mem, 1, size, f1);
fclose(f1);
}
@@ -277,6 +279,25 @@ static const char *regnames[offsetof(psxRegisters, intCycle) / 4] = {
"PC", "code", "cycle", "interrupt",
};
+static struct {
+ int reg;
+ u32 val, val_expect;
+ u32 pc, cycle;
+} miss_log[64];
+static int miss_log_i;
+#define miss_log_len (sizeof(miss_log)/sizeof(miss_log[0]))
+#define miss_log_mask (miss_log_len-1)
+
+static void miss_log_add(int reg, u32 val, u32 val_expect, u32 pc, u32 cycle)
+{
+ miss_log[miss_log_i].reg = reg;
+ miss_log[miss_log_i].val = val;
+ miss_log[miss_log_i].val_expect = val_expect;
+ miss_log[miss_log_i].pc = pc;
+ miss_log[miss_log_i].cycle = cycle;
+ miss_log_i = (miss_log_i + 1) & miss_log_mask;
+}
+
void breakme() {}
void do_insn_cmp(void)
@@ -336,8 +357,7 @@ psxRegs.CP0.r[9] = rregs.CP0.r[9]; // Count
for (i = 0; i < offsetof(psxRegisters, intCycle) / 4; i++) {
if (allregs_p[i] != allregs_e[i]) {
- printf("bad %5s: %08x %08x, pc=%08x, cycle %u\n",
- regnames[i], allregs_p[i], allregs_e[i], psxRegs.pc, psxRegs.cycle);
+ miss_log_add(i, allregs_p[i], allregs_e[i], psxRegs.pc, psxRegs.cycle);
bad++;
}
}
@@ -348,12 +368,24 @@ psxRegs.CP0.r[9] = rregs.CP0.r[9]; // Count
}
if (psxRegs.pc == rregs.pc && bad < 6 && failcount < 32) {
- printf("-- %d\n", bad);
+ static int last_mcycle;
+ if (last_mcycle != psxRegs.cycle >> 20) {
+ printf("%u\n", psxRegs.cycle);
+ last_mcycle = psxRegs.cycle >> 20;
+ }
failcount++;
goto ok;
}
end:
+ for (i = 0; i < miss_log_len; i++, miss_log_i = (miss_log_i + 1) & miss_log_mask)
+ printf("bad %5s: %08x %08x, pc=%08x, cycle %u\n",
+ regnames[miss_log[miss_log_i].reg], miss_log[miss_log_i].val,
+ miss_log[miss_log_i].val_expect, miss_log[miss_log_i].pc, miss_log[miss_log_i].cycle);
+ printf("-- %d\n", bad);
+ for (i = 0; i < 8; i++)
+ printf("r%d=%08x r%2d=%08x r%2d=%08x r%2d=%08x\n", i, allregs_p[i],
+ i+8, allregs_p[i+8], i+16, allregs_p[i+16], i+24, allregs_p[i+23]);
printf("PC: %08x/%08x, cycle %u\n", psxRegs.pc, ppc, psxRegs.cycle);
dump_mem("/mnt/ntz/dev/pnd/tmp/psxram.dump", psxM, 0x200000);
dump_mem("/mnt/ntz/dev/pnd/tmp/psxregs.dump", psxH, 0x10000);