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

Side by Side Diff: sky/engine/v8_inspector/InspectorDebuggerAgent.cpp

Issue 772563003: Move many of v8_inspector dependencies out of core/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 10 matching lines...) Expand all
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "sky/engine/config.h" 30 #include "sky/engine/config.h"
31 #include "sky/engine/core/inspector/InspectorDebuggerAgent.h" 31 #include "sky/engine/v8_inspector/InspectorDebuggerAgent.h"
32 32
33 #include "sky/engine/bindings/core/v8/ScriptDebugServer.h"
34 #include "sky/engine/bindings/core/v8/ScriptRegexp.h"
35 #include "sky/engine/bindings/core/v8/ScriptSourceCode.h" 33 #include "sky/engine/bindings/core/v8/ScriptSourceCode.h"
36 #include "sky/engine/bindings/core/v8/ScriptValue.h" 34 #include "sky/engine/bindings/core/v8/ScriptValue.h"
37 #include "sky/engine/core/dom/Document.h" 35 #include "sky/engine/core/dom/Document.h"
38 #include "sky/engine/core/fetch/Resource.h"
39 #include "sky/engine/core/inspector/ConsoleMessage.h" 36 #include "sky/engine/core/inspector/ConsoleMessage.h"
40 #include "sky/engine/core/inspector/ContentSearchUtils.h"
41 #include "sky/engine/core/inspector/InjectedScriptManager.h"
42 #include "sky/engine/core/inspector/InspectorState.h"
43 #include "sky/engine/core/inspector/JavaScriptCallFrame.h" 37 #include "sky/engine/core/inspector/JavaScriptCallFrame.h"
44 #include "sky/engine/core/inspector/ScriptArguments.h" 38 #include "sky/engine/core/inspector/ScriptArguments.h"
45 #include "sky/engine/core/inspector/ScriptAsyncCallStack.h" 39 #include "sky/engine/core/inspector/ScriptAsyncCallStack.h"
46 #include "sky/engine/core/inspector/ScriptCallFrame.h" 40 #include "sky/engine/core/inspector/ScriptCallFrame.h"
47 #include "sky/engine/core/inspector/ScriptCallStack.h" 41 #include "sky/engine/core/inspector/ScriptCallStack.h"
48 #include "sky/engine/platform/JSONValues.h" 42 #include "sky/engine/platform/JSONValues.h"
43 #include "sky/engine/v8_inspector/ContentSearchUtils.h"
44 #include "sky/engine/v8_inspector/InjectedScriptManager.h"
45 #include "sky/engine/v8_inspector/InspectorState.h"
46 #include "sky/engine/v8_inspector/ScriptDebugServer.h"
47 #include "sky/engine/v8_inspector/ScriptRegexp.h"
49 #include "sky/engine/wtf/text/StringBuilder.h" 48 #include "sky/engine/wtf/text/StringBuilder.h"
50 #include "sky/engine/wtf/text/WTFString.h" 49 #include "sky/engine/wtf/text/WTFString.h"
51 50
52 using blink::TypeBuilder::Array; 51 using blink::TypeBuilder::Array;
53 using blink::TypeBuilder::Debugger::BreakpointId; 52 using blink::TypeBuilder::Debugger::BreakpointId;
54 using blink::TypeBuilder::Debugger::CallFrame; 53 using blink::TypeBuilder::Debugger::CallFrame;
55 using blink::TypeBuilder::Debugger::CollectionEntry; 54 using blink::TypeBuilder::Debugger::CollectionEntry;
56 using blink::TypeBuilder::Debugger::ExceptionDetails; 55 using blink::TypeBuilder::Debugger::ExceptionDetails;
57 using blink::TypeBuilder::Debugger::FunctionDetails; 56 using blink::TypeBuilder::Debugger::FunctionDetails;
58 using blink::TypeBuilder::Debugger::ScriptId; 57 using blink::TypeBuilder::Debugger::ScriptId;
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 // therefore contents of the stack does not provide necessary information 996 // therefore contents of the stack does not provide necessary information
998 if (exceptionDetails) 997 if (exceptionDetails)
999 exceptionDetails->setStackTrace(TypeBuilder::Array<TypeBuilder::Console: :CallFrame>::create()); 998 exceptionDetails->setStackTrace(TypeBuilder::Array<TypeBuilder::Console: :CallFrame>::create());
1000 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { 999 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
1001 unmuteConsole(); 1000 unmuteConsole();
1002 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 1001 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
1003 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 1002 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
1004 } 1003 }
1005 } 1004 }
1006 1005
1006 namespace {
1007
1008 PassRefPtr<TypeBuilder::Console::CallFrame> buildInspectorObject(const ScriptCal lFrame& frame)
1009 {
1010 return TypeBuilder::Console::CallFrame::create()
1011 .setFunctionName(frame.functionName())
1012 .setScriptId(frame.scriptId())
1013 .setUrl(frame.sourceURL())
1014 .setLineNumber(frame.lineNumber())
1015 .setColumnNumber(frame.columnNumber())
1016 .release();
1017 }
1018
1019 PassRefPtr<TypeBuilder::Array<TypeBuilder::Console::CallFrame> > buildInspectorA rray(const RefPtr<ScriptCallStack>& stack)
1020 {
1021 RefPtr<TypeBuilder::Array<TypeBuilder::Console::CallFrame> > frames = TypeBu ilder::Array<TypeBuilder::Console::CallFrame>::create();
1022 for (size_t i = 0; i < stack->size(); i++)
1023 frames->addItem(buildInspectorObject(stack->at(i)));
1024 return frames;
1025 }
1026
1027 } // namespace
1028
1007 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, const int* executionContextId, TypeBuild er::OptOutput<ScriptId>* scriptId, RefPtr<ExceptionDetails>& exceptionDetails) 1029 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, const int* executionContextId, TypeBuild er::OptOutput<ScriptId>* scriptId, RefPtr<ExceptionDetails>& exceptionDetails)
1008 { 1030 {
1009 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 1031 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
1010 if (injectedScript.isEmpty()) { 1032 if (injectedScript.isEmpty()) {
1011 *errorString = "Inspected frame has gone"; 1033 *errorString = "Inspected frame has gone";
1012 return; 1034 return;
1013 } 1035 }
1014 1036
1015 String scriptIdValue; 1037 String scriptIdValue;
1016 String exceptionDetailsText; 1038 String exceptionDetailsText;
1017 int lineNumberValue = 0; 1039 int lineNumberValue = 0;
1018 int columnNumberValue = 0; 1040 int columnNumberValue = 0;
1019 RefPtr<ScriptCallStack> stackTraceValue; 1041 RefPtr<ScriptCallStack> stackTraceValue;
1020 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionDetailsText, &lineNumberValue, &columnNumbe rValue, &stackTraceValue); 1042 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionDetailsText, &lineNumberValue, &columnNumbe rValue, &stackTraceValue);
1021 if (!scriptIdValue && !exceptionDetailsText) { 1043 if (!scriptIdValue && !exceptionDetailsText) {
1022 *errorString = "Script compilation failed"; 1044 *errorString = "Script compilation failed";
1023 return; 1045 return;
1024 } 1046 }
1025 *scriptId = scriptIdValue; 1047 *scriptId = scriptIdValue;
1026 if (!scriptIdValue.isEmpty()) 1048 if (!scriptIdValue.isEmpty())
1027 return; 1049 return;
1028 1050
1029 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsText); 1051 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsText);
1030 exceptionDetails->setLine(lineNumberValue); 1052 exceptionDetails->setLine(lineNumberValue);
1031 exceptionDetails->setColumn(columnNumberValue); 1053 exceptionDetails->setColumn(columnNumberValue);
1032 if (stackTraceValue && stackTraceValue->size() > 0) 1054 if (stackTraceValue && stackTraceValue->size() > 0)
1033 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray()); 1055 exceptionDetails->setStackTrace(buildInspectorArray(stackTraceValue));
1034 } 1056 }
1035 1057
1036 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<RemoteObject>& result, RefPtr<ExceptionDetails>& exceptionDetails) 1058 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<RemoteObject>& result, RefPtr<ExceptionDetails>& exceptionDetails)
1037 { 1059 {
1038 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 1060 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
1039 if (injectedScript.isEmpty()) { 1061 if (injectedScript.isEmpty()) {
1040 *errorString = "Inspected frame has gone"; 1062 *errorString = "Inspected frame has gone";
1041 return; 1063 return;
1042 } 1064 }
1043 1065
(...skipping 14 matching lines...) Expand all
1058 if (value.isEmpty()) { 1080 if (value.isEmpty()) {
1059 *errorString = "Script execution failed"; 1081 *errorString = "Script execution failed";
1060 return; 1082 return;
1061 } 1083 }
1062 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); 1084 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
1063 if (wasThrownValue) { 1085 if (wasThrownValue) {
1064 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsTe xt); 1086 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsTe xt);
1065 exceptionDetails->setLine(lineNumberValue); 1087 exceptionDetails->setLine(lineNumberValue);
1066 exceptionDetails->setColumn(columnNumberValue); 1088 exceptionDetails->setColumn(columnNumberValue);
1067 if (stackTraceValue && stackTraceValue->size() > 0) 1089 if (stackTraceValue && stackTraceValue->size() > 0)
1068 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray ()); 1090 exceptionDetails->setStackTrace(buildInspectorArray(stackTraceValue) );
1069 } 1091 }
1070 1092
1071 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { 1093 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
1072 unmuteConsole(); 1094 unmuteConsole();
1073 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 1095 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
1074 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 1096 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
1075 } 1097 }
1076 } 1098 }
1077 1099
1078 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*) 1100 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 .setCallFrames(injectedScript.wrapCallFrames(callFrames, asyncOrdina l)) 1195 .setCallFrames(injectedScript.wrapCallFrames(callFrames, asyncOrdina l))
1174 .release(); 1196 .release();
1175 next->setDescription((*it)->description()); 1197 next->setDescription((*it)->description());
1176 if (result) 1198 if (result)
1177 next->setAsyncStackTrace(result.release()); 1199 next->setAsyncStackTrace(result.release());
1178 result.swap(next); 1200 result.swap(next);
1179 } 1201 }
1180 return result.release(); 1202 return result.release();
1181 } 1203 }
1182 1204
1183 static PassRefPtr<ScriptCallStack> toScriptCallStack(JavaScriptCallFrame* callFr ame)
1184 {
1185 Vector<ScriptCallFrame> frames;
1186 for (; callFrame; callFrame = callFrame->caller()) {
1187 StringBuilder stringBuilder;
1188 stringBuilder.appendNumber(callFrame->sourceID());
1189 String scriptId = stringBuilder.toString();
1190 // FIXME(WK62725): Debugger line/column are 0-based, while console ones are 1-based.
1191 int line = callFrame->line() + 1;
1192 int column = callFrame->column() + 1;
1193 frames.append(ScriptCallFrame(callFrame->functionName(), scriptId, callF rame->scriptName(), line, column));
1194 }
1195 return ScriptCallStack::create(frames);
1196 }
1197
1198 PassRefPtr<ScriptAsyncCallStack> InspectorDebuggerAgent::currentAsyncStackTraceF orConsole()
1199 {
1200 if (!asyncCallStackTracker().isEnabled())
1201 return nullptr;
1202 const AsyncCallStackTracker::AsyncCallChain* chain = asyncCallStackTracker() .currentAsyncCallChain();
1203 if (!chain)
1204 return nullptr;
1205 const AsyncCallStackTracker::AsyncCallStackVector& callStacks = chain->callS tacks();
1206 if (callStacks.isEmpty())
1207 return nullptr;
1208 RefPtr<ScriptAsyncCallStack> result = nullptr;
1209 for (AsyncCallStackTracker::AsyncCallStackVector::const_reverse_iterator it = callStacks.rbegin(); it != callStacks.rend(); ++it) {
1210 RefPtr<JavaScriptCallFrame> callFrame = ScriptDebugServer::toJavaScriptC allFrameUnsafe((*it)->callFrames());
1211 if (!callFrame)
1212 break;
1213 result = ScriptAsyncCallStack::create((*it)->description(), toScriptCall Stack(callFrame.get()), result.release());
1214 }
1215 return result.release();
1216 }
1217
1218 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script, Compi leResult compileResult) 1205 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script, Compi leResult compileResult)
1219 { 1206 {
1220 bool hasSyntaxError = compileResult != CompileSuccess; 1207 bool hasSyntaxError = compileResult != CompileSuccess;
1221 if (hasSyntaxError) { 1208 if (hasSyntaxError) {
1222 bool deprecated; 1209 bool deprecated;
1223 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source , ContentSearchUtils::JavaScriptMagicComment, &deprecated); 1210 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source , ContentSearchUtils::JavaScriptMagicComment, &deprecated);
1224 if (!sourceMapURL.isEmpty()) 1211 if (!sourceMapURL.isEmpty())
1225 return sourceMapURL; 1212 return sourceMapURL;
1226 } 1213 }
1227 1214
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 m_scripts.clear(); 1429 m_scripts.clear();
1443 m_breakpointIdToDebugServerBreakpointIds.clear(); 1430 m_breakpointIdToDebugServerBreakpointIds.clear();
1444 asyncCallStackTracker().clear(); 1431 asyncCallStackTracker().clear();
1445 m_promiseTracker.clear(); 1432 m_promiseTracker.clear();
1446 if (m_frontend) 1433 if (m_frontend)
1447 m_frontend->globalObjectCleared(); 1434 m_frontend->globalObjectCleared();
1448 } 1435 }
1449 1436
1450 } // namespace blink 1437 } // namespace blink
1451 1438
OLDNEW
« no previous file with comments | « sky/engine/v8_inspector/InspectorDebuggerAgent.h ('k') | sky/engine/v8_inspector/InspectorFrontendChannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698