| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/v8_inspector/V8Debugger.h" | 5 #include "platform/v8_inspector/V8Debugger.h" |
| 6 | 6 |
| 7 #include "platform/v8_inspector/DebuggerScript.h" | 7 #include "platform/v8_inspector/DebuggerScript.h" |
| 8 #include "platform/v8_inspector/ScriptBreakpoint.h" | 8 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 9 #include "platform/v8_inspector/StringUtil.h" |
| 9 #include "platform/v8_inspector/V8Compat.h" | 10 #include "platform/v8_inspector/V8Compat.h" |
| 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 11 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 11 #include "platform/v8_inspector/V8InspectorImpl.h" | 12 #include "platform/v8_inspector/V8InspectorImpl.h" |
| 12 #include "platform/v8_inspector/V8InternalValueType.h" | 13 #include "platform/v8_inspector/V8InternalValueType.h" |
| 13 #include "platform/v8_inspector/V8StackTraceImpl.h" | 14 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 14 #include "platform/v8_inspector/V8StringUtil.h" | |
| 15 #include "platform/v8_inspector/V8ValueCopier.h" | 15 #include "platform/v8_inspector/V8ValueCopier.h" |
| 16 #include "platform/v8_inspector/protocol/Protocol.h" |
| 16 #include "platform/v8_inspector/public/V8InspectorClient.h" | 17 #include "platform/v8_inspector/public/V8InspectorClient.h" |
| 17 | 18 |
| 18 namespace v8_inspector { | 19 namespace v8_inspector { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 const char stepIntoV8MethodName[] = "stepIntoStatement"; | 22 const char stepIntoV8MethodName[] = "stepIntoStatement"; |
| 22 const char stepOutV8MethodName[] = "stepOutOfFunction"; | 23 const char stepOutV8MethodName[] = "stepOutOfFunction"; |
| 23 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; | 24 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; |
| 24 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; | 25 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; |
| 25 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; | 26 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 122 |
| 122 void V8Debugger::getCompiledScripts(int contextGroupId, std::vector<std::unique_
ptr<V8DebuggerScript>>& result) | 123 void V8Debugger::getCompiledScripts(int contextGroupId, std::vector<std::unique_
ptr<V8DebuggerScript>>& result) |
| 123 { | 124 { |
| 124 v8::HandleScope scope(m_isolate); | 125 v8::HandleScope scope(m_isolate); |
| 125 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | 126 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); |
| 126 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); | 127 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); |
| 127 DCHECK(!debuggerScript->IsUndefined()); | 128 DCHECK(!debuggerScript->IsUndefined()); |
| 128 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts"))); | 129 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts"))); |
| 129 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId)
}; | 130 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId)
}; |
| 130 v8::Local<v8::Value> value; | 131 v8::Local<v8::Value> value; |
| 131 if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, PROTOCOL_AR
RAY_LENGTH(argv), argv).ToLocal(&value)) | 132 if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, V8_INSPECTO
R_ARRAY_LENGTH(argv), argv).ToLocal(&value)) |
| 132 return; | 133 return; |
| 133 DCHECK(value->IsArray()); | 134 DCHECK(value->IsArray()); |
| 134 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); | 135 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); |
| 135 result.reserve(scriptsArray->Length()); | 136 result.reserve(scriptsArray->Length()); |
| 136 for (unsigned i = 0; i < scriptsArray->Length(); ++i) { | 137 for (unsigned i = 0; i < scriptsArray->Length(); ++i) { |
| 137 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(scripts
Array->Get(v8::Integer::New(m_isolate, i))); | 138 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(scripts
Array->Get(v8::Integer::New(m_isolate, i))); |
| 138 result.push_back(wrapUnique(new V8DebuggerScript(m_isolate, scriptObject
, inLiveEditScope))); | 139 result.push_back(wrapUnique(new V8DebuggerScript(m_isolate, scriptObject
, inLiveEditScope))); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) | 379 JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) |
| 379 { | 380 { |
| 380 if (!m_isolate->InContext()) | 381 if (!m_isolate->InContext()) |
| 381 return JavaScriptCallFrames(); | 382 return JavaScriptCallFrames(); |
| 382 v8::Local<v8::Value> currentCallFramesV8; | 383 v8::Local<v8::Value> currentCallFramesV8; |
| 383 if (m_executionState.IsEmpty()) { | 384 if (m_executionState.IsEmpty()) { |
| 384 v8::Local<v8::Function> currentCallFramesFunction = v8::Local<v8::Functi
on>::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate,
"currentCallFrames"))); | 385 v8::Local<v8::Function> currentCallFramesFunction = v8::Local<v8::Functi
on>::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate,
"currentCallFrames"))); |
| 385 currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFram
esFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked(); | 386 currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFram
esFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked(); |
| 386 } else { | 387 } else { |
| 387 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso
late, limit) }; | 388 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso
late, limit) }; |
| 388 currentCallFramesV8 = callDebuggerMethod("currentCallFrames", PROTOCOL_A
RRAY_LENGTH(argv), argv).ToLocalChecked(); | 389 currentCallFramesV8 = callDebuggerMethod("currentCallFrames", V8_INSPECT
OR_ARRAY_LENGTH(argv), argv).ToLocalChecked(); |
| 389 } | 390 } |
| 390 DCHECK(!currentCallFramesV8.IsEmpty()); | 391 DCHECK(!currentCallFramesV8.IsEmpty()); |
| 391 if (!currentCallFramesV8->IsArray()) | 392 if (!currentCallFramesV8->IsArray()) |
| 392 return JavaScriptCallFrames(); | 393 return JavaScriptCallFrames(); |
| 393 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); | 394 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); |
| 394 JavaScriptCallFrames callFrames; | 395 JavaScriptCallFrames callFrames; |
| 395 for (size_t i = 0; i < callFramesArray->Length(); ++i) { | 396 for (size_t i = 0; i < callFramesArray->Length(); ++i) { |
| 396 v8::Local<v8::Value> callFrameValue; | 397 v8::Local<v8::Value> callFrameValue; |
| 397 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue)
) | 398 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue)
) |
| 398 return JavaScriptCallFrames(); | 399 return JavaScriptCallFrames(); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 return nullptr; | 838 return nullptr; |
| 838 | 839 |
| 839 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; | 840 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; |
| 840 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 841 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 841 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 842 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 842 | 843 |
| 843 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 844 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 844 } | 845 } |
| 845 | 846 |
| 846 } // namespace v8_inspector | 847 } // namespace v8_inspector |
| OLD | NEW |