Bug 1556813 Part 5 - Server changes for instrumentation based control logic, r=loganfsmyth.

--HG--
extra : rebase_source : b678f9170a1d2250c5916d9a9dcbfe7ed82c0a0b
extra : histedit_source : 548ebf0a3570200dcf856cff249a518a568e9d5a
This commit is contained in:
Brian Hackett 2019-06-12 07:42:49 -10:00
Родитель 6bc30082c3
Коммит 35c0ee1da7
3 изменённых файлов: 42 добавлений и 33 удалений

Просмотреть файл

@ -46,7 +46,7 @@ function BreakpointActor(threadActor, location) {
BreakpointActor.prototype = {
setOptions(options) {
for (const [script, offsets] of this.scripts) {
this._updateOptionsForScript(script, offsets, options);
this._newOffsetsOrOptions(script, offsets, this.options, options);
}
this.options = options;
@ -71,11 +71,7 @@ BreakpointActor.prototype = {
*/
addScript: function(script, offsets) {
this.scripts.set(script, offsets.concat(this.scripts.get(offsets) || []));
for (const offset of offsets) {
script.setBreakpoint(offset, this);
}
this._updateOptionsForScript(script, offsets, this.options);
this._newOffsetsOrOptions(script, offsets, null, this.options);
},
/**
@ -88,12 +84,20 @@ BreakpointActor.prototype = {
this.scripts.clear();
},
// Update any state affected by changing options on a script this breakpoint
// is associated with.
_updateOptionsForScript(script, offsets, options) {
/**
* Called on changes to this breakpoint's script offsets or options.
*/
_newOffsetsOrOptions(script, offsets, oldOptions, options) {
// When replaying, logging breakpoints are handled using an API to get logged
// messages from throughout the recording.
if (this.threadActor.dbg.replaying && options.logValue) {
if (
oldOptions &&
oldOptions.logValue == options.logValue &&
oldOptions.condition == options.condition
) {
return;
}
for (const offset of offsets) {
const { lineNumber, columnNumber } = script.getOffsetLocation(offset);
script.replayVirtualConsoleLog(
@ -113,6 +117,15 @@ BreakpointActor.prototype = {
}
);
}
return;
}
// In all other cases, this is used as a script breakpoint handler.
// Clear any existing handler first in case this is called multiple times
// after options change.
for (const offset of offsets) {
script.clearBreakpoint(this, offset);
script.setBreakpoint(offset, this);
}
},
@ -202,12 +215,6 @@ BreakpointActor.prototype = {
const reason = { type: "breakpoint", actors: [this.actorID] };
const { condition, logValue } = this.options || {};
// When replaying, breakpoints with log values are handled via
// _updateOptionsForScript.
if (logValue && this.threadActor.dbg.replaying) {
return undefined;
}
if (condition) {
const { result, message } = this.checkCondition(frame, condition);

Просмотреть файл

@ -163,20 +163,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
this._dbg.replayingOnForcedPause = this.replayingOnForcedPause.bind(
this
);
const sendProgress = throttle((recording, executionPoint) => {
if (this.attached) {
this.conn.send({
type: "progress",
from: this.actorID,
recording,
executionPoint,
});
}
}, 100);
this._dbg.replayingOnPositionChange = this.replayingOnPositionChange.bind(
this,
sendProgress
);
this._dbg.replayingOnPositionChange = this._makeReplayingOnPositionChange();
}
// Keep the debugger disabled until a client attaches.
this._dbg.enabled = this._state != "detached";
@ -1849,10 +1836,23 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
* changed its position: a checkpoint was reached or a switch between a
* recording and replaying child process occurred.
*/
replayingOnPositionChange: function(sendProgress) {
const recording = this.dbg.replayIsRecording();
const executionPoint = this.dbg.replayCurrentExecutionPoint();
sendProgress(recording, executionPoint);
_makeReplayingOnPositionChange() {
return throttle(() => {
if (this.attached) {
const recording = this.dbg.replayIsRecording();
const executionPoint = this.dbg.replayCurrentExecutionPoint();
const unscannedRegions = this.dbg.replayUnscannedRegions();
const cachedPoints = this.dbg.replayCachedPoints();
this.conn.send({
type: "progress",
from: this.actorID,
recording,
executionPoint,
unscannedRegions,
cachedPoints,
});
}
}, 100);
},
/**

Просмотреть файл

@ -42,6 +42,8 @@ const threadSpec = generateActorSpec({
progress: {
recording: Option(0, "json"),
executionPoint: Option(0, "json"),
unscannedRegions: Option(0, "json"),
cachedPoints: Option(0, "json"),
},
},