mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 05:44:08 -07:00
Adds initial support for the Debug Adapter Protocol (DAP) to SpiderMonkey via debugger.js. This JavaScript-based implementation enables external debuggers (e.g., VS Code) to interact with the JS runtime using the DAP interface. Implemented DAP requests and events: - attach - initialize (capabilities) - stopped event - threads - scopes - variables (globalThis pending) - continue - stepIn - stepOut - setBreakpoints - Handling of debugger statements This forms the foundation for interactive debugging of in-game scripts, providing smoother integration with developer tools.
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
import { logger } from 'tools/dap/logger.js';
|
|
import { JsDebugger } from 'tools/dap/jsdebugger.js';
|
|
import { DapProtocolHandler } from 'tools/dap/daphandler.js';
|
|
import { plugins as managerPlugins } from 'tools/dap/managers/index.js';
|
|
import { plugins as commandPlugins } from 'tools/dap/commands/index.js';
|
|
|
|
// ===== Bootstrap System =====
|
|
// Set the logging level to 'info' for the entire system.
|
|
// TODO: Make this configurable via a settings file or command line argument.
|
|
logger.setLevel('debug');
|
|
logger.debug('Boostrapping system...');
|
|
|
|
const jsDebugger = new JsDebugger();
|
|
const dapHandler = new DapProtocolHandler(jsDebugger);
|
|
|
|
function loadPlugins(pluginClasses)
|
|
{
|
|
for (const PluginClass of pluginClasses)
|
|
{
|
|
const plugin = new PluginClass(jsDebugger, dapHandler);
|
|
}
|
|
}
|
|
|
|
logger.debug('Loading manager plugins...');
|
|
loadPlugins(managerPlugins);
|
|
|
|
logger.debug('Loading commands plugins...');
|
|
loadPlugins(commandPlugins);
|
|
|
|
// ===== Global Functions =====
|
|
export function sendEventToClient()
|
|
{
|
|
return jsDebugger.events.shift();
|
|
}
|
|
|
|
export function handleMessage(message)
|
|
{
|
|
return dapHandler.handleRequest(message);
|
|
}
|