0ad/binaries/data/mods/mod/tools/dap/managers/attach.js
trompetin17 20b7c3f9b8
Implement Debug Adapter Protocol (DAP) Interface in debugger.js
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.
2025-07-11 11:06:05 -05:00

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;