mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-20 07:13:56 -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.
32 lines
891 B
JavaScript
32 lines
891 B
JavaScript
import { Plugin } from 'tools/dap/plugin.js';
|
|
|
|
class AttachManager extends Plugin {
|
|
constructor(jsDebugger, dapHandler) {
|
|
super('AttachManager', 'manager');
|
|
|
|
this.logger.debug('Setting up AttachManager');
|
|
jsDebugger.on('onDebuggerAttached', () => {
|
|
this.logger.debug('Debugger attached');
|
|
jsDebugger.instance.addAllGlobalsAsDebuggees();
|
|
}, this.name);
|
|
|
|
jsDebugger.on('onDebuggerDetached', () => {
|
|
this.logger.debug('Debugger detached');
|
|
jsDebugger.instance.removeAllDebuggees();
|
|
}, this.name);
|
|
|
|
jsDebugger.on('onNewGlobalObject', (global) => {
|
|
if (!jsDebugger.debuggerAttached)
|
|
return;
|
|
|
|
this.logger.debug(`Added global object as debuggee`);
|
|
jsDebugger.instance.addDebuggee(global);
|
|
}, this.name);
|
|
|
|
jsDebugger.on('onUncaughtException', (e) => {
|
|
this.logger.error(`Uncaught exception: ${e}`);
|
|
}, this.name);
|
|
}
|
|
}
|
|
|
|
export default AttachManager;
|