| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 static const char url[] = "url"; | 44 static const char url[] = "url"; |
| 45 static const char isRegex[] = "isRegex"; | 45 static const char isRegex[] = "isRegex"; |
| 46 static const char lineNumber[] = "lineNumber"; | 46 static const char lineNumber[] = "lineNumber"; |
| 47 static const char columnNumber[] = "columnNumber"; | 47 static const char columnNumber[] = "columnNumber"; |
| 48 static const char condition[] = "condition"; | 48 static const char condition[] = "condition"; |
| 49 static const char skipAllPauses[] = "skipAllPauses"; | 49 static const char skipAllPauses[] = "skipAllPauses"; |
| 50 | 50 |
| 51 } // namespace DebuggerAgentState; | 51 } // namespace DebuggerAgentState; |
| 52 | 52 |
| 53 static const int maxSkipStepFrameCount = 128; | 53 static const int maxSkipStepFrameCount = 128; |
| 54 static const char backtraceObjectGroup[] = "backtrace"; |
| 54 | 55 |
| 55 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) | 56 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) |
| 56 { | 57 { |
| 57 switch (source) { | 58 switch (source) { |
| 58 case V8DebuggerAgentImpl::UserBreakpointSource: | 59 case V8DebuggerAgentImpl::UserBreakpointSource: |
| 59 break; | 60 break; |
| 60 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: | 61 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: |
| 61 return ":debug"; | 62 return ":debug"; |
| 62 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: | 63 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: |
| 63 return ":monitor"; | 64 return ":monitor"; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 m_steppingFromFramework = false; | 644 m_steppingFromFramework = false; |
| 644 debugger().setPauseOnNextStatement(true); | 645 debugger().setPauseOnNextStatement(true); |
| 645 } | 646 } |
| 646 | 647 |
| 647 void V8DebuggerAgentImpl::resume(ErrorString* errorString) | 648 void V8DebuggerAgentImpl::resume(ErrorString* errorString) |
| 648 { | 649 { |
| 649 if (!assertPaused(errorString)) | 650 if (!assertPaused(errorString)) |
| 650 return; | 651 return; |
| 651 m_scheduledDebuggerStep = NoStep; | 652 m_scheduledDebuggerStep = NoStep; |
| 652 m_steppingFromFramework = false; | 653 m_steppingFromFramework = false; |
| 653 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); | 654 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 654 debugger().continueProgram(); | 655 debugger().continueProgram(); |
| 655 } | 656 } |
| 656 | 657 |
| 657 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) | 658 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) |
| 658 { | 659 { |
| 659 if (!assertPaused(errorString)) | 660 if (!assertPaused(errorString)) |
| 660 return; | 661 return; |
| 661 // StepOver at function return point should fallback to StepInto. | 662 // StepOver at function return point should fallback to StepInto. |
| 662 JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrame
s[0].get() : nullptr; | 663 JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrame
s[0].get() : nullptr; |
| 663 if (frame && frame->isAtReturn()) { | 664 if (frame && frame->isAtReturn()) { |
| 664 stepInto(errorString); | 665 stepInto(errorString); |
| 665 return; | 666 return; |
| 666 } | 667 } |
| 667 m_scheduledDebuggerStep = StepOver; | 668 m_scheduledDebuggerStep = StepOver; |
| 668 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 669 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 669 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); | 670 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 670 debugger().stepOverStatement(); | 671 debugger().stepOverStatement(); |
| 671 } | 672 } |
| 672 | 673 |
| 673 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) | 674 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) |
| 674 { | 675 { |
| 675 if (!assertPaused(errorString)) | 676 if (!assertPaused(errorString)) |
| 676 return; | 677 return; |
| 677 m_scheduledDebuggerStep = StepInto; | 678 m_scheduledDebuggerStep = StepInto; |
| 678 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 679 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 679 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); | 680 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 680 debugger().stepIntoStatement(); | 681 debugger().stepIntoStatement(); |
| 681 } | 682 } |
| 682 | 683 |
| 683 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) | 684 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) |
| 684 { | 685 { |
| 685 if (!assertPaused(errorString)) | 686 if (!assertPaused(errorString)) |
| 686 return; | 687 return; |
| 687 m_scheduledDebuggerStep = StepOut; | 688 m_scheduledDebuggerStep = StepOut; |
| 688 m_skipNextDebuggerStepOut = false; | 689 m_skipNextDebuggerStepOut = false; |
| 689 m_recursionLevelForStepOut = 1; | 690 m_recursionLevelForStepOut = 1; |
| 690 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 691 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 691 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); | 692 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 692 debugger().stepOutOfFunction(); | 693 debugger().stepOutOfFunction(); |
| 693 } | 694 } |
| 694 | 695 |
| 695 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring16& stringPauseState) | 696 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring16& stringPauseState) |
| 696 { | 697 { |
| 697 if (!checkEnabled(errorString)) | 698 if (!checkEnabled(errorString)) |
| 698 return; | 699 return; |
| 699 V8DebuggerImpl::PauseOnExceptionsState pauseState; | 700 V8DebuggerImpl::PauseOnExceptionsState pauseState; |
| 700 if (stringPauseState == "none") { | 701 if (stringPauseState == "none") { |
| 701 pauseState = V8DebuggerImpl::DontPauseOnExceptions; | 702 pauseState = V8DebuggerImpl::DontPauseOnExceptions; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 | 943 |
| 943 String16 callFrameId = RemoteCallFrameId::serialize(contextId, frameOrdi
nal); | 944 String16 callFrameId = RemoteCallFrameId::serialize(contextId, frameOrdi
nal); |
| 944 if (hasInternalError(errorString, !details->Set(debuggerContext, toV8Str
ingInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).F
romMaybe(false))) | 945 if (hasInternalError(errorString, !details->Set(debuggerContext, toV8Str
ingInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).F
romMaybe(false))) |
| 945 return Array<CallFrame>::create(); | 946 return Array<CallFrame>::create(); |
| 946 | 947 |
| 947 if (injectedScript) { | 948 if (injectedScript) { |
| 948 v8::Local<v8::Value> scopeChain; | 949 v8::Local<v8::Value> scopeChain; |
| 949 if (hasInternalError(errorString, !details->Get(debuggerContext, toV
8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChai
n->IsArray())) | 950 if (hasInternalError(errorString, !details->Get(debuggerContext, toV
8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChai
n->IsArray())) |
| 950 return Array<CallFrame>::create(); | 951 return Array<CallFrame>::create(); |
| 951 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>(); | 952 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>(); |
| 952 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArra
y, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObj
ectGroup)) | 953 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArra
y, toV8StringInternalized(m_isolate, "object"), backtraceObjectGroup)) |
| 953 return Array<CallFrame>::create(); | 954 return Array<CallFrame>::create(); |
| 954 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St
ringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) | 955 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St
ringInternalized(m_isolate, "this"), backtraceObjectGroup)) |
| 955 return Array<CallFrame>::create(); | 956 return Array<CallFrame>::create(); |
| 956 if (details->Has(debuggerContext, toV8StringInternalized(m_isolate,
"returnValue")).FromMaybe(false)) { | 957 if (details->Has(debuggerContext, toV8StringInternalized(m_isolate,
"returnValue")).FromMaybe(false)) { |
| 957 if (!injectedScript->wrapObjectProperty(errorString, details, to
V8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObj
ectGroup)) | 958 if (!injectedScript->wrapObjectProperty(errorString, details, to
V8StringInternalized(m_isolate, "returnValue"), backtraceObjectGroup)) |
| 958 return Array<CallFrame>::create(); | 959 return Array<CallFrame>::create(); |
| 959 } | 960 } |
| 960 } else { | 961 } else { |
| 961 if (hasInternalError(errorString, !details->Set(debuggerContext, toV
8StringInternalized(m_isolate, "scopeChain"), v8::Array::New(m_isolate, 0)).From
Maybe(false))) | 962 if (hasInternalError(errorString, !details->Set(debuggerContext, toV
8StringInternalized(m_isolate, "scopeChain"), v8::Array::New(m_isolate, 0)).From
Maybe(false))) |
| 962 return Array<CallFrame>::create(); | 963 return Array<CallFrame>::create(); |
| 963 v8::Local<v8::Object> remoteObject = v8::Object::New(m_isolate); | 964 v8::Local<v8::Object> remoteObject = v8::Object::New(m_isolate); |
| 964 if (hasInternalError(errorString, !remoteObject->Set(debuggerContext
, toV8StringInternalized(m_isolate, "type"), toV8StringInternalized(m_isolate, "
undefined")).FromMaybe(false))) | 965 if (hasInternalError(errorString, !remoteObject->Set(debuggerContext
, toV8StringInternalized(m_isolate, "type"), toV8StringInternalized(m_isolate, "
undefined")).FromMaybe(false))) |
| 965 return Array<CallFrame>::create(); | 966 return Array<CallFrame>::create(); |
| 966 if (hasInternalError(errorString, !details->Set(debuggerContext, toV
8StringInternalized(m_isolate, "this"), remoteObject).FromMaybe(false))) | 967 if (hasInternalError(errorString, !details->Set(debuggerContext, toV
8StringInternalized(m_isolate, "this"), remoteObject).FromMaybe(false))) |
| 967 return Array<CallFrame>::create(); | 968 return Array<CallFrame>::create(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 m_pausedCallFrames.swap(frames); | 1088 m_pausedCallFrames.swap(frames); |
| 1088 m_pausedContext.Reset(m_isolate, context); | 1089 m_pausedContext.Reset(m_isolate, context); |
| 1089 v8::HandleScope handles(m_isolate); | 1090 v8::HandleScope handles(m_isolate); |
| 1090 | 1091 |
| 1091 if (!exception.IsEmpty()) { | 1092 if (!exception.IsEmpty()) { |
| 1092 ErrorString ignored; | 1093 ErrorString ignored; |
| 1093 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored,
V8DebuggerImpl::contextId(context)); | 1094 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored,
V8DebuggerImpl::contextId(context)); |
| 1094 if (injectedScript) { | 1095 if (injectedScript) { |
| 1095 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea
sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; | 1096 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea
sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; |
| 1096 ErrorString errorString; | 1097 ErrorString errorString; |
| 1097 auto obj = injectedScript->wrapObject(&errorString, exception, V8Ins
pectorSession::backtraceObjectGroup); | 1098 auto obj = injectedScript->wrapObject(&errorString, exception, backt
raceObjectGroup); |
| 1098 m_breakAuxData = obj ? obj->serialize() : nullptr; | 1099 m_breakAuxData = obj ? obj->serialize() : nullptr; |
| 1099 // m_breakAuxData might be null after this. | 1100 // m_breakAuxData might be null after this. |
| 1100 } | 1101 } |
| 1101 } | 1102 } |
| 1102 | 1103 |
| 1103 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(
); | 1104 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(
); |
| 1104 | 1105 |
| 1105 for (const auto& point : hitBreakpoints) { | 1106 for (const auto& point : hitBreakpoints) { |
| 1106 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); | 1107 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); |
| 1107 if (breakpointIterator != m_serverBreakpoints.end()) { | 1108 if (breakpointIterator != m_serverBreakpoints.end()) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 { | 1190 { |
| 1190 if (!enabled()) | 1191 if (!enabled()) |
| 1191 return; | 1192 return; |
| 1192 m_scheduledDebuggerStep = NoStep; | 1193 m_scheduledDebuggerStep = NoStep; |
| 1193 m_scripts.clear(); | 1194 m_scripts.clear(); |
| 1194 m_blackboxedPositions.clear(); | 1195 m_blackboxedPositions.clear(); |
| 1195 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1196 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1196 } | 1197 } |
| 1197 | 1198 |
| 1198 } // namespace blink | 1199 } // namespace blink |
| OLD | NEW |