mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
if ("dbg" in this) {
|
|
throw new Error("Debugger script must not run more than once!");
|
|
}
|
|
|
|
const dbg = new Debugger;
|
|
const debuggeesToPipelineIds = new Map;
|
|
const debuggeesToWorkerIds = new Map;
|
|
const sourceIdsToScripts = new Map;
|
|
|
|
dbg.uncaughtExceptionHook = function(error) {
|
|
console.error(`[debugger] Uncaught exception at ${error.fileName}:${error.lineNumber}:${error.columnNumber}: ${error.name}: ${error.message}`);
|
|
};
|
|
|
|
dbg.onNewScript = function(script, /* undefined; seems to be `script.global` now */ global) {
|
|
// TODO: handle wasm (`script.source.introductionType == wasm`)
|
|
sourceIdsToScripts.set(script.source.id, script);
|
|
notifyNewSource({
|
|
pipelineId: debuggeesToPipelineIds.get(script.global),
|
|
workerId: debuggeesToWorkerIds.get(script.global),
|
|
spidermonkeyId: script.source.id,
|
|
url: script.source.url,
|
|
urlOverride: script.source.displayURL,
|
|
text: script.source.text,
|
|
introductionType: script.source.introductionType ?? null,
|
|
});
|
|
};
|
|
|
|
addEventListener("addDebuggee", event => {
|
|
const {global, pipelineId: {namespaceId, index}, workerId} = event;
|
|
dbg.addDebuggee(global);
|
|
const debuggerObject = dbg.addDebuggee(global);
|
|
debuggeesToPipelineIds.set(debuggerObject, {
|
|
namespaceId,
|
|
index,
|
|
});
|
|
debuggeesToWorkerIds.set(debuggerObject, workerId);
|
|
});
|
|
|
|
addEventListener("getPossibleBreakpoints", event => {
|
|
const {spidermonkeyId} = event;
|
|
getPossibleBreakpointsResult(event, sourceIdsToScripts.get(spidermonkeyId).getPossibleBreakpoints(/* TODO: `query` */));
|
|
});
|