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() {
m_scripts.clear();
m_breakpointIdToDebuggerBreakpointIds.clear();
m_debugger->setAsyncCallStackDepth(this, 0);
m_continueToLocationBreakpointId = String16();
clearBreakDetails();
m_skipAllPauses = false;
m_state->setBoolean(DebuggerAgentState::skipAllPauses, false);
......@@ -486,19 +485,9 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints(
Response V8DebuggerAgentImpl::continueToLocation(
std::unique_ptr<protocol::Debugger::Location> location) {
if (!enabled()) return Response::Error(kDebuggerNotEnabled);
if (!m_continueToLocationBreakpointId.isEmpty()) {
m_debugger->removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
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();
if (!isPaused()) return Response::Error(kDebuggerNotPaused);
return m_debugger->continueToLocation(m_session->contextGroupId(),
std::move(location));
}
bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId,
......@@ -1233,11 +1222,6 @@ void V8DebuggerAgentImpl::didPause(int contextId,
m_frontend.paused(std::move(protocolCallFrames), breakReason,
std::move(breakAuxData), std::move(hitBreakpointIds),
currentAsyncStackTrace());
if (!m_continueToLocationBreakpointId.isEmpty()) {
m_debugger->removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
}
void V8DebuggerAgentImpl::didContinue() {
......
......@@ -184,7 +184,6 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
ScriptsMap m_scripts;
BreakpointIdToDebuggerBreakpointIdsMap m_breakpointIdToDebuggerBreakpointIds;
DebugServerBreakpointToBreakpointIdAndSourceMap m_serverBreakpoints;
String16 m_continueToLocationBreakpointId;
using BreakReason =
std::pair<String16, std::unique_ptr<protocol::DictionaryValue>>;
......
......@@ -194,6 +194,7 @@ void V8Debugger::disable() {
if (--m_enableCount) return;
DCHECK(enabled());
clearBreakpoints();
clearContinueToLocation();
m_debuggerScript.Reset();
m_debuggerContext.Reset();
allAsyncTasksCanceled();
......@@ -411,6 +412,36 @@ void V8Debugger::scheduleStepIntoAsync(
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(
const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun,
Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails,
......@@ -567,6 +598,7 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
hitBreakpointNumber->Int32Value(debuggerContext()).FromJust()));
}
}
clearContinueToLocation();
m_pausedContext = pausedContext;
m_executionState = executionState;
......
......@@ -61,6 +61,9 @@ class V8Debugger : public v8::debug::DebugDelegate {
std::unique_ptr<ScheduleStepIntoAsyncCallback> callback,
int targetContextGroupId);
Response continueToLocation(int targetContextGroupId,
std::unique_ptr<protocol::Debugger::Location>);
Response setScriptSource(
const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun,
protocol::Maybe<protocol::Runtime::ExceptionDetails>*,
......@@ -119,6 +122,7 @@ class V8Debugger : public v8::debug::DebugDelegate {
bool catchExceptions);
v8::Local<v8::Context> debuggerContext() const;
void clearBreakpoints();
void clearContinueToLocation();
static void v8OOMCallback(void* data);
......@@ -184,6 +188,7 @@ class V8Debugger : public v8::debug::DebugDelegate {
bool m_scheduledOOMBreak = false;
int m_targetContextGroupId = 0;
int m_pausedContextGroupId = 0;
String16 m_continueToLocationBreakpointId;
using AsyncTaskToStackTrace =
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