Commit f661fe84 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] V8DebuggerAgent should not resume break in different group

- introduced pausedContextGroupId,
- added targetContextGroupId param for V8Debugger::continueProgram method.

BUG=chromium:714955
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2842733002
Cr-Commit-Position: refs/heads/master@{#44871}
parent 6d9ca97c
...@@ -237,7 +237,7 @@ Response V8DebuggerAgentImpl::disable() { ...@@ -237,7 +237,7 @@ Response V8DebuggerAgentImpl::disable() {
v8::debug::NoBreakOnException); v8::debug::NoBreakOnException);
m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0);
if (isPaused()) m_debugger->continueProgram(); if (isPaused()) m_debugger->continueProgram(m_session->contextGroupId());
m_debugger->disable(); m_debugger->disable();
JavaScriptCallFrames emptyCallFrames; JavaScriptCallFrames emptyCallFrames;
m_pausedCallFrames.swap(emptyCallFrames); m_pausedCallFrames.swap(emptyCallFrames);
...@@ -715,7 +715,7 @@ Response V8DebuggerAgentImpl::pause() { ...@@ -715,7 +715,7 @@ Response V8DebuggerAgentImpl::pause() {
Response V8DebuggerAgentImpl::resume() { Response V8DebuggerAgentImpl::resume() {
if (!isPaused()) return Response::Error(kDebuggerNotPaused); if (!isPaused()) return Response::Error(kDebuggerNotPaused);
m_session->releaseObjectGroup(kBacktraceObjectGroup); m_session->releaseObjectGroup(kBacktraceObjectGroup);
m_debugger->continueProgram(); m_debugger->continueProgram(m_session->contextGroupId());
return Response::OK(); return Response::OK();
} }
......
...@@ -172,7 +172,6 @@ V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) ...@@ -172,7 +172,6 @@ V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector)
m_inspector(inspector), m_inspector(inspector),
m_enableCount(0), m_enableCount(0),
m_breakpointsActivated(true), m_breakpointsActivated(true),
m_runningNestedMessageLoop(false),
m_ignoreScriptParsedEventsCounter(0), m_ignoreScriptParsedEventsCounter(0),
m_maxAsyncCallStacks(kMaxAsyncTaskStacks), m_maxAsyncCallStacks(kMaxAsyncTaskStacks),
m_maxAsyncCallStackDepth(0), m_maxAsyncCallStackDepth(0),
...@@ -362,7 +361,8 @@ void V8Debugger::breakProgram() { ...@@ -362,7 +361,8 @@ void V8Debugger::breakProgram() {
v8::debug::BreakRightNow(m_isolate); v8::debug::BreakRightNow(m_isolate);
} }
void V8Debugger::continueProgram() { void V8Debugger::continueProgram(int targetContextGroupId) {
if (m_pausedContextGroupId != targetContextGroupId) return;
if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); if (isPaused()) m_inspector->client()->quitMessageLoopOnPause();
m_pausedContext.Clear(); m_pausedContext.Clear();
m_executionState.Clear(); m_executionState.Clear();
...@@ -374,7 +374,7 @@ void V8Debugger::stepIntoStatement(int targetContextGroupId) { ...@@ -374,7 +374,7 @@ void V8Debugger::stepIntoStatement(int targetContextGroupId) {
DCHECK(targetContextGroupId); DCHECK(targetContextGroupId);
m_targetContextGroupId = targetContextGroupId; m_targetContextGroupId = targetContextGroupId;
v8::debug::PrepareStep(m_isolate, v8::debug::StepIn); v8::debug::PrepareStep(m_isolate, v8::debug::StepIn);
continueProgram(); continueProgram(targetContextGroupId);
} }
void V8Debugger::stepOverStatement(int targetContextGroupId) { void V8Debugger::stepOverStatement(int targetContextGroupId) {
...@@ -383,7 +383,7 @@ void V8Debugger::stepOverStatement(int targetContextGroupId) { ...@@ -383,7 +383,7 @@ void V8Debugger::stepOverStatement(int targetContextGroupId) {
DCHECK(targetContextGroupId); DCHECK(targetContextGroupId);
m_targetContextGroupId = targetContextGroupId; m_targetContextGroupId = targetContextGroupId;
v8::debug::PrepareStep(m_isolate, v8::debug::StepNext); v8::debug::PrepareStep(m_isolate, v8::debug::StepNext);
continueProgram(); continueProgram(targetContextGroupId);
} }
void V8Debugger::stepOutOfFunction(int targetContextGroupId) { void V8Debugger::stepOutOfFunction(int targetContextGroupId) {
...@@ -392,7 +392,7 @@ void V8Debugger::stepOutOfFunction(int targetContextGroupId) { ...@@ -392,7 +392,7 @@ void V8Debugger::stepOutOfFunction(int targetContextGroupId) {
DCHECK(targetContextGroupId); DCHECK(targetContextGroupId);
m_targetContextGroupId = targetContextGroupId; m_targetContextGroupId = targetContextGroupId;
v8::debug::PrepareStep(m_isolate, v8::debug::StepOut); v8::debug::PrepareStep(m_isolate, v8::debug::StepOut);
continueProgram(); continueProgram(targetContextGroupId);
} }
void V8Debugger::scheduleStepIntoAsync( void V8Debugger::scheduleStepIntoAsync(
...@@ -568,7 +568,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, ...@@ -568,7 +568,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
m_pausedContext = pausedContext; m_pausedContext = pausedContext;
m_executionState = executionState; m_executionState = executionState;
m_runningNestedMessageLoop = true; m_pausedContextGroupId = contextGroupId;
agent->didPause(InspectedContext::contextId(pausedContext), exception, agent->didPause(InspectedContext::contextId(pausedContext), exception,
breakpointIds, isPromiseRejection, isUncaught, breakpointIds, isPromiseRejection, isUncaught,
m_scheduledOOMBreak); m_scheduledOOMBreak);
...@@ -580,7 +580,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, ...@@ -580,7 +580,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
CHECK(!context.IsEmpty() && CHECK(!context.IsEmpty() &&
context != v8::debug::GetDebugContext(m_isolate)); context != v8::debug::GetDebugContext(m_isolate));
m_inspector->client()->runMessageLoopOnPause(groupId); m_inspector->client()->runMessageLoopOnPause(groupId);
m_runningNestedMessageLoop = false; m_pausedContextGroupId = 0;
} }
// The agent may have been removed in the nested loop. // The agent may have been removed in the nested loop.
agent = m_inspector->enabledDebuggerAgentForGroup(groupId); agent = m_inspector->enabledDebuggerAgentForGroup(groupId);
......
...@@ -51,7 +51,7 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -51,7 +51,7 @@ class V8Debugger : public v8::debug::DebugDelegate {
void setPauseOnExceptionsState(v8::debug::ExceptionBreakState); void setPauseOnExceptionsState(v8::debug::ExceptionBreakState);
bool canBreakProgram(); bool canBreakProgram();
void breakProgram(); void breakProgram();
void continueProgram(); void continueProgram(int targetContextGroupId);
void setPauseOnNextStatement(bool, int targetContextGroupId); void setPauseOnNextStatement(bool, int targetContextGroupId);
void stepIntoStatement(int targetContextGroupId); void stepIntoStatement(int targetContextGroupId);
...@@ -77,7 +77,7 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -77,7 +77,7 @@ class V8Debugger : public v8::debug::DebugDelegate {
void enable(); void enable();
void disable(); void disable();
bool isPaused() const { return m_runningNestedMessageLoop; } bool isPaused() const { return m_pausedContextGroupId; }
v8::Local<v8::Context> pausedContext() { return m_pausedContext; } v8::Local<v8::Context> pausedContext() { return m_pausedContext; }
int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; }
...@@ -180,10 +180,10 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -180,10 +180,10 @@ class V8Debugger : public v8::debug::DebugDelegate {
v8::Global<v8::Context> m_debuggerContext; v8::Global<v8::Context> m_debuggerContext;
v8::Local<v8::Object> m_executionState; v8::Local<v8::Object> m_executionState;
v8::Local<v8::Context> m_pausedContext; v8::Local<v8::Context> m_pausedContext;
bool m_runningNestedMessageLoop;
int m_ignoreScriptParsedEventsCounter; int m_ignoreScriptParsedEventsCounter;
bool m_scheduledOOMBreak = false; bool m_scheduledOOMBreak = false;
int m_targetContextGroupId = 0; int m_targetContextGroupId = 0;
int m_pausedContextGroupId = 0;
using AsyncTaskToStackTrace = using AsyncTaskToStackTrace =
protocol::HashMap<void*, std::weak_ptr<AsyncStackTrace>>; protocol::HashMap<void*, std::weak_ptr<AsyncStackTrace>>;
......
...@@ -19,6 +19,9 @@ Running test: testSkipOtherContext2 ...@@ -19,6 +19,9 @@ Running test: testSkipOtherContext2
paused at: paused at:
#var a = 239; #var a = 239;
paused at:
var a = #239;
Running test: testWithNativeBreakpoint Running test: testWithNativeBreakpoint
paused at: paused at:
......
...@@ -43,7 +43,11 @@ InspectorTest.runAsyncTestSuite([ ...@@ -43,7 +43,11 @@ InspectorTest.runAsyncTestSuite([
Protocol.Runtime.evaluate({expression: 'var a = 239;'}, contextGroupId); Protocol.Runtime.evaluate({expression: 'var a = 239;'}, contextGroupId);
Protocol.Runtime.evaluate({expression: 'var a = 1;'}); Protocol.Runtime.evaluate({expression: 'var a = 1;'});
await waitPauseAndDumpLocation(); await waitPauseAndDumpLocation();
await Protocol.Debugger.resume(); // should not resume pause from different context group id.
Protocol.Debugger.resume();
Protocol.Debugger.stepOver({}, contextGroupId);
await waitPauseAndDumpLocation();
await Protocol.Debugger.resume({}, contextGroupId);
await Protocol.Debugger.disable({}, contextGroupId); await Protocol.Debugger.disable({}, contextGroupId);
}, },
......
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