| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/V8DebuggerAgentImpl.h" | 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/String16.h" | 7 #include "platform/inspector_protocol/String16.h" |
| 8 #include "platform/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
| 9 #include "platform/v8_inspector/InjectedScript.h" | 9 #include "platform/v8_inspector/InjectedScript.h" |
| 10 #include "platform/v8_inspector/InspectedContext.h" | 10 #include "platform/v8_inspector/InspectedContext.h" |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 m_skipNextDebuggerStepOut = true; | 980 m_skipNextDebuggerStepOut = true; |
| 981 } | 981 } |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 | 984 |
| 985 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
ring* errorString) | 985 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
ring* errorString) |
| 986 { | 986 { |
| 987 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) | 987 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) |
| 988 return Array<CallFrame>::create(); | 988 return Array<CallFrame>::create(); |
| 989 ErrorString ignored; | 989 ErrorString ignored; |
| 990 InjectedScript* topFrameInjectedScript = m_session->findInjectedScript(&igno
red, V8DebuggerImpl::contextId(m_pausedContext.Get(m_isolate))); | |
| 991 if (!topFrameInjectedScript) { | |
| 992 // Context has been reported as removed while on pause. | |
| 993 return Array<CallFrame>::create(); | |
| 994 } | |
| 995 | |
| 996 v8::HandleScope handles(m_isolate); | 990 v8::HandleScope handles(m_isolate); |
| 997 v8::Local<v8::Context> context = topFrameInjectedScript->context()->context(
); | 991 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(m_isolat
e); |
| 998 v8::Context::Scope contextScope(context); | 992 v8::Context::Scope contextScope(debuggerContext); |
| 999 | 993 |
| 1000 v8::Local<v8::Array> objects = v8::Array::New(m_isolate); | 994 v8::Local<v8::Array> objects = v8::Array::New(m_isolate); |
| 995 |
| 1001 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++fr
ameOrdinal) { | 996 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++fr
ameOrdinal) { |
| 1002 const std::unique_ptr<JavaScriptCallFrame>& currentCallFrame = m_pausedC
allFrames[frameOrdinal]; | 997 const std::unique_ptr<JavaScriptCallFrame>& currentCallFrame = m_pausedC
allFrames[frameOrdinal]; |
| 1003 | 998 |
| 1004 v8::Local<v8::Object> details = currentCallFrame->details(); | 999 v8::Local<v8::Object> details = currentCallFrame->details(); |
| 1005 if (hasInternalError(errorString, details.IsEmpty())) | 1000 if (hasInternalError(errorString, details.IsEmpty())) |
| 1006 return Array<CallFrame>::create(); | 1001 return Array<CallFrame>::create(); |
| 1007 | 1002 |
| 1008 int contextId = currentCallFrame->contextId(); | 1003 int contextId = currentCallFrame->contextId(); |
| 1009 InjectedScript* injectedScript = contextId ? m_session->findInjectedScri
pt(&ignored, contextId) : nullptr; | 1004 InjectedScript* injectedScript = contextId ? m_session->findInjectedScri
pt(&ignored, contextId) : nullptr; |
| 1010 if (!injectedScript) | |
| 1011 injectedScript = topFrameInjectedScript; | |
| 1012 | 1005 |
| 1013 String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->cont
ext()->contextId(), frameOrdinal); | 1006 String16 callFrameId = RemoteCallFrameId::serialize(contextId, frameOrdi
nal); |
| 1014 if (hasInternalError(errorString, !details->Set(context, toV8StringInter
nalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe
(false))) | 1007 if (hasInternalError(errorString, !details->Set(debuggerContext, toV8Str
ingInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).F
romMaybe(false))) |
| 1015 return Array<CallFrame>::create(); | 1008 return Array<CallFrame>::create(); |
| 1016 | 1009 |
| 1017 v8::Local<v8::Value> scopeChain; | 1010 if (injectedScript) { |
| 1018 if (hasInternalError(errorString, !details->Get(context, toV8StringInter
nalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray()
)) | 1011 v8::Local<v8::Value> scopeChain; |
| 1019 return Array<CallFrame>::create(); | 1012 if (hasInternalError(errorString, !details->Get(debuggerContext, toV
8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChai
n->IsArray())) |
| 1020 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>(); | 1013 return Array<CallFrame>::create(); |
| 1021 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, t
oV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectG
roup)) | 1014 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>(); |
| 1022 return Array<CallFrame>::create(); | 1015 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArra
y, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObj
ectGroup)) |
| 1023 | 1016 return Array<CallFrame>::create(); |
| 1024 if (!injectedScript->wrapObjectProperty(errorString, details, toV8String
Internalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) | 1017 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St
ringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) |
| 1025 return Array<CallFrame>::create(); | 1018 return Array<CallFrame>::create(); |
| 1026 | 1019 if (details->Has(debuggerContext, toV8StringInternalized(m_isolate,
"returnValue")).FromMaybe(false)) { |
| 1027 if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue
")).FromMaybe(false)) { | 1020 if (!injectedScript->wrapObjectProperty(errorString, details, to
V8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObj
ectGroup)) |
| 1028 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St
ringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectG
roup)) | 1021 return Array<CallFrame>::create(); |
| 1022 } |
| 1023 } else { |
| 1024 if (hasInternalError(errorString, !details->Set(debuggerContext, toV
8StringInternalized(m_isolate, "scopeChain"), v8::Array::New(m_isolate, 0)).From
Maybe(false))) |
| 1025 return Array<CallFrame>::create(); |
| 1026 v8::Local<v8::Object> remoteObject = v8::Object::New(m_isolate); |
| 1027 if (hasInternalError(errorString, !remoteObject->Set(debuggerContext
, toV8StringInternalized(m_isolate, "type"), toV8StringInternalized(m_isolate, "
undefined")).FromMaybe(false))) |
| 1028 return Array<CallFrame>::create(); |
| 1029 if (hasInternalError(errorString, !details->Set(debuggerContext, toV
8StringInternalized(m_isolate, "this"), remoteObject).FromMaybe(false))) |
| 1030 return Array<CallFrame>::create(); |
| 1031 if (hasInternalError(errorString, !details->Delete(debuggerContext,
toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false))) |
| 1029 return Array<CallFrame>::create(); | 1032 return Array<CallFrame>::create(); |
| 1030 } | 1033 } |
| 1031 | 1034 |
| 1032 if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, d
etails).FromMaybe(false))) | 1035 if (hasInternalError(errorString, !objects->Set(debuggerContext, frameOr
dinal, details).FromMaybe(false))) |
| 1033 return Array<CallFrame>::create(); | 1036 return Array<CallFrame>::create(); |
| 1034 } | 1037 } |
| 1035 | 1038 |
| 1036 protocol::ErrorSupport errorSupport; | 1039 protocol::ErrorSupport errorSupport; |
| 1037 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro
tocolValue(context, objects).get(), &errorSupport); | 1040 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro
tocolValue(debuggerContext, objects).get(), &errorSupport); |
| 1038 if (hasInternalError(errorString, !callFrames)) | 1041 if (hasInternalError(errorString, !callFrames)) |
| 1039 return Array<CallFrame>::create(); | 1042 return Array<CallFrame>::create(); |
| 1040 return callFrames; | 1043 return callFrames; |
| 1041 } | 1044 } |
| 1042 | 1045 |
| 1043 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() | 1046 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() |
| 1044 { | 1047 { |
| 1045 if (m_pausedContext.IsEmpty()) | 1048 if (m_pausedContext.IsEmpty()) |
| 1046 return nullptr; | 1049 return nullptr; |
| 1047 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); | 1050 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 { | 1245 { |
| 1243 if (!enabled()) | 1246 if (!enabled()) |
| 1244 return; | 1247 return; |
| 1245 m_scheduledDebuggerStep = NoStep; | 1248 m_scheduledDebuggerStep = NoStep; |
| 1246 m_scripts.clear(); | 1249 m_scripts.clear(); |
| 1247 m_blackboxedPositions.clear(); | 1250 m_blackboxedPositions.clear(); |
| 1248 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1251 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1249 } | 1252 } |
| 1250 | 1253 |
| 1251 } // namespace blink | 1254 } // namespace blink |
| OLD | NEW |