Index: src/inspector/v8-debugger.cc |
diff --git a/src/inspector/v8-debugger.cc b/src/inspector/v8-debugger.cc |
index f4980e2f87e1de3d4916b2c526dd7c2c0d107b3b..d044b8540ac24f3c49f76eb520dfbfcfa633bfa1 100644 |
--- a/src/inspector/v8-debugger.cc |
+++ b/src/inspector/v8-debugger.cc |
@@ -298,6 +298,18 @@ void V8Debugger::stepIntoStatement() { |
continueProgram(); |
} |
+Response V8Debugger::stepIntoAsync() { |
+ DCHECK(isPaused()); |
+ DCHECK(!m_executionState.IsEmpty()); |
+ if (!m_currentCreatedAsyncTask) { |
+ return Response::Error("No scheduled chained callback"); |
+ } |
+ m_asyncTasksWithScheduledBreak.insert(m_currentCreatedAsyncTask); |
+ v8::debug::ClearStepping(m_isolate); |
+ continueProgram(); |
+ return Response::OK(); |
+} |
+ |
void V8Debugger::stepOverStatement() { |
DCHECK(isPaused()); |
DCHECK(!m_executionState.IsEmpty()); |
@@ -837,11 +849,7 @@ bool V8Debugger::isPaused() { return !m_pausedContext.IsEmpty(); } |
std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace( |
v8::Local<v8::StackTrace> stackTrace) { |
- int contextGroupId = |
- m_isolate->InContext() |
- ? m_inspector->contextGroupId(m_isolate->GetCurrentContext()) |
- : 0; |
- return V8StackTraceImpl::create(this, contextGroupId, stackTrace, |
+ return V8StackTraceImpl::create(this, currentContextGroupId(), stackTrace, |
V8StackTraceImpl::maxCallStackSizeToCapture); |
} |
@@ -888,6 +896,13 @@ void V8Debugger::asyncTaskCreated(void* task, void* parentTask) { |
m_asyncTaskCreationStacks[task] = std::move(creationStack); |
registerAsyncTaskIfNeeded(task); |
} |
+ if (!parentTask) return; |
+ V8DebuggerAgentImpl* agent = |
+ m_inspector->enabledDebuggerAgentForGroup(currentContextGroupId()); |
+ if (!agent) return; |
+ m_currentCreatedAsyncTask = task; |
+ agent->asyncTaskCreated(); |
+ m_currentCreatedAsyncTask = nullptr; |
} |
void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task, |
@@ -900,13 +915,9 @@ void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, |
bool recurring) { |
if (!m_maxAsyncCallStackDepth) return; |
v8::HandleScope scope(m_isolate); |
- int contextGroupId = |
- m_isolate->InContext() |
- ? m_inspector->contextGroupId(m_isolate->GetCurrentContext()) |
- : 0; |
std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture( |
- this, contextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, |
- taskName); |
+ this, currentContextGroupId(), |
+ V8StackTraceImpl::maxCallStackSizeToCapture, taskName); |
if (chain) { |
m_asyncTaskStacks[task] = std::move(chain); |
if (recurring) m_recurringTasks.insert(task); |
@@ -920,6 +931,8 @@ void V8Debugger::asyncTaskCanceled(void* task) { |
m_recurringTasks.erase(task); |
m_parentTask.erase(task); |
m_asyncTaskCreationStacks.erase(task); |
+ if (m_currentCreatedAsyncTask == task) m_currentCreatedAsyncTask = nullptr; |
+ m_asyncTasksWithScheduledBreak.erase(task); |
auto it = m_taskToId.find(task); |
if (it == m_taskToId.end()) return; |
m_idToTask.erase(it->second); |
@@ -947,6 +960,13 @@ void V8Debugger::asyncTaskStarted(void* task) { |
stack->setCreation(itCreation->second->cloneImpl()); |
} |
m_currentStacks.push_back(std::move(stack)); |
+ if (m_asyncTasksWithScheduledBreak.find(task) == |
+ m_asyncTasksWithScheduledBreak.end()) |
+ return; |
+ V8DebuggerAgentImpl* agent = |
+ m_inspector->enabledDebuggerAgentForGroup(currentContextGroupId()); |
+ if (!agent) return; |
+ agent->asyncTaskStarted(); |
} |
void V8Debugger::asyncTaskFinished(void* task) { |
@@ -958,6 +978,15 @@ void V8Debugger::asyncTaskFinished(void* task) { |
m_currentTasks.pop_back(); |
m_currentStacks.pop_back(); |
+ if (m_asyncTasksWithScheduledBreak.find(task) != |
+ m_asyncTasksWithScheduledBreak.end()) { |
+ V8DebuggerAgentImpl* agent = |
+ m_inspector->enabledDebuggerAgentForGroup(currentContextGroupId()); |
+ if (!agent) return; |
+ agent->asyncTaskFinished(); |
+ m_asyncTasksWithScheduledBreak.erase(task); |
+ } |
+ |
if (m_recurringTasks.find(task) == m_recurringTasks.end()) { |
asyncTaskCanceled(task); |
} |
@@ -970,6 +999,8 @@ void V8Debugger::allAsyncTasksCanceled() { |
m_currentTasks.clear(); |
m_parentTask.clear(); |
m_asyncTaskCreationStacks.clear(); |
+ m_currentCreatedAsyncTask = nullptr; |
+ m_asyncTasksWithScheduledBreak.clear(); |
m_idToTask.clear(); |
m_taskToId.clear(); |
m_lastTaskId = 0; |
@@ -986,13 +1017,10 @@ void V8Debugger::unmuteScriptParsedEvents() { |
std::unique_ptr<V8StackTraceImpl> V8Debugger::captureStackTrace( |
bool fullStack) { |
- if (!m_isolate->InContext()) return nullptr; |
- |
- v8::HandleScope handles(m_isolate); |
- int contextGroupId = |
- m_inspector->contextGroupId(m_isolate->GetCurrentContext()); |
+ int contextGroupId = currentContextGroupId(); |
if (!contextGroupId) return nullptr; |
+ v8::HandleScope handles(m_isolate); |
size_t stackSize = |
fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
@@ -1001,4 +1029,9 @@ std::unique_ptr<V8StackTraceImpl> V8Debugger::captureStackTrace( |
return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
} |
+int V8Debugger::currentContextGroupId() { |
+ if (!m_isolate->InContext()) return 0; |
+ return m_inspector->contextGroupId(m_isolate->GetCurrentContext()); |
+} |
+ |
} // namespace v8_inspector |