From ad74710129cf071e47c4cb3186c687ac7a0a0940 Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Fri, 30 Aug 2019 17:10:57 +0000 Subject: [PATCH] Bug 1576318 Part 4 - Add testing method to get the debugger requests and associated stacks for the current pause, r=loganfsmyth. Depends on D43320 Differential Revision: https://phabricator.services.mozilla.com/D43321 --HG-- extra : moz-landing-system : lando --- devtools/server/actors/replay/control.js | 17 ++++++++++++++--- devtools/server/actors/replay/debugger.js | 4 ++++ devtools/server/actors/thread.js | 4 ++++ devtools/shared/specs/thread.js | 7 +++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/devtools/server/actors/replay/control.js b/devtools/server/actors/replay/control.js index d3e0740ad952..06309067a107 100644 --- a/devtools/server/actors/replay/control.js +++ b/devtools/server/actors/replay/control.js @@ -1033,6 +1033,13 @@ let gPausePoint = null; // In ARRIVING mode, the requests must be sent once the child arrives. const gDebuggerRequests = []; +function addDebuggerRequest(request) { + gDebuggerRequests.push({ + request, + stack: Error().stack, + }); +} + function setPauseState(mode, point, child) { assert(mode); const idString = child ? ` #${child.id}` : ""; @@ -1077,7 +1084,7 @@ function sendActiveChildToPausePoint() { gActiveChild.sendManifest({ contents: { kind: "batchDebuggerRequest", - requests: gDebuggerRequests, + requests: gDebuggerRequests.map(r => r.request), }, onFinished(finishData) { assert(!finishData || !finishData.restoredCheckpoint); @@ -1823,7 +1830,7 @@ const gControl = { gActiveChild.divergedFromRecording = true; } - gDebuggerRequests.push(request); + addDebuggerRequest(request); return data.response; }, @@ -1860,6 +1867,10 @@ const gControl = { unscannedRegions, cachedPoints, + debuggerRequests() { + return gDebuggerRequests; + }, + getPauseData() { // If the child has not arrived at the pause point yet, see if there is // cached pause data for this point already which we can immediately return. @@ -1868,7 +1879,7 @@ const gControl = { if (data) { // After the child pauses, it will need to generate the pause data so // that any referenced objects will be instantiated. - gDebuggerRequests.push({ type: "pauseData" }); + addDebuggerRequest({ type: "pauseData" }); return data; } } diff --git a/devtools/server/actors/replay/debugger.js b/devtools/server/actors/replay/debugger.js index 9dbda280de73..d0321dc72b49 100644 --- a/devtools/server/actors/replay/debugger.js +++ b/devtools/server/actors/replay/debugger.js @@ -120,6 +120,10 @@ ReplayDebugger.prototype = { return this._control.cachedPoints(); }, + replayDebuggerRequests() { + return this._control.debuggerRequests(); + }, + addDebuggee() {}, removeAllDebuggees() {}, diff --git a/devtools/server/actors/thread.js b/devtools/server/actors/thread.js index 92373850b1a9..cf7af51128a9 100644 --- a/devtools/server/actors/thread.js +++ b/devtools/server/actors/thread.js @@ -2127,6 +2127,10 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { const loc = this.sources.getFrameLocation(frame); dump(`${prefix} (${loc.line}, ${loc.column})\n`); }, + + debuggerRequests() { + return this.dbg.replayDebuggerRequests(); + }, }); Object.assign(ThreadActor.prototype.requestTypes, { diff --git a/devtools/shared/specs/thread.js b/devtools/shared/specs/thread.js index 15fdbce74ffe..36ea041498c9 100644 --- a/devtools/shared/specs/thread.js +++ b/devtools/shared/specs/thread.js @@ -154,6 +154,13 @@ const threadSpec = generateActorSpec({ ignoreCaughtExceptions: Arg(1, "string"), }, }, + + // For testing. + debuggerRequests: { + response: { + value: RetVal("array:json"), + }, + }, }, });