| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 "platform/v8_inspector/V8DebuggerAgentImpl.h" | 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/String16.h" | 7 #include "platform/inspector_protocol/String16.h" |
| 8 #include "platform/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
| 9 #include "platform/v8_inspector/InjectedScript.h" | 9 #include "platform/v8_inspector/InjectedScript.h" |
| 10 #include "platform/v8_inspector/InspectedContext.h" | 10 #include "platform/v8_inspector/InspectedContext.h" |
| 11 #include "platform/v8_inspector/JavaScriptCallFrame.h" | 11 #include "platform/v8_inspector/JavaScriptCallFrame.h" |
| 12 #include "platform/v8_inspector/RemoteObjectId.h" | 12 #include "platform/v8_inspector/RemoteObjectId.h" |
| 13 #include "platform/v8_inspector/ScriptBreakpoint.h" | 13 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 14 #include "platform/v8_inspector/V8Debugger.h" |
| 15 #include "platform/v8_inspector/V8DebuggerScript.h" |
| 14 #include "platform/v8_inspector/V8InspectorImpl.h" | 16 #include "platform/v8_inspector/V8InspectorImpl.h" |
| 15 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 17 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| 16 #include "platform/v8_inspector/V8Regex.h" | 18 #include "platform/v8_inspector/V8Regex.h" |
| 17 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 19 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
| 18 #include "platform/v8_inspector/V8StackTraceImpl.h" | 20 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 19 #include "platform/v8_inspector/V8StringUtil.h" | 21 #include "platform/v8_inspector/V8StringUtil.h" |
| 20 #include "platform/v8_inspector/public/V8InspectorClient.h" | 22 #include "platform/v8_inspector/public/V8InspectorClient.h" |
| 21 | 23 |
| 22 #include <algorithm> | 24 #include <algorithm> |
| 23 | 25 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const
String16& scriptId, int lineNumber, int columnNumber) | 89 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const
String16& scriptId, int lineNumber, int columnNumber) |
| 88 { | 90 { |
| 89 return protocol::Debugger::Location::create() | 91 return protocol::Debugger::Location::create() |
| 90 .setScriptId(scriptId) | 92 .setScriptId(scriptId) |
| 91 .setLineNumber(lineNumber) | 93 .setLineNumber(lineNumber) |
| 92 .setColumnNumber(columnNumber).build(); | 94 .setColumnNumber(columnNumber).build(); |
| 93 } | 95 } |
| 94 | 96 |
| 95 V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc
ol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) | 97 V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc
ol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) |
| 96 : m_inspector(session->inspector()) | 98 : m_inspector(session->inspector()) |
| 99 , m_debugger(m_inspector->debugger()) |
| 97 , m_session(session) | 100 , m_session(session) |
| 98 , m_enabled(false) | 101 , m_enabled(false) |
| 99 , m_state(state) | 102 , m_state(state) |
| 100 , m_frontend(frontendChannel) | 103 , m_frontend(frontendChannel) |
| 101 , m_isolate(m_inspector->isolate()) | 104 , m_isolate(m_inspector->isolate()) |
| 102 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) | 105 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) |
| 103 , m_scheduledDebuggerStep(NoStep) | 106 , m_scheduledDebuggerStep(NoStep) |
| 104 , m_skipNextDebuggerStepOut(false) | 107 , m_skipNextDebuggerStepOut(false) |
| 105 , m_javaScriptPauseScheduled(false) | 108 , m_javaScriptPauseScheduled(false) |
| 106 , m_steppingFromFramework(false) | 109 , m_steppingFromFramework(false) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 *errorString = "Debugger agent is not enabled"; | 127 *errorString = "Debugger agent is not enabled"; |
| 125 return false; | 128 return false; |
| 126 } | 129 } |
| 127 | 130 |
| 128 void V8DebuggerAgentImpl::enable() | 131 void V8DebuggerAgentImpl::enable() |
| 129 { | 132 { |
| 130 // m_inspector->addListener may result in reporting all parsed scripts to | 133 // m_inspector->addListener may result in reporting all parsed scripts to |
| 131 // the agent so it should already be in enabled state by then. | 134 // the agent so it should already be in enabled state by then. |
| 132 m_enabled = true; | 135 m_enabled = true; |
| 133 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); | 136 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); |
| 134 m_inspector->debuggerAgentEnabled(); | 137 m_debugger->enable(); |
| 135 | 138 |
| 136 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts; | 139 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts; |
| 137 m_inspector->getCompiledScripts(m_session->contextGroupId(), compiledScripts
); | 140 m_debugger->getCompiledScripts(m_session->contextGroupId(), compiledScripts)
; |
| 138 for (size_t i = 0; i < compiledScripts.size(); i++) | 141 for (size_t i = 0; i < compiledScripts.size(); i++) |
| 139 didParseSource(std::move(compiledScripts[i]), true); | 142 didParseSource(std::move(compiledScripts[i]), true); |
| 140 | 143 |
| 141 // FIXME(WK44513): breakpoints activated flag should be synchronized between
all front-ends | 144 // FIXME(WK44513): breakpoints activated flag should be synchronized between
all front-ends |
| 142 m_inspector->setBreakpointsActivated(true); | 145 m_debugger->setBreakpointsActivated(true); |
| 143 } | 146 } |
| 144 | 147 |
| 145 bool V8DebuggerAgentImpl::enabled() | 148 bool V8DebuggerAgentImpl::enabled() |
| 146 { | 149 { |
| 147 return m_enabled; | 150 return m_enabled; |
| 148 } | 151 } |
| 149 | 152 |
| 150 void V8DebuggerAgentImpl::enable(ErrorString* errorString) | 153 void V8DebuggerAgentImpl::enable(ErrorString* errorString) |
| 151 { | 154 { |
| 152 if (enabled()) | 155 if (enabled()) |
| 153 return; | 156 return; |
| 154 | 157 |
| 155 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId()))
{ | 158 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId()))
{ |
| 156 *errorString = "Script execution is prohibited"; | 159 *errorString = "Script execution is prohibited"; |
| 157 return; | 160 return; |
| 158 } | 161 } |
| 159 | 162 |
| 160 enable(); | 163 enable(); |
| 161 } | 164 } |
| 162 | 165 |
| 163 void V8DebuggerAgentImpl::disable(ErrorString*) | 166 void V8DebuggerAgentImpl::disable(ErrorString*) |
| 164 { | 167 { |
| 165 if (!enabled()) | 168 if (!enabled()) |
| 166 return; | 169 return; |
| 167 | 170 |
| 168 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict
ionaryValue::create()); | 171 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict
ionaryValue::create()); |
| 169 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8InspectorI
mpl::DontPauseOnExceptions); | 172 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8Debugger::
DontPauseOnExceptions); |
| 170 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); | 173 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); |
| 171 | 174 |
| 172 if (!m_pausedContext.IsEmpty()) | 175 if (!m_pausedContext.IsEmpty()) |
| 173 m_inspector->continueProgram(); | 176 m_debugger->continueProgram(); |
| 174 m_inspector->debuggerAgentDisabled(); | 177 m_debugger->disable(); |
| 175 m_pausedContext.Reset(); | 178 m_pausedContext.Reset(); |
| 176 JavaScriptCallFrames emptyCallFrames; | 179 JavaScriptCallFrames emptyCallFrames; |
| 177 m_pausedCallFrames.swap(emptyCallFrames); | 180 m_pausedCallFrames.swap(emptyCallFrames); |
| 178 m_scripts.clear(); | 181 m_scripts.clear(); |
| 179 m_blackboxedPositions.clear(); | 182 m_blackboxedPositions.clear(); |
| 180 m_breakpointIdToDebuggerBreakpointIds.clear(); | 183 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 181 m_inspector->setAsyncCallStackDepth(this, 0); | 184 m_debugger->setAsyncCallStackDepth(this, 0); |
| 182 m_continueToLocationBreakpointId = String16(); | 185 m_continueToLocationBreakpointId = String16(); |
| 183 clearBreakDetails(); | 186 clearBreakDetails(); |
| 184 m_scheduledDebuggerStep = NoStep; | 187 m_scheduledDebuggerStep = NoStep; |
| 185 m_skipNextDebuggerStepOut = false; | 188 m_skipNextDebuggerStepOut = false; |
| 186 m_javaScriptPauseScheduled = false; | 189 m_javaScriptPauseScheduled = false; |
| 187 m_steppingFromFramework = false; | 190 m_steppingFromFramework = false; |
| 188 m_pausingOnNativeEvent = false; | 191 m_pausingOnNativeEvent = false; |
| 189 m_skippedStepFrameCount = 0; | 192 m_skippedStepFrameCount = 0; |
| 190 m_recursionLevelForStepFrame = 0; | 193 m_recursionLevelForStepFrame = 0; |
| 191 m_skipAllPauses = false; | 194 m_skipAllPauses = false; |
| 192 m_blackboxPattern = nullptr; | 195 m_blackboxPattern = nullptr; |
| 193 m_state->remove(DebuggerAgentState::blackboxPattern); | 196 m_state->remove(DebuggerAgentState::blackboxPattern); |
| 194 m_enabled = false; | 197 m_enabled = false; |
| 195 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); | 198 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); |
| 196 } | 199 } |
| 197 | 200 |
| 198 void V8DebuggerAgentImpl::restore() | 201 void V8DebuggerAgentImpl::restore() |
| 199 { | 202 { |
| 200 DCHECK(!m_enabled); | 203 DCHECK(!m_enabled); |
| 201 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) | 204 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) |
| 202 return; | 205 return; |
| 203 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) | 206 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) |
| 204 return; | 207 return; |
| 205 | 208 |
| 206 enable(); | 209 enable(); |
| 207 ErrorString error; | 210 ErrorString error; |
| 208 | 211 |
| 209 int pauseState = V8InspectorImpl::DontPauseOnExceptions; | 212 int pauseState = V8Debugger::DontPauseOnExceptions; |
| 210 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState)
; | 213 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState)
; |
| 211 setPauseOnExceptionsImpl(&error, pauseState); | 214 setPauseOnExceptionsImpl(&error, pauseState); |
| 212 DCHECK(error.isEmpty()); | 215 DCHECK(error.isEmpty()); |
| 213 | 216 |
| 214 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); | 217 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); |
| 215 | 218 |
| 216 int asyncCallStackDepth = 0; | 219 int asyncCallStackDepth = 0; |
| 217 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, &asyncCallStack
Depth); | 220 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, &asyncCallStack
Depth); |
| 218 m_inspector->setAsyncCallStackDepth(this, asyncCallStackDepth); | 221 m_debugger->setAsyncCallStackDepth(this, asyncCallStackDepth); |
| 219 | 222 |
| 220 String16 blackboxPattern; | 223 String16 blackboxPattern; |
| 221 if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern
)) { | 224 if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern
)) { |
| 222 if (!setBlackboxPattern(&error, blackboxPattern)) | 225 if (!setBlackboxPattern(&error, blackboxPattern)) |
| 223 NOTREACHED(); | 226 NOTREACHED(); |
| 224 } | 227 } |
| 225 } | 228 } |
| 226 | 229 |
| 227 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) | 230 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) |
| 228 { | 231 { |
| 229 if (!checkEnabled(errorString)) | 232 if (!checkEnabled(errorString)) |
| 230 return; | 233 return; |
| 231 m_inspector->setBreakpointsActivated(active); | 234 m_debugger->setBreakpointsActivated(active); |
| 232 } | 235 } |
| 233 | 236 |
| 234 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) | 237 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) |
| 235 { | 238 { |
| 236 m_skipAllPauses = skipped; | 239 m_skipAllPauses = skipped; |
| 237 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); | 240 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); |
| 238 } | 241 } |
| 239 | 242 |
| 240 static std::unique_ptr<protocol::DictionaryValue> buildObjectForBreakpointCookie
(const String16& url, int lineNumber, int columnNumber, const String16& conditio
n, bool isRegex) | 243 static std::unique_ptr<protocol::DictionaryValue> buildObjectForBreakpointCookie
(const String16& url, int lineNumber, int columnNumber, const String16& conditio
n, bool isRegex) |
| 241 { | 244 { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) | 362 void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) |
| 360 { | 363 { |
| 361 DCHECK(enabled()); | 364 DCHECK(enabled()); |
| 362 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); | 365 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); |
| 363 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) | 366 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) |
| 364 return; | 367 return; |
| 365 const std::vector<String16>& ids = debuggerBreakpointIdsIterator->second; | 368 const std::vector<String16>& ids = debuggerBreakpointIdsIterator->second; |
| 366 for (size_t i = 0; i < ids.size(); ++i) { | 369 for (size_t i = 0; i < ids.size(); ++i) { |
| 367 const String16& debuggerBreakpointId = ids[i]; | 370 const String16& debuggerBreakpointId = ids[i]; |
| 368 | 371 |
| 369 m_inspector->removeBreakpoint(debuggerBreakpointId); | 372 m_debugger->removeBreakpoint(debuggerBreakpointId); |
| 370 m_serverBreakpoints.erase(debuggerBreakpointId); | 373 m_serverBreakpoints.erase(debuggerBreakpointId); |
| 371 } | 374 } |
| 372 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); | 375 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); |
| 373 } | 376 } |
| 374 | 377 |
| 375 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, | 378 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, |
| 376 std::unique_ptr<protocol::Debugger::Location> location, | 379 std::unique_ptr<protocol::Debugger::Location> location, |
| 377 const protocol::Maybe<bool>& interstateLocationOpt) | 380 const protocol::Maybe<bool>& interstateLocationOpt) |
| 378 { | 381 { |
| 379 if (!checkEnabled(errorString)) | 382 if (!checkEnabled(errorString)) |
| 380 return; | 383 return; |
| 381 if (!m_continueToLocationBreakpointId.isEmpty()) { | 384 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 382 m_inspector->removeBreakpoint(m_continueToLocationBreakpointId); | 385 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
| 383 m_continueToLocationBreakpointId = ""; | 386 m_continueToLocationBreakpointId = ""; |
| 384 } | 387 } |
| 385 | 388 |
| 386 String16 scriptId; | 389 String16 scriptId; |
| 387 int lineNumber; | 390 int lineNumber; |
| 388 int columnNumber; | 391 int columnNumber; |
| 389 | 392 |
| 390 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber,
&columnNumber)) | 393 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber,
&columnNumber)) |
| 391 return; | 394 return; |
| 392 | 395 |
| 393 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); | 396 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); |
| 394 m_continueToLocationBreakpointId = m_inspector->setBreakpoint(scriptId, brea
kpoint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); | 397 m_continueToLocationBreakpointId = m_debugger->setBreakpoint(scriptId, break
point, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); |
| 395 resume(errorString); | 398 resume(errorString); |
| 396 } | 399 } |
| 397 | 400 |
| 398 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr
<Array<CallFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace) | 401 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr
<Array<CallFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace) |
| 399 { | 402 { |
| 400 if (!assertPaused(errorString)) | 403 if (!assertPaused(errorString)) |
| 401 return; | 404 return; |
| 402 JavaScriptCallFrames frames = m_inspector->currentCallFrames(); | 405 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); |
| 403 m_pausedCallFrames.swap(frames); | 406 m_pausedCallFrames.swap(frames); |
| 404 *callFrames = currentCallFrames(errorString); | 407 *callFrames = currentCallFrames(errorString); |
| 405 if (!*callFrames) | 408 if (!*callFrames) |
| 406 return; | 409 return; |
| 407 *asyncStackTrace = currentAsyncStackTrace(); | 410 *asyncStackTrace = currentAsyncStackTrace(); |
| 408 } | 411 } |
| 409 | 412 |
| 410 bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() | 413 bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() |
| 411 { | 414 { |
| 412 DCHECK(enabled()); | 415 DCHECK(enabled()); |
| 413 JavaScriptCallFrames callFrames = m_inspector->currentCallFrames(); | 416 JavaScriptCallFrames callFrames = m_debugger->currentCallFrames(); |
| 414 for (size_t index = 0; index < callFrames.size(); ++index) { | 417 for (size_t index = 0; index < callFrames.size(); ++index) { |
| 415 if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) | 418 if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) |
| 416 return false; | 419 return false; |
| 417 } | 420 } |
| 418 return true; | 421 return true; |
| 419 } | 422 } |
| 420 | 423 |
| 421 bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed() | 424 bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed() |
| 422 { | 425 { |
| 423 DCHECK(enabled()); | 426 DCHECK(enabled()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 CHECK(!breakpointId.isEmpty()); | 494 CHECK(!breakpointId.isEmpty()); |
| 492 CHECK(!scriptId.isEmpty()); | 495 CHECK(!scriptId.isEmpty()); |
| 493 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 496 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
| 494 if (scriptIterator == m_scripts.end()) | 497 if (scriptIterator == m_scripts.end()) |
| 495 return nullptr; | 498 return nullptr; |
| 496 if (breakpoint.lineNumber < scriptIterator->second->startLine() || scriptIte
rator->second->endLine() < breakpoint.lineNumber) | 499 if (breakpoint.lineNumber < scriptIterator->second->startLine() || scriptIte
rator->second->endLine() < breakpoint.lineNumber) |
| 497 return nullptr; | 500 return nullptr; |
| 498 | 501 |
| 499 int actualLineNumber; | 502 int actualLineNumber; |
| 500 int actualColumnNumber; | 503 int actualColumnNumber; |
| 501 String16 debuggerBreakpointId = m_inspector->setBreakpoint(scriptId, breakpo
int, &actualLineNumber, &actualColumnNumber, false); | 504 String16 debuggerBreakpointId = m_debugger->setBreakpoint(scriptId, breakpoi
nt, &actualLineNumber, &actualColumnNumber, false); |
| 502 if (debuggerBreakpointId.isEmpty()) | 505 if (debuggerBreakpointId.isEmpty()) |
| 503 return nullptr; | 506 return nullptr; |
| 504 | 507 |
| 505 m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, sou
rce); | 508 m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, sou
rce); |
| 506 CHECK(!breakpointId.isEmpty()); | 509 CHECK(!breakpointId.isEmpty()); |
| 507 | 510 |
| 508 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakp
ointId); | 511 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakp
ointId); |
| 509 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber)
; | 512 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber)
; |
| 510 } | 513 } |
| 511 | 514 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 534 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 537 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
| 535 Maybe<bool>* stackChanged, | 538 Maybe<bool>* stackChanged, |
| 536 Maybe<StackTrace>* asyncStackTrace, | 539 Maybe<StackTrace>* asyncStackTrace, |
| 537 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) | 540 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) |
| 538 { | 541 { |
| 539 if (!checkEnabled(errorString)) | 542 if (!checkEnabled(errorString)) |
| 540 return; | 543 return; |
| 541 | 544 |
| 542 v8::HandleScope handles(m_isolate); | 545 v8::HandleScope handles(m_isolate); |
| 543 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); | 546 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); |
| 544 if (!m_inspector->setScriptSource(scriptId, newSource, preview.fromMaybe(fal
se), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) | 547 if (!m_debugger->setScriptSource(scriptId, newSource, preview.fromMaybe(fals
e), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) |
| 545 return; | 548 return; |
| 546 | 549 |
| 547 ScriptsMap::iterator it = m_scripts.find(scriptId); | 550 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 548 if (it != m_scripts.end()) | 551 if (it != m_scripts.end()) |
| 549 it->second->setSource(m_isolate, newSource); | 552 it->second->setSource(m_isolate, newSource); |
| 550 | 553 |
| 551 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString
); | 554 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString
); |
| 552 if (!callFrames) | 555 if (!callFrames) |
| 553 return; | 556 return; |
| 554 *newCallFrames = std::move(callFrames); | 557 *newCallFrames = std::move(callFrames); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 569 *errorString = "Could not find call frame with given id"; | 572 *errorString = "Could not find call frame with given id"; |
| 570 return; | 573 return; |
| 571 } | 574 } |
| 572 | 575 |
| 573 v8::Local<v8::Value> resultValue; | 576 v8::Local<v8::Value> resultValue; |
| 574 v8::Local<v8::Boolean> result; | 577 v8::Local<v8::Boolean> result; |
| 575 if (!m_pausedCallFrames[scope.frameOrdinal()]->restart().ToLocal(&resultValu
e) || scope.tryCatch().HasCaught() || !resultValue->ToBoolean(scope.context()).T
oLocal(&result) || !result->Value()) { | 578 if (!m_pausedCallFrames[scope.frameOrdinal()]->restart().ToLocal(&resultValu
e) || scope.tryCatch().HasCaught() || !resultValue->ToBoolean(scope.context()).T
oLocal(&result) || !result->Value()) { |
| 576 *errorString = "Internal error"; | 579 *errorString = "Internal error"; |
| 577 return; | 580 return; |
| 578 } | 581 } |
| 579 JavaScriptCallFrames frames = m_inspector->currentCallFrames(); | 582 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); |
| 580 m_pausedCallFrames.swap(frames); | 583 m_pausedCallFrames.swap(frames); |
| 581 | 584 |
| 582 *newCallFrames = currentCallFrames(errorString); | 585 *newCallFrames = currentCallFrames(errorString); |
| 583 if (!*newCallFrames) | 586 if (!*newCallFrames) |
| 584 return; | 587 return; |
| 585 *asyncStackTrace = currentAsyncStackTrace(); | 588 *asyncStackTrace = currentAsyncStackTrace(); |
| 586 } | 589 } |
| 587 | 590 |
| 588 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
riptId, String16* scriptSource) | 591 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
riptId, String16* scriptSource) |
| 589 { | 592 { |
| 590 if (!checkEnabled(error)) | 593 if (!checkEnabled(error)) |
| 591 return; | 594 return; |
| 592 ScriptsMap::iterator it = m_scripts.find(scriptId); | 595 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 593 if (it == m_scripts.end()) { | 596 if (it == m_scripts.end()) { |
| 594 *error = "No script for id: " + scriptId; | 597 *error = "No script for id: " + scriptId; |
| 595 return; | 598 return; |
| 596 } | 599 } |
| 597 v8::HandleScope handles(m_isolate); | 600 v8::HandleScope handles(m_isolate); |
| 598 *scriptSource = toProtocolString(it->second->source(m_isolate)); | 601 *scriptSource = toProtocolString(it->second->source(m_isolate)); |
| 599 } | 602 } |
| 600 | 603 |
| 601 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas
on, std::unique_ptr<protocol::DictionaryValue> data) | 604 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas
on, std::unique_ptr<protocol::DictionaryValue> data) |
| 602 { | 605 { |
| 603 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc
heduled || m_inspector->isPaused() || !m_inspector->breakpointsActivated()) | 606 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc
heduled || m_debugger->isPaused() || !m_debugger->breakpointsActivated()) |
| 604 return; | 607 return; |
| 605 m_breakReason = breakReason; | 608 m_breakReason = breakReason; |
| 606 m_breakAuxData = std::move(data); | 609 m_breakAuxData = std::move(data); |
| 607 m_pausingOnNativeEvent = true; | 610 m_pausingOnNativeEvent = true; |
| 608 m_skipNextDebuggerStepOut = false; | 611 m_skipNextDebuggerStepOut = false; |
| 609 m_inspector->setPauseOnNextStatement(true); | 612 m_debugger->setPauseOnNextStatement(true); |
| 610 } | 613 } |
| 611 | 614 |
| 612 void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() | 615 void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() |
| 613 { | 616 { |
| 614 DCHECK(enabled()); | 617 DCHECK(enabled()); |
| 615 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || m_i
nspector->isPaused()) | 618 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || m_d
ebugger->isPaused()) |
| 616 return; | 619 return; |
| 617 clearBreakDetails(); | 620 clearBreakDetails(); |
| 618 m_pausingOnNativeEvent = false; | 621 m_pausingOnNativeEvent = false; |
| 619 m_skippedStepFrameCount = 0; | 622 m_skippedStepFrameCount = 0; |
| 620 m_recursionLevelForStepFrame = 0; | 623 m_recursionLevelForStepFrame = 0; |
| 621 m_inspector->setPauseOnNextStatement(true); | 624 m_debugger->setPauseOnNextStatement(true); |
| 622 } | 625 } |
| 623 | 626 |
| 624 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() | 627 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() |
| 625 { | 628 { |
| 626 if (m_javaScriptPauseScheduled || m_inspector->isPaused()) | 629 if (m_javaScriptPauseScheduled || m_debugger->isPaused()) |
| 627 return; | 630 return; |
| 628 clearBreakDetails(); | 631 clearBreakDetails(); |
| 629 m_pausingOnNativeEvent = false; | 632 m_pausingOnNativeEvent = false; |
| 630 m_inspector->setPauseOnNextStatement(false); | 633 m_debugger->setPauseOnNextStatement(false); |
| 631 } | 634 } |
| 632 | 635 |
| 633 void V8DebuggerAgentImpl::pause(ErrorString* errorString) | 636 void V8DebuggerAgentImpl::pause(ErrorString* errorString) |
| 634 { | 637 { |
| 635 if (!checkEnabled(errorString)) | 638 if (!checkEnabled(errorString)) |
| 636 return; | 639 return; |
| 637 if (m_javaScriptPauseScheduled || m_inspector->isPaused()) | 640 if (m_javaScriptPauseScheduled || m_debugger->isPaused()) |
| 638 return; | 641 return; |
| 639 clearBreakDetails(); | 642 clearBreakDetails(); |
| 640 m_javaScriptPauseScheduled = true; | 643 m_javaScriptPauseScheduled = true; |
| 641 m_scheduledDebuggerStep = NoStep; | 644 m_scheduledDebuggerStep = NoStep; |
| 642 m_skippedStepFrameCount = 0; | 645 m_skippedStepFrameCount = 0; |
| 643 m_steppingFromFramework = false; | 646 m_steppingFromFramework = false; |
| 644 m_inspector->setPauseOnNextStatement(true); | 647 m_debugger->setPauseOnNextStatement(true); |
| 645 } | 648 } |
| 646 | 649 |
| 647 void V8DebuggerAgentImpl::resume(ErrorString* errorString) | 650 void V8DebuggerAgentImpl::resume(ErrorString* errorString) |
| 648 { | 651 { |
| 649 if (!assertPaused(errorString)) | 652 if (!assertPaused(errorString)) |
| 650 return; | 653 return; |
| 651 m_scheduledDebuggerStep = NoStep; | 654 m_scheduledDebuggerStep = NoStep; |
| 652 m_steppingFromFramework = false; | 655 m_steppingFromFramework = false; |
| 653 m_session->releaseObjectGroup(backtraceObjectGroup); | 656 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 654 m_inspector->continueProgram(); | 657 m_debugger->continueProgram(); |
| 655 } | 658 } |
| 656 | 659 |
| 657 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) | 660 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) |
| 658 { | 661 { |
| 659 if (!assertPaused(errorString)) | 662 if (!assertPaused(errorString)) |
| 660 return; | 663 return; |
| 661 // StepOver at function return point should fallback to StepInto. | 664 // StepOver at function return point should fallback to StepInto. |
| 662 JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrame
s[0].get() : nullptr; | 665 JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrame
s[0].get() : nullptr; |
| 663 if (frame && frame->isAtReturn()) { | 666 if (frame && frame->isAtReturn()) { |
| 664 stepInto(errorString); | 667 stepInto(errorString); |
| 665 return; | 668 return; |
| 666 } | 669 } |
| 667 m_scheduledDebuggerStep = StepOver; | 670 m_scheduledDebuggerStep = StepOver; |
| 668 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 671 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 669 m_session->releaseObjectGroup(backtraceObjectGroup); | 672 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 670 m_inspector->stepOverStatement(); | 673 m_debugger->stepOverStatement(); |
| 671 } | 674 } |
| 672 | 675 |
| 673 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) | 676 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) |
| 674 { | 677 { |
| 675 if (!assertPaused(errorString)) | 678 if (!assertPaused(errorString)) |
| 676 return; | 679 return; |
| 677 m_scheduledDebuggerStep = StepInto; | 680 m_scheduledDebuggerStep = StepInto; |
| 678 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 681 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 679 m_session->releaseObjectGroup(backtraceObjectGroup); | 682 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 680 m_inspector->stepIntoStatement(); | 683 m_debugger->stepIntoStatement(); |
| 681 } | 684 } |
| 682 | 685 |
| 683 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) | 686 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) |
| 684 { | 687 { |
| 685 if (!assertPaused(errorString)) | 688 if (!assertPaused(errorString)) |
| 686 return; | 689 return; |
| 687 m_scheduledDebuggerStep = StepOut; | 690 m_scheduledDebuggerStep = StepOut; |
| 688 m_skipNextDebuggerStepOut = false; | 691 m_skipNextDebuggerStepOut = false; |
| 689 m_recursionLevelForStepOut = 1; | 692 m_recursionLevelForStepOut = 1; |
| 690 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 693 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 691 m_session->releaseObjectGroup(backtraceObjectGroup); | 694 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 692 m_inspector->stepOutOfFunction(); | 695 m_debugger->stepOutOfFunction(); |
| 693 } | 696 } |
| 694 | 697 |
| 695 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring16& stringPauseState) | 698 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring16& stringPauseState) |
| 696 { | 699 { |
| 697 if (!checkEnabled(errorString)) | 700 if (!checkEnabled(errorString)) |
| 698 return; | 701 return; |
| 699 V8InspectorImpl::PauseOnExceptionsState pauseState; | 702 V8Debugger::PauseOnExceptionsState pauseState; |
| 700 if (stringPauseState == "none") { | 703 if (stringPauseState == "none") { |
| 701 pauseState = V8InspectorImpl::DontPauseOnExceptions; | 704 pauseState = V8Debugger::DontPauseOnExceptions; |
| 702 } else if (stringPauseState == "all") { | 705 } else if (stringPauseState == "all") { |
| 703 pauseState = V8InspectorImpl::PauseOnAllExceptions; | 706 pauseState = V8Debugger::PauseOnAllExceptions; |
| 704 } else if (stringPauseState == "uncaught") { | 707 } else if (stringPauseState == "uncaught") { |
| 705 pauseState = V8InspectorImpl::PauseOnUncaughtExceptions; | 708 pauseState = V8Debugger::PauseOnUncaughtExceptions; |
| 706 } else { | 709 } else { |
| 707 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; | 710 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; |
| 708 return; | 711 return; |
| 709 } | 712 } |
| 710 setPauseOnExceptionsImpl(errorString, pauseState); | 713 setPauseOnExceptionsImpl(errorString, pauseState); |
| 711 } | 714 } |
| 712 | 715 |
| 713 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int
pauseState) | 716 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int
pauseState) |
| 714 { | 717 { |
| 715 m_inspector->setPauseOnExceptionsState(static_cast<V8InspectorImpl::PauseOnE
xceptionsState>(pauseState)); | 718 m_debugger->setPauseOnExceptionsState(static_cast<V8Debugger::PauseOnExcepti
onsState>(pauseState)); |
| 716 if (m_inspector->getPauseOnExceptionsState() != pauseState) | 719 if (m_debugger->getPauseOnExceptionsState() != pauseState) |
| 717 *errorString = "Internal error. Could not change pause on exceptions sta
te"; | 720 *errorString = "Internal error. Could not change pause on exceptions sta
te"; |
| 718 else | 721 else |
| 719 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseSta
te); | 722 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseSta
te); |
| 720 } | 723 } |
| 721 | 724 |
| 722 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, | 725 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, |
| 723 const String16& callFrameId, | 726 const String16& callFrameId, |
| 724 const String16& expression, | 727 const String16& expression, |
| 725 const Maybe<String16>& objectGroup, | 728 const Maybe<String16>& objectGroup, |
| 726 const Maybe<bool>& includeCommandLineAPI, | 729 const Maybe<bool>& includeCommandLineAPI, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 *errorString = "Internal error"; | 792 *errorString = "Internal error"; |
| 790 return; | 793 return; |
| 791 } | 794 } |
| 792 } | 795 } |
| 793 | 796 |
| 794 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) | 797 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) |
| 795 { | 798 { |
| 796 if (!checkEnabled(errorString)) | 799 if (!checkEnabled(errorString)) |
| 797 return; | 800 return; |
| 798 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, depth); | 801 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, depth); |
| 799 m_inspector->setAsyncCallStackDepth(this, depth); | 802 m_debugger->setAsyncCallStackDepth(this, depth); |
| 800 } | 803 } |
| 801 | 804 |
| 802 void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni
que_ptr<protocol::Array<String16>> patterns) | 805 void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni
que_ptr<protocol::Array<String16>> patterns) |
| 803 { | 806 { |
| 804 if (!patterns->length()) { | 807 if (!patterns->length()) { |
| 805 m_blackboxPattern = nullptr; | 808 m_blackboxPattern = nullptr; |
| 806 m_state->remove(DebuggerAgentState::blackboxPattern); | 809 m_state->remove(DebuggerAgentState::blackboxPattern); |
| 807 return; | 810 return; |
| 808 } | 811 } |
| 809 | 812 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 schedulePauseOnNextStatementIfSteppingInto(); | 884 schedulePauseOnNextStatementIfSteppingInto(); |
| 882 } | 885 } |
| 883 | 886 |
| 884 void V8DebuggerAgentImpl::didExecuteScript() | 887 void V8DebuggerAgentImpl::didExecuteScript() |
| 885 { | 888 { |
| 886 changeJavaScriptRecursionLevel(-1); | 889 changeJavaScriptRecursionLevel(-1); |
| 887 } | 890 } |
| 888 | 891 |
| 889 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) | 892 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) |
| 890 { | 893 { |
| 891 if (m_javaScriptPauseScheduled && !m_skipAllPauses && !m_inspector->isPaused
()) { | 894 if (m_javaScriptPauseScheduled && !m_skipAllPauses && !m_debugger->isPaused(
)) { |
| 892 // Do not ever loose user's pause request until we have actually paused. | 895 // Do not ever loose user's pause request until we have actually paused. |
| 893 m_inspector->setPauseOnNextStatement(true); | 896 m_debugger->setPauseOnNextStatement(true); |
| 894 } | 897 } |
| 895 if (m_scheduledDebuggerStep == StepOut) { | 898 if (m_scheduledDebuggerStep == StepOut) { |
| 896 m_recursionLevelForStepOut += step; | 899 m_recursionLevelForStepOut += step; |
| 897 if (!m_recursionLevelForStepOut) { | 900 if (!m_recursionLevelForStepOut) { |
| 898 // When StepOut crosses a task boundary (i.e. js -> blink_c++) from
where it was requested, | 901 // When StepOut crosses a task boundary (i.e. js -> blink_c++) from
where it was requested, |
| 899 // switch stepping to step into a next JS task, as if we exited to a
blackboxed framework. | 902 // switch stepping to step into a next JS task, as if we exited to a
blackboxed framework. |
| 900 m_scheduledDebuggerStep = StepInto; | 903 m_scheduledDebuggerStep = StepInto; |
| 901 m_skipNextDebuggerStepOut = false; | 904 m_skipNextDebuggerStepOut = false; |
| 902 } | 905 } |
| 903 } | 906 } |
| 904 if (m_recursionLevelForStepFrame) { | 907 if (m_recursionLevelForStepFrame) { |
| 905 m_recursionLevelForStepFrame += step; | 908 m_recursionLevelForStepFrame += step; |
| 906 if (!m_recursionLevelForStepFrame) { | 909 if (!m_recursionLevelForStepFrame) { |
| 907 // We have walked through a blackboxed framework and got back to whe
re we started. | 910 // We have walked through a blackboxed framework and got back to whe
re we started. |
| 908 // If there was no stepping scheduled, we should cancel the stepping
explicitly, | 911 // If there was no stepping scheduled, we should cancel the stepping
explicitly, |
| 909 // since there may be a scheduled StepFrame left. | 912 // since there may be a scheduled StepFrame left. |
| 910 // Otherwise, if we were stepping in/over, the StepFrame will stop a
t the right location, | 913 // Otherwise, if we were stepping in/over, the StepFrame will stop a
t the right location, |
| 911 // whereas if we were stepping out, we should continue doing so afte
r debugger pauses | 914 // whereas if we were stepping out, we should continue doing so afte
r debugger pauses |
| 912 // from the old StepFrame. | 915 // from the old StepFrame. |
| 913 m_skippedStepFrameCount = 0; | 916 m_skippedStepFrameCount = 0; |
| 914 if (m_scheduledDebuggerStep == NoStep) | 917 if (m_scheduledDebuggerStep == NoStep) |
| 915 m_inspector->clearStepping(); | 918 m_debugger->clearStepping(); |
| 916 else if (m_scheduledDebuggerStep == StepOut) | 919 else if (m_scheduledDebuggerStep == StepOut) |
| 917 m_skipNextDebuggerStepOut = true; | 920 m_skipNextDebuggerStepOut = true; |
| 918 } | 921 } |
| 919 } | 922 } |
| 920 } | 923 } |
| 921 | 924 |
| 922 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
ring* errorString) | 925 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
ring* errorString) |
| 923 { | 926 { |
| 924 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) | 927 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) |
| 925 return Array<CallFrame>::create(); | 928 return Array<CallFrame>::create(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro
tocolValue(debuggerContext, objects).get(), &errorSupport); | 980 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro
tocolValue(debuggerContext, objects).get(), &errorSupport); |
| 978 if (hasInternalError(errorString, !callFrames)) | 981 if (hasInternalError(errorString, !callFrames)) |
| 979 return Array<CallFrame>::create(); | 982 return Array<CallFrame>::create(); |
| 980 return callFrames; | 983 return callFrames; |
| 981 } | 984 } |
| 982 | 985 |
| 983 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() | 986 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() |
| 984 { | 987 { |
| 985 if (m_pausedContext.IsEmpty()) | 988 if (m_pausedContext.IsEmpty()) |
| 986 return nullptr; | 989 return nullptr; |
| 987 V8StackTraceImpl* stackTrace = m_inspector->currentAsyncCallChain(); | 990 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); |
| 988 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_inspector) : n
ullptr; | 991 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) : nu
llptr; |
| 989 } | 992 } |
| 990 | 993 |
| 991 void V8DebuggerAgentImpl::didParseSource(std::unique_ptr<V8DebuggerScript> scrip
t, bool success) | 994 void V8DebuggerAgentImpl::didParseSource(std::unique_ptr<V8DebuggerScript> scrip
t, bool success) |
| 992 { | 995 { |
| 993 v8::HandleScope handles(m_isolate); | 996 v8::HandleScope handles(m_isolate); |
| 994 String16 scriptSource = toProtocolString(script->source(m_isolate)); | 997 String16 scriptSource = toProtocolString(script->source(m_isolate)); |
| 995 bool isDeprecatedSourceURL = false; | 998 bool isDeprecatedSourceURL = false; |
| 996 if (!success) | 999 if (!success) |
| 997 script->setSourceURL(findSourceURL(scriptSource, false, &isDeprecatedSou
rceURL)); | 1000 script->setSourceURL(findSourceURL(scriptSource, false, &isDeprecatedSou
rceURL)); |
| 998 else if (script->hasSourceURL()) | 1001 else if (script->hasSourceURL()) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 breakpointObject->getInteger(DebuggerAgentState::columnNumber, &breakpoi
nt.columnNumber); | 1049 breakpointObject->getInteger(DebuggerAgentState::columnNumber, &breakpoi
nt.columnNumber); |
| 1047 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); | 1050 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); |
| 1048 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi
nt(cookie.first, scriptId, breakpoint, UserBreakpointSource); | 1051 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi
nt(cookie.first, scriptId, breakpoint, UserBreakpointSource); |
| 1049 if (location) | 1052 if (location) |
| 1050 m_frontend.breakpointResolved(cookie.first, std::move(location)); | 1053 m_frontend.breakpointResolved(cookie.first, std::move(location)); |
| 1051 } | 1054 } |
| 1052 } | 1055 } |
| 1053 | 1056 |
| 1054 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>&
hitBreakpoints, bool isPromiseRejection) | 1057 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>&
hitBreakpoints, bool isPromiseRejection) |
| 1055 { | 1058 { |
| 1056 JavaScriptCallFrames callFrames = m_inspector->currentCallFrames(1); | 1059 JavaScriptCallFrames callFrames = m_debugger->currentCallFrames(1); |
| 1057 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin()
->get() : nullptr; | 1060 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin()
->get() : nullptr; |
| 1058 | 1061 |
| 1059 // Skip pause in internal scripts (e.g. InjectedScriptSource.js). | 1062 // Skip pause in internal scripts (e.g. InjectedScriptSource.js). |
| 1060 if (topCallFrame) { | 1063 if (topCallFrame) { |
| 1061 ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(topCallFr
ame->sourceID())); | 1064 ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(topCallFr
ame->sourceID())); |
| 1062 if (it != m_scripts.end() && it->second->isInternalScript()) | 1065 if (it != m_scripts.end() && it->second->isInternalScript()) |
| 1063 return RequestStepFrame; | 1066 return RequestStepFrame; |
| 1064 } | 1067 } |
| 1065 | 1068 |
| 1066 V8DebuggerAgentImpl::SkipPauseRequest result; | 1069 V8DebuggerAgentImpl::SkipPauseRequest result; |
| 1067 if (m_skipAllPauses) | 1070 if (m_skipAllPauses) |
| 1068 result = RequestContinue; | 1071 result = RequestContinue; |
| 1069 else if (!hitBreakpoints.empty()) | 1072 else if (!hitBreakpoints.empty()) |
| 1070 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. | 1073 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. |
| 1071 else if (!exception.IsEmpty()) | 1074 else if (!exception.IsEmpty()) |
| 1072 result = shouldSkipExceptionPause(topCallFrame); | 1075 result = shouldSkipExceptionPause(topCallFrame); |
| 1073 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) | 1076 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) |
| 1074 result = shouldSkipStepPause(topCallFrame); | 1077 result = shouldSkipStepPause(topCallFrame); |
| 1075 else | 1078 else |
| 1076 result = RequestNoSkip; | 1079 result = RequestNoSkip; |
| 1077 | 1080 |
| 1078 m_skipNextDebuggerStepOut = false; | 1081 m_skipNextDebuggerStepOut = false; |
| 1079 if (result != RequestNoSkip) | 1082 if (result != RequestNoSkip) |
| 1080 return result; | 1083 return result; |
| 1081 // Skip pauses inside V8 internal scripts and on syntax errors. | 1084 // Skip pauses inside V8 internal scripts and on syntax errors. |
| 1082 if (!topCallFrame) | 1085 if (!topCallFrame) |
| 1083 return RequestContinue; | 1086 return RequestContinue; |
| 1084 | 1087 |
| 1085 DCHECK(m_pausedContext.IsEmpty()); | 1088 DCHECK(m_pausedContext.IsEmpty()); |
| 1086 JavaScriptCallFrames frames = m_inspector->currentCallFrames(); | 1089 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); |
| 1087 m_pausedCallFrames.swap(frames); | 1090 m_pausedCallFrames.swap(frames); |
| 1088 m_pausedContext.Reset(m_isolate, context); | 1091 m_pausedContext.Reset(m_isolate, context); |
| 1089 v8::HandleScope handles(m_isolate); | 1092 v8::HandleScope handles(m_isolate); |
| 1090 | 1093 |
| 1091 if (!exception.IsEmpty()) { | 1094 if (!exception.IsEmpty()) { |
| 1092 ErrorString ignored; | 1095 ErrorString ignored; |
| 1093 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored,
V8InspectorImpl::contextId(context)); | 1096 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored,
V8Debugger::contextId(context)); |
| 1094 if (injectedScript) { | 1097 if (injectedScript) { |
| 1095 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea
sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; | 1098 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea
sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; |
| 1096 ErrorString errorString; | 1099 ErrorString errorString; |
| 1097 auto obj = injectedScript->wrapObject(&errorString, exception, backt
raceObjectGroup); | 1100 auto obj = injectedScript->wrapObject(&errorString, exception, backt
raceObjectGroup); |
| 1098 m_breakAuxData = obj ? obj->serialize() : nullptr; | 1101 m_breakAuxData = obj ? obj->serialize() : nullptr; |
| 1099 // m_breakAuxData might be null after this. | 1102 // m_breakAuxData might be null after this. |
| 1100 } | 1103 } |
| 1101 } | 1104 } |
| 1102 | 1105 |
| 1103 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(
); | 1106 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(
); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1117 ErrorString errorString; | 1120 ErrorString errorString; |
| 1118 m_frontend.paused(currentCallFrames(&errorString), m_breakReason, std::move(
m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace()); | 1121 m_frontend.paused(currentCallFrames(&errorString), m_breakReason, std::move(
m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace()); |
| 1119 m_scheduledDebuggerStep = NoStep; | 1122 m_scheduledDebuggerStep = NoStep; |
| 1120 m_javaScriptPauseScheduled = false; | 1123 m_javaScriptPauseScheduled = false; |
| 1121 m_steppingFromFramework = false; | 1124 m_steppingFromFramework = false; |
| 1122 m_pausingOnNativeEvent = false; | 1125 m_pausingOnNativeEvent = false; |
| 1123 m_skippedStepFrameCount = 0; | 1126 m_skippedStepFrameCount = 0; |
| 1124 m_recursionLevelForStepFrame = 0; | 1127 m_recursionLevelForStepFrame = 0; |
| 1125 | 1128 |
| 1126 if (!m_continueToLocationBreakpointId.isEmpty()) { | 1129 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 1127 m_inspector->removeBreakpoint(m_continueToLocationBreakpointId); | 1130 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
| 1128 m_continueToLocationBreakpointId = ""; | 1131 m_continueToLocationBreakpointId = ""; |
| 1129 } | 1132 } |
| 1130 return result; | 1133 return result; |
| 1131 } | 1134 } |
| 1132 | 1135 |
| 1133 void V8DebuggerAgentImpl::didContinue() | 1136 void V8DebuggerAgentImpl::didContinue() |
| 1134 { | 1137 { |
| 1135 m_pausedContext.Reset(); | 1138 m_pausedContext.Reset(); |
| 1136 JavaScriptCallFrames emptyCallFrames; | 1139 JavaScriptCallFrames emptyCallFrames; |
| 1137 m_pausedCallFrames.swap(emptyCallFrames); | 1140 m_pausedCallFrames.swap(emptyCallFrames); |
| 1138 clearBreakDetails(); | 1141 clearBreakDetails(); |
| 1139 m_frontend.resumed(); | 1142 m_frontend.resumed(); |
| 1140 } | 1143 } |
| 1141 | 1144 |
| 1142 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_
ptr<protocol::DictionaryValue> data) | 1145 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_
ptr<protocol::DictionaryValue> data) |
| 1143 { | 1146 { |
| 1144 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent
CallStackEmptyOrBlackboxed() || !m_inspector->breakpointsActivated()) | 1147 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent
CallStackEmptyOrBlackboxed() || !m_debugger->breakpointsActivated()) |
| 1145 return; | 1148 return; |
| 1146 m_breakReason = breakReason; | 1149 m_breakReason = breakReason; |
| 1147 m_breakAuxData = std::move(data); | 1150 m_breakAuxData = std::move(data); |
| 1148 m_scheduledDebuggerStep = NoStep; | 1151 m_scheduledDebuggerStep = NoStep; |
| 1149 m_steppingFromFramework = false; | 1152 m_steppingFromFramework = false; |
| 1150 m_pausingOnNativeEvent = false; | 1153 m_pausingOnNativeEvent = false; |
| 1151 m_inspector->breakProgram(); | 1154 m_debugger->breakProgram(); |
| 1152 } | 1155 } |
| 1153 | 1156 |
| 1154 void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, s
td::unique_ptr<protocol::DictionaryValue> data) | 1157 void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, s
td::unique_ptr<protocol::DictionaryValue> data) |
| 1155 { | 1158 { |
| 1156 if (!enabled() || m_inspector->getPauseOnExceptionsState() == V8InspectorImp
l::DontPauseOnExceptions) | 1159 if (!enabled() || m_debugger->getPauseOnExceptionsState() == V8Debugger::Don
tPauseOnExceptions) |
| 1157 return; | 1160 return; |
| 1158 breakProgram(breakReason, std::move(data)); | 1161 breakProgram(breakReason, std::move(data)); |
| 1159 } | 1162 } |
| 1160 | 1163 |
| 1161 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) | 1164 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) |
| 1162 { | 1165 { |
| 1163 if (m_pausedContext.IsEmpty()) { | 1166 if (m_pausedContext.IsEmpty()) { |
| 1164 *errorString = "Can only perform operation while paused."; | 1167 *errorString = "Can only perform operation while paused."; |
| 1165 return false; | 1168 return false; |
| 1166 } | 1169 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1189 { | 1192 { |
| 1190 if (!enabled()) | 1193 if (!enabled()) |
| 1191 return; | 1194 return; |
| 1192 m_scheduledDebuggerStep = NoStep; | 1195 m_scheduledDebuggerStep = NoStep; |
| 1193 m_scripts.clear(); | 1196 m_scripts.clear(); |
| 1194 m_blackboxedPositions.clear(); | 1197 m_blackboxedPositions.clear(); |
| 1195 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1198 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1196 } | 1199 } |
| 1197 | 1200 |
| 1198 } // namespace blink | 1201 } // namespace blink |
| OLD | NEW |