Index: src/inspector/v8-debugger-agent-impl.cc |
diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc |
index 8af7d5243418c7e559b1b5ce5d7fa2087d9a1217..7064ae95ee8b526833244781f3018efce3a8ac46 100644 |
--- a/src/inspector/v8-debugger-agent-impl.cc |
+++ b/src/inspector/v8-debugger-agent-impl.cc |
@@ -247,7 +247,7 @@ Response V8DebuggerAgentImpl::disable() { |
m_scripts.clear(); |
m_breakpointIdToDebuggerBreakpointIds.clear(); |
m_debugger->setAsyncCallStackDepth(this, 0); |
- m_continueToLocationBreakpointId = String16(); |
+ clearContinueToLocation(); |
clearBreakDetails(); |
m_skipAllPauses = false; |
m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); |
@@ -484,12 +484,11 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints( |
} |
Response V8DebuggerAgentImpl::continueToLocation( |
- std::unique_ptr<protocol::Debugger::Location> location) { |
+ std::unique_ptr<protocol::Debugger::Location> location, |
+ Maybe<String16> strategy) { |
if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
- if (!m_continueToLocationBreakpointId.isEmpty()) { |
- m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
- m_continueToLocationBreakpointId = ""; |
- } |
+ if (!isPaused()) return Response::Error(kDebuggerNotPaused); |
+ clearContinueToLocation(); |
ScriptBreakpoint breakpoint(location->getScriptId(), |
location->getLineNumber(), |
@@ -497,10 +496,31 @@ Response V8DebuggerAgentImpl::continueToLocation( |
m_continueToLocationBreakpointId = m_debugger->setBreakpoint( |
breakpoint, &breakpoint.line_number, &breakpoint.column_number); |
+ if (m_continueToLocationBreakpointId.isEmpty()) { |
+ return Response::Error("Location can't be resolved"); |
+ } |
+ m_continueToLocationStrategy = strategy.fromMaybe( |
+ protocol::Debugger::ContinueToLocation::StrategyEnum::Default); |
+ if (m_continueToLocationStrategy != |
+ protocol::Debugger::ContinueToLocation::StrategyEnum::Default) { |
+ m_continueToLocationStack = m_debugger->captureStackTrace(true); |
+ if (m_continueToLocationStack) { |
+ m_continueToLocationStrategy = |
+ protocol::Debugger::ContinueToLocation::StrategyEnum::Default; |
+ } |
+ } |
// TODO(kozyatinskiy): Return actual line and column number. |
return resume(); |
} |
+void V8DebuggerAgentImpl::clearContinueToLocation() { |
+ if (m_continueToLocationBreakpointId.isEmpty()) return; |
+ m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
+ m_continueToLocationBreakpointId = String16(); |
+ m_continueToLocationStrategy = String16(); |
+ m_continueToLocationStack.reset(); |
+} |
+ |
bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId, |
const v8::debug::Location& start, |
const v8::debug::Location& end) { |
@@ -1144,6 +1164,23 @@ void V8DebuggerAgentImpl::didParseSource( |
} |
} |
+bool V8DebuggerAgentImpl::shouldIgnoreContinueToLocation( |
+ const String16& breakpointId) { |
+ if (breakpointId != m_continueToLocationBreakpointId) return false; |
+ if (m_continueToLocationStrategy == |
+ protocol::Debugger::ContinueToLocation::StrategyEnum::Default) { |
+ return false; |
+ } |
+ std::unique_ptr<V8StackTraceImpl> currentStack = |
+ m_debugger->captureStackTrace(true); |
+ if (m_continueToLocationStrategy == |
+ protocol::Debugger::ContinueToLocation::StrategyEnum::InCurrentFrame) { |
+ return !m_continueToLocationStack->isEqualIgnoringTopFrame( |
+ currentStack.get()); |
+ } |
+ return false; |
+} |
+ |
void V8DebuggerAgentImpl::didPause(int contextId, |
v8::Local<v8::Value> exception, |
const std::vector<String16>& hitBreakpoints, |
@@ -1234,10 +1271,7 @@ void V8DebuggerAgentImpl::didPause(int contextId, |
std::move(breakAuxData), std::move(hitBreakpointIds), |
currentAsyncStackTrace()); |
- if (!m_continueToLocationBreakpointId.isEmpty()) { |
- m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
- m_continueToLocationBreakpointId = ""; |
- } |
+ clearContinueToLocation(); |
} |
void V8DebuggerAgentImpl::didContinue() { |