Time travel debugging and integration with VSCode DAP adapter
I would like to debug a program with QEMU record/replay from a GUI like VSCode with GDB connected through a DAP adapter. I would like to see the reverse-step/continue buttons. Has anybody managed to write a DAP adapter configuration which would allow this?
How far did I get? I followed a tutorial for running the Zephyr OS on an ARM system model in QEMU. Below is a link for an Zephyr application with VSCode debuger configuration file launch.json using the cortex-debug DAP adapter with 3 configurations, on without record/replay, one for recording and one for replay. I also run the replay configuration from command line, connected to it using GDB and got a response containing ReverseStep+;ReverseContinue+; when asked by the $qSupported packet. I did not test the reverse-step/continue commands yet from GDB CLI, so I am not sure if I would have full access to registers/memory state in the replay. For now I assume they would work.
https://github.com/jeras/zephyr-qemu-test-app
I have seen blogs showing such integration with custom GDB builds for ARM microcontrollers with tracing functionality. But I am focusing on QEMU, since its full record/replay functionality is closer to what I can do in my project. See the debugger icons in the pictures in this post:
https://www.justinmklam.com/posts/2017/10/vscode-debugger-setup/
My actual aim is to get this to work for my own project, which is a GDB serial protocol stub simulating a RISC-V CPU/SoC system with a HDL simulator (Questa, Verilator, ...). And QEMU is the closest existing project with similar functionality (full instruction level record of execution including state changes PC/GPR and memory), so I am using it as a reference for how time travel debugging is supposed to work. For my project I would probably have to use a different DAP adapter, one that is not specifically designed for ARM Cortex. I tried the VSCode default cppdbg DAP adapter which connects to GDB over the GDB/MI interface, but I do not know the right steps required so that VSCode would ask GDB whether the reverse debugging feature is available. I have studied a bit how the reverse debugging functionality would be exposed through DAP and GDB/MI, but I have a long way to go. It would be great to have something that already works to learn from. I suspect I would have to write my own DAP adapter, but I would definitely try to avoid this.
https://github.com/jeras/gdb_server_stub_sv
For now I used QEMU ARM, since according to documentation RISC-V record/replay is not yet tested (and some online posts seem to indicate it does not work yet).
I know I could stick to GDB CLI or some ncurses based GUI, but VSCode provides a better user experience (not accounting for all the bugs the early versions are bound to have).