Rework NACT command tracing

- Now tracing is not a build-time config but a runtime option (`-trace`)
- One command per line, so that traces are not mixed with other outputs
- Send traces to DAP client
- Fix garbled characters in non-SJIS environments
This commit is contained in:
kichikuou
2025-01-02 16:53:01 +09:00
parent ea77d594bf
commit 1a53c50c75
15 changed files with 125 additions and 112 deletions
+19
View File
@@ -127,6 +127,25 @@ public:
}
bool console_output(const char* format, va_list ap) override {
char buf[1024];
vsnprintf(buf, sizeof(buf), format, ap);
Json json = {
{"type", "event"},
{"event", "output"},
{"body", {
{"output", buf},
}}
};
const char *src = symbols.page2src(g_nact->sco.page());
if (src)
json["body"]["source"] = create_source(src);
int line = symbols.addr2line(g_nact->sco.page(), g_nact->sco.cmd_addr());
if (line >= 0)
json["body"]["line"] = line;
send_json(json);
return true;
}