I was distracted by Anthony Green’s Moxie blog this last week and a bit, specifically by the bit about qemu gdb support. This seemed like a really good idea, not to mention being fairly simple to implement, so it’s in now for both the SH4 and ARM. The actual debug support just hangs off the existing debugging framework, so the work needed was really just to implement the protocol.
If you want to have a play with it, run lxdream with -g <port> to start an SH4 GDB listener on the given TCP port, or -G <port> to start an ARM GDB listener. Or both for that matter, although gdb is likely to be confused if you actually connect more than one debugger at a time. To note the obvious, you’ll need to build an sh-elf-gdb or arm-elf-gdb (respectively) for this; your system debugger is just going to get confused. Also worth noting is that GDB tends to default to big-endian if there’s no file loaded – you need to explicitly force it to little endian (“set endian little”).
It supports all the usual bells and whistles except watchpoints, which I’m looking into at the moment. They should be reasonably straightforward to implement now, and will have zero cost when they’re not being used. And as a nice side-effect of all this I can finally do a full implementation of the on-board UBC.
I probably should have done this a long time ago – It’s nice to have a full symbolic debugger without having to actually write one from scratch ^_^