Commit 4d67e356 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] move continueToLocation implementation to debugger

So continue to location can be called only for one context group id at the same time.

BUG=v8:6397

Review-Url: https://codereview.chromium.org/2882213004
Cr-Commit-Position: refs/heads/master@{#45349}
parent b0560730
...@@ -247,7 +247,6 @@ Response V8DebuggerAgentImpl::disable() { ...@@ -247,7 +247,6 @@ Response V8DebuggerAgentImpl::disable() {
m_scripts.clear(); m_scripts.clear();
m_breakpointIdToDebuggerBreakpointIds.clear(); m_breakpointIdToDebuggerBreakpointIds.clear();
m_debugger->setAsyncCallStackDepth(this, 0); m_debugger->setAsyncCallStackDepth(this, 0);
m_continueToLocationBreakpointId = String16();
clearBreakDetails(); clearBreakDetails();
m_skipAllPauses = false; m_skipAllPauses = false;
m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); m_state->setBoolean(DebuggerAgentState::skipAllPauses, false);
...@@ -486,19 +485,9 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints( ...@@ -486,19 +485,9 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints(
Response V8DebuggerAgentImpl::continueToLocation( Response V8DebuggerAgentImpl::continueToLocation(
std::unique_ptr<protocol::Debugger::Location> location) { std::unique_ptr<protocol::Debugger::Location> location) {
if (!enabled()) return Response::Error(kDebuggerNotEnabled); if (!enabled()) return Response::Error(kDebuggerNotEnabled);
if (!m_continueToLocationBreakpointId.isEmpty()) { if (!isPaused()) return Response::Error(kDebuggerNotPaused);
m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); return m_debugger->continueToLocation(m_session->contextGroupId(),
m_continueToLocationBreakpointId = ""; std::move(location));
}
ScriptBreakpoint breakpoint(location->getScriptId(),
location->getLineNumber(),
location->getColumnNumber(0), String16());
m_continueToLocationBreakpointId = m_debugger->setBreakpoint(
breakpoint, &breakpoint.line_number, &breakpoint.column_number);
// TODO(kozyatinskiy): Return actual line and column number.
return resume();
} }
bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId, bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId,
...@@ -1233,11 +1222,6 @@ void V8DebuggerAgentImpl::didPause(int contextId, ...@@ -1233,11 +1222,6 @@ void V8DebuggerAgentImpl::didPause(int contextId,
m_frontend.paused(std::move(protocolCallFrames), breakReason, m_frontend.paused(std::move(protocolCallFrames), breakReason,
std::move(breakAuxData), std::move(hitBreakpointIds), std::move(breakAuxData), std::move(hitBreakpointIds),
currentAsyncStackTrace()); currentAsyncStackTrace());
if (!m_continueToLocationBreakpointId.isEmpty()) {
m_debugger->removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
} }
void V8DebuggerAgentImpl::didContinue() { void V8DebuggerAgentImpl::didContinue() {
......
...@@ -184,7 +184,6 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { ...@@ -184,7 +184,6 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
ScriptsMap m_scripts; ScriptsMap m_scripts;
BreakpointIdToDebuggerBreakpointIdsMap m_breakpointIdToDebuggerBreakpointIds; BreakpointIdToDebuggerBreakpointIdsMap m_breakpointIdToDebuggerBreakpointIds;
DebugServerBreakpointToBreakpointIdAndSourceMap m_serverBreakpoints; DebugServerBreakpointToBreakpointIdAndSourceMap m_serverBreakpoints;
String16 m_continueToLocationBreakpointId;
using BreakReason = using BreakReason =
std::pair<String16, std::unique_ptr<protocol::DictionaryValue>>; std::pair<String16, std::unique_ptr<protocol::DictionaryValue>>;
......
...@@ -194,6 +194,7 @@ void V8Debugger::disable() { ...@@ -194,6 +194,7 @@ void V8Debugger::disable() {
if (--m_enableCount) return; if (--m_enableCount) return;
DCHECK(enabled()); DCHECK(enabled());
clearBreakpoints(); clearBreakpoints();
clearContinueToLocation();
m_debuggerScript.Reset(); m_debuggerScript.Reset();
m_debuggerContext.Reset(); m_debuggerContext.Reset();
allAsyncTasksCanceled(); allAsyncTasksCanceled();
...@@ -411,6 +412,36 @@ void V8Debugger::scheduleStepIntoAsync( ...@@ -411,6 +412,36 @@ void V8Debugger::scheduleStepIntoAsync(
m_stepIntoAsyncCallback = std::move(callback); m_stepIntoAsyncCallback = std::move(callback);
} }
Response V8Debugger::continueToLocation(
int targetContextGroupId,
std::unique_ptr<protocol::Debugger::Location> location) {
DCHECK(isPaused());
DCHECK(!m_executionState.IsEmpty());
DCHECK(targetContextGroupId);
m_targetContextGroupId = targetContextGroupId;
ScriptBreakpoint breakpoint(location->getScriptId(),
location->getLineNumber(),
location->getColumnNumber(0), String16());
int lineNumber = 0;
int columnNumber = 0;
m_continueToLocationBreakpointId =
setBreakpoint(breakpoint, &lineNumber, &columnNumber);
if (!m_continueToLocationBreakpointId.isEmpty()) {
continueProgram(targetContextGroupId);
// TODO(kozyatinskiy): Return actual line and column number.
return Response::OK();
} else {
return Response::Error("Cannot continue to specified location");
}
}
void V8Debugger::clearContinueToLocation() {
if (m_continueToLocationBreakpointId.length()) {
removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = String16();
}
}
Response V8Debugger::setScriptSource( Response V8Debugger::setScriptSource(
const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun,
Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails,
...@@ -567,6 +598,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, ...@@ -567,6 +598,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); hitBreakpointNumber->Int32Value(debuggerContext()).FromJust()));
} }
} }
clearContinueToLocation();
m_pausedContext = pausedContext; m_pausedContext = pausedContext;
m_executionState = executionState; m_executionState = executionState;
......
...@@ -61,6 +61,9 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -61,6 +61,9 @@ class V8Debugger : public v8::debug::DebugDelegate {
std::unique_ptr<ScheduleStepIntoAsyncCallback> callback, std::unique_ptr<ScheduleStepIntoAsyncCallback> callback,
int targetContextGroupId); int targetContextGroupId);
Response continueToLocation(int targetContextGroupId,
std::unique_ptr<protocol::Debugger::Location>);
Response setScriptSource( Response setScriptSource(
const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun,
protocol::Maybe<protocol::Runtime::ExceptionDetails>*, protocol::Maybe<protocol::Runtime::ExceptionDetails>*,
...@@ -119,6 +122,7 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -119,6 +122,7 @@ class V8Debugger : public v8::debug::DebugDelegate {
bool catchExceptions); bool catchExceptions);
v8::Local<v8::Context> debuggerContext() const; v8::Local<v8::Context> debuggerContext() const;
void clearBreakpoints(); void clearBreakpoints();
void clearContinueToLocation();
static void v8OOMCallback(void* data); static void v8OOMCallback(void* data);
...@@ -184,6 +188,7 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -184,6 +188,7 @@ class V8Debugger : public v8::debug::DebugDelegate {
bool m_scheduledOOMBreak = false; bool m_scheduledOOMBreak = false;
int m_targetContextGroupId = 0; int m_targetContextGroupId = 0;
int m_pausedContextGroupId = 0; int m_pausedContextGroupId = 0;
String16 m_continueToLocationBreakpointId;
using AsyncTaskToStackTrace = using AsyncTaskToStackTrace =
protocol::HashMap<void*, std::weak_ptr<AsyncStackTrace>>; protocol::HashMap<void*, std::weak_ptr<AsyncStackTrace>>;
......
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