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

Side by Side Diff: Source/core/inspector/InspectorDebuggerAgent.cpp

Issue 290633009: DevTools: Show detailed information for exceptions during snippet execution. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 /* 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/inspector/InspectorState.h" 43 #include "core/inspector/InspectorState.h"
44 #include "core/inspector/InstrumentingAgents.h" 44 #include "core/inspector/InstrumentingAgents.h"
45 #include "core/inspector/ScriptArguments.h" 45 #include "core/inspector/ScriptArguments.h"
46 #include "core/inspector/ScriptCallStack.h" 46 #include "core/inspector/ScriptCallStack.h"
47 #include "platform/JSONValues.h" 47 #include "platform/JSONValues.h"
48 #include "wtf/text/WTFString.h" 48 #include "wtf/text/WTFString.h"
49 49
50 using WebCore::TypeBuilder::Array; 50 using WebCore::TypeBuilder::Array;
51 using WebCore::TypeBuilder::Debugger::BreakpointId; 51 using WebCore::TypeBuilder::Debugger::BreakpointId;
52 using WebCore::TypeBuilder::Debugger::CallFrame; 52 using WebCore::TypeBuilder::Debugger::CallFrame;
53 using WebCore::TypeBuilder::Debugger::ExceptionDetails;
53 using WebCore::TypeBuilder::Debugger::FunctionDetails; 54 using WebCore::TypeBuilder::Debugger::FunctionDetails;
54 using WebCore::TypeBuilder::Debugger::ScriptId; 55 using WebCore::TypeBuilder::Debugger::ScriptId;
55 using WebCore::TypeBuilder::Debugger::StackTrace; 56 using WebCore::TypeBuilder::Debugger::StackTrace;
56 using WebCore::TypeBuilder::Runtime::RemoteObject; 57 using WebCore::TypeBuilder::Runtime::RemoteObject;
57 58
58 namespace WebCore { 59 namespace WebCore {
59 60
60 namespace DebuggerAgentState { 61 namespace DebuggerAgentState {
61 static const char debuggerEnabled[] = "debuggerEnabled"; 62 static const char debuggerEnabled[] = "debuggerEnabled";
62 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; 63 static const char javaScriptBreakpoints[] = "javaScriptBreakopints";
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 929
929 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, asyncCal lStacks, callFrameId, expression, objectGroup ? *objectGroup : "", includeComman dLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : fals e, generatePreview ? *generatePreview : false, &result, wasThrown); 930 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, asyncCal lStacks, callFrameId, expression, objectGroup ? *objectGroup : "", includeComman dLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : fals e, generatePreview ? *generatePreview : false, &result, wasThrown);
930 931
931 if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteCon sole : false) { 932 if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteCon sole : false) {
932 unmuteConsole(); 933 unmuteConsole();
933 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 934 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
934 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 935 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
935 } 936 }
936 } 937 }
937 938
938 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, const int* executionContextId, TypeBuild er::OptOutput<ScriptId>* scriptId, TypeBuilder::OptOutput<String>* syntaxErrorMe ssage, TypeBuilder::OptOutput<int>* lineNumber, TypeBuilder::OptOutput<int>* col umnNumber) 939 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, const int* executionContextId, TypeBuild er::OptOutput<ScriptId>* scriptId, RefPtr<TypeBuilder::Debugger::ExceptionDetail s>& exceptionDetails)
939 { 940 {
940 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 941 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
941 if (injectedScript.isEmpty()) { 942 if (injectedScript.isEmpty()) {
942 *errorString = "Inspected frame has gone"; 943 *errorString = "Inspected frame has gone";
943 return; 944 return;
944 } 945 }
945 946
946 String scriptIdValue; 947 String scriptIdValue;
947 String exceptionMessage; 948 String exceptionDetailsText;
948 int lineNumberValue = 0; 949 int lineNumberValue = 0;
949 int columnNumberValue = 0; 950 int columnNumberValue = 0;
950 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionMessage, &lineNumberValue, &columnNumberVal ue); 951 RefPtr<ScriptCallStack> stackTraceValue;
951 if (!scriptIdValue && !exceptionMessage) { 952 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionDetailsText, &lineNumberValue, &columnNumbe rValue, &stackTraceValue);
953 if (!scriptIdValue && !exceptionDetailsText) {
952 *errorString = "Script compilation failed"; 954 *errorString = "Script compilation failed";
953 return; 955 return;
954 } 956 }
955 *syntaxErrorMessage = exceptionMessage;
956 *scriptId = scriptIdValue; 957 *scriptId = scriptIdValue;
957 *lineNumber = lineNumberValue; 958 if (!!scriptIdValue)
vsevik 2014/05/22 15:56:15 "if (scriptIdValue)" is well enough.
958 *columnNumber = columnNumberValue; 959 return;
960
961 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsText);
962 exceptionDetails->setLine(lineNumberValue);
963 exceptionDetails->setColumn(columnNumberValue);
964 if (stackTraceValue && stackTraceValue->size() > 0)
965 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray());
959 } 966 }
960 967
961 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown, TypeBuilder::OptOutput<int>* lineNumbe r, TypeBuilder::OptOutput<int>* columnNumber) 968 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<RemoteObject>& result, RefPtr<TypeBuilder::Debugger::ExceptionDetails>& exceptionDetails)
962 { 969 {
963 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 970 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
964 if (injectedScript.isEmpty()) { 971 if (injectedScript.isEmpty()) {
965 *errorString = "Inspected frame has gone"; 972 *errorString = "Inspected frame has gone";
966 return; 973 return;
967 } 974 }
968 975
969 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState(); 976 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState();
970 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) { 977 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) {
971 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions) 978 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions)
972 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions); 979 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions);
973 muteConsole(); 980 muteConsole();
974 } 981 }
975 982
976 ScriptValue value; 983 ScriptValue value;
977 bool wasThrownValue; 984 bool wasThrownValue;
978 String exceptionMessage; 985 String exceptionDetailsText;
979 int lineNumberValue = 0; 986 int lineNumberValue = 0;
980 int columnNumberValue = 0; 987 int columnNumberValue = 0;
981 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value , &wasThrownValue, &exceptionMessage, &lineNumberValue, &columnNumberValue); 988 RefPtr<ScriptCallStack> stackTraceValue;
982 *wasThrown = wasThrownValue; 989 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value , &wasThrownValue, &exceptionDetailsText, &lineNumberValue, &columnNumberValue, &stackTraceValue);
983 if (value.isEmpty()) { 990 if (value.isEmpty()) {
984 *errorString = "Script execution failed"; 991 *errorString = "Script execution failed";
985 return; 992 return;
986 } 993 }
987 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); 994 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
988 if (wasThrownValue) 995 if (wasThrownValue) {
989 { 996 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsTe xt);
990 result->setDescription(exceptionMessage); 997 exceptionDetails->setLine(lineNumberValue);
991 *lineNumber = lineNumberValue; 998 exceptionDetails->setColumn(columnNumberValue);
992 *columnNumber = columnNumberValue; 999 if (stackTraceValue && stackTraceValue->size() > 0)
1000 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray ());
993 } 1001 }
994 1002
995 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) { 1003 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) {
996 unmuteConsole(); 1004 unmuteConsole();
997 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 1005 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
998 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 1006 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
999 } 1007 }
1000 } 1008 }
1001 1009
1002 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*) 1010 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*)
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 m_scripts.clear(); 1330 m_scripts.clear();
1323 m_breakpointIdToDebugServerBreakpointIds.clear(); 1331 m_breakpointIdToDebugServerBreakpointIds.clear();
1324 m_asyncCallStackTracker.clear(); 1332 m_asyncCallStackTracker.clear();
1325 m_promiseTracker.clear(); 1333 m_promiseTracker.clear();
1326 if (m_frontend) 1334 if (m_frontend)
1327 m_frontend->globalObjectCleared(); 1335 m_frontend->globalObjectCleared();
1328 } 1336 }
1329 1337
1330 } // namespace WebCore 1338 } // namespace WebCore
1331 1339
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698