caprice32
caprice32 copied to clipboard
Embedded debugger
Provide a tool allowing to:
- examine registers
- disassemble code
- modify code and memory.
Perhaps a gdb remote would be great https://sourceware.org/gdb/onlinedocs/gdb/Remote-Stub.html
There is a Visual-Studio Code Z80 debugger for Spectrum called DeZog. It is interfaced via a simple IP socket connection (typically on localhost), via a documented protocol. Some hints to add a new remote are given too, and there is an implementation as a DLL.
Originally the Debugger was made for the ZX Next and can manage sprite information, in addition to classical Z80 data.
The Visual-Studio Code option sounds interesting.
Some thoughts on how to implement it in Caprice32 directly (some applies to an external debugger too):
- CPC.break_points provide an address at which z80_execute will stop and return EC_BREAKPOINT
- showGui, userConfirmsQuitWithoutSaving and showVKeyboard are 3 examples of GUI display - the difference here is that we would want to be able to update the back_surface. We may also want a way to see it without the GUI in front of it (or have the GUI next to it and force a higher resolution when using it).
- when stepping, set the break_point to the next address. If we want to be able to step-in, some logic is needed to identify jumps. Another option is to add a support in the code to break at the next instruction no matter what.
The protocol approach, on network or unix socket, is interesting as it could allow to support multiple debuggers (e.g DeZog + custom one running as a separate process but that can be launched from the UI)
Development of the debugger has started. It can be invoked with F2 and already supports showing z80 registers, memory content, disassembly. It supports setting breakpoints and watchpoints. Missing features:
- step instruction
- read or write watch points (as opposed to read&write)
- load symbol files
- display stack
- have multiple windows opened at the same time
I'll call it done at this point although I still have some ideas of features that could be added.