mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1479058 Part 5 - ReplayDebugger cleanup, r=jimb.
--HG-- extra : rebase_source : 7a95159485386cd4fdf0b3d1fabc33da2ab7866d
This commit is contained in:
parent
5913321baf
commit
cb73c42b70
@ -105,14 +105,26 @@ ReplayDebugger.prototype = {
|
||||
return undefined;
|
||||
},
|
||||
|
||||
// Getter for a breakpoint kind that has no script/offset/frameIndex.
|
||||
_breakpointKindGetter(kind) {
|
||||
return this._searchBreakpoints(({position, data}) => {
|
||||
return (position.kind == kind) ? data : null;
|
||||
});
|
||||
},
|
||||
|
||||
// Setter for a breakpoint kind that has no script/offset/frameIndex.
|
||||
_breakpointKindSetter(kind, handler, callback) {
|
||||
if (handler) {
|
||||
this._setBreakpoint(callback, { kind }, handler);
|
||||
} else {
|
||||
this._clearMatchingBreakpoints(({position}) => position.kind == kind);
|
||||
}
|
||||
},
|
||||
|
||||
// This is called on all ReplayDebuggers whenever the child process is about
|
||||
// to unpause. Clear out all data that is invalidated as a result.
|
||||
invalidateAfterUnpause() {
|
||||
this._frames.forEach(frame => {
|
||||
if (frame) {
|
||||
frame._invalidate();
|
||||
}
|
||||
});
|
||||
this._frames.forEach(frame => frame._invalidate());
|
||||
this._frames.length = 0;
|
||||
|
||||
this._objects.forEach(obj => obj._invalidate());
|
||||
@ -234,11 +246,6 @@ ReplayDebugger.prototype = {
|
||||
// There are no frames on the stack.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fill in the older frames.
|
||||
while (index >= this._frames.length) {
|
||||
this._frames.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
this._frames[index] = new ReplayDebuggerFrame(this, data);
|
||||
@ -249,37 +256,24 @@ ReplayDebugger.prototype = {
|
||||
return this._getFrame(NewestFrameIndex);
|
||||
},
|
||||
|
||||
get onNewScript() {
|
||||
return this._searchBreakpoints(({position, data}) => {
|
||||
return position.kind == "NewScript" ? data : null;
|
||||
});
|
||||
/////////////////////////////////////////////////////////
|
||||
// Handlers
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
_getNewScript() {
|
||||
return this._addScript(this._sendRequest({ type: "getNewScript" }));
|
||||
},
|
||||
|
||||
get onNewScript() { return this._breakpointKindGetter("NewScript"); },
|
||||
set onNewScript(handler) {
|
||||
if (handler) {
|
||||
this._setBreakpoint(() => {
|
||||
const script = this._sendRequest({ type: "getNewScript" });
|
||||
const debugScript = this._addScript(script);
|
||||
handler.call(this, debugScript);
|
||||
}, { kind: "NewScript" }, handler);
|
||||
} else {
|
||||
this._clearMatchingBreakpoints(({position}) => position.kind == "NewScript");
|
||||
}
|
||||
},
|
||||
|
||||
get onEnterFrame() {
|
||||
return this._searchBreakpoints(({position, data}) => {
|
||||
return position.kind == "EnterFrame" ? data : null;
|
||||
});
|
||||
this._breakpointKindSetter("NewScript", handler,
|
||||
() => handler.call(this, this._getNewScript()));
|
||||
},
|
||||
|
||||
get onEnterFrame() { return this._breakpointKindGetter("EnterFrame"); },
|
||||
set onEnterFrame(handler) {
|
||||
if (handler) {
|
||||
this._setBreakpoint(() => handler.call(this, this.getNewestFrame()),
|
||||
{ kind: "EnterFrame" }, handler);
|
||||
} else {
|
||||
this._clearMatchingBreakpoints(({position}) => position.kind == "EnterFrame");
|
||||
}
|
||||
this._breakpointKindSetter("EnterFrame", handler,
|
||||
() => handler.call(this, this.getNewestFrame()));
|
||||
},
|
||||
|
||||
get replayingOnPopFrame() {
|
||||
@ -294,7 +288,7 @@ ReplayDebugger.prototype = {
|
||||
{ kind: "OnPop" }, handler);
|
||||
} else {
|
||||
this._clearMatchingBreakpoints(({position}) => {
|
||||
return position.kind == "EnterFrame" && !position.script;
|
||||
return position.kind == "OnPop" && !position.script;
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -455,7 +449,7 @@ ReplayDebuggerFrame.prototype = {
|
||||
|
||||
get onPop() {
|
||||
return this._dbg._searchBreakpoints(({position, data}) => {
|
||||
return this._positionMatches(position, "OnPop");
|
||||
return this._positionMatches(position, "OnPop") ? data : null;
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -166,9 +166,7 @@ dbg.onNewScript = function(script) {
|
||||
// without executing any scripts.
|
||||
RecordReplayControl.advanceProgressCounter();
|
||||
|
||||
if (gHasNewScriptHandler) {
|
||||
RecordReplayControl.positionHit({ kind: "NewScript" });
|
||||
}
|
||||
hitGlobalHandler("NewScript");
|
||||
|
||||
// Check in case any handlers we need to install are on the scripts just
|
||||
// created.
|
||||
@ -179,11 +177,8 @@ dbg.onNewScript = function(script) {
|
||||
// Position Handler State
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Whether there is a position handler for NewScript.
|
||||
let gHasNewScriptHandler = false;
|
||||
|
||||
// Whether there is a position handler for EnterFrame.
|
||||
let gHasEnterFrameHandler = false;
|
||||
// Position kinds we are expected to hit.
|
||||
let gPositionHandlerKinds = Object.create(null);
|
||||
|
||||
// Handlers we tried to install but couldn't due to a script not existing.
|
||||
// Breakpoints requested by the middleman --- which are preserved when
|
||||
@ -204,8 +199,7 @@ function ClearPositionHandlers() {
|
||||
dbg.clearAllBreakpoints();
|
||||
dbg.onEnterFrame = undefined;
|
||||
|
||||
gHasNewScriptHandler = false;
|
||||
gHasEnterFrameHandler = false;
|
||||
gPositionHandlerKinds = Object.create(null);
|
||||
gPendingPcHandlers.length = 0;
|
||||
gInstalledPcHandlers.length = 0;
|
||||
gOnPopFilters.length = 0;
|
||||
@ -218,6 +212,14 @@ function installPendingHandlers() {
|
||||
pending.forEach(EnsurePositionHandler);
|
||||
}
|
||||
|
||||
// Hit a position with the specified kind if we are expected to. This is for
|
||||
// use with position kinds that have no script/offset/frameIndex information.
|
||||
function hitGlobalHandler(kind) {
|
||||
if (gPositionHandlerKinds[kind]) {
|
||||
RecordReplayControl.positionHit({ kind });
|
||||
}
|
||||
}
|
||||
|
||||
// The completion state of any frame that is being popped.
|
||||
let gPopFrameResult = null;
|
||||
|
||||
@ -232,9 +234,7 @@ function onPopFrame(completion) {
|
||||
}
|
||||
|
||||
function onEnterFrame(frame) {
|
||||
if (gHasEnterFrameHandler) {
|
||||
RecordReplayControl.positionHit({ kind: "EnterFrame" });
|
||||
}
|
||||
hitGlobalHandler("EnterFrame");
|
||||
|
||||
if (considerScript(frame.script)) {
|
||||
gOnPopFilters.forEach(filter => {
|
||||
@ -259,6 +259,8 @@ function addOnPopFilter(filter) {
|
||||
}
|
||||
|
||||
function EnsurePositionHandler(position) {
|
||||
gPositionHandlerKinds[position.kind] = true;
|
||||
|
||||
switch (position.kind) {
|
||||
case "Break":
|
||||
case "OnStep":
|
||||
@ -301,12 +303,8 @@ function EnsurePositionHandler(position) {
|
||||
}
|
||||
break;
|
||||
case "EnterFrame":
|
||||
gHasEnterFrameHandler = true;
|
||||
dbg.onEnterFrame = onEnterFrame;
|
||||
break;
|
||||
case "NewScript":
|
||||
gHasNewScriptHandler = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user