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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 enableImpl(); | 176 enableImpl(); |
177 return Response::OK(); | 177 return Response::OK(); |
178 } | 178 } |
179 | 179 |
180 Response V8DebuggerAgentImpl::disable() { | 180 Response V8DebuggerAgentImpl::disable() { |
181 if (!enabled()) return Response::OK(); | 181 if (!enabled()) return Response::OK(); |
182 | 182 |
183 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, | 183 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, |
184 protocol::DictionaryValue::create()); | 184 protocol::DictionaryValue::create()); |
185 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, | 185 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, |
186 v8::DebugInterface::NoBreakOnException); | 186 v8::debug::NoBreakOnException); |
187 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); | 187 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); |
188 | 188 |
189 if (!m_pausedContext.IsEmpty()) m_debugger->continueProgram(); | 189 if (!m_pausedContext.IsEmpty()) m_debugger->continueProgram(); |
190 m_debugger->disable(); | 190 m_debugger->disable(); |
191 m_pausedContext.Reset(); | 191 m_pausedContext.Reset(); |
192 JavaScriptCallFrames emptyCallFrames; | 192 JavaScriptCallFrames emptyCallFrames; |
193 m_pausedCallFrames.swap(emptyCallFrames); | 193 m_pausedCallFrames.swap(emptyCallFrames); |
194 m_scripts.clear(); | 194 m_scripts.clear(); |
195 m_blackboxedPositions.clear(); | 195 m_blackboxedPositions.clear(); |
196 m_breakpointIdToDebuggerBreakpointIds.clear(); | 196 m_breakpointIdToDebuggerBreakpointIds.clear(); |
(...skipping 17 matching lines...) Expand all Loading... |
214 | 214 |
215 void V8DebuggerAgentImpl::restore() { | 215 void V8DebuggerAgentImpl::restore() { |
216 DCHECK(!m_enabled); | 216 DCHECK(!m_enabled); |
217 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) | 217 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) |
218 return; | 218 return; |
219 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) | 219 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) |
220 return; | 220 return; |
221 | 221 |
222 enableImpl(); | 222 enableImpl(); |
223 | 223 |
224 int pauseState = v8::DebugInterface::NoBreakOnException; | 224 int pauseState = v8::debug::NoBreakOnException; |
225 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState); | 225 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState); |
226 setPauseOnExceptionsImpl(pauseState); | 226 setPauseOnExceptionsImpl(pauseState); |
227 | 227 |
228 m_skipAllPauses = | 228 m_skipAllPauses = |
229 m_state->booleanProperty(DebuggerAgentState::skipAllPauses, false); | 229 m_state->booleanProperty(DebuggerAgentState::skipAllPauses, false); |
230 | 230 |
231 int asyncCallStackDepth = 0; | 231 int asyncCallStackDepth = 0; |
232 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, | 232 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, |
233 &asyncCallStackDepth); | 233 &asyncCallStackDepth); |
234 m_debugger->setAsyncCallStackDepth(this, asyncCallStackDepth); | 234 m_debugger->setAsyncCallStackDepth(this, asyncCallStackDepth); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 m_recursionLevelForStepOut = 1; | 719 m_recursionLevelForStepOut = 1; |
720 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 720 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
721 m_session->releaseObjectGroup(kBacktraceObjectGroup); | 721 m_session->releaseObjectGroup(kBacktraceObjectGroup); |
722 m_debugger->stepOutOfFunction(); | 722 m_debugger->stepOutOfFunction(); |
723 return Response::OK(); | 723 return Response::OK(); |
724 } | 724 } |
725 | 725 |
726 Response V8DebuggerAgentImpl::setPauseOnExceptions( | 726 Response V8DebuggerAgentImpl::setPauseOnExceptions( |
727 const String16& stringPauseState) { | 727 const String16& stringPauseState) { |
728 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 728 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
729 v8::DebugInterface::ExceptionBreakState pauseState; | 729 v8::debug::ExceptionBreakState pauseState; |
730 if (stringPauseState == "none") { | 730 if (stringPauseState == "none") { |
731 pauseState = v8::DebugInterface::NoBreakOnException; | 731 pauseState = v8::debug::NoBreakOnException; |
732 } else if (stringPauseState == "all") { | 732 } else if (stringPauseState == "all") { |
733 pauseState = v8::DebugInterface::BreakOnAnyException; | 733 pauseState = v8::debug::BreakOnAnyException; |
734 } else if (stringPauseState == "uncaught") { | 734 } else if (stringPauseState == "uncaught") { |
735 pauseState = v8::DebugInterface::BreakOnUncaughtException; | 735 pauseState = v8::debug::BreakOnUncaughtException; |
736 } else { | 736 } else { |
737 return Response::Error("Unknown pause on exceptions mode: " + | 737 return Response::Error("Unknown pause on exceptions mode: " + |
738 stringPauseState); | 738 stringPauseState); |
739 } | 739 } |
740 setPauseOnExceptionsImpl(pauseState); | 740 setPauseOnExceptionsImpl(pauseState); |
741 return Response::OK(); | 741 return Response::OK(); |
742 } | 742 } |
743 | 743 |
744 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(int pauseState) { | 744 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(int pauseState) { |
745 m_debugger->setPauseOnExceptionsState( | 745 m_debugger->setPauseOnExceptionsState( |
746 static_cast<v8::DebugInterface::ExceptionBreakState>(pauseState)); | 746 static_cast<v8::debug::ExceptionBreakState>(pauseState)); |
747 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); | 747 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); |
748 } | 748 } |
749 | 749 |
750 Response V8DebuggerAgentImpl::evaluateOnCallFrame( | 750 Response V8DebuggerAgentImpl::evaluateOnCallFrame( |
751 const String16& callFrameId, const String16& expression, | 751 const String16& callFrameId, const String16& expression, |
752 Maybe<String16> objectGroup, Maybe<bool> includeCommandLineAPI, | 752 Maybe<String16> objectGroup, Maybe<bool> includeCommandLineAPI, |
753 Maybe<bool> silent, Maybe<bool> returnByValue, Maybe<bool> generatePreview, | 753 Maybe<bool> silent, Maybe<bool> returnByValue, Maybe<bool> generatePreview, |
754 std::unique_ptr<RemoteObject>* result, | 754 std::unique_ptr<RemoteObject>* result, |
755 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { | 755 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { |
756 if (m_pausedContext.IsEmpty()) return Response::Error(kDebuggerNotPaused); | 756 if (m_pausedContext.IsEmpty()) return Response::Error(kDebuggerNotPaused); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 } | 930 } |
931 | 931 |
932 Response V8DebuggerAgentImpl::currentCallFrames( | 932 Response V8DebuggerAgentImpl::currentCallFrames( |
933 std::unique_ptr<Array<CallFrame>>* result) { | 933 std::unique_ptr<Array<CallFrame>>* result) { |
934 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) { | 934 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) { |
935 *result = Array<CallFrame>::create(); | 935 *result = Array<CallFrame>::create(); |
936 return Response::OK(); | 936 return Response::OK(); |
937 } | 937 } |
938 v8::HandleScope handles(m_isolate); | 938 v8::HandleScope handles(m_isolate); |
939 v8::Local<v8::Context> debuggerContext = | 939 v8::Local<v8::Context> debuggerContext = |
940 v8::DebugInterface::GetDebugContext(m_isolate); | 940 v8::debug::DebugInterface::GetDebugContext(m_isolate); |
941 v8::Context::Scope contextScope(debuggerContext); | 941 v8::Context::Scope contextScope(debuggerContext); |
942 | 942 |
943 v8::Local<v8::Array> objects = v8::Array::New(m_isolate); | 943 v8::Local<v8::Array> objects = v8::Array::New(m_isolate); |
944 | 944 |
945 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); | 945 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); |
946 ++frameOrdinal) { | 946 ++frameOrdinal) { |
947 const std::unique_ptr<JavaScriptCallFrame>& currentCallFrame = | 947 const std::unique_ptr<JavaScriptCallFrame>& currentCallFrame = |
948 m_pausedCallFrames[frameOrdinal]; | 948 m_pausedCallFrames[frameOrdinal]; |
949 | 949 |
950 v8::Local<v8::Object> details = currentCallFrame->details(); | 950 v8::Local<v8::Object> details = currentCallFrame->details(); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 m_scheduledDebuggerStep = NoStep; | 1229 m_scheduledDebuggerStep = NoStep; |
1230 m_steppingFromFramework = false; | 1230 m_steppingFromFramework = false; |
1231 m_pausingOnNativeEvent = false; | 1231 m_pausingOnNativeEvent = false; |
1232 m_debugger->breakProgram(); | 1232 m_debugger->breakProgram(); |
1233 } | 1233 } |
1234 | 1234 |
1235 void V8DebuggerAgentImpl::breakProgramOnException( | 1235 void V8DebuggerAgentImpl::breakProgramOnException( |
1236 const String16& breakReason, | 1236 const String16& breakReason, |
1237 std::unique_ptr<protocol::DictionaryValue> data) { | 1237 std::unique_ptr<protocol::DictionaryValue> data) { |
1238 if (!enabled() || | 1238 if (!enabled() || |
1239 m_debugger->getPauseOnExceptionsState() == | 1239 m_debugger->getPauseOnExceptionsState() == v8::debug::NoBreakOnException) |
1240 v8::DebugInterface::NoBreakOnException) | |
1241 return; | 1240 return; |
1242 breakProgram(breakReason, std::move(data)); | 1241 breakProgram(breakReason, std::move(data)); |
1243 } | 1242 } |
1244 | 1243 |
1245 void V8DebuggerAgentImpl::clearBreakDetails() { | 1244 void V8DebuggerAgentImpl::clearBreakDetails() { |
1246 m_breakReason = protocol::Debugger::Paused::ReasonEnum::Other; | 1245 m_breakReason = protocol::Debugger::Paused::ReasonEnum::Other; |
1247 m_breakAuxData = nullptr; | 1246 m_breakAuxData = nullptr; |
1248 } | 1247 } |
1249 | 1248 |
1250 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, | 1249 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, |
(...skipping 15 matching lines...) Expand all Loading... |
1266 | 1265 |
1267 void V8DebuggerAgentImpl::reset() { | 1266 void V8DebuggerAgentImpl::reset() { |
1268 if (!enabled()) return; | 1267 if (!enabled()) return; |
1269 m_scheduledDebuggerStep = NoStep; | 1268 m_scheduledDebuggerStep = NoStep; |
1270 m_scripts.clear(); | 1269 m_scripts.clear(); |
1271 m_blackboxedPositions.clear(); | 1270 m_blackboxedPositions.clear(); |
1272 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1271 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1273 } | 1272 } |
1274 | 1273 |
1275 } // namespace v8_inspector | 1274 } // namespace v8_inspector |
OLD | NEW |