Index: src/inspector/v8-debugger.cc |
diff --git a/src/inspector/v8-debugger.cc b/src/inspector/v8-debugger.cc |
index 3a2fc89f0039869b49a3c5cef4f4b92eab0017a6..85129338e6acccea4e99cca931082a4ccd84403a 100644 |
--- a/src/inspector/v8-debugger.cc |
+++ b/src/inspector/v8-debugger.cc |
@@ -190,7 +190,6 @@ void V8Debugger::enable() { |
void V8Debugger::disable() { |
if (--m_enableCount) return; |
DCHECK(enabled()); |
- clearBreakpoints(); |
m_debuggerScript.Reset(); |
m_debuggerContext.Reset(); |
allAsyncTasksCanceled(); |
@@ -220,91 +219,6 @@ void V8Debugger::getCompiledScripts( |
} |
} |
-String16 V8Debugger::setBreakpoint(const ScriptBreakpoint& breakpoint, |
- int* actualLineNumber, |
- int* actualColumnNumber) { |
- v8::HandleScope scope(m_isolate); |
- v8::Local<v8::Context> context = debuggerContext(); |
- v8::Context::Scope contextScope(context); |
- |
- v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
- bool success = false; |
- success = info->Set(context, toV8StringInternalized(m_isolate, "sourceID"), |
- toV8String(m_isolate, breakpoint.script_id)) |
- .FromMaybe(false); |
- DCHECK(success); |
- success = info->Set(context, toV8StringInternalized(m_isolate, "lineNumber"), |
- v8::Integer::New(m_isolate, breakpoint.line_number)) |
- .FromMaybe(false); |
- DCHECK(success); |
- success = |
- info->Set(context, toV8StringInternalized(m_isolate, "columnNumber"), |
- v8::Integer::New(m_isolate, breakpoint.column_number)) |
- .FromMaybe(false); |
- DCHECK(success); |
- success = info->Set(context, toV8StringInternalized(m_isolate, "condition"), |
- toV8String(m_isolate, breakpoint.condition)) |
- .FromMaybe(false); |
- DCHECK(success); |
- USE(success); |
- |
- v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast( |
- m_debuggerScript.Get(m_isolate) |
- ->Get(context, toV8StringInternalized(m_isolate, "setBreakpoint")) |
- .ToLocalChecked()); |
- v8::Local<v8::Value> breakpointId = |
- v8::debug::Call(debuggerContext(), setBreakpointFunction, info) |
- .ToLocalChecked(); |
- if (!breakpointId->IsString()) return ""; |
- *actualLineNumber = |
- info->Get(context, toV8StringInternalized(m_isolate, "lineNumber")) |
- .ToLocalChecked() |
- ->Int32Value(context) |
- .FromJust(); |
- *actualColumnNumber = |
- info->Get(context, toV8StringInternalized(m_isolate, "columnNumber")) |
- .ToLocalChecked() |
- ->Int32Value(context) |
- .FromJust(); |
- return toProtocolString(breakpointId.As<v8::String>()); |
-} |
- |
-void V8Debugger::removeBreakpoint(const String16& breakpointId) { |
- v8::HandleScope scope(m_isolate); |
- v8::Local<v8::Context> context = debuggerContext(); |
- v8::Context::Scope contextScope(context); |
- |
- v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
- bool success = false; |
- success = |
- info->Set(context, toV8StringInternalized(m_isolate, "breakpointId"), |
- toV8String(m_isolate, breakpointId)) |
- .FromMaybe(false); |
- DCHECK(success); |
- USE(success); |
- |
- v8::Local<v8::Function> removeBreakpointFunction = |
- v8::Local<v8::Function>::Cast( |
- m_debuggerScript.Get(m_isolate) |
- ->Get(context, |
- toV8StringInternalized(m_isolate, "removeBreakpoint")) |
- .ToLocalChecked()); |
- v8::debug::Call(debuggerContext(), removeBreakpointFunction, info) |
- .ToLocalChecked(); |
-} |
- |
-void V8Debugger::clearBreakpoints() { |
- v8::HandleScope scope(m_isolate); |
- v8::Local<v8::Context> context = debuggerContext(); |
- v8::Context::Scope contextScope(context); |
- |
- v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast( |
- m_debuggerScript.Get(m_isolate) |
- ->Get(context, toV8StringInternalized(m_isolate, "clearBreakpoints")) |
- .ToLocalChecked()); |
- v8::debug::Call(debuggerContext(), clearBreakpoints).ToLocalChecked(); |
-} |
- |
void V8Debugger::setBreakpointsActivated(bool activated) { |
if (!enabled()) { |
UNREACHABLE(); |
@@ -517,17 +431,18 @@ void V8Debugger::breakProgramCallback( |
v8::Local<v8::Context> pausedContext = |
thisPtr->m_isolate->GetCurrentContext(); |
v8::Local<v8::Value> exception; |
- v8::Local<v8::Array> hitBreakpoints; |
+ v8::PersistentValueVector<v8::debug::BreakPoint> hitBreakpoints( |
+ thisPtr->m_isolate); |
thisPtr->handleProgramBreak(pausedContext, |
v8::Local<v8::Object>::Cast(info[0]), exception, |
hitBreakpoints); |
} |
-void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, |
- v8::Local<v8::Object> executionState, |
- v8::Local<v8::Value> exception, |
- v8::Local<v8::Array> hitBreakpointNumbers, |
- bool isPromiseRejection, bool isUncaught) { |
+void V8Debugger::handleProgramBreak( |
+ v8::Local<v8::Context> pausedContext, v8::Local<v8::Object> executionState, |
+ v8::Local<v8::Value> exception, |
+ const v8::PersistentValueVector<v8::debug::BreakPoint>& hitBreakPoints, |
+ bool isPromiseRejection, bool isUncaught) { |
// Don't allow nested breaks. |
if (isPaused()) return; |
@@ -535,23 +450,11 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, |
m_inspector->contextGroupId(pausedContext)); |
if (!agent || (agent->skipAllPauses() && !m_scheduledOOMBreak)) return; |
- std::vector<String16> breakpointIds; |
- if (!hitBreakpointNumbers.IsEmpty()) { |
- breakpointIds.reserve(hitBreakpointNumbers->Length()); |
- for (uint32_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
- v8::Local<v8::Value> hitBreakpointNumber = |
- hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked(); |
- DCHECK(hitBreakpointNumber->IsInt32()); |
- breakpointIds.push_back(String16::fromInteger( |
- hitBreakpointNumber->Int32Value(debuggerContext()).FromJust())); |
- } |
- } |
- |
m_pausedContext = pausedContext; |
m_executionState = executionState; |
m_runningNestedMessageLoop = true; |
agent->didPause(InspectedContext::contextId(pausedContext), exception, |
- breakpointIds, isPromiseRejection, isUncaught, |
+ hitBreakPoints, isPromiseRejection, isUncaught, |
m_scheduledOOMBreak); |
int groupId = m_inspector->contextGroupId(pausedContext); |
DCHECK(groupId); |
@@ -595,15 +498,25 @@ void V8Debugger::ScriptCompiled(v8::Local<v8::debug::Script> script, |
void V8Debugger::BreakProgramRequested(v8::Local<v8::Context> pausedContext, |
v8::Local<v8::Object> execState, |
v8::Local<v8::Value> breakPointsHit) { |
- v8::Local<v8::Value> argv[] = {breakPointsHit}; |
- v8::Local<v8::Value> hitBreakpoints; |
- if (!callDebuggerMethod("getBreakpointNumbers", 1, argv, true) |
- .ToLocal(&hitBreakpoints)) { |
+ v8::PersistentValueVector<v8::debug::BreakPoint> breakPoints(m_isolate); |
+ if (!breakPointsHit->IsArray()) { |
+ handleProgramBreak(pausedContext, execState, v8::Local<v8::Value>(), |
+ breakPoints); |
return; |
} |
- DCHECK(hitBreakpoints->IsArray()); |
+ v8::Local<v8::Array> breakPointsHitArray = |
+ v8::Local<v8::Array>::Cast(breakPointsHit); |
+ for (uint32_t i = 0; i < breakPointsHitArray->Length(); ++i) { |
+ v8::Local<v8::Value> item; |
+ if (!breakPointsHitArray->Get(pausedContext, i).ToLocal(&item)) continue; |
+ v8::Local<v8::debug::BreakPoint> breakPoint; |
+ if (!v8::debug::BreakPoint::Cast(m_isolate, item).ToLocal(&breakPoint)) { |
+ continue; |
+ } |
+ breakPoints.Append(breakPoint); |
+ } |
handleProgramBreak(pausedContext, execState, v8::Local<v8::Value>(), |
- hitBreakpoints.As<v8::Array>()); |
+ breakPoints); |
} |
void V8Debugger::ExceptionThrown(v8::Local<v8::Context> pausedContext, |
@@ -612,8 +525,9 @@ void V8Debugger::ExceptionThrown(v8::Local<v8::Context> pausedContext, |
v8::Local<v8::Value> promise, |
bool isUncaught) { |
bool isPromiseRejection = promise->IsPromise(); |
- handleProgramBreak(pausedContext, execState, exception, |
- v8::Local<v8::Array>(), isPromiseRejection, isUncaught); |
+ v8::PersistentValueVector<v8::debug::BreakPoint> hitBreakpoints(m_isolate); |
+ handleProgramBreak(pausedContext, execState, exception, hitBreakpoints, |
+ isPromiseRejection, isUncaught); |
} |
bool V8Debugger::IsFunctionBlackboxed(v8::Local<v8::debug::Script> script, |