Commit fe3d51e1 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

[inspector] Simplify async stepping

Currently, debugger pauses on async call schedule and then waits for Debugger.pauseOnAsyncCall
with parentStackTraceId to actually schedule the pause.

This CL combines these two steps:
- For local async tasks, it just stores m_taskWithScheduledBreak at the time of schedule,
  to be able to pause once this task is run.
- For external async tasks, it plumbs "should_pause" boolean in V8StackTraceId from
  the point of schedule to the point of execution, and schedules a pause once
  externalAsyncTaskStarted is called with "should_pause" set to true.

This approach greatly simplifies the implementation, and reduced frontend to a single
"breakOnAsyncCall: true" parameter in Debugger.stepInto.

Drive-by: introduce hasScheduledBreakOnNextFunctionCall() to make
SetBreakOnNextFunctionCall management more robust.

Note: artificial pauses at async call schedule time are gone from test expectations -
we now only pause when user actually wants to pause, which makes protocol much simpler.

See also design doc linked in the bug.

BUG=chromium:1000475

Change-Id: I2d16f79c599fe196b2aaeca8223c63437a2954a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1783724
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63737}
parent 25c11657
......@@ -237,7 +237,7 @@ domain Debugger
# Stops on the next JavaScript statement.
command pause
experimental command pauseOnAsyncCall
experimental deprecated command pauseOnAsyncCall
parameters
# Debugger will pause when async call with given stack trace is started.
Runtime.StackTraceId parentStackTraceId
......@@ -435,7 +435,7 @@ domain Debugger
# Steps into the function call.
command stepInto
parameters
# Debugger will issue additional Debugger.paused notification if any async task is scheduled
# Debugger will pause on the execution of the first async task which was scheduled
# before next pause.
experimental optional boolean breakOnAsyncCall
......@@ -479,9 +479,8 @@ domain Debugger
optional Runtime.StackTrace asyncStackTrace
# Async stack trace, if any.
experimental optional Runtime.StackTraceId asyncStackTraceId
# Just scheduled async call will have this stack trace as parent stack during async execution.
# This field is available only after `Debugger.stepInto` call with `breakOnAsynCall` flag.
experimental optional Runtime.StackTraceId asyncCallStackTraceId
# Never present, will be removed.
experimental deprecated optional Runtime.StackTraceId asyncCallStackTraceId
# Fired when the virtual machine resumed execution.
event resumed
......
......@@ -1039,13 +1039,7 @@ Response V8DebuggerAgentImpl::stepOut() {
Response V8DebuggerAgentImpl::pauseOnAsyncCall(
std::unique_ptr<protocol::Runtime::StackTraceId> inParentStackTraceId) {
bool isOk = false;
int64_t stackTraceId = inParentStackTraceId->getId().toInteger64(&isOk);
if (!isOk) {
return Response::Error("Invalid stack trace id");
}
m_debugger->pauseOnAsyncCall(m_session->contextGroupId(), stackTraceId,
inParentStackTraceId->getDebuggerId(String16()));
// Deprecated, just return OK.
return Response::OK();
}
......@@ -1376,24 +1370,6 @@ V8DebuggerAgentImpl::currentExternalStackTrace() {
.build();
}
std::unique_ptr<protocol::Runtime::StackTraceId>
V8DebuggerAgentImpl::currentScheduledAsyncCall() {
v8_inspector::V8StackTraceId scheduledAsyncCall =
m_debugger->scheduledAsyncCall();
if (scheduledAsyncCall.IsInvalid()) return nullptr;
std::unique_ptr<protocol::Runtime::StackTraceId> asyncCallStackTrace =
protocol::Runtime::StackTraceId::create()
.setId(stackTraceIdToString(scheduledAsyncCall.id))
.build();
// TODO(kozyatinskiy): extract this check to IsLocal function.
if (scheduledAsyncCall.debugger_id.first ||
scheduledAsyncCall.debugger_id.second) {
asyncCallStackTrace->setDebuggerId(
debuggerIdToString(scheduledAsyncCall.debugger_id));
}
return asyncCallStackTrace;
}
bool V8DebuggerAgentImpl::isPaused() const {
return m_debugger->isPausedInContextGroup(m_session->contextGroupId());
}
......@@ -1658,8 +1634,7 @@ void V8DebuggerAgentImpl::didPause(
m_frontend.paused(std::move(protocolCallFrames), breakReason,
std::move(breakAuxData), std::move(hitBreakpointIds),
currentAsyncStackTrace(), currentExternalStackTrace(),
currentScheduledAsyncCall());
currentAsyncStackTrace(), currentExternalStackTrace());
}
void V8DebuggerAgentImpl::didContinue() {
......
......@@ -165,7 +165,6 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>*);
std::unique_ptr<protocol::Runtime::StackTrace> currentAsyncStackTrace();
std::unique_ptr<protocol::Runtime::StackTraceId> currentExternalStackTrace();
std::unique_ptr<protocol::Runtime::StackTraceId> currentScheduledAsyncCall();
void setPauseOnExceptionsImpl(int);
......
......@@ -107,7 +107,9 @@ void V8Debugger::disable() {
if (--m_enableCount) return;
clearContinueToLocation();
m_taskWithScheduledBreak = nullptr;
m_taskWithScheduledBreakDebuggerId = String16();
m_externalAsyncTaskPauseRequested = false;
m_taskWithScheduledBreakPauseRequested = false;
m_pauseOnNextCallRequested = false;
m_pauseOnAsyncCall = false;
m_wasmTranslation.Clear();
v8::debug::SetDebugDelegate(m_isolate, nullptr);
......@@ -171,12 +173,19 @@ void V8Debugger::setPauseOnNextCall(bool pause, int targetContextGroupId) {
m_targetContextGroupId != targetContextGroupId) {
return;
}
m_targetContextGroupId = targetContextGroupId;
m_breakRequested = pause;
if (pause)
v8::debug::SetBreakOnNextFunctionCall(m_isolate);
else
v8::debug::ClearBreakOnNextFunctionCall(m_isolate);
if (pause) {
bool didHaveBreak = hasScheduledBreakOnNextFunctionCall();
m_pauseOnNextCallRequested = true;
if (!didHaveBreak) {
m_targetContextGroupId = targetContextGroupId;
v8::debug::SetBreakOnNextFunctionCall(m_isolate);
}
} else {
m_pauseOnNextCallRequested = false;
if (!hasScheduledBreakOnNextFunctionCall()) {
v8::debug::ClearBreakOnNextFunctionCall(m_isolate);
}
}
}
bool V8Debugger::canBreakProgram() {
......@@ -275,21 +284,12 @@ bool V8Debugger::asyncStepOutOfFunction(int targetContextGroupId,
void* parentTask =
std::shared_ptr<AsyncStackTrace>(parent)->suspendedTaskId();
if (!parentTask) return false;
pauseOnAsyncCall(targetContextGroupId,
reinterpret_cast<uintptr_t>(parentTask), String16());
m_targetContextGroupId = targetContextGroupId;
m_taskWithScheduledBreak = parentTask;
continueProgram(targetContextGroupId);
return true;
}
void V8Debugger::pauseOnAsyncCall(int targetContextGroupId, uintptr_t task,
const String16& debuggerId) {
DCHECK(targetContextGroupId);
m_targetContextGroupId = targetContextGroupId;
m_taskWithScheduledBreak = reinterpret_cast<void*>(task);
m_taskWithScheduledBreakDebuggerId = debuggerId;
}
void V8Debugger::terminateExecution(
std::unique_ptr<TerminateExecutionCallback> callback) {
if (m_terminateExecutionCallback) {
......@@ -390,10 +390,11 @@ void V8Debugger::handleProgramBreak(
return;
}
m_targetContextGroupId = 0;
m_breakRequested = false;
m_pauseOnNextCallRequested = false;
m_pauseOnAsyncCall = false;
m_taskWithScheduledBreak = nullptr;
m_taskWithScheduledBreakDebuggerId = String16();
m_externalAsyncTaskPauseRequested = false;
m_taskWithScheduledBreakPauseRequested = false;
bool scheduledOOMBreak = m_scheduledOOMBreak;
bool scheduledAssertBreak = m_scheduledAssertBreak;
......@@ -540,15 +541,15 @@ void V8Debugger::AsyncEventOccurred(v8::debug::DebugAsyncActionType type,
switch (type) {
case v8::debug::kDebugPromiseThen:
asyncTaskScheduledForStack("Promise.then", task, false);
if (!isBlackboxed) asyncTaskCandidateForStepping(task, true);
if (!isBlackboxed) asyncTaskCandidateForStepping(task);
break;
case v8::debug::kDebugPromiseCatch:
asyncTaskScheduledForStack("Promise.catch", task, false);
if (!isBlackboxed) asyncTaskCandidateForStepping(task, true);
if (!isBlackboxed) asyncTaskCandidateForStepping(task);
break;
case v8::debug::kDebugPromiseFinally:
asyncTaskScheduledForStack("Promise.finally", task, false);
if (!isBlackboxed) asyncTaskCandidateForStepping(task, true);
if (!isBlackboxed) asyncTaskCandidateForStepping(task);
break;
case v8::debug::kDebugWillHandle:
asyncTaskStartedForStack(task);
......@@ -811,9 +812,13 @@ V8StackTraceId V8Debugger::storeCurrentStackTrace(
++m_asyncStacksCount;
collectOldAsyncStacksIfNeeded();
asyncTaskCandidateForStepping(reinterpret_cast<void*>(id), false);
return V8StackTraceId(id, debuggerIdFor(contextGroupId));
bool shouldPause =
m_pauseOnAsyncCall && contextGroupId == m_targetContextGroupId;
if (shouldPause) {
m_pauseOnAsyncCall = false;
v8::debug::ClearStepping(m_isolate); // Cancel step into.
}
return V8StackTraceId(id, debuggerIdFor(contextGroupId), shouldPause);
}
uintptr_t V8Debugger::storeStackTrace(
......@@ -829,13 +834,12 @@ void V8Debugger::externalAsyncTaskStarted(const V8StackTraceId& parent) {
m_currentAsyncParent.emplace_back();
m_currentTasks.push_back(reinterpret_cast<void*>(parent.id));
if (m_breakRequested) return;
if (!m_taskWithScheduledBreakDebuggerId.isEmpty() &&
reinterpret_cast<uintptr_t>(m_taskWithScheduledBreak) == parent.id &&
m_taskWithScheduledBreakDebuggerId ==
debuggerIdToString(parent.debugger_id)) {
v8::debug::SetBreakOnNextFunctionCall(m_isolate);
}
if (!parent.should_pause) return;
bool didHaveBreak = hasScheduledBreakOnNextFunctionCall();
m_externalAsyncTaskPauseRequested = true;
if (didHaveBreak) return;
m_targetContextGroupId = currentContextGroupId();
v8::debug::SetBreakOnNextFunctionCall(m_isolate);
}
void V8Debugger::externalAsyncTaskFinished(const V8StackTraceId& parent) {
......@@ -845,22 +849,16 @@ void V8Debugger::externalAsyncTaskFinished(const V8StackTraceId& parent) {
DCHECK(m_currentTasks.back() == reinterpret_cast<void*>(parent.id));
m_currentTasks.pop_back();
if (m_taskWithScheduledBreakDebuggerId.isEmpty() ||
reinterpret_cast<uintptr_t>(m_taskWithScheduledBreak) != parent.id ||
m_taskWithScheduledBreakDebuggerId !=
debuggerIdToString(parent.debugger_id)) {
return;
}
m_taskWithScheduledBreak = nullptr;
m_taskWithScheduledBreakDebuggerId = String16();
if (m_breakRequested) return;
if (!parent.should_pause) return;
m_externalAsyncTaskPauseRequested = false;
if (hasScheduledBreakOnNextFunctionCall()) return;
v8::debug::ClearBreakOnNextFunctionCall(m_isolate);
}
void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task,
bool recurring) {
asyncTaskScheduledForStack(toString16(taskName), task, recurring);
asyncTaskCandidateForStepping(task, true);
asyncTaskCandidateForStepping(task);
}
void V8Debugger::asyncTaskCanceled(void* task) {
......@@ -936,46 +934,36 @@ void V8Debugger::asyncTaskFinishedForStack(void* task) {
}
}
void V8Debugger::asyncTaskCandidateForStepping(void* task, bool isLocal) {
void V8Debugger::asyncTaskCandidateForStepping(void* task) {
if (!m_pauseOnAsyncCall) return;
int contextGroupId = currentContextGroupId();
if (contextGroupId != m_targetContextGroupId) return;
if (isLocal) {
m_scheduledAsyncCall = v8_inspector::V8StackTraceId(
reinterpret_cast<uintptr_t>(task), std::make_pair(0, 0));
} else {
m_scheduledAsyncCall = v8_inspector::V8StackTraceId(
reinterpret_cast<uintptr_t>(task), debuggerIdFor(contextGroupId));
}
breakProgram(m_targetContextGroupId);
m_scheduledAsyncCall = v8_inspector::V8StackTraceId();
m_taskWithScheduledBreak = task;
m_pauseOnAsyncCall = false;
v8::debug::ClearStepping(m_isolate); // Cancel step into.
}
void V8Debugger::asyncTaskStartedForStepping(void* task) {
if (m_breakRequested) return;
// TODO(kozyatinskiy): we should search task in async chain to support
// blackboxing.
if (m_taskWithScheduledBreakDebuggerId.isEmpty() &&
task == m_taskWithScheduledBreak) {
v8::debug::SetBreakOnNextFunctionCall(m_isolate);
}
if (task != m_taskWithScheduledBreak) return;
bool didHaveBreak = hasScheduledBreakOnNextFunctionCall();
m_taskWithScheduledBreakPauseRequested = true;
if (didHaveBreak) return;
m_targetContextGroupId = currentContextGroupId();
v8::debug::SetBreakOnNextFunctionCall(m_isolate);
}
void V8Debugger::asyncTaskFinishedForStepping(void* task) {
if (!m_taskWithScheduledBreakDebuggerId.isEmpty() ||
task != m_taskWithScheduledBreak) {
return;
}
if (task != m_taskWithScheduledBreak) return;
m_taskWithScheduledBreak = nullptr;
if (m_breakRequested) return;
m_taskWithScheduledBreakPauseRequested = false;
if (hasScheduledBreakOnNextFunctionCall()) return;
v8::debug::ClearBreakOnNextFunctionCall(m_isolate);
}
void V8Debugger::asyncTaskCanceledForStepping(void* task) {
if (!m_taskWithScheduledBreakDebuggerId.isEmpty() ||
task != m_taskWithScheduledBreak)
return;
m_taskWithScheduledBreak = nullptr;
asyncTaskFinishedForStepping(task);
}
void V8Debugger::allAsyncTasksCanceled() {
......@@ -1110,4 +1098,9 @@ void V8Debugger::dumpAsyncTaskStacksStateForTest() {
fprintf(stdout, "\n");
}
bool V8Debugger::hasScheduledBreakOnNextFunctionCall() const {
return m_pauseOnNextCallRequested || m_taskWithScheduledBreakPauseRequested ||
m_externalAsyncTaskPauseRequested;
}
} // namespace v8_inspector
......@@ -59,8 +59,6 @@ class V8Debugger : public v8::debug::DebugDelegate,
void stepIntoStatement(int targetContextGroupId, bool breakOnAsyncCall);
void stepOverStatement(int targetContextGroupId);
void stepOutOfFunction(int targetContextGroupId);
void pauseOnAsyncCall(int targetContextGroupId, uintptr_t task,
const String16& debuggerId);
void terminateExecution(std::unique_ptr<TerminateExecutionCallback> callback);
......@@ -121,10 +119,6 @@ class V8Debugger : public v8::debug::DebugDelegate,
void setMaxAsyncTaskStacksForTest(int limit);
void dumpAsyncTaskStacksStateForTest();
v8_inspector::V8StackTraceId scheduledAsyncCall() {
return m_scheduledAsyncCall;
}
std::pair<int64_t, int64_t> debuggerIdFor(int contextGroupId);
std::pair<int64_t, int64_t> debuggerIdFor(
const String16& serializedDebuggerId);
......@@ -173,7 +167,7 @@ class V8Debugger : public v8::debug::DebugDelegate,
void asyncTaskStartedForStack(void* task);
void asyncTaskFinishedForStack(void* task);
void asyncTaskCandidateForStepping(void* task, bool isLocal);
void asyncTaskCandidateForStepping(void* task);
void asyncTaskStartedForStepping(void* task);
void asyncTaskFinishedForStepping(void* task);
void asyncTaskCanceledForStepping(void* task);
......@@ -197,6 +191,8 @@ class V8Debugger : public v8::debug::DebugDelegate,
int currentContextGroupId();
bool asyncStepOutOfFunction(int targetContextGroupId, bool onlyAtReturn);
bool hasScheduledBreakOnNextFunctionCall() const;
v8::Isolate* m_isolate;
V8InspectorImpl* m_inspector;
int m_enableCount;
......@@ -233,13 +229,17 @@ class V8Debugger : public v8::debug::DebugDelegate,
std::unordered_map<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap;
void* m_taskWithScheduledBreak = nullptr;
String16 m_taskWithScheduledBreakDebuggerId;
bool m_breakRequested = false;
// If any of the following three is true, we schedule pause on next JS
// execution using SetBreakOnNextFunctionCall.
bool m_externalAsyncTaskPauseRequested = false; // External async task.
bool m_taskWithScheduledBreakPauseRequested = false; // Local async task.
bool m_pauseOnNextCallRequested = false; // setPauseOnNextCall API call.
v8::debug::ExceptionBreakState m_pauseOnExceptionsState;
// Whether we should pause on async call execution (if any) while stepping in.
// See Debugger.stepInto for details.
bool m_pauseOnAsyncCall = false;
v8_inspector::V8StackTraceId m_scheduledAsyncCall;
using StackTraceIdToStackTrace =
std::unordered_map<uintptr_t, std::weak_ptr<AsyncStackTrace>>;
......
......@@ -28,13 +28,6 @@ paused at:
#Promise.resolve().then(v => v * 2);
}
paused at:
debugger;
Promise.resolve().#then(v => v * 2);
}
asyncCallStackTraceId is set
paused at:
debugger;
Promise.resolve().then(v => v #* 2);
......@@ -52,13 +45,6 @@ paused at:
p.#then(v => v * 2);
resolveCallback();
paused at:
debugger;
p.#then(v => v * 2);
resolveCallback();
asyncCallStackTraceId is set
paused at:
debugger;
p.then(v => v #* 2);
......@@ -76,13 +62,6 @@ paused at:
#Promise.resolve().then(v => v * 2);
Promise.resolve().then(v => v * 4);
paused at:
debugger;
Promise.resolve().#then(v => v * 2);
Promise.resolve().then(v => v * 4);
asyncCallStackTraceId is set
paused at:
debugger;
Promise.resolve().then(v => v #* 2);
......@@ -105,13 +84,6 @@ paused at:
#Promise.resolve().then(v => v * 4);
}
paused at:
Promise.resolve().then(v => v * 2);
Promise.resolve().#then(v => v * 4);
}
asyncCallStackTraceId is set
paused at:
Promise.resolve().then(v => v * 2);
Promise.resolve().then(v => v #* 4);
......@@ -129,13 +101,6 @@ paused at:
#Promise.resolve().then(v => v * 2);
debugger;
paused at:
debugger;
Promise.resolve().#then(v => v * 2);
debugger;
asyncCallStackTraceId is set
paused at:
Promise.resolve().then(v => v * 2);
#debugger;
......@@ -146,13 +111,6 @@ paused at:
#Promise.resolve().then(v => v * 4);
}
paused at:
debugger;
Promise.resolve().#then(v => v * 4);
}
asyncCallStackTraceId is set
paused at:
debugger;
Promise.resolve().then(v => v #* 4);
......@@ -170,13 +128,6 @@ paused at:
#Promise.all([ Promise.resolve(), Promise.resolve() ]).then(v => v * 2);
}
paused at:
debugger;
Promise.all([ Promise.resolve(), Promise.resolve() ]).#then(v => v * 2);
}
asyncCallStackTraceId is set
paused at:
debugger;
Promise.all([ Promise.resolve(), Promise.resolve() ]).then(v => v #* 2);
......@@ -194,13 +145,6 @@ paused at:
#createPromise().then(v => v * 2);
}
paused at:
debugger;
createPromise().#then(v => v * 2);
}
asyncCallStackTraceId is set
paused at:
debugger;
createPromise().then(v => v #* 2);
......@@ -218,13 +162,6 @@ paused at:
#createPromise().then(v => v * 2);
}
paused at:
debugger;
createPromise().#then(v => v * 2);
}
asyncCallStackTraceId is set
paused at:
debugger;
createPromise().then(v => v #* 2);
......@@ -272,13 +209,6 @@ paused at:
foo().#then(boo);
paused at:
await foo();
foo().#then(boo);
asyncCallStackTraceId is set
paused at:
function boo() {
#}
......
......@@ -12,9 +12,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -26,9 +23,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
await Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
......@@ -43,9 +37,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
await InspectorTest.waitForPendingTasks();
......@@ -57,9 +48,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -69,20 +57,14 @@ InspectorTest.runAsyncTestSuite([
Protocol.Runtime.evaluate({expression: 'setTimeout(() => 42, 0)'});
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
}
]);
async function waitPauseAndDumpLocation() {
var {params: {callFrames, asyncCallStackTraceId}} =
var {params: {callFrames}} =
await Protocol.Debugger.oncePaused();
if (!asyncCallStackTraceId) {
InspectorTest.log('paused at:');
await session.logSourceLocation(callFrames[0].location);
}
return asyncCallStackTraceId;
InspectorTest.log('paused at:');
await session.logSourceLocation(callFrames[0].location);
}
......@@ -90,9 +90,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -103,9 +100,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -116,9 +110,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepInto();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -131,9 +122,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -144,16 +132,10 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -164,9 +146,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -178,9 +157,6 @@ InspectorTest.runAsyncTestSuite([
await waitPauseAndDumpLocation();
await Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js'] });
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -192,9 +168,6 @@ InspectorTest.runAsyncTestSuite([
await waitPauseAndDumpLocation();
await Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']});
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
},
......@@ -205,17 +178,11 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOver();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let parentStackTraceId = await waitPauseAndDumpLocation();
if (parentStackTraceId)
InspectorTest.log(
'ERROR: we should not report parent stack trace id on async call');
await waitPauseAndDumpLocation();
Protocol.Debugger.stepOut();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
parentStackTraceId = await waitPauseAndDumpLocation();
if (parentStackTraceId)
InspectorTest.log(
'ERROR: we should not report parent stack trace id on async call');
await waitPauseAndDumpLocation();
Protocol.Debugger.stepOut();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
......@@ -223,9 +190,6 @@ InspectorTest.runAsyncTestSuite([
Protocol.Debugger.stepOut();
await waitPauseAndDumpLocation();
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
parentStackTraceId = await waitPauseAndDumpLocation();
Protocol.Debugger.pauseOnAsyncCall({parentStackTraceId});
Protocol.Debugger.resume();
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume();
......@@ -233,12 +197,8 @@ InspectorTest.runAsyncTestSuite([
]);
async function waitPauseAndDumpLocation() {
var {params: {callFrames, asyncCallStackTraceId}} =
var {params: {callFrames}} =
await Protocol.Debugger.oncePaused();
InspectorTest.log('paused at:');
await session.logSourceLocation(callFrames[0].location);
if (asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is set\n');
}
return asyncCallStackTraceId;
}
Test for Debugger.stepInto with breakOnAsyncCall.
Running test: testSetTimeout
(anonymous) (test.js:0:0)
asyncCallStackTraceId is set
(anonymous) (test.js:0:17)
asyncCallStackTraceId is empty
Running test: testPromiseThen
(anonymous) (test.js:0:2)
asyncCallStackTraceId is set
(anonymous) (test.js:0:13)
asyncCallStackTraceId is empty
......@@ -17,21 +17,8 @@ InspectorTest.runAsyncTestSuite([
});
await pausedPromise;
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let {params: {callFrames, asyncCallStackTraceId}} =
await Protocol.Debugger.oncePaused();
let {params: {callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
if (asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is set');
}
Protocol.Debugger.pauseOnAsyncCall(
{parentStackTraceId: asyncCallStackTraceId});
pausedPromise = Protocol.Debugger.oncePaused();
Protocol.Debugger.resume();
({params: {callFrames, asyncCallStackTraceId}} = await pausedPromise);
session.logCallFrames(callFrames);
if (!asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is empty');
}
await Protocol.Debugger.disable();
},
......@@ -45,21 +32,8 @@ InspectorTest.runAsyncTestSuite([
Protocol.Runtime.evaluate({expression: 'p.then(() => 42)//# sourceURL=test.js'});
await pausedPromise;
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let {params: {callFrames, asyncCallStackTraceId}} =
await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
if (asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is set');
}
Protocol.Debugger.pauseOnAsyncCall(
{parentStackTraceId: asyncCallStackTraceId});
pausedPromise = Protocol.Debugger.oncePaused();
Protocol.Debugger.resume();
({params: {callFrames, asyncCallStackTraceId}} = await pausedPromise);
let {params: {callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
if (!asyncCallStackTraceId) {
InspectorTest.log('asyncCallStackTraceId is empty');
}
await Protocol.Debugger.disable();
}
]);
......@@ -2,7 +2,6 @@ Test for step-into remote async task
Setup debugger agents..
Pause before stack trace is captured..
Run stepInto with breakOnAsyncCall flag
Call pauseOnAsyncCall
Trigger external async task on another context group
Dump stack trace
boo (target.js:1:22)
......
......@@ -2,7 +2,6 @@ Test for step-into remote async task.
Setup debugger agents..
Pause before stack trace is captured..
Run stepInto with breakOnAsyncCall flag
Call pauseOnAsyncCall
Trigger external async task on another context group
Dump stack trace
boo (target.js:1:22)
......
......@@ -42,13 +42,6 @@ session.setupScriptMap();
InspectorTest.log('Run stepInto with breakOnAsyncCall flag');
Protocol.Debugger.stepInto({breakOnAsyncCall: true});
let {params: {asyncCallStackTraceId}} = await Protocol.Debugger.oncePaused();
InspectorTest.log('Call pauseOnAsyncCall');
Protocol.Debugger.pauseOnAsyncCall({
parentStackTraceId: asyncCallStackTraceId,
});
Protocol.Debugger.resume();
InspectorTest.log('Trigger external async task on another context group');
let stackTraceId = (await evaluatePromise).result.result.value;
......
......@@ -62,13 +62,6 @@ session2.setupScriptMap();
InspectorTest.log('Run stepInto with breakOnAsyncCall flag');
Protocol1.Debugger.stepInto({breakOnAsyncCall: true});
let {params: {asyncCallStackTraceId}} = await Protocol1.Debugger.oncePaused();
InspectorTest.log('Call pauseOnAsyncCall');
Protocol2.Debugger.pauseOnAsyncCall({
parentStackTraceId: asyncCallStackTraceId,
});
Protocol1.Debugger.resume();
InspectorTest.log('Trigger external async task on another context group');
let stackTraceId = (await evaluatePromise).result.result.value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment