Add support for Debug Adapter Protocol

If -debug_dap flag is given, xsystem35 speaks the Debug Adapter Protocol
(https://microsoft.github.io/debug-adapter-protocol/) via stdin/stdout.
This enables xsystem35 to work as a backend of VS Code's Debugger (and
possibly other debuggers that support DAP).
This commit is contained in:
kichikuou
2021-10-17 21:05:24 +09:00
parent 4bea33d852
commit 089520ec55
12 changed files with 556 additions and 26 deletions
+17 -2
View File
@@ -315,7 +315,7 @@ static void sigint_handler(int sig_num) {
dbg_state = DBG_STOPPED_INTERRUPT;
}
void dbg_cui_init(void) {
static void dbg_cui_init(void) {
#ifdef HAVE_SIGACTION
sys_set_signalhandler(SIGINT, sigint_handler);
#endif
@@ -325,6 +325,9 @@ void dbg_cui_init(void) {
#endif
}
static void dbg_cui_quit(void) {
}
typedef struct {
const char *name;
const char *alias;
@@ -379,7 +382,7 @@ static CommandResult cmd_help(void) {
return CONTINUE_REPL;
}
void dbg_cui_repl(void) {
static void dbg_cui_repl(void) {
if (dbg_state == DBG_STOPPED_BREAKPOINT) {
Breakpoint *bp = dbg_find_breakpoint(nact->current_page, nact->current_addr);
if (bp)
@@ -408,3 +411,15 @@ void dbg_cui_repl(void) {
}
}
}
static void dbg_cui_onsleep(void) {
if (dbg_state == DBG_STOPPED_INTERRUPT)
dbg_main();
}
DebuggerImpl dbg_cui_impl = {
.init = dbg_cui_init,
.quit = dbg_cui_quit,
.repl = dbg_cui_repl,
.onsleep = dbg_cui_onsleep,
};