2025-05-29 20:40:33 -07:00
|
|
|
import { Plugin } from 'tools/dap/plugin.js';
|
|
|
|
|
|
2025-12-30 00:57:37 -08:00
|
|
|
class AttachManager extends Plugin
|
|
|
|
|
{
|
|
|
|
|
constructor(jsDebugger, dapHandler)
|
|
|
|
|
{
|
2025-05-29 20:40:33 -07:00
|
|
|
super('AttachManager', 'manager');
|
|
|
|
|
|
|
|
|
|
this.logger.debug('Setting up AttachManager');
|
2025-12-30 00:57:37 -08:00
|
|
|
jsDebugger.on('onDebuggerAttached', () =>
|
|
|
|
|
{
|
2025-05-29 20:40:33 -07:00
|
|
|
this.logger.debug('Debugger attached');
|
|
|
|
|
jsDebugger.instance.addAllGlobalsAsDebuggees();
|
|
|
|
|
}, this.name);
|
|
|
|
|
|
2025-12-30 00:57:37 -08:00
|
|
|
jsDebugger.on('onDebuggerDetached', () =>
|
|
|
|
|
{
|
2025-05-29 20:40:33 -07:00
|
|
|
this.logger.debug('Debugger detached');
|
|
|
|
|
jsDebugger.instance.removeAllDebuggees();
|
|
|
|
|
}, this.name);
|
|
|
|
|
|
2025-12-30 00:57:37 -08:00
|
|
|
jsDebugger.on('onNewGlobalObject', (global) =>
|
|
|
|
|
{
|
2025-05-29 20:40:33 -07:00
|
|
|
if (!jsDebugger.debuggerAttached)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this.logger.debug(`Added global object as debuggee`);
|
|
|
|
|
jsDebugger.instance.addDebuggee(global);
|
|
|
|
|
}, this.name);
|
|
|
|
|
|
2025-12-30 00:57:37 -08:00
|
|
|
jsDebugger.on('onUncaughtException', (e) =>
|
|
|
|
|
{
|
2025-05-29 20:40:33 -07:00
|
|
|
this.logger.error(`Uncaught exception: ${e}`);
|
|
|
|
|
}, this.name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AttachManager;
|