OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/inspector/v8-debugger-agent-impl.h" | 5 #include "src/inspector/v8-debugger-agent-impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/debug/debug-interface.h" | 9 #include "src/debug/debug-interface.h" |
10 #include "src/inspector/injected-script.h" | 10 #include "src/inspector/injected-script.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 enable(); | 157 enable(); |
158 } | 158 } |
159 | 159 |
160 void V8DebuggerAgentImpl::disable(ErrorString*) { | 160 void V8DebuggerAgentImpl::disable(ErrorString*) { |
161 if (!enabled()) return; | 161 if (!enabled()) return; |
162 | 162 |
163 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, | 163 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, |
164 protocol::DictionaryValue::create()); | 164 protocol::DictionaryValue::create()); |
165 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, | 165 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, |
166 V8Debugger::DontPauseOnExceptions); | 166 v8::DebugInterface::NoBreakOnException); |
167 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); | 167 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); |
168 | 168 |
169 if (!m_pausedContext.IsEmpty()) m_debugger->continueProgram(); | 169 if (!m_pausedContext.IsEmpty()) m_debugger->continueProgram(); |
170 m_debugger->disable(); | 170 m_debugger->disable(); |
171 m_pausedContext.Reset(); | 171 m_pausedContext.Reset(); |
172 JavaScriptCallFrames emptyCallFrames; | 172 JavaScriptCallFrames emptyCallFrames; |
173 m_pausedCallFrames.swap(emptyCallFrames); | 173 m_pausedCallFrames.swap(emptyCallFrames); |
174 m_scripts.clear(); | 174 m_scripts.clear(); |
175 m_blackboxedPositions.clear(); | 175 m_blackboxedPositions.clear(); |
176 m_breakpointIdToDebuggerBreakpointIds.clear(); | 176 m_breakpointIdToDebuggerBreakpointIds.clear(); |
(...skipping 17 matching lines...) Expand all Loading... |
194 void V8DebuggerAgentImpl::restore() { | 194 void V8DebuggerAgentImpl::restore() { |
195 DCHECK(!m_enabled); | 195 DCHECK(!m_enabled); |
196 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) | 196 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) |
197 return; | 197 return; |
198 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) | 198 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) |
199 return; | 199 return; |
200 | 200 |
201 enable(); | 201 enable(); |
202 ErrorString error; | 202 ErrorString error; |
203 | 203 |
204 int pauseState = V8Debugger::DontPauseOnExceptions; | 204 int pauseState = v8::DebugInterface::NoBreakOnException; |
205 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState); | 205 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState); |
206 setPauseOnExceptionsImpl(&error, pauseState); | 206 setPauseOnExceptionsImpl(&error, pauseState); |
207 DCHECK(error.isEmpty()); | 207 DCHECK(error.isEmpty()); |
208 | 208 |
209 m_skipAllPauses = | 209 m_skipAllPauses = |
210 m_state->booleanProperty(DebuggerAgentState::skipAllPauses, false); | 210 m_state->booleanProperty(DebuggerAgentState::skipAllPauses, false); |
211 | 211 |
212 int asyncCallStackDepth = 0; | 212 int asyncCallStackDepth = 0; |
213 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, | 213 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, |
214 &asyncCallStackDepth); | 214 &asyncCallStackDepth); |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 m_skipNextDebuggerStepOut = false; | 681 m_skipNextDebuggerStepOut = false; |
682 m_recursionLevelForStepOut = 1; | 682 m_recursionLevelForStepOut = 1; |
683 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 683 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
684 m_session->releaseObjectGroup(backtraceObjectGroup); | 684 m_session->releaseObjectGroup(backtraceObjectGroup); |
685 m_debugger->stepOutOfFunction(); | 685 m_debugger->stepOutOfFunction(); |
686 } | 686 } |
687 | 687 |
688 void V8DebuggerAgentImpl::setPauseOnExceptions( | 688 void V8DebuggerAgentImpl::setPauseOnExceptions( |
689 ErrorString* errorString, const String16& stringPauseState) { | 689 ErrorString* errorString, const String16& stringPauseState) { |
690 if (!checkEnabled(errorString)) return; | 690 if (!checkEnabled(errorString)) return; |
691 V8Debugger::PauseOnExceptionsState pauseState; | 691 v8::DebugInterface::ExceptionBreakState pauseState; |
692 if (stringPauseState == "none") { | 692 if (stringPauseState == "none") { |
693 pauseState = V8Debugger::DontPauseOnExceptions; | 693 pauseState = v8::DebugInterface::NoBreakOnException; |
694 } else if (stringPauseState == "all") { | 694 } else if (stringPauseState == "all") { |
695 pauseState = V8Debugger::PauseOnAllExceptions; | 695 pauseState = v8::DebugInterface::BreakOnAnyException; |
696 } else if (stringPauseState == "uncaught") { | 696 } else if (stringPauseState == "uncaught") { |
697 pauseState = V8Debugger::PauseOnUncaughtExceptions; | 697 pauseState = v8::DebugInterface::BreakOnUncaughtException; |
698 } else { | 698 } else { |
699 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; | 699 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; |
700 return; | 700 return; |
701 } | 701 } |
702 setPauseOnExceptionsImpl(errorString, pauseState); | 702 setPauseOnExceptionsImpl(errorString, pauseState); |
703 } | 703 } |
704 | 704 |
705 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, | 705 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, |
706 int pauseState) { | 706 int pauseState) { |
707 m_debugger->setPauseOnExceptionsState( | 707 m_debugger->setPauseOnExceptionsState( |
708 static_cast<V8Debugger::PauseOnExceptionsState>(pauseState)); | 708 static_cast<v8::DebugInterface::ExceptionBreakState>(pauseState)); |
709 if (m_debugger->getPauseOnExceptionsState() != pauseState) | 709 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); |
710 *errorString = "Internal error. Could not change pause on exceptions state"; | |
711 else | |
712 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); | |
713 } | 710 } |
714 | 711 |
715 void V8DebuggerAgentImpl::evaluateOnCallFrame( | 712 void V8DebuggerAgentImpl::evaluateOnCallFrame( |
716 ErrorString* errorString, const String16& callFrameId, | 713 ErrorString* errorString, const String16& callFrameId, |
717 const String16& expression, const Maybe<String16>& objectGroup, | 714 const String16& expression, const Maybe<String16>& objectGroup, |
718 const Maybe<bool>& includeCommandLineAPI, const Maybe<bool>& silent, | 715 const Maybe<bool>& includeCommandLineAPI, const Maybe<bool>& silent, |
719 const Maybe<bool>& returnByValue, const Maybe<bool>& generatePreview, | 716 const Maybe<bool>& returnByValue, const Maybe<bool>& generatePreview, |
720 std::unique_ptr<RemoteObject>* result, | 717 std::unique_ptr<RemoteObject>* result, |
721 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { | 718 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { |
722 if (!assertPaused(errorString)) return; | 719 if (!assertPaused(errorString)) return; |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 m_steppingFromFramework = false; | 1200 m_steppingFromFramework = false; |
1204 m_pausingOnNativeEvent = false; | 1201 m_pausingOnNativeEvent = false; |
1205 m_debugger->breakProgram(); | 1202 m_debugger->breakProgram(); |
1206 } | 1203 } |
1207 | 1204 |
1208 void V8DebuggerAgentImpl::breakProgramOnException( | 1205 void V8DebuggerAgentImpl::breakProgramOnException( |
1209 const String16& breakReason, | 1206 const String16& breakReason, |
1210 std::unique_ptr<protocol::DictionaryValue> data) { | 1207 std::unique_ptr<protocol::DictionaryValue> data) { |
1211 if (!enabled() || | 1208 if (!enabled() || |
1212 m_debugger->getPauseOnExceptionsState() == | 1209 m_debugger->getPauseOnExceptionsState() == |
1213 V8Debugger::DontPauseOnExceptions) | 1210 v8::DebugInterface::NoBreakOnException) |
1214 return; | 1211 return; |
1215 breakProgram(breakReason, std::move(data)); | 1212 breakProgram(breakReason, std::move(data)); |
1216 } | 1213 } |
1217 | 1214 |
1218 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) { | 1215 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) { |
1219 if (m_pausedContext.IsEmpty()) { | 1216 if (m_pausedContext.IsEmpty()) { |
1220 *errorString = "Can only perform operation while paused."; | 1217 *errorString = "Can only perform operation while paused."; |
1221 return false; | 1218 return false; |
1222 } | 1219 } |
1223 return true; | 1220 return true; |
(...skipping 23 matching lines...) Expand all Loading... |
1247 | 1244 |
1248 void V8DebuggerAgentImpl::reset() { | 1245 void V8DebuggerAgentImpl::reset() { |
1249 if (!enabled()) return; | 1246 if (!enabled()) return; |
1250 m_scheduledDebuggerStep = NoStep; | 1247 m_scheduledDebuggerStep = NoStep; |
1251 m_scripts.clear(); | 1248 m_scripts.clear(); |
1252 m_blackboxedPositions.clear(); | 1249 m_blackboxedPositions.clear(); |
1253 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1250 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1254 } | 1251 } |
1255 | 1252 |
1256 } // namespace v8_inspector | 1253 } // namespace v8_inspector |
OLD | NEW |