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

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, 6 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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 882
882 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, asyncCal lStacks, callFrameId, expression, objectGroup ? *objectGroup : "", includeComman dLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : fals e, generatePreview ? *generatePreview : false, &result, wasThrown); 883 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, asyncCal lStacks, callFrameId, expression, objectGroup ? *objectGroup : "", includeComman dLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : fals e, generatePreview ? *generatePreview : false, &result, wasThrown);
883 884
884 if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteCon sole : false) { 885 if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteCon sole : false) {
885 unmuteConsole(); 886 unmuteConsole();
886 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 887 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
887 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 888 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
888 } 889 }
889 } 890 }
890 891
891 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) 892 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, const int* executionContextId, TypeBuild er::OptOutput<ScriptId>* scriptId, RefPtr<ExceptionDetails>& exceptionDetails)
892 { 893 {
893 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 894 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
894 if (injectedScript.isEmpty()) { 895 if (injectedScript.isEmpty()) {
895 *errorString = "Inspected frame has gone"; 896 *errorString = "Inspected frame has gone";
896 return; 897 return;
897 } 898 }
898 899
899 String scriptIdValue; 900 String scriptIdValue;
900 String exceptionMessage; 901 String exceptionDetailsText;
901 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionMessage); 902 int lineNumberValue = 0;
902 if (!scriptIdValue && !exceptionMessage) { 903 int columnNumberValue = 0;
904 RefPtr<ScriptCallStack> stackTraceValue;
905 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionDetailsText, &lineNumberValue, &columnNumbe rValue, &stackTraceValue);
906 if (!scriptIdValue && !exceptionDetailsText) {
903 *errorString = "Script compilation failed"; 907 *errorString = "Script compilation failed";
904 return; 908 return;
905 } 909 }
906 *syntaxErrorMessage = exceptionMessage;
907 *scriptId = scriptIdValue; 910 *scriptId = scriptIdValue;
911 if (!scriptIdValue.isEmpty())
912 return;
913
914 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsText);
915 exceptionDetails->setLine(lineNumberValue);
916 exceptionDetails->setColumn(columnNumberValue);
917 if (stackTraceValue && stackTraceValue->size() > 0)
918 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray());
908 } 919 }
909 920
910 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) 921 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)
911 { 922 {
912 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 923 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
913 if (injectedScript.isEmpty()) { 924 if (injectedScript.isEmpty()) {
914 *errorString = "Inspected frame has gone"; 925 *errorString = "Inspected frame has gone";
915 return; 926 return;
916 } 927 }
917 928
918 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState(); 929 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState();
919 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) { 930 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) {
920 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions) 931 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions)
921 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions); 932 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions);
922 muteConsole(); 933 muteConsole();
923 } 934 }
924 935
925 ScriptValue value; 936 ScriptValue value;
926 bool wasThrownValue; 937 bool wasThrownValue;
927 String exceptionMessage; 938 String exceptionDetailsText;
928 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value , &wasThrownValue, &exceptionMessage); 939 int lineNumberValue = 0;
929 *wasThrown = wasThrownValue; 940 int columnNumberValue = 0;
941 RefPtr<ScriptCallStack> stackTraceValue;
942 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value , &wasThrownValue, &exceptionDetailsText, &lineNumberValue, &columnNumberValue, &stackTraceValue);
930 if (value.isEmpty()) { 943 if (value.isEmpty()) {
931 *errorString = "Script execution failed"; 944 *errorString = "Script execution failed";
932 return; 945 return;
933 } 946 }
934 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); 947 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
935 if (wasThrownValue) 948 if (wasThrownValue) {
936 result->setDescription(exceptionMessage); 949 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsTe xt);
950 exceptionDetails->setLine(lineNumberValue);
951 exceptionDetails->setColumn(columnNumberValue);
952 if (stackTraceValue && stackTraceValue->size() > 0)
953 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray ());
954 }
937 955
938 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) { 956 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) {
939 unmuteConsole(); 957 unmuteConsole();
940 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 958 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
941 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 959 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
942 } 960 }
943 } 961 }
944 962
945 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*) 963 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*)
946 { 964 {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 { 1265 {
1248 m_scripts.clear(); 1266 m_scripts.clear();
1249 m_breakpointIdToDebugServerBreakpointIds.clear(); 1267 m_breakpointIdToDebugServerBreakpointIds.clear();
1250 m_asyncCallStackTracker.clear(); 1268 m_asyncCallStackTracker.clear();
1251 if (m_frontend) 1269 if (m_frontend)
1252 m_frontend->globalObjectCleared(); 1270 m_frontend->globalObjectCleared();
1253 } 1271 }
1254 1272
1255 } // namespace WebCore 1273 } // namespace WebCore
1256 1274
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698