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

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::ExceptionMessage;
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) 939 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, const int* executionContextId, TypeBuild er::OptOutput<ScriptId>* scriptId, RefPtr<TypeBuilder::Debugger::ExceptionMessag e>& exceptionMessage)
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 exceptionMessageText;
948 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionMessage); 949 int lineNumberValue = 0;
949 if (!scriptIdValue && !exceptionMessage) { 950 int columnNumberValue = 0;
951 RefPtr<ScriptCallStack> stackTraceValue;
952 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, &scriptIdValue, &exceptionMessageText, &lineNumberValue, &columnNumbe rValue, &stackTraceValue);
953 if (!scriptIdValue && !exceptionMessageText) {
950 *errorString = "Script compilation failed"; 954 *errorString = "Script compilation failed";
951 return; 955 return;
952 } 956 }
953 *syntaxErrorMessage = exceptionMessage;
954 *scriptId = scriptIdValue; 957 *scriptId = scriptIdValue;
958 exceptionMessage = ExceptionMessage::create().setText(exceptionMessageText);
vsevik 2014/05/19 12:40:23 We should only do this when scriptIdValue is not s
959 exceptionMessage->setLine(lineNumberValue);
960 exceptionMessage->setColumn(columnNumberValue);
961 if (stackTraceValue && stackTraceValue->size() > 0)
962 exceptionMessage->setStackTrace(stackTraceValue->buildInspectorArray());
955 } 963 }
956 964
957 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) 965 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::ExceptionMessage>& exceptionMessage)
958 { 966 {
959 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 967 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
960 if (injectedScript.isEmpty()) { 968 if (injectedScript.isEmpty()) {
961 *errorString = "Inspected frame has gone"; 969 *errorString = "Inspected frame has gone";
962 return; 970 return;
963 } 971 }
964 972
965 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState(); 973 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState();
966 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) { 974 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) {
967 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions) 975 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions)
968 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions); 976 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions);
969 muteConsole(); 977 muteConsole();
970 } 978 }
971 979
972 ScriptValue value; 980 ScriptValue value;
973 bool wasThrownValue; 981 bool wasThrownValue;
974 String exceptionMessage; 982 String exceptionMessageText;
975 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value , &wasThrownValue, &exceptionMessage); 983 int lineNumberValue = 0;
976 *wasThrown = wasThrownValue; 984 int columnNumberValue = 0;
985 RefPtr<ScriptCallStack> stackTraceValue;
986 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value , &wasThrownValue, &exceptionMessageText, &lineNumberValue, &columnNumberValue, &stackTraceValue);
977 if (value.isEmpty()) { 987 if (value.isEmpty()) {
978 *errorString = "Script execution failed"; 988 *errorString = "Script execution failed";
979 return; 989 return;
980 } 990 }
981 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); 991 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
982 if (wasThrownValue) 992 if (wasThrownValue) {
983 result->setDescription(exceptionMessage); 993 exceptionMessage = ExceptionMessage::create().setText(exceptionMessageTe xt);
994 exceptionMessage->setLine(lineNumberValue);
995 exceptionMessage->setColumn(columnNumberValue);
996 if (stackTraceValue && stackTraceValue->size() > 0)
997 exceptionMessage->setStackTrace(stackTraceValue->buildInspectorArray ());
998 }
984 999
985 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) { 1000 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo nsole) {
986 unmuteConsole(); 1001 unmuteConsole();
987 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 1002 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
988 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 1003 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
989 } 1004 }
990 } 1005 }
991 1006
992 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*) 1007 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*)
993 { 1008 {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 m_scripts.clear(); 1327 m_scripts.clear();
1313 m_breakpointIdToDebugServerBreakpointIds.clear(); 1328 m_breakpointIdToDebugServerBreakpointIds.clear();
1314 m_asyncCallStackTracker.clear(); 1329 m_asyncCallStackTracker.clear();
1315 m_promiseTracker.clear(); 1330 m_promiseTracker.clear();
1316 if (m_frontend) 1331 if (m_frontend)
1317 m_frontend->globalObjectCleared(); 1332 m_frontend->globalObjectCleared();
1318 } 1333 }
1319 1334
1320 } // namespace WebCore 1335 } // namespace WebCore
1321 1336
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698