Here is are the neccessary changes to debug programs for the simulator with gdb. It it only a partial implementation. Without debugging information, no pseudo registers are available, the stack-backtrace doesn't work, only stepping one assembler instruction as well as using hard registers work.

The frame unwinding is not complete. The register of parent stack stackframes are not restored. Also calling function with gdb is not implemented. The execute file must be made known to gdb, so that the file is passed to the simulator.

An usage example:

m68hc05-gdb testprog
(gdb) target sim
(gdb) load testprog
(gdb) break main
(gdb) run
Note, that the bss-section is not cleared and the data-section is not reloaded, if run is executed a second time. For the SP and FP-Register, the absolute address is printed, not the relative to SP. Only dwarf2 provides all needed debugging informations.

The newest patched source is available in the GIT repository.