Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: src/inspector/v8-debugger-agent-impl.cc

Issue 2743163002: [inspector] use same schedulePauseOnNextStatement strategy for Debugger.pause (Closed)
Patch Set: better test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/v8-debugger-agent-impl.h ('k') | test/inspector/debugger/pause.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 V8DebuggerAgentImpl::V8DebuggerAgentImpl( 192 V8DebuggerAgentImpl::V8DebuggerAgentImpl(
193 V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, 193 V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel,
194 protocol::DictionaryValue* state) 194 protocol::DictionaryValue* state)
195 : m_inspector(session->inspector()), 195 : m_inspector(session->inspector()),
196 m_debugger(m_inspector->debugger()), 196 m_debugger(m_inspector->debugger()),
197 m_session(session), 197 m_session(session),
198 m_enabled(false), 198 m_enabled(false),
199 m_state(state), 199 m_state(state),
200 m_frontend(frontendChannel), 200 m_frontend(frontendChannel),
201 m_isolate(m_inspector->isolate()), 201 m_isolate(m_inspector->isolate()) {}
202 m_javaScriptPauseScheduled(false) {}
203 202
204 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() {} 203 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() {}
205 204
206 void V8DebuggerAgentImpl::enableImpl() { 205 void V8DebuggerAgentImpl::enableImpl() {
207 m_enabled = true; 206 m_enabled = true;
208 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); 207 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true);
209 m_debugger->enable(); 208 m_debugger->enable();
210 209
211 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts; 210 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts;
212 m_debugger->getCompiledScripts(m_session->contextGroupId(), compiledScripts); 211 m_debugger->getCompiledScripts(m_session->contextGroupId(), compiledScripts);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 JavaScriptCallFrames emptyCallFrames; 243 JavaScriptCallFrames emptyCallFrames;
245 m_pausedCallFrames.swap(emptyCallFrames); 244 m_pausedCallFrames.swap(emptyCallFrames);
246 m_blackboxedPositions.clear(); 245 m_blackboxedPositions.clear();
247 m_blackboxPattern.reset(); 246 m_blackboxPattern.reset();
248 resetBlackboxedStateCache(); 247 resetBlackboxedStateCache();
249 m_scripts.clear(); 248 m_scripts.clear();
250 m_breakpointIdToDebuggerBreakpointIds.clear(); 249 m_breakpointIdToDebuggerBreakpointIds.clear();
251 m_debugger->setAsyncCallStackDepth(this, 0); 250 m_debugger->setAsyncCallStackDepth(this, 0);
252 m_continueToLocationBreakpointId = String16(); 251 m_continueToLocationBreakpointId = String16();
253 clearBreakDetails(); 252 clearBreakDetails();
254 m_javaScriptPauseScheduled = false;
255 m_skipAllPauses = false; 253 m_skipAllPauses = false;
256 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); 254 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false);
257 m_state->remove(DebuggerAgentState::blackboxPattern); 255 m_state->remove(DebuggerAgentState::blackboxPattern);
258 m_enabled = false; 256 m_enabled = false;
259 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); 257 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false);
260 return Response::OK(); 258 return Response::OK();
261 } 259 }
262 260
263 void V8DebuggerAgentImpl::restore() { 261 void V8DebuggerAgentImpl::restore() {
264 DCHECK(!m_enabled); 262 DCHECK(!m_enabled);
(...skipping 19 matching lines...) Expand all
284 String16 blackboxPattern; 282 String16 blackboxPattern;
285 if (m_state->getString(DebuggerAgentState::blackboxPattern, 283 if (m_state->getString(DebuggerAgentState::blackboxPattern,
286 &blackboxPattern)) { 284 &blackboxPattern)) {
287 setBlackboxPattern(blackboxPattern); 285 setBlackboxPattern(blackboxPattern);
288 } 286 }
289 } 287 }
290 288
291 Response V8DebuggerAgentImpl::setBreakpointsActive(bool active) { 289 Response V8DebuggerAgentImpl::setBreakpointsActive(bool active) {
292 if (!enabled()) return Response::Error(kDebuggerNotEnabled); 290 if (!enabled()) return Response::Error(kDebuggerNotEnabled);
293 m_debugger->setBreakpointsActivated(active); 291 m_debugger->setBreakpointsActivated(active);
292 if (!active && !m_breakReason.empty()) {
293 clearBreakDetails();
294 m_debugger->setPauseOnNextStatement(false, m_session->contextGroupId());
295 }
294 return Response::OK(); 296 return Response::OK();
295 } 297 }
296 298
297 Response V8DebuggerAgentImpl::setSkipAllPauses(bool skip) { 299 Response V8DebuggerAgentImpl::setSkipAllPauses(bool skip) {
298 m_state->setBoolean(DebuggerAgentState::skipAllPauses, skip); 300 m_state->setBoolean(DebuggerAgentState::skipAllPauses, skip);
299 m_skipAllPauses = skip; 301 m_skipAllPauses = skip;
300 return Response::OK(); 302 return Response::OK();
301 } 303 }
302 304
303 static std::unique_ptr<protocol::DictionaryValue> 305 static std::unique_ptr<protocol::DictionaryValue>
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 } 680 }
679 681
680 void V8DebuggerAgentImpl::clearBreakDetails() { 682 void V8DebuggerAgentImpl::clearBreakDetails() {
681 std::vector<BreakReason> emptyBreakReason; 683 std::vector<BreakReason> emptyBreakReason;
682 m_breakReason.swap(emptyBreakReason); 684 m_breakReason.swap(emptyBreakReason);
683 } 685 }
684 686
685 void V8DebuggerAgentImpl::schedulePauseOnNextStatement( 687 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(
686 const String16& breakReason, 688 const String16& breakReason,
687 std::unique_ptr<protocol::DictionaryValue> data) { 689 std::unique_ptr<protocol::DictionaryValue> data) {
688 if (!enabled() || m_javaScriptPauseScheduled || isPaused() || 690 if (!enabled() || isPaused() || !m_debugger->breakpointsActivated()) return;
689 !m_debugger->breakpointsActivated())
690 return;
691 if (m_breakReason.empty()) { 691 if (m_breakReason.empty()) {
692 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); 692 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId());
693 } 693 }
694 pushBreakDetails(breakReason, std::move(data)); 694 pushBreakDetails(breakReason, std::move(data));
695 } 695 }
696 696
697 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() { 697 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() {
698 if (m_javaScriptPauseScheduled || isPaused()) return; 698 if (!enabled() || isPaused() || !m_debugger->breakpointsActivated()) return;
699 if (m_breakReason.size() == 1) {
700 m_debugger->setPauseOnNextStatement(false, m_session->contextGroupId());
701 }
699 popBreakDetails(); 702 popBreakDetails();
700 if (m_breakReason.empty())
701 m_debugger->setPauseOnNextStatement(false, m_session->contextGroupId());
702 } 703 }
703 704
704 Response V8DebuggerAgentImpl::pause() { 705 Response V8DebuggerAgentImpl::pause() {
705 if (!enabled()) return Response::Error(kDebuggerNotEnabled); 706 if (!enabled()) return Response::Error(kDebuggerNotEnabled);
706 if (m_javaScriptPauseScheduled || isPaused()) return Response::OK(); 707 if (isPaused()) return Response::OK();
707 clearBreakDetails(); 708 if (m_breakReason.empty()) {
708 m_javaScriptPauseScheduled = true; 709 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId());
709 m_debugger->setPauseOnNextStatement(true, m_session->contextGroupId()); 710 }
711 pushBreakDetails(protocol::Debugger::Paused::ReasonEnum::Other, nullptr);
710 return Response::OK(); 712 return Response::OK();
711 } 713 }
712 714
713 Response V8DebuggerAgentImpl::resume() { 715 Response V8DebuggerAgentImpl::resume() {
714 if (!isPaused()) return Response::Error(kDebuggerNotPaused); 716 if (!isPaused()) return Response::Error(kDebuggerNotPaused);
715 m_session->releaseObjectGroup(kBacktraceObjectGroup); 717 m_session->releaseObjectGroup(kBacktraceObjectGroup);
716 m_debugger->continueProgram(); 718 m_debugger->continueProgram();
717 return Response::OK(); 719 return Response::OK();
718 } 720 }
719 721
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 Response::Error("No async tasks were scheduled before pause.")); 1235 Response::Error("No async tasks were scheduled before pause."));
1234 m_stepIntoAsyncCallback.reset(); 1236 m_stepIntoAsyncCallback.reset();
1235 } 1237 }
1236 1238
1237 std::unique_ptr<Array<CallFrame>> protocolCallFrames; 1239 std::unique_ptr<Array<CallFrame>> protocolCallFrames;
1238 Response response = currentCallFrames(&protocolCallFrames); 1240 Response response = currentCallFrames(&protocolCallFrames);
1239 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); 1241 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create();
1240 m_frontend.paused(std::move(protocolCallFrames), breakReason, 1242 m_frontend.paused(std::move(protocolCallFrames), breakReason,
1241 std::move(breakAuxData), std::move(hitBreakpointIds), 1243 std::move(breakAuxData), std::move(hitBreakpointIds),
1242 currentAsyncStackTrace()); 1244 currentAsyncStackTrace());
1243 m_javaScriptPauseScheduled = false;
1244 1245
1245 if (!m_continueToLocationBreakpointId.isEmpty()) { 1246 if (!m_continueToLocationBreakpointId.isEmpty()) {
1246 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); 1247 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId);
1247 m_continueToLocationBreakpointId = ""; 1248 m_continueToLocationBreakpointId = "";
1248 } 1249 }
1249 } 1250 }
1250 1251
1251 void V8DebuggerAgentImpl::didContinue() { 1252 void V8DebuggerAgentImpl::didContinue() {
1252 JavaScriptCallFrames emptyCallFrames; 1253 JavaScriptCallFrames emptyCallFrames;
1253 m_pausedCallFrames.swap(emptyCallFrames); 1254 m_pausedCallFrames.swap(emptyCallFrames);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1299
1299 void V8DebuggerAgentImpl::reset() { 1300 void V8DebuggerAgentImpl::reset() {
1300 if (!enabled()) return; 1301 if (!enabled()) return;
1301 m_blackboxedPositions.clear(); 1302 m_blackboxedPositions.clear();
1302 resetBlackboxedStateCache(); 1303 resetBlackboxedStateCache();
1303 m_scripts.clear(); 1304 m_scripts.clear();
1304 m_breakpointIdToDebuggerBreakpointIds.clear(); 1305 m_breakpointIdToDebuggerBreakpointIds.clear();
1305 } 1306 }
1306 1307
1307 } // namespace v8_inspector 1308 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger-agent-impl.h ('k') | test/inspector/debugger/pause.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698