This patch series introduces support for the Multi-Core Debug (MCD) API, a commonly used debug interface by emulators. The MCD API, defined through a header file, consists of 54 functions for implementing debug and trace. However, since it is a header-file-only interface, MCD does not specify a communication protocol.
To keep the overhead of a communication protocol on top of MCD minimal, we follow a remote procedure call approach by using QAPI as an interface definition and transport infrastructure. This way, we can use qapi-gen to take care of generating the infrastructure to dispatch MCD functions and to (un)marshal their arguments and results. Furthermore, qapi-doc and qtest provide good integration into QEMU's documentation and test frameworks. In v1 of this patch series, the MCD protocol was directly integrated in QMP and the QMP monitor was responsible for dispatching MCD's server stub. This introduced a dependency between QEMU's machine protocol and the MCD debug protocol which is not to be expected. For this reason, v2 introduces a MCD monitor which uses as much of the QMP monitor's framework as possible but keeps the two protocols separate from each other. Similarly, MCD's test suite uses as much of the qtest framework as is useful for sending JSON commands to the QEMU under test but adds new code where required to prevent dependencies to QMP. To enable MCD, configure QEMU with `--enable-mcd`. To start the MCD monitor, run QEMU with the `-mcd` option: qemu-system-<arch> [options] -qmp tcp::1235,server=on,wait=off To run the MCD test suite independently, start `mcd-test`: V=1 QTEST_QEMU_BINARY="./qemu-system-<arch> [options]" tests/qtest/mcd-test To connect from a MCD client, a client stub corresponding to this patch series can be found at https://gitlab.com/lauterbach/mcdrefsrv Mario Fleischmann (20): mcd: Introduce Multi-Core Debug (MCD) API meson: Add --enable-mcd option mcd: Introduce MCD server qapi: Introduce MCD schema mcd: Introduce MCD server stub qtest: Introduce MCD test suite mcd: Implement target initialization API mcd: Implement server connection API mcd: Implement target system query mcd: Implement core connection control mcd: Implement memory space query gdbstub: Expose GDBRegisterState mcd: Implement register query mcd: Implement runstate control mcd test: Implement core state query gdbstub: Expose gdb_write_register mcd: Implement register/memory access mcd: Implement single stepping mcd: Implement trigger control mcd: Implement reset control MAINTAINERS | 9 + docs/interop/index.rst | 1 + docs/interop/mcd.rst | 65 + gdbstub/gdbstub.c | 15 +- include/exec/gdbstub.h | 18 +- include/exec/mcdstub.h | 18 + mcd/mcd_api.h | 3963 +++++++++++++++++++++++++++++++++ mcd/mcd_monitor.c | 90 + mcd/mcd_qapi.c | 505 +++++ mcd/mcd_qapi.h | 81 + mcd/mcd_server.c | 2274 +++++++++++++++++++ mcd/mcd_stub.c | 988 ++++++++ mcd/meson.build | 60 + meson.build | 5 + meson_options.txt | 3 + qapi/mcd.json | 2366 ++++++++++++++++++++ qemu-options.hx | 11 + scripts/meson-buildoptions.sh | 3 + system/vl.c | 13 + tests/qtest/mcd-test.c | 698 ++++++ tests/qtest/mcd-util.c | 389 ++++ tests/qtest/mcd-util.h | 73 + tests/qtest/meson.build | 5 + 23 files changed, 11643 insertions(+), 10 deletions(-) create mode 100644 docs/interop/mcd.rst create mode 100644 include/exec/mcdstub.h create mode 100644 mcd/mcd_api.h create mode 100644 mcd/mcd_monitor.c create mode 100644 mcd/mcd_qapi.c create mode 100644 mcd/mcd_qapi.h create mode 100644 mcd/mcd_server.c create mode 100644 mcd/mcd_stub.c create mode 100644 mcd/meson.build create mode 100644 qapi/mcd.json create mode 100644 tests/qtest/mcd-test.c create mode 100644 tests/qtest/mcd-util.c create mode 100644 tests/qtest/mcd-util.h -- 2.34.1