Chromium Code Reviews| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 | 190 |
| 191 V8DebuggerAgentImpl::V8DebuggerAgentImpl( | 191 V8DebuggerAgentImpl::V8DebuggerAgentImpl( |
| 192 V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, | 192 V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, |
| 193 protocol::DictionaryValue* state) | 193 protocol::DictionaryValue* state) |
| 194 : m_inspector(session->inspector()), | 194 : m_inspector(session->inspector()), |
| 195 m_debugger(m_inspector->debugger()), | 195 m_debugger(m_inspector->debugger()), |
| 196 m_session(session), | 196 m_session(session), |
| 197 m_enabled(false), | 197 m_enabled(false), |
| 198 m_state(state), | 198 m_state(state), |
| 199 m_frontend(frontendChannel), | 199 m_frontend(frontendChannel), |
| 200 m_isolate(m_inspector->isolate()), | 200 m_isolate(m_inspector->isolate()) {} |
| 201 m_javaScriptPauseScheduled(false) {} | |
| 202 | 201 |
| 203 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() {} | 202 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() {} |
| 204 | 203 |
| 205 void V8DebuggerAgentImpl::enableImpl() { | 204 void V8DebuggerAgentImpl::enableImpl() { |
| 206 m_enabled = true; | 205 m_enabled = true; |
| 207 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); | 206 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); |
| 208 m_debugger->enable(); | 207 m_debugger->enable(); |
| 209 | 208 |
| 210 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts; | 209 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts; |
| 211 m_debugger->getCompiledScripts(m_session->contextGroupId(), compiledScripts); | 210 m_debugger->getCompiledScripts(m_session->contextGroupId(), compiledScripts); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 JavaScriptCallFrames emptyCallFrames; | 242 JavaScriptCallFrames emptyCallFrames; |
| 244 m_pausedCallFrames.swap(emptyCallFrames); | 243 m_pausedCallFrames.swap(emptyCallFrames); |
| 245 m_blackboxedPositions.clear(); | 244 m_blackboxedPositions.clear(); |
| 246 m_blackboxPattern.reset(); | 245 m_blackboxPattern.reset(); |
| 247 resetBlackboxedStateCache(); | 246 resetBlackboxedStateCache(); |
| 248 m_scripts.clear(); | 247 m_scripts.clear(); |
| 249 m_breakpointIdToDebuggerBreakpointIds.clear(); | 248 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 250 m_debugger->setAsyncCallStackDepth(this, 0); | 249 m_debugger->setAsyncCallStackDepth(this, 0); |
| 251 m_continueToLocationBreakpointId = String16(); | 250 m_continueToLocationBreakpointId = String16(); |
| 252 clearBreakDetails(); | 251 clearBreakDetails(); |
| 253 m_javaScriptPauseScheduled = false; | |
| 254 m_skipAllPauses = false; | 252 m_skipAllPauses = false; |
| 255 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); | 253 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); |
| 256 m_state->remove(DebuggerAgentState::blackboxPattern); | 254 m_state->remove(DebuggerAgentState::blackboxPattern); |
| 257 m_enabled = false; | 255 m_enabled = false; |
| 258 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); | 256 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); |
| 259 return Response::OK(); | 257 return Response::OK(); |
| 260 } | 258 } |
| 261 | 259 |
| 262 void V8DebuggerAgentImpl::restore() { | 260 void V8DebuggerAgentImpl::restore() { |
| 263 DCHECK(!m_enabled); | 261 DCHECK(!m_enabled); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 282 | 280 |
| 283 String16 blackboxPattern; | 281 String16 blackboxPattern; |
| 284 if (m_state->getString(DebuggerAgentState::blackboxPattern, | 282 if (m_state->getString(DebuggerAgentState::blackboxPattern, |
| 285 &blackboxPattern)) { | 283 &blackboxPattern)) { |
| 286 setBlackboxPattern(blackboxPattern); | 284 setBlackboxPattern(blackboxPattern); |
| 287 } | 285 } |
| 288 } | 286 } |
| 289 | 287 |
| 290 Response V8DebuggerAgentImpl::setBreakpointsActive(bool active) { | 288 Response V8DebuggerAgentImpl::setBreakpointsActive(bool active) { |
| 291 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 289 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
| 292 m_debugger->setBreakpointsActivated(active); | 290 m_debugger->setBreakpointsActivated(active); |
|
dgozman
2017/03/13 18:10:52
clearBreakDetails();
And test it :-)
kozy
2017/03/24 01:53:04
Done.
| |
| 293 return Response::OK(); | 291 return Response::OK(); |
| 294 } | 292 } |
| 295 | 293 |
| 296 Response V8DebuggerAgentImpl::setSkipAllPauses(bool skip) { | 294 Response V8DebuggerAgentImpl::setSkipAllPauses(bool skip) { |
| 297 m_state->setBoolean(DebuggerAgentState::skipAllPauses, skip); | 295 m_state->setBoolean(DebuggerAgentState::skipAllPauses, skip); |
| 298 m_skipAllPauses = skip; | 296 m_skipAllPauses = skip; |
| 299 return Response::OK(); | 297 return Response::OK(); |
| 300 } | 298 } |
| 301 | 299 |
| 302 static std::unique_ptr<protocol::DictionaryValue> | 300 static std::unique_ptr<protocol::DictionaryValue> |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 } | 675 } |
| 678 | 676 |
| 679 void V8DebuggerAgentImpl::clearBreakDetails() { | 677 void V8DebuggerAgentImpl::clearBreakDetails() { |
| 680 std::vector<BreakReason> emptyBreakReason; | 678 std::vector<BreakReason> emptyBreakReason; |
| 681 m_breakReason.swap(emptyBreakReason); | 679 m_breakReason.swap(emptyBreakReason); |
| 682 } | 680 } |
| 683 | 681 |
| 684 void V8DebuggerAgentImpl::schedulePauseOnNextStatement( | 682 void V8DebuggerAgentImpl::schedulePauseOnNextStatement( |
| 685 const String16& breakReason, | 683 const String16& breakReason, |
| 686 std::unique_ptr<protocol::DictionaryValue> data) { | 684 std::unique_ptr<protocol::DictionaryValue> data) { |
| 687 if (!enabled() || m_javaScriptPauseScheduled || isPaused() || | 685 if (!enabled() || isPaused() || !m_debugger->breakpointsActivated()) return; |
| 688 !m_debugger->breakpointsActivated()) | |
| 689 return; | |
| 690 if (m_breakReason.empty()) { | 686 if (m_breakReason.empty()) { |
| 691 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); | 687 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); |
| 692 } | 688 } |
| 693 pushBreakDetails(breakReason, std::move(data)); | 689 pushBreakDetails(breakReason, std::move(data)); |
| 694 } | 690 } |
| 695 | 691 |
| 696 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() { | 692 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() { |
| 697 if (m_javaScriptPauseScheduled || isPaused()) return; | 693 if (!enabled() || isPaused() || !m_debugger->breakpointsActivated()) return; |
| 694 if (m_breakReason.size() == 1) m_debugger->setPauseOnNextStatement(false, 0); | |
| 698 popBreakDetails(); | 695 popBreakDetails(); |
| 699 if (m_breakReason.empty()) m_debugger->setPauseOnNextStatement(false, 0); | |
| 700 } | 696 } |
| 701 | 697 |
| 702 Response V8DebuggerAgentImpl::pause() { | 698 Response V8DebuggerAgentImpl::pause() { |
| 703 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 699 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
| 704 if (m_javaScriptPauseScheduled || isPaused()) return Response::OK(); | 700 if (isPaused()) return Response::OK(); |
| 705 clearBreakDetails(); | 701 if (m_breakReason.empty()) { |
| 706 m_javaScriptPauseScheduled = true; | 702 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); |
| 707 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); | 703 } |
| 704 pushBreakDetails(protocol::Debugger::Paused::ReasonEnum::Other, nullptr); | |
| 708 return Response::OK(); | 705 return Response::OK(); |
| 709 } | 706 } |
| 710 | 707 |
| 711 Response V8DebuggerAgentImpl::resume() { | 708 Response V8DebuggerAgentImpl::resume() { |
| 712 if (!isPaused()) return Response::Error(kDebuggerNotPaused); | 709 if (!isPaused()) return Response::Error(kDebuggerNotPaused); |
| 713 m_session->releaseObjectGroup(kBacktraceObjectGroup); | 710 m_session->releaseObjectGroup(kBacktraceObjectGroup); |
| 714 m_debugger->continueProgram(); | 711 m_debugger->continueProgram(); |
| 715 return Response::OK(); | 712 return Response::OK(); |
| 716 } | 713 } |
| 717 | 714 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1229 Response::Error("No async tasks were scheduled before pause.")); | 1226 Response::Error("No async tasks were scheduled before pause.")); |
| 1230 m_stepIntoAsyncCallback.reset(); | 1227 m_stepIntoAsyncCallback.reset(); |
| 1231 } | 1228 } |
| 1232 | 1229 |
| 1233 std::unique_ptr<Array<CallFrame>> protocolCallFrames; | 1230 std::unique_ptr<Array<CallFrame>> protocolCallFrames; |
| 1234 Response response = currentCallFrames(&protocolCallFrames); | 1231 Response response = currentCallFrames(&protocolCallFrames); |
| 1235 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); | 1232 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); |
| 1236 m_frontend.paused(std::move(protocolCallFrames), breakReason, | 1233 m_frontend.paused(std::move(protocolCallFrames), breakReason, |
| 1237 std::move(breakAuxData), std::move(hitBreakpointIds), | 1234 std::move(breakAuxData), std::move(hitBreakpointIds), |
| 1238 currentAsyncStackTrace()); | 1235 currentAsyncStackTrace()); |
| 1239 m_javaScriptPauseScheduled = false; | |
| 1240 | 1236 |
| 1241 if (!m_continueToLocationBreakpointId.isEmpty()) { | 1237 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 1242 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 1238 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
| 1243 m_continueToLocationBreakpointId = ""; | 1239 m_continueToLocationBreakpointId = ""; |
| 1244 } | 1240 } |
| 1245 } | 1241 } |
| 1246 | 1242 |
| 1247 void V8DebuggerAgentImpl::didContinue() { | 1243 void V8DebuggerAgentImpl::didContinue() { |
| 1248 JavaScriptCallFrames emptyCallFrames; | 1244 JavaScriptCallFrames emptyCallFrames; |
| 1249 m_pausedCallFrames.swap(emptyCallFrames); | 1245 m_pausedCallFrames.swap(emptyCallFrames); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1294 | 1290 |
| 1295 void V8DebuggerAgentImpl::reset() { | 1291 void V8DebuggerAgentImpl::reset() { |
| 1296 if (!enabled()) return; | 1292 if (!enabled()) return; |
| 1297 m_blackboxedPositions.clear(); | 1293 m_blackboxedPositions.clear(); |
| 1298 resetBlackboxedStateCache(); | 1294 resetBlackboxedStateCache(); |
| 1299 m_scripts.clear(); | 1295 m_scripts.clear(); |
| 1300 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1296 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1301 } | 1297 } |
| 1302 | 1298 |
| 1303 } // namespace v8_inspector | 1299 } // namespace v8_inspector |
| OLD | NEW |