Bug 1512437 - Part 2: Convert breakpoint APIs to be synchronous now that there are no sourcemaps. r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D14628

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Logan Smyth 2018-12-14 23:29:58 +00:00
Родитель 6b24ffee98
Коммит 67c9ac56bc
2 изменённых файлов: 33 добавлений и 42 удалений

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

@ -470,21 +470,14 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
* A promise that resolves to a JSON object representing the
* response.
*/
setBreakpoint: function(line, column, condition, noSliding, inNestedLoop) {
if (!inNestedLoop && this.threadActor.state !== "paused") {
const errorObject = {
error: "wrongState",
message: "Cannot set breakpoint while debuggee is running.",
};
throw errorObject;
}
setBreakpoint: function(line, column, condition, noSliding) {
const location = new OriginalLocation(this, line, column);
return this._getOrCreateBreakpointActor(
const actor = this._getOrCreateBreakpointActor(
location,
condition,
noSliding
).then((actor) => {
);
const response = {
actor: actor.actorID,
isPending: actor.isPending,
@ -496,7 +489,6 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
}
return response;
});
},
/**
@ -591,7 +583,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
// GCed as well, and no scripts will exist on those lines
// anymore. We will never slide through a GCed script.
if (originalLocation.originalColumn || scripts.length === 0) {
return Promise.resolve(actor);
return actor;
}
// Find the script that spans the largest amount of code to
@ -617,13 +609,14 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
// which means there must be valid entry points somewhere
// within those scripts.
if (actualLine > maxLine) {
return Promise.reject({
// eslint-disable-next-line no-throw-literal
throw {
error: "noCodeAtLineColumn",
message:
"Could not find any entry points to set a breakpoint on, " +
"even though I was told a script existed on the line I started " +
"the search with.",
});
};
}
// Update the actor to use the new location (reusing a
@ -640,7 +633,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
}
}
return Promise.resolve(actor);
return actor;
},
_setBreakpointAtAllGeneratedLocations: function(actor, generatedLocations) {

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

@ -487,19 +487,19 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
line: generatedLine,
column: generatedColumn,
};
const pkt = onPacket(packet);
Promise.resolve(onPacket(packet))
.catch(error => {
this.conn.send(pkt);
} catch (error) {
reportError(error);
return {
this.conn.send({
error: "unknownError",
message: error.message + "\n" + error.stack,
};
})
.then(pkt => {
this.conn.send(pkt);
});
return undefined;
}
try {
this._pushThreadPause();
} catch (e) {
reportError(e, "Got an exception during TA__pauseAndRespond: ");
@ -1240,10 +1240,10 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
return res ? res : {};
},
onSources: async function(request) {
await Promise.all(this.dbg.findSources().map(source => {
onSources: function(request) {
for (const source of this.dbg.findSources()) {
this.sources.createSourceActor(source);
}));
}
// No need to flush the new source packets here, as we are sending the
// list of sources out immediately and we don't need to invoke the
@ -1963,9 +1963,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
}
if (this._onLoadBreakpointURLs.has(source.url)) {
this.unsafeSynchronize(
sourceActor.setBreakpoint(1, undefined, undefined, undefined, true)
);
sourceActor.setBreakpoint(1);
}
this._debuggerSourcesSeen.add(source);