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

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

Issue 2678313002: [inspector] support for nested scheduled breaks (Closed)
Patch Set: reverted not related changes 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 side-by-side diff with in-line comments
Download patch
Index: src/inspector/v8-debugger-agent-impl.cc
diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc
index 664c2ed095a0545d2ee655c3b15178e21e056f3f..dec383db2b22d468526f50572a9245e67061a3ae 100644
--- a/src/inspector/v8-debugger-agent-impl.cc
+++ b/src/inspector/v8-debugger-agent-impl.cc
@@ -131,7 +131,6 @@ V8DebuggerAgentImpl::V8DebuggerAgentImpl(
m_state(state),
m_frontend(frontendChannel),
m_isolate(m_inspector->isolate()),
- m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other),
m_scheduledDebuggerStep(NoStep),
m_javaScriptPauseScheduled(false),
m_recursionLevelForStepOut(0) {
@@ -589,6 +588,26 @@ Response V8DebuggerAgentImpl::getScriptSource(const String16& scriptId,
return Response::OK();
}
+void V8DebuggerAgentImpl::pushBreakDetails(
+ const String16& breakReason,
+ std::unique_ptr<protocol::DictionaryValue> breakAuxData) {
+ m_breakReason.push_back(breakReason);
+ m_breakAuxData.push_back(std::move(breakAuxData));
+}
+
+void V8DebuggerAgentImpl::popBreakDetails() {
+ if (m_breakReason.empty()) return;
pfeldman 2017/02/07 19:01:05 Is it not strict enough to put DCHECK here? So we
kozy 2017/02/07 22:54:36 We cleanup break reasons on actual break and we do
+ m_breakReason.pop_back();
+ m_breakAuxData.pop_back();
+}
+
+void V8DebuggerAgentImpl::clearBreakDetails() {
+ std::vector<String16> emptyBreakReason;
+ m_breakReason.swap(emptyBreakReason);
+ std::vector<std::unique_ptr<protocol::DictionaryValue>> emptyBreakAuxData;
+ m_breakAuxData.swap(emptyBreakAuxData);
+}
+
void V8DebuggerAgentImpl::schedulePauseOnNextStatement(
const String16& breakReason,
std::unique_ptr<protocol::DictionaryValue> data) {
@@ -596,9 +615,8 @@ void V8DebuggerAgentImpl::schedulePauseOnNextStatement(
m_javaScriptPauseScheduled || isPaused() ||
!m_debugger->breakpointsActivated())
return;
- m_breakReason = breakReason;
- m_breakAuxData = std::move(data);
- m_debugger->setPauseOnNextStatement(true);
+ if (m_breakReason.empty()) m_debugger->setPauseOnNextStatement(true);
+ pushBreakDetails(breakReason, std::move(data));
}
void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() {
@@ -612,8 +630,8 @@ void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() {
void V8DebuggerAgentImpl::cancelPauseOnNextStatement() {
if (m_javaScriptPauseScheduled || isPaused()) return;
- clearBreakDetails();
- m_debugger->setPauseOnNextStatement(false);
+ popBreakDetails();
+ if (m_breakReason.empty()) m_debugger->setPauseOnNextStatement(false);
}
Response V8DebuggerAgentImpl::pause() {
@@ -1071,14 +1089,21 @@ void V8DebuggerAgentImpl::didPause(int contextId,
m_pausedCallFrames.swap(frames);
v8::HandleScope handles(m_isolate);
+ String16 breakReason = m_breakReason.empty()
+ ? protocol::Debugger::Paused::ReasonEnum::Other
+ : m_breakReason.back();
+ std::unique_ptr<protocol::DictionaryValue> breakAuxData =
+ m_breakAuxData.empty() ? nullptr : std::move(m_breakAuxData.back());
+ clearBreakDetails();
+ std::vector<std::unique_ptr<protocol::DictionaryValue>> emptyBreakAuxData;
if (isOOMBreak) {
- m_breakReason = protocol::Debugger::Paused::ReasonEnum::OOM;
- m_breakAuxData = nullptr;
+ breakReason = protocol::Debugger::Paused::ReasonEnum::OOM;
+ breakAuxData = nullptr;
} else if (!exception.IsEmpty()) {
InjectedScript* injectedScript = nullptr;
m_session->findInjectedScript(contextId, injectedScript);
if (injectedScript) {
- m_breakReason =
+ breakReason =
isPromiseRejection
? protocol::Debugger::Paused::ReasonEnum::PromiseRejection
: protocol::Debugger::Paused::ReasonEnum::Exception;
@@ -1086,12 +1111,12 @@ void V8DebuggerAgentImpl::didPause(int contextId,
injectedScript->wrapObject(exception, kBacktraceObjectGroup, false, false,
&obj);
if (obj) {
- m_breakAuxData = obj->toValue();
- m_breakAuxData->setBoolean("uncaught", isUncaught);
+ breakAuxData = obj->toValue();
+ breakAuxData->setBoolean("uncaught", isUncaught);
} else {
- m_breakAuxData = nullptr;
+ breakAuxData = nullptr;
}
- // m_breakAuxData might be null after this.
+ // breakAuxData might be null after this.
}
}
@@ -1105,17 +1130,17 @@ void V8DebuggerAgentImpl::didPause(int contextId,
hitBreakpointIds->addItem(localId);
BreakpointSource source = breakpointIterator->second.second;
- if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other &&
+ if (breakReason == protocol::Debugger::Paused::ReasonEnum::Other &&
source == DebugCommandBreakpointSource)
- m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCommand;
+ breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCommand;
}
}
std::unique_ptr<Array<CallFrame>> protocolCallFrames;
Response response = currentCallFrames(&protocolCallFrames);
if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create();
- m_frontend.paused(std::move(protocolCallFrames), m_breakReason,
- std::move(m_breakAuxData), std::move(hitBreakpointIds),
+ m_frontend.paused(std::move(protocolCallFrames), breakReason,
+ std::move(breakAuxData), std::move(hitBreakpointIds),
currentAsyncStackTrace());
m_scheduledDebuggerStep = NoStep;
m_javaScriptPauseScheduled = false;
@@ -1137,8 +1162,7 @@ void V8DebuggerAgentImpl::breakProgram(
const String16& breakReason,
std::unique_ptr<protocol::DictionaryValue> data) {
if (!enabled() || !m_debugger->canBreakProgram() || m_skipAllPauses) return;
- m_breakReason = breakReason;
- m_breakAuxData = std::move(data);
+ pushBreakDetails(breakReason, std::move(data));
m_scheduledDebuggerStep = NoStep;
m_debugger->breakProgram();
}
@@ -1152,11 +1176,6 @@ void V8DebuggerAgentImpl::breakProgramOnException(
breakProgram(breakReason, std::move(data));
}
-void V8DebuggerAgentImpl::clearBreakDetails() {
- m_breakReason = protocol::Debugger::Paused::ReasonEnum::Other;
- m_breakAuxData = nullptr;
-}
-
void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId,
int lineNumber, int columnNumber,
BreakpointSource source,

Powered by Google App Engine
This is Rietveld 408576698