OLD | NEW |
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 Loading... |
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 Loading... |
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 if (!!scriptIdValue) |
| 959 return; |
| 960 |
| 961 exceptionMessage = ExceptionMessage::create().setText(exceptionMessageText); |
| 962 exceptionMessage->setLine(lineNumberValue); |
| 963 exceptionMessage->setColumn(columnNumberValue); |
| 964 if (stackTraceValue && stackTraceValue->size() > 0) |
| 965 exceptionMessage->setStackTrace(stackTraceValue->buildInspectorArray()); |
955 } | 966 } |
956 | 967 |
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) | 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::ExceptionMessage>& exceptionMessage) |
958 { | 969 { |
959 InjectedScript injectedScript = injectedScriptForEval(errorString, execution
ContextId); | 970 InjectedScript injectedScript = injectedScriptForEval(errorString, execution
ContextId); |
960 if (injectedScript.isEmpty()) { | 971 if (injectedScript.isEmpty()) { |
961 *errorString = "Inspected frame has gone"; | 972 *errorString = "Inspected frame has gone"; |
962 return; | 973 return; |
963 } | 974 } |
964 | 975 |
965 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
criptDebugServer().pauseOnExceptionsState(); | 976 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
criptDebugServer().pauseOnExceptionsState(); |
966 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo
nsole) { | 977 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo
nsole) { |
967 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce
ptions) | 978 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce
ptions) |
968 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don
tPauseOnExceptions); | 979 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don
tPauseOnExceptions); |
969 muteConsole(); | 980 muteConsole(); |
970 } | 981 } |
971 | 982 |
972 ScriptValue value; | 983 ScriptValue value; |
973 bool wasThrownValue; | 984 bool wasThrownValue; |
974 String exceptionMessage; | 985 String exceptionMessageText; |
975 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value
, &wasThrownValue, &exceptionMessage); | 986 int lineNumberValue = 0; |
976 *wasThrown = wasThrownValue; | 987 int columnNumberValue = 0; |
| 988 RefPtr<ScriptCallStack> stackTraceValue; |
| 989 scriptDebugServer().runScript(injectedScript.scriptState(), scriptId, &value
, &wasThrownValue, &exceptionMessageText, &lineNumberValue, &columnNumberValue,
&stackTraceValue); |
977 if (value.isEmpty()) { | 990 if (value.isEmpty()) { |
978 *errorString = "Script execution failed"; | 991 *errorString = "Script execution failed"; |
979 return; | 992 return; |
980 } | 993 } |
981 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); | 994 result = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); |
982 if (wasThrownValue) | 995 if (wasThrownValue) { |
983 result->setDescription(exceptionMessage); | 996 exceptionMessage = ExceptionMessage::create().setText(exceptionMessageTe
xt); |
| 997 exceptionMessage->setLine(lineNumberValue); |
| 998 exceptionMessage->setColumn(columnNumberValue); |
| 999 if (stackTraceValue && stackTraceValue->size() > 0) |
| 1000 exceptionMessage->setStackTrace(stackTraceValue->buildInspectorArray
()); |
| 1001 } |
984 | 1002 |
985 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo
nsole) { | 1003 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo
nsole) { |
986 unmuteConsole(); | 1004 unmuteConsole(); |
987 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep
tionsState) | 1005 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep
tionsState) |
988 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti
onsState); | 1006 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti
onsState); |
989 } | 1007 } |
990 } | 1008 } |
991 | 1009 |
992 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*) | 1010 void InspectorDebuggerAgent::setOverlayMessage(ErrorString*, const String*) |
993 { | 1011 { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 m_scripts.clear(); | 1330 m_scripts.clear(); |
1313 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1331 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1314 m_asyncCallStackTracker.clear(); | 1332 m_asyncCallStackTracker.clear(); |
1315 m_promiseTracker.clear(); | 1333 m_promiseTracker.clear(); |
1316 if (m_frontend) | 1334 if (m_frontend) |
1317 m_frontend->globalObjectCleared(); | 1335 m_frontend->globalObjectCleared(); |
1318 } | 1336 } |
1319 | 1337 |
1320 } // namespace WebCore | 1338 } // namespace WebCore |
1321 | 1339 |
OLD | NEW |