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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 pauseState = v8::debug::BreakOnUncaughtException; | 757 pauseState = v8::debug::BreakOnUncaughtException; |
758 } else { | 758 } else { |
759 return Response::Error("Unknown pause on exceptions mode: " + | 759 return Response::Error("Unknown pause on exceptions mode: " + |
760 stringPauseState); | 760 stringPauseState); |
761 } | 761 } |
762 setPauseOnExceptionsImpl(pauseState); | 762 setPauseOnExceptionsImpl(pauseState); |
763 return Response::OK(); | 763 return Response::OK(); |
764 } | 764 } |
765 | 765 |
766 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(int pauseState) { | 766 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(int pauseState) { |
| 767 // TODO(dgozman): this changes the global state and forces all context groups |
| 768 // to pause. We should make this flag be per-context-group. |
767 m_debugger->setPauseOnExceptionsState( | 769 m_debugger->setPauseOnExceptionsState( |
768 static_cast<v8::debug::ExceptionBreakState>(pauseState)); | 770 static_cast<v8::debug::ExceptionBreakState>(pauseState)); |
769 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); | 771 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); |
770 } | 772 } |
771 | 773 |
772 Response V8DebuggerAgentImpl::evaluateOnCallFrame( | 774 Response V8DebuggerAgentImpl::evaluateOnCallFrame( |
773 const String16& callFrameId, const String16& expression, | 775 const String16& callFrameId, const String16& expression, |
774 Maybe<String16> objectGroup, Maybe<bool> includeCommandLineAPI, | 776 Maybe<String16> objectGroup, Maybe<bool> includeCommandLineAPI, |
775 Maybe<bool> silent, Maybe<bool> returnByValue, Maybe<bool> generatePreview, | 777 Maybe<bool> silent, Maybe<bool> returnByValue, Maybe<bool> generatePreview, |
776 Maybe<bool> throwOnSideEffect, std::unique_ptr<RemoteObject>* result, | 778 Maybe<bool> throwOnSideEffect, std::unique_ptr<RemoteObject>* result, |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 } | 1132 } |
1131 if (location) | 1133 if (location) |
1132 m_frontend.breakpointResolved(cookie.first, std::move(location)); | 1134 m_frontend.breakpointResolved(cookie.first, std::move(location)); |
1133 } | 1135 } |
1134 } | 1136 } |
1135 | 1137 |
1136 void V8DebuggerAgentImpl::didPause(int contextId, | 1138 void V8DebuggerAgentImpl::didPause(int contextId, |
1137 v8::Local<v8::Value> exception, | 1139 v8::Local<v8::Value> exception, |
1138 const std::vector<String16>& hitBreakpoints, | 1140 const std::vector<String16>& hitBreakpoints, |
1139 bool isPromiseRejection, bool isUncaught, | 1141 bool isPromiseRejection, bool isUncaught, |
1140 bool isOOMBreak) { | 1142 bool isOOMBreak, bool isAssert) { |
1141 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); | 1143 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); |
1142 m_pausedCallFrames.swap(frames); | 1144 m_pausedCallFrames.swap(frames); |
1143 v8::HandleScope handles(m_isolate); | 1145 v8::HandleScope handles(m_isolate); |
1144 | 1146 |
1145 std::vector<BreakReason> hitReasons; | 1147 std::vector<BreakReason> hitReasons; |
1146 | 1148 |
1147 if (isOOMBreak) { | 1149 if (isOOMBreak) { |
1148 hitReasons.push_back( | 1150 hitReasons.push_back( |
1149 std::make_pair(protocol::Debugger::Paused::ReasonEnum::OOM, nullptr)); | 1151 std::make_pair(protocol::Debugger::Paused::ReasonEnum::OOM, nullptr)); |
| 1152 } else if (isAssert) { |
| 1153 hitReasons.push_back(std::make_pair( |
| 1154 protocol::Debugger::Paused::ReasonEnum::Assert, nullptr)); |
1150 } else if (!exception.IsEmpty()) { | 1155 } else if (!exception.IsEmpty()) { |
1151 InjectedScript* injectedScript = nullptr; | 1156 InjectedScript* injectedScript = nullptr; |
1152 m_session->findInjectedScript(contextId, injectedScript); | 1157 m_session->findInjectedScript(contextId, injectedScript); |
1153 if (injectedScript) { | 1158 if (injectedScript) { |
1154 String16 breakReason = | 1159 String16 breakReason = |
1155 isPromiseRejection | 1160 isPromiseRejection |
1156 ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection | 1161 ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection |
1157 : protocol::Debugger::Paused::ReasonEnum::Exception; | 1162 : protocol::Debugger::Paused::ReasonEnum::Exception; |
1158 std::unique_ptr<protocol::Runtime::RemoteObject> obj; | 1163 std::unique_ptr<protocol::Runtime::RemoteObject> obj; |
1159 injectedScript->wrapObject(exception, kBacktraceObjectGroup, false, false, | 1164 injectedScript->wrapObject(exception, kBacktraceObjectGroup, false, false, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 if (!inspector->sessionById(contextGroupId, sessionId)) return; | 1252 if (!inspector->sessionById(contextGroupId, sessionId)) return; |
1248 if (!enabled()) return; | 1253 if (!enabled()) return; |
1249 | 1254 |
1250 popBreakDetails(); | 1255 popBreakDetails(); |
1251 m_breakReason.swap(currentScheduledReason); | 1256 m_breakReason.swap(currentScheduledReason); |
1252 if (!m_breakReason.empty()) { | 1257 if (!m_breakReason.empty()) { |
1253 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); | 1258 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); |
1254 } | 1259 } |
1255 } | 1260 } |
1256 | 1261 |
1257 void V8DebuggerAgentImpl::breakProgramOnException( | |
1258 const String16& breakReason, | |
1259 std::unique_ptr<protocol::DictionaryValue> data) { | |
1260 if (!enabled() || | |
1261 m_debugger->getPauseOnExceptionsState() == v8::debug::NoBreakOnException) | |
1262 return; | |
1263 breakProgram(breakReason, std::move(data)); | |
1264 } | |
1265 | |
1266 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, | 1262 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, |
1267 int lineNumber, int columnNumber, | 1263 int lineNumber, int columnNumber, |
1268 BreakpointSource source, | 1264 BreakpointSource source, |
1269 const String16& condition) { | 1265 const String16& condition) { |
1270 ScriptBreakpoint breakpoint(scriptId, lineNumber, columnNumber, condition); | 1266 ScriptBreakpoint breakpoint(scriptId, lineNumber, columnNumber, condition); |
1271 String16 breakpointId = generateBreakpointId(breakpoint, source); | 1267 String16 breakpointId = generateBreakpointId(breakpoint, source); |
1272 resolveBreakpoint(breakpointId, breakpoint, source, /* hint */ String16()); | 1268 resolveBreakpoint(breakpointId, breakpoint, source, /* hint */ String16()); |
1273 } | 1269 } |
1274 | 1270 |
1275 void V8DebuggerAgentImpl::removeBreakpointAt(const String16& scriptId, | 1271 void V8DebuggerAgentImpl::removeBreakpointAt(const String16& scriptId, |
1276 int lineNumber, int columnNumber, | 1272 int lineNumber, int columnNumber, |
1277 BreakpointSource source) { | 1273 BreakpointSource source) { |
1278 removeBreakpointImpl(generateBreakpointId( | 1274 removeBreakpointImpl(generateBreakpointId( |
1279 ScriptBreakpoint(scriptId, lineNumber, columnNumber, String16()), | 1275 ScriptBreakpoint(scriptId, lineNumber, columnNumber, String16()), |
1280 source)); | 1276 source)); |
1281 } | 1277 } |
1282 | 1278 |
1283 void V8DebuggerAgentImpl::reset() { | 1279 void V8DebuggerAgentImpl::reset() { |
1284 if (!enabled()) return; | 1280 if (!enabled()) return; |
1285 m_blackboxedPositions.clear(); | 1281 m_blackboxedPositions.clear(); |
1286 resetBlackboxedStateCache(); | 1282 resetBlackboxedStateCache(); |
1287 m_scripts.clear(); | 1283 m_scripts.clear(); |
1288 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1284 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1289 } | 1285 } |
1290 | 1286 |
1291 } // namespace v8_inspector | 1287 } // namespace v8_inspector |
OLD | NEW |