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) 2014 Google Inc. All rights reserved. | 3 * Copyright (C) 2014 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return String(); | 100 return String(); |
101 } | 101 } |
102 | 102 |
103 static String generateBreakpointIdDart(const String& scriptId, int lineNumber, i
nt columnNumber, DartInspectorDebuggerAgent::BreakpointSource source) | 103 static String generateBreakpointIdDart(const String& scriptId, int lineNumber, i
nt columnNumber, DartInspectorDebuggerAgent::BreakpointSource source) |
104 { | 104 { |
105 return scriptId + ':' + String::number(lineNumber) + ':' + String::number(co
lumnNumber) + breakpointIdSuffixDart(source); | 105 return scriptId + ':' + String::number(lineNumber) + ':' + String::number(co
lumnNumber) + breakpointIdSuffixDart(source); |
106 } | 106 } |
107 | 107 |
108 DartInspectorDebuggerAgent::DartInspectorDebuggerAgent(DartInjectedScriptManager
* injectedScriptManager, InspectorDebuggerAgent* inspectorDebuggerAgent, Inspect
orPageAgent* pageAgent) | 108 DartInspectorDebuggerAgent::DartInspectorDebuggerAgent(DartInjectedScriptManager
* injectedScriptManager, InspectorDebuggerAgent* inspectorDebuggerAgent, Inspect
orPageAgent* pageAgent) |
109 : m_injectedScriptManager(injectedScriptManager) | 109 : m_injectedScriptManager(injectedScriptManager) |
110 , m_frontend(0) | |
111 , m_pausedScriptState(nullptr) | 110 , m_pausedScriptState(nullptr) |
112 , m_currentCallStack(0) | 111 , m_currentCallStack(0) |
113 , m_javaScriptPauseScheduled(false) | 112 , m_javaScriptPauseScheduled(false) |
114 , m_debuggerStepScheduled(false) | 113 , m_debuggerStepScheduled(false) |
115 , m_steppingFromFramework(false) | 114 , m_steppingFromFramework(false) |
116 , m_pausingOnNativeEvent(false) | 115 , m_pausingOnNativeEvent(false) |
117 , m_listener(nullptr) | 116 , m_listener(nullptr) |
118 , m_skippedStepInCount(0) | 117 , m_skippedStepInCount(0) |
119 , m_skipAllPauses(false) | 118 , m_skipAllPauses(false) |
120 , m_inspectorDebuggerAgent(inspectorDebuggerAgent) | 119 , m_inspectorDebuggerAgent(inspectorDebuggerAgent) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 170 } |
172 | 171 |
173 void DartInspectorDebuggerAgent::enable(ErrorString*) | 172 void DartInspectorDebuggerAgent::enable(ErrorString*) |
174 { | 173 { |
175 if (enabled()) | 174 if (enabled()) |
176 return; | 175 return; |
177 | 176 |
178 enable(); | 177 enable(); |
179 state()->setBoolean(DartDebuggerAgentState::debuggerEnabled, true); | 178 state()->setBoolean(DartDebuggerAgentState::debuggerEnabled, true); |
180 | 179 |
181 ASSERT(m_frontend); | 180 ASSERT(frontend()); |
182 } | 181 } |
183 | 182 |
184 void DartInspectorDebuggerAgent::disable(ErrorString*) | 183 void DartInspectorDebuggerAgent::disable(ErrorString*) |
185 { | 184 { |
186 if (!enabled()) | 185 if (!enabled()) |
187 return; | 186 return; |
188 | 187 |
189 disable(); | 188 disable(); |
190 state()->setBoolean(DartDebuggerAgentState::debuggerEnabled, false); | 189 state()->setBoolean(DartDebuggerAgentState::debuggerEnabled, false); |
191 } | 190 } |
192 | 191 |
193 static PassOwnPtr<ScriptRegexp> compileSkipCallFramePattern(String patternText) | 192 static PassOwnPtr<ScriptRegexp> compileSkipCallFramePattern(String patternText) |
194 { | 193 { |
195 if (patternText.isEmpty()) | 194 if (patternText.isEmpty()) |
196 return nullptr; | 195 return nullptr; |
197 OwnPtr<ScriptRegexp> result = adoptPtr(new ScriptRegexp(patternText, TextCas
eSensitive)); | 196 OwnPtr<ScriptRegexp> result = adoptPtr(new ScriptRegexp(patternText, TextCas
eSensitive)); |
198 if (!result->isValid()) | 197 if (!result->isValid()) |
199 result.clear(); | 198 result.clear(); |
200 return result.release(); | 199 return result.release(); |
201 } | 200 } |
202 | 201 |
203 void DartInspectorDebuggerAgent::restore() | 202 void DartInspectorDebuggerAgent::restore() |
204 { | 203 { |
205 if (enabled()) { | 204 if (enabled()) { |
206 m_frontend->globalObjectCleared(); | 205 frontend()->globalObjectCleared(); |
207 enable(); | 206 enable(); |
208 long pauseState = state()->getLong(DartDebuggerAgentState::pauseOnExcept
ionsState); | 207 long pauseState = state()->getLong(DartDebuggerAgentState::pauseOnExcept
ionsState); |
209 String error; | 208 String error; |
210 setPauseOnExceptionsImpl(&error, pauseState); | 209 setPauseOnExceptionsImpl(&error, pauseState); |
211 m_cachedSkipStackRegExp = compileSkipCallFramePattern(state()->getString
(DartDebuggerAgentState::skipStackPattern)); | 210 m_cachedSkipStackRegExp = compileSkipCallFramePattern(state()->getString
(DartDebuggerAgentState::skipStackPattern)); |
212 m_skipAllPauses = state()->getBoolean(DartDebuggerAgentState::skipAllPau
ses); | 211 m_skipAllPauses = state()->getBoolean(DartDebuggerAgentState::skipAllPau
ses); |
213 if (m_skipAllPauses && state()->getBoolean(DartDebuggerAgentState::skipA
llPausesExpiresOnReload)) { | 212 if (m_skipAllPauses && state()->getBoolean(DartDebuggerAgentState::skipA
llPausesExpiresOnReload)) { |
214 m_skipAllPauses = false; | 213 m_skipAllPauses = false; |
215 state()->setBoolean(DartDebuggerAgentState::skipAllPauses, false); | 214 state()->setBoolean(DartDebuggerAgentState::skipAllPauses, false); |
216 } | 215 } |
217 } | 216 } |
218 } | 217 } |
219 | 218 |
220 void DartInspectorDebuggerAgent::setFrontend(InspectorFrontend* frontend) | 219 InspectorFrontend::Debugger* DartInspectorDebuggerAgent::frontend() |
221 { | 220 { |
222 m_frontend = InspectorFrontend::Debugger::from(frontend); | 221 return m_inspectorDebuggerAgent->frontend(); |
223 } | 222 } |
224 | 223 |
| 224 |
225 void DartInspectorDebuggerAgent::clearFrontend() | 225 void DartInspectorDebuggerAgent::clearFrontend() |
226 { | 226 { |
227 m_frontend = 0; | |
228 | |
229 if (!enabled()) | 227 if (!enabled()) |
230 return; | 228 return; |
231 | 229 |
232 disable(); | 230 disable(); |
233 | 231 |
234 // FIXME: due to state()->mute() hack in InspectorController, debuggerEnable
d is actually set to false only | 232 // FIXME: due to state()->mute() hack in InspectorController, debuggerEnable
d is actually set to false only |
235 // in InspectorState, but not in cookie. That's why after navigation debugge
rEnabled will be true, | 233 // in InspectorState, but not in cookie. That's why after navigation debugge
rEnabled will be true, |
236 // but after front-end re-open it will still be false. | 234 // but after front-end re-open it will still be false. |
237 state()->setBoolean(DartDebuggerAgentState::debuggerEnabled, false); | 235 state()->setBoolean(DartDebuggerAgentState::debuggerEnabled, false); |
238 } | 236 } |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 } | 863 } |
866 | 864 |
867 const bool* isInternalScript = script.isInternalScript ? &script.isInternalS
cript : 0; | 865 const bool* isInternalScript = script.isInternalScript ? &script.isInternalS
cript : 0; |
868 bool hasSourceURL = !script.sourceURL.isEmpty(); | 866 bool hasSourceURL = !script.sourceURL.isEmpty(); |
869 String scriptURL = hasSourceURL ? script.sourceURL : script.url; | 867 String scriptURL = hasSourceURL ? script.sourceURL : script.url; |
870 | 868 |
871 String sourceMapURL = sourceMapURLForScript(script, compileResult); | 869 String sourceMapURL = sourceMapURLForScript(script, compileResult); |
872 String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL; | 870 String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL; |
873 | 871 |
874 bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0; | 872 bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0; |
| 873 ASSERT(frontend()); |
875 if (!hasSyntaxError) | 874 if (!hasSyntaxError) |
876 m_frontend->scriptParsed(scriptId, scriptURL, script.startLine, script.s
tartColumn, script.endLine, script.endColumn, isContentScript, isInternalScript,
sourceMapURLParam, hasSourceURLParam, languageParam, libraryIdParam); | 875 frontend()->scriptParsed(scriptId, scriptURL, script.startLine, script.s
tartColumn, script.endLine, script.endColumn, isContentScript, isInternalScript,
sourceMapURLParam, hasSourceURLParam, languageParam, libraryIdParam); |
877 else | 876 else |
878 m_frontend->scriptFailedToParse(scriptId, scriptURL, script.startLine, s
cript.startColumn, script.endLine, script.endColumn, isContentScript, isInternal
Script, sourceMapURLParam, hasSourceURLParam, languageParam, libraryIdParam); | 877 frontend()->scriptFailedToParse(scriptId, scriptURL, script.startLine, s
cript.startColumn, script.endLine, script.endColumn, isContentScript, isInternal
Script, sourceMapURLParam, hasSourceURLParam, languageParam, libraryIdParam); |
879 | 878 |
880 m_scripts.set(scriptId, script); | 879 m_scripts.set(scriptId, script); |
881 | 880 |
882 if (scriptURL.isEmpty() || hasSyntaxError) | 881 if (scriptURL.isEmpty() || hasSyntaxError) |
883 return; | 882 return; |
884 | 883 |
885 RefPtr<JSONObject> breakpointsCookie = state()->getObject(DartDebuggerAgentS
tate::dartBreakpoints); | 884 RefPtr<JSONObject> breakpointsCookie = state()->getObject(DartDebuggerAgentS
tate::dartBreakpoints); |
886 for (JSONObject::iterator it = breakpointsCookie->begin(); it != breakpoints
Cookie->end(); ++it) { | 885 for (JSONObject::iterator it = breakpointsCookie->begin(); it != breakpoints
Cookie->end(); ++it) { |
887 RefPtr<JSONObject> breakpointObject = it->value->asObject(); | 886 RefPtr<JSONObject> breakpointObject = it->value->asObject(); |
888 bool isAntibreakpoint; | 887 bool isAntibreakpoint; |
889 breakpointObject->getBoolean(DartDebuggerAgentState::isAnti, &isAntibrea
kpoint); | 888 breakpointObject->getBoolean(DartDebuggerAgentState::isAnti, &isAntibrea
kpoint); |
890 if (isAntibreakpoint) | 889 if (isAntibreakpoint) |
891 continue; | 890 continue; |
892 bool isRegex; | 891 bool isRegex; |
893 breakpointObject->getBoolean(DartDebuggerAgentState::isRegex, &isRegex); | 892 breakpointObject->getBoolean(DartDebuggerAgentState::isRegex, &isRegex); |
894 String url; | 893 String url; |
895 breakpointObject->getString(DartDebuggerAgentState::url, &url); | 894 breakpointObject->getString(DartDebuggerAgentState::url, &url); |
896 if (!matches(scriptURL, url, isRegex)) | 895 if (!matches(scriptURL, url, isRegex)) |
897 continue; | 896 continue; |
898 ScriptBreakpoint breakpoint; | 897 ScriptBreakpoint breakpoint; |
899 breakpointObject->getNumber(DartDebuggerAgentState::lineNumber, &breakpo
int.lineNumber); | 898 breakpointObject->getNumber(DartDebuggerAgentState::lineNumber, &breakpo
int.lineNumber); |
900 breakpointObject->getNumber(DartDebuggerAgentState::columnNumber, &break
point.columnNumber); | 899 breakpointObject->getNumber(DartDebuggerAgentState::columnNumber, &break
point.columnNumber); |
901 breakpointObject->getString(DartDebuggerAgentState::condition, &breakpoi
nt.condition); | 900 breakpointObject->getString(DartDebuggerAgentState::condition, &breakpoi
nt.condition); |
902 RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(it-
>key, scriptId, breakpoint, UserBreakpointSource); | 901 RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(it-
>key, scriptId, breakpoint, UserBreakpointSource); |
903 if (location) | 902 if (location) |
904 m_frontend->breakpointResolved(it->key, location); | 903 frontend()->breakpointResolved(it->key, location); |
905 } | 904 } |
906 } | 905 } |
907 | 906 |
908 DartScriptDebugListener::SkipPauseRequest DartInspectorDebuggerAgent::didPause(D
artScriptState* scriptState, Dart_StackTrace callFrames, Dart_Handle exception,
const Vector<String>& hitBreakpoints) | 907 DartScriptDebugListener::SkipPauseRequest DartInspectorDebuggerAgent::didPause(D
artScriptState* scriptState, Dart_StackTrace callFrames, Dart_Handle exception,
const Vector<String>& hitBreakpoints) |
909 { | 908 { |
910 DartScriptDebugListener::SkipPauseRequest result; | 909 DartScriptDebugListener::SkipPauseRequest result; |
911 if (!callFrames) | 910 if (!callFrames) |
912 result = DartScriptDebugListener::Continue; // Skip pauses inside V8 int
ernal scripts and on syntax errors. | 911 result = DartScriptDebugListener::Continue; // Skip pauses inside V8 int
ernal scripts and on syntax errors. |
913 else if (m_javaScriptPauseScheduled) | 912 else if (m_javaScriptPauseScheduled) |
914 result = DartScriptDebugListener::NoSkip; // Don't skip explicit pause r
equests from front-end. | 913 result = DartScriptDebugListener::NoSkip; // Don't skip explicit pause r
equests from front-end. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 if (breakpointIterator != m_serverBreakpoints.end()) { | 945 if (breakpointIterator != m_serverBreakpoints.end()) { |
947 const String& localId = breakpointIterator->value.first; | 946 const String& localId = breakpointIterator->value.first; |
948 hitBreakpointIds->addItem(localId); | 947 hitBreakpointIds->addItem(localId); |
949 | 948 |
950 BreakpointSource source = breakpointIterator->value.second; | 949 BreakpointSource source = breakpointIterator->value.second; |
951 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) | 950 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) |
952 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; | 951 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; |
953 } | 952 } |
954 } | 953 } |
955 | 954 |
956 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr
eakpointIds, nullptr); | 955 frontend()->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr
eakpointIds, nullptr); |
957 m_javaScriptPauseScheduled = false; | 956 m_javaScriptPauseScheduled = false; |
958 m_debuggerStepScheduled = false; | 957 m_debuggerStepScheduled = false; |
959 m_steppingFromFramework = false; | 958 m_steppingFromFramework = false; |
960 m_pausingOnNativeEvent = false; | 959 m_pausingOnNativeEvent = false; |
961 m_skippedStepInCount = 0; | 960 m_skippedStepInCount = 0; |
962 | 961 |
963 if (!m_continueToLocationBreakpointId.isEmpty()) { | 962 if (!m_continueToLocationBreakpointId.isEmpty()) { |
964 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); | 963 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); |
965 m_continueToLocationBreakpointId = ""; | 964 m_continueToLocationBreakpointId = ""; |
966 } | 965 } |
967 if (m_listener) | 966 if (m_listener) |
968 m_listener->didPause(); | 967 m_listener->didPause(); |
969 return result; | 968 return result; |
970 } | 969 } |
971 | 970 |
972 void DartInspectorDebuggerAgent::didContinue() | 971 void DartInspectorDebuggerAgent::didContinue() |
973 { | 972 { |
974 m_pausedScriptState = nullptr; | 973 m_pausedScriptState = nullptr; |
975 m_currentCallStack = 0; | 974 m_currentCallStack = 0; |
976 clearBreakDetails(); | 975 clearBreakDetails(); |
977 // Already called by InspectorDebuggerAgent? | 976 // Already called by InspectorDebuggerAgent? |
978 m_frontend->resumed(); | 977 frontend()->resumed(); |
979 } | 978 } |
980 | 979 |
981 bool DartInspectorDebuggerAgent::canBreakProgram() | 980 bool DartInspectorDebuggerAgent::canBreakProgram() |
982 { | 981 { |
983 return scriptDebugServer().canBreakProgram(); | 982 return scriptDebugServer().canBreakProgram(); |
984 } | 983 } |
985 | 984 |
986 void DartInspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reaso
n::Enum breakReason, PassRefPtr<JSONObject> data) | 985 void DartInspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reaso
n::Enum breakReason, PassRefPtr<JSONObject> data) |
987 { | 986 { |
988 if (m_skipAllPauses) | 987 if (m_skipAllPauses) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1043 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1045 } | 1044 } |
1046 | 1045 |
1047 DartScriptDebugServer& DartInspectorDebuggerAgent::scriptDebugServer() | 1046 DartScriptDebugServer& DartInspectorDebuggerAgent::scriptDebugServer() |
1048 { | 1047 { |
1049 return DartScriptDebugServer::shared(); | 1048 return DartScriptDebugServer::shared(); |
1050 } | 1049 } |
1051 | 1050 |
1052 } // namespace blink | 1051 } // namespace blink |
1053 | 1052 |
OLD | NEW |