| 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/IgnoreExceptionsScope.h" | 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" |
| 10 #include "platform/v8_inspector/InjectedScript.h" | 10 #include "platform/v8_inspector/InjectedScript.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 return; | 488 return; |
| 489 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); | 489 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); |
| 490 *callFrames = currentCallFrames(); | 490 *callFrames = currentCallFrames(); |
| 491 *asyncStackTrace = currentAsyncStackTrace(); | 491 *asyncStackTrace = currentAsyncStackTrace(); |
| 492 } | 492 } |
| 493 | 493 |
| 494 bool V8DebuggerAgentImpl::isCallStackEmptyOrBlackboxed() | 494 bool V8DebuggerAgentImpl::isCallStackEmptyOrBlackboxed() |
| 495 { | 495 { |
| 496 ASSERT(enabled()); | 496 ASSERT(enabled()); |
| 497 for (int index = 0; ; ++index) { | 497 for (int index = 0; ; ++index) { |
| 498 OwnPtr<JavaScriptCallFrame> frame = debugger().callFrameNoScopes(index); | 498 OwnPtr<JavaScriptCallFrame> frame = debugger().callFrame(index); |
| 499 if (!frame) | 499 if (!frame) |
| 500 break; | 500 break; |
| 501 if (!isCallFrameWithUnknownScriptOrBlackboxed(frame.get())) | 501 if (!isCallFrameWithUnknownScriptOrBlackboxed(frame.get())) |
| 502 return false; | 502 return false; |
| 503 } | 503 } |
| 504 return true; | 504 return true; |
| 505 } | 505 } |
| 506 | 506 |
| 507 bool V8DebuggerAgentImpl::isTopCallFrameBlackboxed() | 507 bool V8DebuggerAgentImpl::isTopCallFrameBlackboxed() |
| 508 { | 508 { |
| 509 ASSERT(enabled()); | 509 ASSERT(enabled()); |
| 510 return isCallFrameWithUnknownScriptOrBlackboxed(debugger().callFrameNoScopes
(0).get()); | 510 return isCallFrameWithUnknownScriptOrBlackboxed(debugger().callFrame(0).get(
)); |
| 511 } | 511 } |
| 512 | 512 |
| 513 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal
lFrame* frame) | 513 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal
lFrame* frame) |
| 514 { | 514 { |
| 515 if (!frame) | 515 if (!frame) |
| 516 return true; | 516 return true; |
| 517 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID())
); | 517 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID())
); |
| 518 if (it == m_scripts.end()) { | 518 if (it == m_scripts.end()) { |
| 519 // Unknown scripts are blackboxed. | 519 // Unknown scripts are blackboxed. |
| 520 return true; | 520 return true; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 return; | 646 return; |
| 647 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); | 647 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); |
| 648 if (!injectedScript) | 648 if (!injectedScript) |
| 649 return; | 649 return; |
| 650 | 650 |
| 651 v8::HandleScope scope(m_isolate); | 651 v8::HandleScope scope(m_isolate); |
| 652 v8::Local<v8::Context> localContext = injectedScript->context(); | 652 v8::Local<v8::Context> localContext = injectedScript->context(); |
| 653 | 653 |
| 654 v8::TryCatch tryCatch(m_isolate); | 654 v8::TryCatch tryCatch(m_isolate); |
| 655 | 655 |
| 656 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop
es(remoteId->frameOrdinal()); | 656 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrame(remot
eId->frameOrdinal()); |
| 657 if (!javaScriptCallFrame) { | 657 if (!javaScriptCallFrame) { |
| 658 *errorString = "Could not find call frame with given id"; | 658 *errorString = "Could not find call frame with given id"; |
| 659 return; | 659 return; |
| 660 } | 660 } |
| 661 v8::Local<v8::Value> resultValue; | 661 v8::Local<v8::Value> resultValue; |
| 662 v8::Local<v8::Boolean> result; | 662 v8::Local<v8::Boolean> result; |
| 663 if (!javaScriptCallFrame->restart().ToLocal(&resultValue) || tryCatch.HasCau
ght() || !resultValue->ToBoolean(localContext).ToLocal(&result) || !result->Valu
e()) { | 663 if (!javaScriptCallFrame->restart().ToLocal(&resultValue) || tryCatch.HasCau
ght() || !resultValue->ToBoolean(localContext).ToLocal(&result) || !result->Valu
e()) { |
| 664 *errorString = "Internal error"; | 664 *errorString = "Internal error"; |
| 665 return; | 665 return; |
| 666 } | 666 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 m_steppingFromFramework = false; | 900 m_steppingFromFramework = false; |
| 901 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb
jectGroup); | 901 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb
jectGroup); |
| 902 debugger().continueProgram(); | 902 debugger().continueProgram(); |
| 903 } | 903 } |
| 904 | 904 |
| 905 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) | 905 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) |
| 906 { | 906 { |
| 907 if (!assertPaused(errorString)) | 907 if (!assertPaused(errorString)) |
| 908 return; | 908 return; |
| 909 // StepOver at function return point should fallback to StepInto. | 909 // StepOver at function return point should fallback to StepInto. |
| 910 OwnPtr<JavaScriptCallFrame> frame = debugger().callFrameNoScopes(0); | 910 OwnPtr<JavaScriptCallFrame> frame = debugger().callFrame(0); |
| 911 if (frame && frame->isAtReturn()) { | 911 if (frame && frame->isAtReturn()) { |
| 912 stepInto(errorString); | 912 stepInto(errorString); |
| 913 return; | 913 return; |
| 914 } | 914 } |
| 915 m_scheduledDebuggerStep = StepOver; | 915 m_scheduledDebuggerStep = StepOver; |
| 916 m_steppingFromFramework = isTopCallFrameBlackboxed(); | 916 m_steppingFromFramework = isTopCallFrameBlackboxed(); |
| 917 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb
jectGroup); | 917 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb
jectGroup); |
| 918 debugger().stepOverStatement(); | 918 debugger().stepOverStatement(); |
| 919 } | 919 } |
| 920 | 920 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 if (!injectedScript) | 1003 if (!injectedScript) |
| 1004 return; | 1004 return; |
| 1005 | 1005 |
| 1006 v8::HandleScope scope(injectedScript->isolate()); | 1006 v8::HandleScope scope(injectedScript->isolate()); |
| 1007 | 1007 |
| 1008 if (!injectedScript->canAccessInspectedWindow()) { | 1008 if (!injectedScript->canAccessInspectedWindow()) { |
| 1009 *errorString = "Can not access given context"; | 1009 *errorString = "Can not access given context"; |
| 1010 return; | 1010 return; |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop
es(remoteId->frameOrdinal()); | 1013 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrame(remot
eId->frameOrdinal()); |
| 1014 if (!javaScriptCallFrame) { | 1014 if (!javaScriptCallFrame) { |
| 1015 *errorString = "Could not find call frame with given id"; | 1015 *errorString = "Could not find call frame with given id"; |
| 1016 return; | 1016 return; |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe(
false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object
>(); | 1019 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe(
false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object
>(); |
| 1020 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty()) | 1020 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty()) |
| 1021 return; | 1021 return; |
| 1022 | 1022 |
| 1023 InjectedScriptManager::ScopedGlobalObjectExtension scopeExtension(injectedSc
ript, m_injectedScriptManager, commandLineAPI); | 1023 InjectedScriptManager::ScopedGlobalObjectExtension scopeExtension(injectedSc
ript, m_injectedScriptManager, commandLineAPI); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 if (!injectedScript) | 1061 if (!injectedScript) |
| 1062 return; | 1062 return; |
| 1063 | 1063 |
| 1064 v8::HandleScope scope(m_isolate); | 1064 v8::HandleScope scope(m_isolate); |
| 1065 v8::TryCatch tryCatch(m_isolate); | 1065 v8::TryCatch tryCatch(m_isolate); |
| 1066 | 1066 |
| 1067 v8::Local<v8::Value> newValue; | 1067 v8::Local<v8::Value> newValue; |
| 1068 if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get()
).ToLocal(&newValue)) | 1068 if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get()
).ToLocal(&newValue)) |
| 1069 return; | 1069 return; |
| 1070 | 1070 |
| 1071 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop
es(remoteId->frameOrdinal()); | 1071 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrame(remot
eId->frameOrdinal()); |
| 1072 if (!javaScriptCallFrame) { | 1072 if (!javaScriptCallFrame) { |
| 1073 *errorString = "Could not find call frame with given id"; | 1073 *errorString = "Could not find call frame with given id"; |
| 1074 return; | 1074 return; |
| 1075 } | 1075 } |
| 1076 v8::MaybeLocal<v8::Value> result = javaScriptCallFrame->setVariableValue(sco
peNumber, toV8String(m_isolate, variableName), newValue); | 1076 v8::MaybeLocal<v8::Value> result = javaScriptCallFrame->setVariableValue(sco
peNumber, toV8String(m_isolate, variableName), newValue); |
| 1077 if (tryCatch.HasCaught() || result.IsEmpty()) { | 1077 if (tryCatch.HasCaught() || result.IsEmpty()) { |
| 1078 *errorString = "Internal error"; | 1078 *errorString = "Internal error"; |
| 1079 return; | 1079 return; |
| 1080 } | 1080 } |
| 1081 } | 1081 } |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 return; | 1649 return; |
| 1650 m_scheduledDebuggerStep = NoStep; | 1650 m_scheduledDebuggerStep = NoStep; |
| 1651 m_scripts.clear(); | 1651 m_scripts.clear(); |
| 1652 m_blackboxedPositions.clear(); | 1652 m_blackboxedPositions.clear(); |
| 1653 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1653 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1654 resetAsyncCallTracker(); | 1654 resetAsyncCallTracker(); |
| 1655 m_promiseTracker->clear(); | 1655 m_promiseTracker->clear(); |
| 1656 } | 1656 } |
| 1657 | 1657 |
| 1658 } // namespace blink | 1658 } // namespace blink |
| OLD | NEW |