Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

Issue 1924913002: [DevTools] Move API methods from V8DebuggerAgent to V8InspectorSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 static const char isRegex[] = "isRegex"; 52 static const char isRegex[] = "isRegex";
53 static const char lineNumber[] = "lineNumber"; 53 static const char lineNumber[] = "lineNumber";
54 static const char columnNumber[] = "columnNumber"; 54 static const char columnNumber[] = "columnNumber";
55 static const char condition[] = "condition"; 55 static const char condition[] = "condition";
56 static const char skipAllPauses[] = "skipAllPauses"; 56 static const char skipAllPauses[] = "skipAllPauses";
57 57
58 } // namespace DebuggerAgentState; 58 } // namespace DebuggerAgentState;
59 59
60 static const int maxSkipStepFrameCount = 128; 60 static const int maxSkipStepFrameCount = 128;
61 61
62 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace";
63
64 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) 62 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source)
65 { 63 {
66 switch (source) { 64 switch (source) {
67 case V8DebuggerAgentImpl::UserBreakpointSource: 65 case V8DebuggerAgentImpl::UserBreakpointSource:
68 break; 66 break;
69 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: 67 case V8DebuggerAgentImpl::DebugCommandBreakpointSource:
70 return ":debug"; 68 return ":debug";
71 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: 69 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource:
72 return ":monitor"; 70 return ":monitor";
73 } 71 }
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ; 589 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ;
592 } 590 }
593 591
594 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query, 592 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query,
595 const Maybe<bool>& optionalCaseSensitive, 593 const Maybe<bool>& optionalCaseSensitive,
596 const Maybe<bool>& optionalIsRegex, 594 const Maybe<bool>& optionalIsRegex,
597 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results) 595 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results)
598 { 596 {
599 ScriptsMap::iterator it = m_scripts.find(scriptId); 597 ScriptsMap::iterator it = m_scripts.find(scriptId);
600 if (it != m_scripts.end()) 598 if (it != m_scripts.end())
601 *results = V8ContentSearchUtil::searchInTextByLines(m_debugger, it->seco nd->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fro mMaybe(false)); 599 *results = V8ContentSearchUtil::searchInTextByLines(m_session, it->secon d->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.from Maybe(false));
602 else 600 else
603 *error = String16("No script for id: " + scriptId); 601 *error = String16("No script for id: " + scriptId);
604 } 602 }
605 603
606 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, 604 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString,
607 const String16& scriptId, 605 const String16& scriptId,
608 const String16& newContent, 606 const String16& newContent,
609 const Maybe<bool>& preview, 607 const Maybe<bool>& preview,
610 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, 608 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
611 Maybe<bool>* stackChanged, 609 Maybe<bool>* stackChanged,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 m_steppingFromFramework = false; 832 m_steppingFromFramework = false;
835 debugger().setPauseOnNextStatement(true); 833 debugger().setPauseOnNextStatement(true);
836 } 834 }
837 835
838 void V8DebuggerAgentImpl::resume(ErrorString* errorString) 836 void V8DebuggerAgentImpl::resume(ErrorString* errorString)
839 { 837 {
840 if (!assertPaused(errorString)) 838 if (!assertPaused(errorString))
841 return; 839 return;
842 m_scheduledDebuggerStep = NoStep; 840 m_scheduledDebuggerStep = NoStep;
843 m_steppingFromFramework = false; 841 m_steppingFromFramework = false;
844 m_session->releaseObjectGroup(V8DebuggerAgentImpl::backtraceObjectGroup); 842 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup);
845 debugger().continueProgram(); 843 debugger().continueProgram();
846 } 844 }
847 845
848 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) 846 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString)
849 { 847 {
850 if (!assertPaused(errorString)) 848 if (!assertPaused(errorString))
851 return; 849 return;
852 // StepOver at function return point should fallback to StepInto. 850 // StepOver at function return point should fallback to StepInto.
853 JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[ 0].get() : nullptr; 851 JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[ 0].get() : nullptr;
854 if (frame && frame->isAtReturn()) { 852 if (frame && frame->isAtReturn()) {
855 stepInto(errorString); 853 stepInto(errorString);
856 return; 854 return;
857 } 855 }
858 m_scheduledDebuggerStep = StepOver; 856 m_scheduledDebuggerStep = StepOver;
859 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); 857 m_steppingFromFramework = isTopPausedCallFrameBlackboxed();
860 m_session->releaseObjectGroup(V8DebuggerAgentImpl::backtraceObjectGroup); 858 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup);
861 debugger().stepOverStatement(); 859 debugger().stepOverStatement();
862 } 860 }
863 861
864 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) 862 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString)
865 { 863 {
866 if (!assertPaused(errorString)) 864 if (!assertPaused(errorString))
867 return; 865 return;
868 m_scheduledDebuggerStep = StepInto; 866 m_scheduledDebuggerStep = StepInto;
869 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); 867 m_steppingFromFramework = isTopPausedCallFrameBlackboxed();
870 m_session->releaseObjectGroup(V8DebuggerAgentImpl::backtraceObjectGroup); 868 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup);
871 debugger().stepIntoStatement(); 869 debugger().stepIntoStatement();
872 } 870 }
873 871
874 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) 872 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString)
875 { 873 {
876 if (!assertPaused(errorString)) 874 if (!assertPaused(errorString))
877 return; 875 return;
878 m_scheduledDebuggerStep = StepOut; 876 m_scheduledDebuggerStep = StepOut;
879 m_skipNextDebuggerStepOut = false; 877 m_skipNextDebuggerStepOut = false;
880 m_recursionLevelForStepOut = 1; 878 m_recursionLevelForStepOut = 1;
881 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); 879 m_steppingFromFramework = isTopPausedCallFrameBlackboxed();
882 m_session->releaseObjectGroup(V8DebuggerAgentImpl::backtraceObjectGroup); 880 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup);
883 debugger().stepOutOfFunction(); 881 debugger().stepOutOfFunction();
884 } 882 }
885 883
886 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S tring16& stringPauseState) 884 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S tring16& stringPauseState)
887 { 885 {
888 if (!checkEnabled(errorString)) 886 if (!checkEnabled(errorString))
889 return; 887 return;
890 V8DebuggerImpl::PauseOnExceptionsState pauseState; 888 V8DebuggerImpl::PauseOnExceptionsState pauseState;
891 if (stringPauseState == "none") { 889 if (stringPauseState == "none") {
892 pauseState = V8DebuggerImpl::DontPauseOnExceptions; 890 pauseState = V8DebuggerImpl::DontPauseOnExceptions;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 injectedScript = topFrameInjectedScript; 1206 injectedScript = topFrameInjectedScript;
1209 1207
1210 String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->cont ext()->contextId(), frameOrdinal); 1208 String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->cont ext()->contextId(), frameOrdinal);
1211 if (hasInternalError(errorString, !details->Set(context, toV8StringInter nalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe (false))) 1209 if (hasInternalError(errorString, !details->Set(context, toV8StringInter nalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe (false)))
1212 return Array<CallFrame>::create(); 1210 return Array<CallFrame>::create();
1213 1211
1214 v8::Local<v8::Value> scopeChain; 1212 v8::Local<v8::Value> scopeChain;
1215 if (hasInternalError(errorString, !details->Get(context, toV8StringInter nalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray() )) 1213 if (hasInternalError(errorString, !details->Get(context, toV8StringInter nalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray() ))
1216 return Array<CallFrame>::create(); 1214 return Array<CallFrame>::create();
1217 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>(); 1215 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>();
1218 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, t oV8StringInternalized(m_isolate, "object"), V8DebuggerAgentImpl::backtraceObject Group)) 1216 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, t oV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectG roup))
1219 return Array<CallFrame>::create(); 1217 return Array<CallFrame>::create();
1220 1218
1221 if (!injectedScript->wrapObjectProperty(errorString, details, toV8String Internalized(m_isolate, "this"), V8DebuggerAgentImpl::backtraceObjectGroup)) 1219 if (!injectedScript->wrapObjectProperty(errorString, details, toV8String Internalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup))
1222 return Array<CallFrame>::create(); 1220 return Array<CallFrame>::create();
1223 1221
1224 if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue ")).FromMaybe(false)) { 1222 if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue ")).FromMaybe(false)) {
1225 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(m_isolate, "returnValue"), V8DebuggerAgentImpl::backtraceObject Group)) 1223 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectG roup))
1226 return Array<CallFrame>::create(); 1224 return Array<CallFrame>::create();
1227 } 1225 }
1228 1226
1229 if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, d etails).FromMaybe(false))) 1227 if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, d etails).FromMaybe(false)))
1230 return Array<CallFrame>::create(); 1228 return Array<CallFrame>::create();
1231 } 1229 }
1232 1230
1233 protocol::ErrorSupport errorSupport; 1231 protocol::ErrorSupport errorSupport;
1234 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu e(context, objects).get(), &errorSupport); 1232 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu e(context, objects).get(), &errorSupport);
1235 if (hasInternalError(errorString, !callFrames)) 1233 if (hasInternalError(errorString, !callFrames))
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 m_pausedCallFrames.swap(debugger().currentCallFrames()); 1344 m_pausedCallFrames.swap(debugger().currentCallFrames());
1347 m_pausedContext.Reset(m_isolate, context); 1345 m_pausedContext.Reset(m_isolate, context);
1348 v8::HandleScope handles(m_isolate); 1346 v8::HandleScope handles(m_isolate);
1349 1347
1350 if (!exception.IsEmpty()) { 1348 if (!exception.IsEmpty()) {
1351 ErrorString ignored; 1349 ErrorString ignored;
1352 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(context)); 1350 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(context));
1353 if (injectedScript) { 1351 if (injectedScript) {
1354 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; 1352 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception;
1355 ErrorString errorString; 1353 ErrorString errorString;
1356 auto obj = injectedScript->wrapObject(&errorString, exception, V8Deb uggerAgentImpl::backtraceObjectGroup); 1354 auto obj = injectedScript->wrapObject(&errorString, exception, V8Ins pectorSession::backtraceObjectGroup);
1357 m_breakAuxData = obj ? obj->serialize() : nullptr; 1355 m_breakAuxData = obj ? obj->serialize() : nullptr;
1358 // m_breakAuxData might be null after this. 1356 // m_breakAuxData might be null after this.
1359 } 1357 }
1360 } 1358 }
1361 1359
1362 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create(); 1360 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create();
1363 1361
1364 for (const auto& point : hitBreakpoints) { 1362 for (const auto& point : hitBreakpoints) {
1365 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter ator = m_serverBreakpoints.find(point); 1363 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter ator = m_serverBreakpoints.find(point);
1366 if (breakpointIterator != m_serverBreakpoints.end()) { 1364 if (breakpointIterator != m_serverBreakpoints.end()) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 if (!enabled()) 1447 if (!enabled())
1450 return; 1448 return;
1451 m_scheduledDebuggerStep = NoStep; 1449 m_scheduledDebuggerStep = NoStep;
1452 m_scripts.clear(); 1450 m_scripts.clear();
1453 m_blackboxedPositions.clear(); 1451 m_blackboxedPositions.clear();
1454 m_breakpointIdToDebuggerBreakpointIds.clear(); 1452 m_breakpointIdToDebuggerBreakpointIds.clear();
1455 allAsyncTasksCanceled(); 1453 allAsyncTasksCanceled();
1456 } 1454 }
1457 1455
1458 } // namespace blink 1456 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698