rosco-m68k / rosco_m68k

Design, documentation and software for the Really Old School Computer (M68K)
https://rosco-m68k.com
Other
158 stars 35 forks source link

Feature/gdb lib #381

Closed roscopeco closed 1 year ago

roscopeco commented 1 year ago

What is this?

This PR adds a GDB-compatible remote debug stub to the standard libraries, enabling remote debugging of rosco_m68k programs on both real hardware and in MAME, using the second serial channel.

Usage

To use the debugging capability, add the library to your build with -lgdb. Then, in your code, initialise the debugger and call breakpoint to trigger a wait-for-attach:

#include <debug.h>

// ... later

if (start_debugger()) {
    printf("Start debugger; Connect via GDB\n");
    breakpoint();
} else {
    printf("Unable to start debugger :(\n");
}

When this program is run, it will wait for the remote debugger to attach. Start gdb on your host system:

gdb -b 115200

I have found that commands like the following, placed into a .gdbinit, are very useful to save on typing:

set arch m68k
file gdbtest.elf
add-symbol-file ../../firmware/rosco_m68k_firmware/rosco_m68k.elf
target remote /dev/cu.usbserial-5

Features

Supported

Unsupported

Proof of life

Screenshot 2023-10-30 at 23 38 10