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

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

Issue 2655253004: [inspector] introduced stepIntoAsync for chained callbacks (Closed)
Patch Set: fixed async/await and added tests Created 3 years, 10 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') | src/js/promise.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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 const String16& breakReason, 607 const String16& breakReason,
608 std::unique_ptr<protocol::DictionaryValue> data) { 608 std::unique_ptr<protocol::DictionaryValue> data) {
609 if (!enabled() || m_scheduledDebuggerStep == StepInto || 609 if (!enabled() || m_scheduledDebuggerStep == StepInto ||
610 m_javaScriptPauseScheduled || isPaused() || 610 m_javaScriptPauseScheduled || isPaused() ||
611 !m_debugger->breakpointsActivated()) 611 !m_debugger->breakpointsActivated())
612 return; 612 return;
613 if (m_breakReason.empty()) m_debugger->setPauseOnNextStatement(true); 613 if (m_breakReason.empty()) m_debugger->setPauseOnNextStatement(true);
614 pushBreakDetails(breakReason, std::move(data)); 614 pushBreakDetails(breakReason, std::move(data));
615 } 615 }
616 616
617 void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() {
618 DCHECK(enabled());
619 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled ||
620 isPaused())
621 return;
622 m_debugger->setPauseOnNextStatement(true);
623 }
624
625 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() { 617 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() {
626 if (m_javaScriptPauseScheduled || isPaused()) return; 618 if (m_javaScriptPauseScheduled || isPaused()) return;
627 popBreakDetails(); 619 popBreakDetails();
628 if (m_breakReason.empty()) m_debugger->setPauseOnNextStatement(false); 620 if (m_breakReason.empty()) m_debugger->setPauseOnNextStatement(false);
629 } 621 }
630 622
631 Response V8DebuggerAgentImpl::pause() { 623 Response V8DebuggerAgentImpl::pause() {
632 if (!enabled()) return Response::Error(kDebuggerNotEnabled); 624 if (!enabled()) return Response::Error(kDebuggerNotEnabled);
633 if (m_javaScriptPauseScheduled || isPaused()) return Response::OK(); 625 if (m_javaScriptPauseScheduled || isPaused()) return Response::OK();
634 clearBreakDetails(); 626 clearBreakDetails();
(...skipping 24 matching lines...) Expand all
659 } 651 }
660 652
661 Response V8DebuggerAgentImpl::stepInto() { 653 Response V8DebuggerAgentImpl::stepInto() {
662 if (!isPaused()) return Response::Error(kDebuggerNotPaused); 654 if (!isPaused()) return Response::Error(kDebuggerNotPaused);
663 m_scheduledDebuggerStep = StepInto; 655 m_scheduledDebuggerStep = StepInto;
664 m_session->releaseObjectGroup(kBacktraceObjectGroup); 656 m_session->releaseObjectGroup(kBacktraceObjectGroup);
665 m_debugger->stepIntoStatement(); 657 m_debugger->stepIntoStatement();
666 return Response::OK(); 658 return Response::OK();
667 } 659 }
668 660
661 Response V8DebuggerAgentImpl::stepIntoAsync() {
662 if (!isPaused()) return Response::Error(kDebuggerNotPaused);
663 m_scheduledDebuggerStep = NoStep;
664 m_session->releaseObjectGroup(kBacktraceObjectGroup);
665 return m_debugger->stepIntoScheduledCallback();
666 }
667
669 Response V8DebuggerAgentImpl::stepOut() { 668 Response V8DebuggerAgentImpl::stepOut() {
670 if (!isPaused()) return Response::Error(kDebuggerNotPaused); 669 if (!isPaused()) return Response::Error(kDebuggerNotPaused);
671 m_scheduledDebuggerStep = StepOut; 670 m_scheduledDebuggerStep = StepOut;
672 m_recursionLevelForStepOut = 1; 671 m_recursionLevelForStepOut = 1;
673 m_session->releaseObjectGroup(kBacktraceObjectGroup); 672 m_session->releaseObjectGroup(kBacktraceObjectGroup);
674 m_debugger->stepOutOfFunction(); 673 m_debugger->stepOutOfFunction();
675 return Response::OK(); 674 return Response::OK();
676 } 675 }
677 676
678 Response V8DebuggerAgentImpl::setPauseOnExceptions( 677 Response V8DebuggerAgentImpl::setPauseOnExceptions(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 "Input positions array is not sorted or contains duplicate values."); 837 "Input positions array is not sorted or contains duplicate values.");
839 } 838 }
840 839
841 m_blackboxedPositions[scriptId] = positions; 840 m_blackboxedPositions[scriptId] = positions;
842 it->second->resetBlackboxedStateCache(); 841 it->second->resetBlackboxedStateCache();
843 return Response::OK(); 842 return Response::OK();
844 } 843 }
845 844
846 void V8DebuggerAgentImpl::willExecuteScript(int scriptId) { 845 void V8DebuggerAgentImpl::willExecuteScript(int scriptId) {
847 changeJavaScriptRecursionLevel(+1); 846 changeJavaScriptRecursionLevel(+1);
848 if (m_scheduledDebuggerStep != StepInto) return; 847 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled ||
849 schedulePauseOnNextStatementIfSteppingInto(); 848 isPaused()) {
849 return;
850 }
851 m_debugger->setPauseOnNextStatement(true);
850 } 852 }
851 853
852 void V8DebuggerAgentImpl::didExecuteScript() { 854 void V8DebuggerAgentImpl::didExecuteScript() {
853 changeJavaScriptRecursionLevel(-1); 855 changeJavaScriptRecursionLevel(-1);
854 } 856 }
855 857
856 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) { 858 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) {
857 if (m_javaScriptPauseScheduled && !m_skipAllPauses && !isPaused()) { 859 if (m_javaScriptPauseScheduled && !m_skipAllPauses && !isPaused()) {
858 // Do not ever loose user's pause request until we have actually paused. 860 // Do not ever loose user's pause request until we have actually paused.
859 m_debugger->setPauseOnNextStatement(true); 861 m_debugger->setPauseOnNextStatement(true);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 protocol::DictionaryValue::create(); 1153 protocol::DictionaryValue::create();
1152 reason->setString("reason", hitReasons[i].first); 1154 reason->setString("reason", hitReasons[i].first);
1153 if (hitReasons[i].second) 1155 if (hitReasons[i].second)
1154 reason->setObject("auxData", std::move(hitReasons[i].second)); 1156 reason->setObject("auxData", std::move(hitReasons[i].second));
1155 reasons->pushValue(std::move(reason)); 1157 reasons->pushValue(std::move(reason));
1156 } 1158 }
1157 breakAuxData = protocol::DictionaryValue::create(); 1159 breakAuxData = protocol::DictionaryValue::create();
1158 breakAuxData->setArray("reasons", std::move(reasons)); 1160 breakAuxData->setArray("reasons", std::move(reasons));
1159 } 1161 }
1160 1162
1163 if (m_debugger->stepIntoScheduledCallbackAvailable()) {
1164 if (!breakAuxData) breakAuxData = protocol::DictionaryValue::create();
1165 breakAuxData->setBoolean("stepIntoAsyncAvailable", true);
1166 }
1167
1161 std::unique_ptr<Array<CallFrame>> protocolCallFrames; 1168 std::unique_ptr<Array<CallFrame>> protocolCallFrames;
1162 Response response = currentCallFrames(&protocolCallFrames); 1169 Response response = currentCallFrames(&protocolCallFrames);
1163 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); 1170 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create();
1164 m_frontend.paused(std::move(protocolCallFrames), breakReason, 1171 m_frontend.paused(std::move(protocolCallFrames), breakReason,
1165 std::move(breakAuxData), std::move(hitBreakpointIds), 1172 std::move(breakAuxData), std::move(hitBreakpointIds),
1166 currentAsyncStackTrace()); 1173 currentAsyncStackTrace());
1167 m_scheduledDebuggerStep = NoStep; 1174 m_scheduledDebuggerStep = NoStep;
1168 m_javaScriptPauseScheduled = false; 1175 m_javaScriptPauseScheduled = false;
1169 1176
1170 if (!m_continueToLocationBreakpointId.isEmpty()) { 1177 if (!m_continueToLocationBreakpointId.isEmpty()) {
(...skipping 15 matching lines...) Expand all
1186 if (!enabled() || !m_debugger->canBreakProgram() || m_skipAllPauses) return; 1193 if (!enabled() || !m_debugger->canBreakProgram() || m_skipAllPauses) return;
1187 std::vector<BreakReason> currentScheduledReason; 1194 std::vector<BreakReason> currentScheduledReason;
1188 currentScheduledReason.swap(m_breakReason); 1195 currentScheduledReason.swap(m_breakReason);
1189 pushBreakDetails(breakReason, std::move(data)); 1196 pushBreakDetails(breakReason, std::move(data));
1190 m_scheduledDebuggerStep = NoStep; 1197 m_scheduledDebuggerStep = NoStep;
1191 m_debugger->breakProgram(); 1198 m_debugger->breakProgram();
1192 popBreakDetails(); 1199 popBreakDetails();
1193 m_breakReason.swap(currentScheduledReason); 1200 m_breakReason.swap(currentScheduledReason);
1194 } 1201 }
1195 1202
1203 void V8DebuggerAgentImpl::breakProgramIfSteppingInto(
1204 const String16& breakReason,
1205 std::unique_ptr<protocol::DictionaryValue> data) {
1206 if (m_scheduledDebuggerStep != StepInto) return;
1207 breakProgram(breakReason, std::move(data));
1208 }
1209
1196 void V8DebuggerAgentImpl::breakProgramOnException( 1210 void V8DebuggerAgentImpl::breakProgramOnException(
1197 const String16& breakReason, 1211 const String16& breakReason,
1198 std::unique_ptr<protocol::DictionaryValue> data) { 1212 std::unique_ptr<protocol::DictionaryValue> data) {
1199 if (!enabled() || 1213 if (!enabled() ||
1200 m_debugger->getPauseOnExceptionsState() == v8::debug::NoBreakOnException) 1214 m_debugger->getPauseOnExceptionsState() == v8::debug::NoBreakOnException)
1201 return; 1215 return;
1202 breakProgram(breakReason, std::move(data)); 1216 breakProgram(breakReason, std::move(data));
1203 } 1217 }
1204 1218
1205 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, 1219 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId,
(...skipping 16 matching lines...) Expand all
1222 void V8DebuggerAgentImpl::reset() { 1236 void V8DebuggerAgentImpl::reset() {
1223 if (!enabled()) return; 1237 if (!enabled()) return;
1224 m_scheduledDebuggerStep = NoStep; 1238 m_scheduledDebuggerStep = NoStep;
1225 m_blackboxedPositions.clear(); 1239 m_blackboxedPositions.clear();
1226 resetBlackboxedStateCache(); 1240 resetBlackboxedStateCache();
1227 m_scripts.clear(); 1241 m_scripts.clear();
1228 m_breakpointIdToDebuggerBreakpointIds.clear(); 1242 m_breakpointIdToDebuggerBreakpointIds.clear();
1229 } 1243 }
1230 1244
1231 } // namespace v8_inspector 1245 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger-agent-impl.h ('k') | src/js/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698