mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-07-31 09:40:37 +02:00
byuu says: Commands can be prefixed with: (cpu|smp|ppu|dsp|apu|vram|oam|cgram)/ to set their source. Eg "vram/hex 0800" or "smp/breakpoints.append execute ffc0"; default is cpu. These overlap a little bit in odd ways, but that's just the way the SNES works: it's not a very orthogonal system. CPU is both a processor and the main bus (ROM, RAM, WRAM, etc), APU is the shared memory by the SMP+DSP (eg use it to catch writes from either chip); PPU probably won't ever be used since it's broken down into three separate buses (VRAM, OAM, CGRAM), but DSP could be useful for tracking bugs like we found in Koushien 2 with the DSP echo buffer corrupting SMP opcodes. Technically the PPU memory pools are only ever tripped by the CPU poking at them, as the PPU doesn't ever write. I now have run.for, run.to, step.for, step.to. The difference is that run only prints the next instruction after running, whereas step prints all of the instructions along the way as well. run.to acts the same as "step over" here. Although it's not quite as nice, since you have to specify the address of the next instruction. Logging the Field/Vcounter/Hcounter on instruction listings now, good for timing information. Added in the tracer mask, as well as memory export, as well as VRAM/OAM/CGRAM/SMP read/write/execute breakpoints, as well as an APU usage map (it tracks DSP reads/writes separately, although I don't currently have debugger callbacks on DSP accesses just yet.) Have not hooked up actual SMP debugging just yet, but I plan to soon. Still thinking about how I want to allow / block interleaving of instructions (terminal output and tracing.) So ... remaining tasks at this point: - full SMP debugging - CPU+SMP interleave support - aliases - hotkeys - save states (will be kind of tricky ... will have to suppress breakpoints during synchronization, or abort a save in a break event.) - keep track of window geometry between runs
75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
struct Debugger {
|
|
enum class Source : unsigned { CPU, SMP, PPU, DSP, APU, VRAM, OAM, CGRAM };
|
|
|
|
struct Breakpoint {
|
|
Source source = Source::CPU;
|
|
enum class Mode : unsigned { Disabled, Read, Write, Execute } mode = Mode::Disabled;
|
|
unsigned addr = 0;
|
|
optional<uint8> data = false;
|
|
unsigned triggered = 0; //counter for number of times breakpoint was hit
|
|
};
|
|
|
|
struct Usage {
|
|
enum : unsigned {
|
|
Read = 0x01,
|
|
Write = 0x02,
|
|
Execute = 0x04,
|
|
//CPU
|
|
FlagE = 0x08,
|
|
FlagM = 0x10,
|
|
FlagX = 0x20,
|
|
//APU
|
|
DspRead = 0x08,
|
|
DspWrite = 0x10,
|
|
};
|
|
};
|
|
|
|
Debugger();
|
|
|
|
void load();
|
|
void unload();
|
|
void main();
|
|
|
|
void run();
|
|
void stop();
|
|
void leave();
|
|
|
|
bool breakpointTest(Source source, Breakpoint::Mode mode, unsigned addr, uint8 data = 0x00);
|
|
string cpuDisassemble();
|
|
string cpuDisassemble(unsigned addr, bool e, bool m, bool x);
|
|
void cpuExec(uint24 addr);
|
|
void cpuRead(uint24 addr, uint8 data);
|
|
void cpuWrite(uint24 addr, uint8 data);
|
|
void echoBreakpoints();
|
|
void echoDisassemble(unsigned addr, signed size);
|
|
void echoHex(Source source, unsigned addr, signed size);
|
|
void memoryExport(Source source, string filename);
|
|
uint8 memoryRead(Source source, unsigned addr);
|
|
unsigned memorySize(Source source);
|
|
void memoryWrite(Source source, unsigned addr, uint8 data);
|
|
void ppuCgramRead(uint16 addr, uint8 data);
|
|
void ppuCgramWrite(uint16 addr, uint8 data);
|
|
void ppuOamRead(uint16 addr, uint8 data);
|
|
void ppuOamWrite(uint16 addr, uint8 data);
|
|
void ppuVramRead(uint16 addr, uint8 data);
|
|
void ppuVramWrite(uint16 addr, uint8 data);
|
|
void smpExec(uint16 addr);
|
|
void smpRead(uint16 addr, uint8 data);
|
|
void smpWrite(uint16 addr, uint8 data);
|
|
string sourceName(Source source);
|
|
|
|
bool running = false;
|
|
|
|
vector<Breakpoint> breakpoints;
|
|
optional<unsigned> cpuRunFor = false;
|
|
optional<unsigned> cpuRunTo = false;
|
|
optional<unsigned> cpuStepFor = false;
|
|
optional<unsigned> cpuStepTo = false;
|
|
file tracerFile;
|
|
bitvector tracerMask;
|
|
uint8* usageCPU = nullptr;
|
|
uint8* usageAPU = nullptr;
|
|
};
|
|
|
|
extern Debugger* debugger;
|