snes: support trace logging GB and SMP cores
This commit is contained in:
parent
618951403d
commit
4eaf17c6c1
|
@ -22,7 +22,12 @@ void CPU::main() {
|
||||||
scheduler.exit(Scheduler::ExitReason::SynchronizeEvent);
|
scheduler.exit(Scheduler::ExitReason::SynchronizeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(trace) print(disassemble(r[PC]), "\n");
|
if(SNES::interface()->wanttrace & TRACE_GB_MASK)
|
||||||
|
{
|
||||||
|
auto disasm = disassemble(r[PC]);
|
||||||
|
SNES::interface()->cpuTrace(TRACE_GB, (const char*)disasm);
|
||||||
|
}
|
||||||
|
//if(trace) print(disassemble(r[PC]), "\n");
|
||||||
interrupt_test();
|
interrupt_test();
|
||||||
cdlInfo.currFlags = eCDLog_Flags_ExecFirst;
|
cdlInfo.currFlags = eCDLog_Flags_ExecFirst;
|
||||||
uint8 opcode = op_read(r[PC]++);
|
uint8 opcode = op_read(r[PC]++);
|
||||||
|
|
|
@ -91,12 +91,12 @@ void CPU::enter() {
|
||||||
void CPU::op_step() {
|
void CPU::op_step() {
|
||||||
debugger.op_exec(regs.pc.d);
|
debugger.op_exec(regs.pc.d);
|
||||||
|
|
||||||
if (interface()->wanttrace)
|
if (interface()->wanttrace & TRACE_CPU_MASK)
|
||||||
{
|
{
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
disassemble_opcode(tmp, regs.pc.d);
|
disassemble_opcode(tmp, regs.pc.d);
|
||||||
tmp[511] = 0;
|
tmp[511] = 0;
|
||||||
interface()->cpuTrace(tmp);
|
interface()->cpuTrace(TRACE_CPU, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
(this->*opcode_table[op_readpcfirst()])();
|
(this->*opcode_table[op_readpcfirst()])();
|
||||||
|
|
|
@ -39,7 +39,7 @@ int Interface::getBackdropColor()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::cpuTrace(const char *msg) {
|
void Interface::cpuTrace(uint32_t which, const char *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
|
|
||||||
|
#define TRACE_CPU 0
|
||||||
|
#define TRACE_SMP 1
|
||||||
|
#define TRACE_GB 2
|
||||||
|
|
||||||
|
#define TRACE_MASK_NONE (0)
|
||||||
|
#define TRACE_CPU_MASK (1<<TRACE_CPU)
|
||||||
|
#define TRACE_SMP_MASK (1<<TRACE_SMP)
|
||||||
|
#define TRACE_GB_MASK (1<<TRACE_GB)
|
||||||
|
|
||||||
struct Interface {
|
struct Interface {
|
||||||
Interface();
|
Interface();
|
||||||
virtual void videoRefresh(const uint32_t *data, bool hires, bool interlace, bool overscan);
|
virtual void videoRefresh(const uint32_t *data, bool hires, bool interlace, bool overscan);
|
||||||
|
@ -18,8 +27,8 @@ struct Interface {
|
||||||
//zero 17-oct-2012
|
//zero 17-oct-2012
|
||||||
virtual int getBackdropColor();
|
virtual int getBackdropColor();
|
||||||
|
|
||||||
bool wanttrace;
|
uint32_t wanttrace;
|
||||||
virtual void cpuTrace(const char *msg);
|
virtual void cpuTrace(uint32_t which, const char *msg);
|
||||||
|
|
||||||
//zero 23-dec-2012
|
//zero 23-dec-2012
|
||||||
virtual void* allocSharedMemory(const char* memtype, size_t amt, int initialByte = -1) = 0;
|
virtual void* allocSharedMemory(const char* memtype, size_t amt, int initialByte = -1) = 0;
|
||||||
|
|
|
@ -58,6 +58,11 @@ void SMP::enter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
debugger.op_exec(regs.pc);
|
debugger.op_exec(regs.pc);
|
||||||
|
if(interface()->wanttrace & TRACE_SMP_MASK)
|
||||||
|
{
|
||||||
|
auto str = disassemble_opcode(regs.pc);
|
||||||
|
interface()->cpuTrace(TRACE_SMP, (const char*)str);
|
||||||
|
}
|
||||||
op_step();
|
op_step();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,9 +84,9 @@ struct Interface : public SNES::Interface {
|
||||||
messages.push(text);
|
messages.push(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpuTrace(const char *msg) {
|
void cpuTrace(uint32_t which, const char *msg) {
|
||||||
if (ptrace)
|
if (ptrace)
|
||||||
ptrace((const char *)msg);
|
ptrace(which, (const char *)msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
string path(SNES::Cartridge::Slot slot, const string &hint)
|
string path(SNES::Cartridge::Slot slot, const string &hint)
|
||||||
|
@ -760,16 +760,11 @@ void snes_set_backdropColor(int color)
|
||||||
iface->backdropColor = color;
|
iface->backdropColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void snes_set_trace_callback(snes_trace_t callback)
|
void snes_set_trace_callback(uint32_t mask, snes_trace_t callback)
|
||||||
{
|
{
|
||||||
if (callback)
|
iface->wanttrace = mask;
|
||||||
{
|
if (mask)
|
||||||
iface->wanttrace = true;
|
|
||||||
iface->ptrace = callback;
|
iface->ptrace = callback;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
iface->ptrace = nullptr;
|
||||||
iface->wanttrace = false;
|
|
||||||
iface->ptrace = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -88,7 +88,7 @@ typedef void (*snes_audio_sample_t)(uint16_t left, uint16_t right);
|
||||||
typedef void (*snes_input_poll_t)(void);
|
typedef void (*snes_input_poll_t)(void);
|
||||||
typedef int16_t (*snes_input_state_t)(unsigned port, unsigned device, unsigned index, unsigned id);
|
typedef int16_t (*snes_input_state_t)(unsigned port, unsigned device, unsigned index, unsigned id);
|
||||||
typedef void (*snes_input_notify_t)(int index);
|
typedef void (*snes_input_notify_t)(int index);
|
||||||
typedef void (*snes_trace_t)(const char *msg);
|
typedef void (*snes_trace_t)(uint32_t which, const char *msg);
|
||||||
typedef void* (*snes_allocSharedMemory_t)(const char* memtype, size_t amt);
|
typedef void* (*snes_allocSharedMemory_t)(const char* memtype, size_t amt);
|
||||||
typedef void (*snes_freeSharedMemory_t)(void* ptr);
|
typedef void (*snes_freeSharedMemory_t)(void* ptr);
|
||||||
|
|
||||||
|
@ -169,12 +169,13 @@ void snes_set_path_request(snes_path_request_t path_request);
|
||||||
|
|
||||||
void snes_set_color_lut(uint32_t * colors);
|
void snes_set_color_lut(uint32_t * colors);
|
||||||
|
|
||||||
void snes_set_trace_callback(void (*callback)(const char *));
|
void snes_set_trace_callback(uint32_t mask, void (*callback)(uint32_t mask, const char *));
|
||||||
|
|
||||||
// system bus implementation
|
// system bus implementation
|
||||||
uint8_t bus_read(unsigned addr);
|
uint8_t bus_read(unsigned addr);
|
||||||
void bus_write(unsigned addr, uint8_t val);
|
void bus_write(unsigned addr, uint8_t val);
|
||||||
|
|
||||||
|
|
||||||
//$2105
|
//$2105
|
||||||
#define SNES_REG_BG_MODE 0
|
#define SNES_REG_BG_MODE 0
|
||||||
#define SNES_REG_BG3_PRIORITY 1
|
#define SNES_REG_BG3_PRIORITY 1
|
||||||
|
|
|
@ -258,8 +258,9 @@ void snes_input_notify(int index)
|
||||||
BREAK(eMessage_SIG_input_notify);
|
BREAK(eMessage_SIG_input_notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
void snes_trace(const char *msg)
|
void snes_trace(uint32_t which, const char *msg)
|
||||||
{
|
{
|
||||||
|
comm.value = which;
|
||||||
comm.str = (char*) msg;
|
comm.str = (char*) msg;
|
||||||
BREAK(eMessage_SIG_trace_callback);
|
BREAK(eMessage_SIG_trace_callback);
|
||||||
}
|
}
|
||||||
|
@ -456,9 +457,7 @@ void QUERY_state_hook_irq() {
|
||||||
SNES::cpu.debugger.op_irq = comm.value ? debug_op_irq : hook<void()>();
|
SNES::cpu.debugger.op_irq = comm.value ? debug_op_irq : hook<void()>();
|
||||||
}
|
}
|
||||||
void QUERY_state_enable_trace() {
|
void QUERY_state_enable_trace() {
|
||||||
if (comm.value)
|
snes_set_trace_callback(comm.value, snes_trace);
|
||||||
snes_set_trace_callback(snes_trace);
|
|
||||||
else snes_set_trace_callback(nullptr);
|
|
||||||
}
|
}
|
||||||
void QUERY_state_enable_scanline() {
|
void QUERY_state_enable_scanline() {
|
||||||
if (comm.value)
|
if (comm.value)
|
||||||
|
|
Loading…
Reference in New Issue