| 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/V8InspectorImpl.h" |
| 14 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 15 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| 15 #include "platform/v8_inspector/V8Regex.h" | 16 #include "platform/v8_inspector/V8Regex.h" |
| 16 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 17 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
| 17 #include "platform/v8_inspector/V8StackTraceImpl.h" | 18 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 18 #include "platform/v8_inspector/V8StringUtil.h" | 19 #include "platform/v8_inspector/V8StringUtil.h" |
| 19 #include "platform/v8_inspector/public/V8Debugger.h" | 20 #include "platform/v8_inspector/public/V8InspectorClient.h" |
| 20 #include "platform/v8_inspector/public/V8DebuggerClient.h" | |
| 21 | 21 |
| 22 #include <algorithm> | 22 #include <algorithm> |
| 23 | 23 |
| 24 using blink::protocol::Array; | 24 using blink::protocol::Array; |
| 25 using blink::protocol::Maybe; | 25 using blink::protocol::Maybe; |
| 26 using blink::protocol::Debugger::BreakpointId; | 26 using blink::protocol::Debugger::BreakpointId; |
| 27 using blink::protocol::Debugger::CallFrame; | 27 using blink::protocol::Debugger::CallFrame; |
| 28 using blink::protocol::Runtime::ExceptionDetails; | 28 using blink::protocol::Runtime::ExceptionDetails; |
| 29 using blink::protocol::Runtime::ScriptId; | 29 using blink::protocol::Runtime::ScriptId; |
| 30 using blink::protocol::Runtime::StackTrace; | 30 using blink::protocol::Runtime::StackTrace; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const
String16& scriptId, int lineNumber, int columnNumber) | 87 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const
String16& scriptId, int lineNumber, int columnNumber) |
| 88 { | 88 { |
| 89 return protocol::Debugger::Location::create() | 89 return protocol::Debugger::Location::create() |
| 90 .setScriptId(scriptId) | 90 .setScriptId(scriptId) |
| 91 .setLineNumber(lineNumber) | 91 .setLineNumber(lineNumber) |
| 92 .setColumnNumber(columnNumber).build(); | 92 .setColumnNumber(columnNumber).build(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc
ol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) | 95 V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc
ol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) |
| 96 : m_debugger(session->debugger()) | 96 : m_inspector(session->inspector()) |
| 97 , m_session(session) | 97 , m_session(session) |
| 98 , m_enabled(false) | 98 , m_enabled(false) |
| 99 , m_state(state) | 99 , m_state(state) |
| 100 , m_frontend(frontendChannel) | 100 , m_frontend(frontendChannel) |
| 101 , m_isolate(m_debugger->isolate()) | 101 , m_isolate(m_inspector->isolate()) |
| 102 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) | 102 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) |
| 103 , m_scheduledDebuggerStep(NoStep) | 103 , m_scheduledDebuggerStep(NoStep) |
| 104 , m_skipNextDebuggerStepOut(false) | 104 , m_skipNextDebuggerStepOut(false) |
| 105 , m_javaScriptPauseScheduled(false) | 105 , m_javaScriptPauseScheduled(false) |
| 106 , m_steppingFromFramework(false) | 106 , m_steppingFromFramework(false) |
| 107 , m_pausingOnNativeEvent(false) | 107 , m_pausingOnNativeEvent(false) |
| 108 , m_skippedStepFrameCount(0) | 108 , m_skippedStepFrameCount(0) |
| 109 , m_recursionLevelForStepOut(0) | 109 , m_recursionLevelForStepOut(0) |
| 110 , m_recursionLevelForStepFrame(0) | 110 , m_recursionLevelForStepFrame(0) |
| 111 , m_skipAllPauses(false) | 111 , m_skipAllPauses(false) |
| 112 { | 112 { |
| 113 clearBreakDetails(); | 113 clearBreakDetails(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() | 116 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() |
| 117 { | 117 { |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) | 120 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) |
| 121 { | 121 { |
| 122 if (enabled()) | 122 if (enabled()) |
| 123 return true; | 123 return true; |
| 124 *errorString = "Debugger agent is not enabled"; | 124 *errorString = "Debugger agent is not enabled"; |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 | 127 |
| 128 void V8DebuggerAgentImpl::enable() | 128 void V8DebuggerAgentImpl::enable() |
| 129 { | 129 { |
| 130 // debugger().addListener may result in reporting all parsed scripts to | 130 // m_inspector->addListener may result in reporting all parsed scripts to |
| 131 // the agent so it should already be in enabled state by then. | 131 // the agent so it should already be in enabled state by then. |
| 132 m_enabled = true; | 132 m_enabled = true; |
| 133 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); | 133 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); |
| 134 debugger().debuggerAgentEnabled(); | 134 m_inspector->debuggerAgentEnabled(); |
| 135 | 135 |
| 136 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts; | 136 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts; |
| 137 debugger().getCompiledScripts(m_session->contextGroupId(), compiledScripts); | 137 m_inspector->getCompiledScripts(m_session->contextGroupId(), compiledScripts
); |
| 138 for (size_t i = 0; i < compiledScripts.size(); i++) | 138 for (size_t i = 0; i < compiledScripts.size(); i++) |
| 139 didParseSource(std::move(compiledScripts[i]), true); | 139 didParseSource(std::move(compiledScripts[i]), true); |
| 140 | 140 |
| 141 // FIXME(WK44513): breakpoints activated flag should be synchronized between
all front-ends | 141 // FIXME(WK44513): breakpoints activated flag should be synchronized between
all front-ends |
| 142 debugger().setBreakpointsActivated(true); | 142 m_inspector->setBreakpointsActivated(true); |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool V8DebuggerAgentImpl::enabled() | 145 bool V8DebuggerAgentImpl::enabled() |
| 146 { | 146 { |
| 147 return m_enabled; | 147 return m_enabled; |
| 148 } | 148 } |
| 149 | 149 |
| 150 void V8DebuggerAgentImpl::enable(ErrorString* errorString) | 150 void V8DebuggerAgentImpl::enable(ErrorString* errorString) |
| 151 { | 151 { |
| 152 if (enabled()) | 152 if (enabled()) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 if (!m_debugger->client()->canExecuteScripts(m_session->contextGroupId())) { | 155 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId()))
{ |
| 156 *errorString = "Script execution is prohibited"; | 156 *errorString = "Script execution is prohibited"; |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 enable(); | 160 enable(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void V8DebuggerAgentImpl::disable(ErrorString*) | 163 void V8DebuggerAgentImpl::disable(ErrorString*) |
| 164 { | 164 { |
| 165 if (!enabled()) | 165 if (!enabled()) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict
ionaryValue::create()); | 168 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict
ionaryValue::create()); |
| 169 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerIm
pl::DontPauseOnExceptions); | 169 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8InspectorI
mpl::DontPauseOnExceptions); |
| 170 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); | 170 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); |
| 171 | 171 |
| 172 if (!m_pausedContext.IsEmpty()) | 172 if (!m_pausedContext.IsEmpty()) |
| 173 debugger().continueProgram(); | 173 m_inspector->continueProgram(); |
| 174 debugger().debuggerAgentDisabled(); | 174 m_inspector->debuggerAgentDisabled(); |
| 175 m_pausedContext.Reset(); | 175 m_pausedContext.Reset(); |
| 176 JavaScriptCallFrames emptyCallFrames; | 176 JavaScriptCallFrames emptyCallFrames; |
| 177 m_pausedCallFrames.swap(emptyCallFrames); | 177 m_pausedCallFrames.swap(emptyCallFrames); |
| 178 m_scripts.clear(); | 178 m_scripts.clear(); |
| 179 m_blackboxedPositions.clear(); | 179 m_blackboxedPositions.clear(); |
| 180 m_breakpointIdToDebuggerBreakpointIds.clear(); | 180 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 181 m_debugger->setAsyncCallStackDepth(this, 0); | 181 m_inspector->setAsyncCallStackDepth(this, 0); |
| 182 m_continueToLocationBreakpointId = String16(); | 182 m_continueToLocationBreakpointId = String16(); |
| 183 clearBreakDetails(); | 183 clearBreakDetails(); |
| 184 m_scheduledDebuggerStep = NoStep; | 184 m_scheduledDebuggerStep = NoStep; |
| 185 m_skipNextDebuggerStepOut = false; | 185 m_skipNextDebuggerStepOut = false; |
| 186 m_javaScriptPauseScheduled = false; | 186 m_javaScriptPauseScheduled = false; |
| 187 m_steppingFromFramework = false; | 187 m_steppingFromFramework = false; |
| 188 m_pausingOnNativeEvent = false; | 188 m_pausingOnNativeEvent = false; |
| 189 m_skippedStepFrameCount = 0; | 189 m_skippedStepFrameCount = 0; |
| 190 m_recursionLevelForStepFrame = 0; | 190 m_recursionLevelForStepFrame = 0; |
| 191 m_skipAllPauses = false; | 191 m_skipAllPauses = false; |
| 192 m_blackboxPattern = nullptr; | 192 m_blackboxPattern = nullptr; |
| 193 m_state->remove(DebuggerAgentState::blackboxPattern); | 193 m_state->remove(DebuggerAgentState::blackboxPattern); |
| 194 m_enabled = false; | 194 m_enabled = false; |
| 195 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); | 195 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void V8DebuggerAgentImpl::restore() | 198 void V8DebuggerAgentImpl::restore() |
| 199 { | 199 { |
| 200 DCHECK(!m_enabled); | 200 DCHECK(!m_enabled); |
| 201 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) | 201 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) |
| 202 return; | 202 return; |
| 203 if (!m_debugger->client()->canExecuteScripts(m_session->contextGroupId())) | 203 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) |
| 204 return; | 204 return; |
| 205 | 205 |
| 206 enable(); | 206 enable(); |
| 207 ErrorString error; | 207 ErrorString error; |
| 208 | 208 |
| 209 int pauseState = V8DebuggerImpl::DontPauseOnExceptions; | 209 int pauseState = V8InspectorImpl::DontPauseOnExceptions; |
| 210 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState)
; | 210 m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState)
; |
| 211 setPauseOnExceptionsImpl(&error, pauseState); | 211 setPauseOnExceptionsImpl(&error, pauseState); |
| 212 DCHECK(error.isEmpty()); | 212 DCHECK(error.isEmpty()); |
| 213 | 213 |
| 214 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); | 214 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); |
| 215 | 215 |
| 216 int asyncCallStackDepth = 0; | 216 int asyncCallStackDepth = 0; |
| 217 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, &asyncCallStack
Depth); | 217 m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, &asyncCallStack
Depth); |
| 218 m_debugger->setAsyncCallStackDepth(this, asyncCallStackDepth); | 218 m_inspector->setAsyncCallStackDepth(this, asyncCallStackDepth); |
| 219 | 219 |
| 220 String16 blackboxPattern; | 220 String16 blackboxPattern; |
| 221 if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern
)) { | 221 if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern
)) { |
| 222 if (!setBlackboxPattern(&error, blackboxPattern)) | 222 if (!setBlackboxPattern(&error, blackboxPattern)) |
| 223 NOTREACHED(); | 223 NOTREACHED(); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) | 227 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) |
| 228 { | 228 { |
| 229 if (!checkEnabled(errorString)) | 229 if (!checkEnabled(errorString)) |
| 230 return; | 230 return; |
| 231 debugger().setBreakpointsActivated(active); | 231 m_inspector->setBreakpointsActivated(active); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) | 234 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) |
| 235 { | 235 { |
| 236 m_skipAllPauses = skipped; | 236 m_skipAllPauses = skipped; |
| 237 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); | 237 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); |
| 238 } | 238 } |
| 239 | 239 |
| 240 static std::unique_ptr<protocol::DictionaryValue> buildObjectForBreakpointCookie
(const String16& url, int lineNumber, int columnNumber, const String16& conditio
n, bool isRegex) | 240 static std::unique_ptr<protocol::DictionaryValue> buildObjectForBreakpointCookie
(const String16& url, int lineNumber, int columnNumber, const String16& conditio
n, bool isRegex) |
| 241 { | 241 { |
| 242 std::unique_ptr<protocol::DictionaryValue> breakpointObject = protocol::Dict
ionaryValue::create(); | 242 std::unique_ptr<protocol::DictionaryValue> breakpointObject = protocol::Dict
ionaryValue::create(); |
| 243 breakpointObject->setString(DebuggerAgentState::url, url); | 243 breakpointObject->setString(DebuggerAgentState::url, url); |
| 244 breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); | 244 breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); |
| 245 breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber)
; | 245 breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber)
; |
| 246 breakpointObject->setString(DebuggerAgentState::condition, condition); | 246 breakpointObject->setString(DebuggerAgentState::condition, condition); |
| 247 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); | 247 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); |
| 248 return breakpointObject; | 248 return breakpointObject; |
| 249 } | 249 } |
| 250 | 250 |
| 251 static bool matches(V8DebuggerImpl* debugger, const String16& url, const String1
6& pattern, bool isRegex) | 251 static bool matches(V8InspectorImpl* inspector, const String16& url, const Strin
g16& pattern, bool isRegex) |
| 252 { | 252 { |
| 253 if (isRegex) { | 253 if (isRegex) { |
| 254 V8Regex regex(debugger, pattern, true); | 254 V8Regex regex(inspector, pattern, true); |
| 255 return regex.match(url) != -1; | 255 return regex.match(url) != -1; |
| 256 } | 256 } |
| 257 return url == pattern; | 257 return url == pattern; |
| 258 } | 258 } |
| 259 | 259 |
| 260 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, | 260 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, |
| 261 int lineNumber, | 261 int lineNumber, |
| 262 const Maybe<String16>& optionalURL, | 262 const Maybe<String16>& optionalURL, |
| 263 const Maybe<String16>& optionalURLRegex, | 263 const Maybe<String16>& optionalURLRegex, |
| 264 const Maybe<int>& optionalColumnNumber, | 264 const Maybe<int>& optionalColumnNumber, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 293 } | 293 } |
| 294 if (breakpointsCookie->get(breakpointId)) { | 294 if (breakpointsCookie->get(breakpointId)) { |
| 295 *errorString = "Breakpoint at specified location already exists."; | 295 *errorString = "Breakpoint at specified location already exists."; |
| 296 return; | 296 return; |
| 297 } | 297 } |
| 298 | 298 |
| 299 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex)); | 299 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex)); |
| 300 | 300 |
| 301 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); | 301 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); |
| 302 for (const auto& script : m_scripts) { | 302 for (const auto& script : m_scripts) { |
| 303 if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) | 303 if (!matches(m_inspector, script.second->sourceURL(), url, isRegex)) |
| 304 continue; | 304 continue; |
| 305 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi
nt(breakpointId, script.first, breakpoint, UserBreakpointSource); | 305 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi
nt(breakpointId, script.first, breakpoint, UserBreakpointSource); |
| 306 if (location) | 306 if (location) |
| 307 (*locations)->addItem(std::move(location)); | 307 (*locations)->addItem(std::move(location)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 *outBreakpointId = breakpointId; | 310 *outBreakpointId = breakpointId; |
| 311 } | 311 } |
| 312 | 312 |
| 313 static bool parseLocation(ErrorString* errorString, std::unique_ptr<protocol::De
bugger::Location> location, String16* scriptId, int* lineNumber, int* columnNumb
er) | 313 static bool parseLocation(ErrorString* errorString, std::unique_ptr<protocol::De
bugger::Location> location, String16* scriptId, int* lineNumber, int* columnNumb
er) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) | 359 void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) |
| 360 { | 360 { |
| 361 DCHECK(enabled()); | 361 DCHECK(enabled()); |
| 362 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); | 362 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); |
| 363 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) | 363 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) |
| 364 return; | 364 return; |
| 365 const std::vector<String16>& ids = debuggerBreakpointIdsIterator->second; | 365 const std::vector<String16>& ids = debuggerBreakpointIdsIterator->second; |
| 366 for (size_t i = 0; i < ids.size(); ++i) { | 366 for (size_t i = 0; i < ids.size(); ++i) { |
| 367 const String16& debuggerBreakpointId = ids[i]; | 367 const String16& debuggerBreakpointId = ids[i]; |
| 368 | 368 |
| 369 debugger().removeBreakpoint(debuggerBreakpointId); | 369 m_inspector->removeBreakpoint(debuggerBreakpointId); |
| 370 m_serverBreakpoints.erase(debuggerBreakpointId); | 370 m_serverBreakpoints.erase(debuggerBreakpointId); |
| 371 } | 371 } |
| 372 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); | 372 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, | 375 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, |
| 376 std::unique_ptr<protocol::Debugger::Location> location, | 376 std::unique_ptr<protocol::Debugger::Location> location, |
| 377 const protocol::Maybe<bool>& interstateLocationOpt) | 377 const protocol::Maybe<bool>& interstateLocationOpt) |
| 378 { | 378 { |
| 379 if (!checkEnabled(errorString)) | 379 if (!checkEnabled(errorString)) |
| 380 return; | 380 return; |
| 381 if (!m_continueToLocationBreakpointId.isEmpty()) { | 381 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 382 debugger().removeBreakpoint(m_continueToLocationBreakpointId); | 382 m_inspector->removeBreakpoint(m_continueToLocationBreakpointId); |
| 383 m_continueToLocationBreakpointId = ""; | 383 m_continueToLocationBreakpointId = ""; |
| 384 } | 384 } |
| 385 | 385 |
| 386 String16 scriptId; | 386 String16 scriptId; |
| 387 int lineNumber; | 387 int lineNumber; |
| 388 int columnNumber; | 388 int columnNumber; |
| 389 | 389 |
| 390 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber,
&columnNumber)) | 390 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber,
&columnNumber)) |
| 391 return; | 391 return; |
| 392 | 392 |
| 393 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); | 393 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); |
| 394 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp
oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); | 394 m_continueToLocationBreakpointId = m_inspector->setBreakpoint(scriptId, brea
kpoint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); |
| 395 resume(errorString); | 395 resume(errorString); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr
<Array<CallFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace) | 398 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr
<Array<CallFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace) |
| 399 { | 399 { |
| 400 if (!assertPaused(errorString)) | 400 if (!assertPaused(errorString)) |
| 401 return; | 401 return; |
| 402 JavaScriptCallFrames frames = debugger().currentCallFrames(); | 402 JavaScriptCallFrames frames = m_inspector->currentCallFrames(); |
| 403 m_pausedCallFrames.swap(frames); | 403 m_pausedCallFrames.swap(frames); |
| 404 *callFrames = currentCallFrames(errorString); | 404 *callFrames = currentCallFrames(errorString); |
| 405 if (!*callFrames) | 405 if (!*callFrames) |
| 406 return; | 406 return; |
| 407 *asyncStackTrace = currentAsyncStackTrace(); | 407 *asyncStackTrace = currentAsyncStackTrace(); |
| 408 } | 408 } |
| 409 | 409 |
| 410 bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() | 410 bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() |
| 411 { | 411 { |
| 412 DCHECK(enabled()); | 412 DCHECK(enabled()); |
| 413 JavaScriptCallFrames callFrames = debugger().currentCallFrames(); | 413 JavaScriptCallFrames callFrames = m_inspector->currentCallFrames(); |
| 414 for (size_t index = 0; index < callFrames.size(); ++index) { | 414 for (size_t index = 0; index < callFrames.size(); ++index) { |
| 415 if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) | 415 if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) |
| 416 return false; | 416 return false; |
| 417 } | 417 } |
| 418 return true; | 418 return true; |
| 419 } | 419 } |
| 420 | 420 |
| 421 bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed() | 421 bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed() |
| 422 { | 422 { |
| 423 DCHECK(enabled()); | 423 DCHECK(enabled()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 CHECK(!breakpointId.isEmpty()); | 491 CHECK(!breakpointId.isEmpty()); |
| 492 CHECK(!scriptId.isEmpty()); | 492 CHECK(!scriptId.isEmpty()); |
| 493 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 493 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
| 494 if (scriptIterator == m_scripts.end()) | 494 if (scriptIterator == m_scripts.end()) |
| 495 return nullptr; | 495 return nullptr; |
| 496 if (breakpoint.lineNumber < scriptIterator->second->startLine() || scriptIte
rator->second->endLine() < breakpoint.lineNumber) | 496 if (breakpoint.lineNumber < scriptIterator->second->startLine() || scriptIte
rator->second->endLine() < breakpoint.lineNumber) |
| 497 return nullptr; | 497 return nullptr; |
| 498 | 498 |
| 499 int actualLineNumber; | 499 int actualLineNumber; |
| 500 int actualColumnNumber; | 500 int actualColumnNumber; |
| 501 String16 debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoin
t, &actualLineNumber, &actualColumnNumber, false); | 501 String16 debuggerBreakpointId = m_inspector->setBreakpoint(scriptId, breakpo
int, &actualLineNumber, &actualColumnNumber, false); |
| 502 if (debuggerBreakpointId.isEmpty()) | 502 if (debuggerBreakpointId.isEmpty()) |
| 503 return nullptr; | 503 return nullptr; |
| 504 | 504 |
| 505 m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, sou
rce); | 505 m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, sou
rce); |
| 506 CHECK(!breakpointId.isEmpty()); | 506 CHECK(!breakpointId.isEmpty()); |
| 507 | 507 |
| 508 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakp
ointId); | 508 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakp
ointId); |
| 509 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber)
; | 509 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber)
; |
| 510 } | 510 } |
| 511 | 511 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 534 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 534 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
| 535 Maybe<bool>* stackChanged, | 535 Maybe<bool>* stackChanged, |
| 536 Maybe<StackTrace>* asyncStackTrace, | 536 Maybe<StackTrace>* asyncStackTrace, |
| 537 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) | 537 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) |
| 538 { | 538 { |
| 539 if (!checkEnabled(errorString)) | 539 if (!checkEnabled(errorString)) |
| 540 return; | 540 return; |
| 541 | 541 |
| 542 v8::HandleScope handles(m_isolate); | 542 v8::HandleScope handles(m_isolate); |
| 543 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); | 543 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); |
| 544 if (!debugger().setScriptSource(scriptId, newSource, preview.fromMaybe(false
), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) | 544 if (!m_inspector->setScriptSource(scriptId, newSource, preview.fromMaybe(fal
se), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) |
| 545 return; | 545 return; |
| 546 | 546 |
| 547 ScriptsMap::iterator it = m_scripts.find(scriptId); | 547 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 548 if (it != m_scripts.end()) | 548 if (it != m_scripts.end()) |
| 549 it->second->setSource(m_isolate, newSource); | 549 it->second->setSource(m_isolate, newSource); |
| 550 | 550 |
| 551 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString
); | 551 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString
); |
| 552 if (!callFrames) | 552 if (!callFrames) |
| 553 return; | 553 return; |
| 554 *newCallFrames = std::move(callFrames); | 554 *newCallFrames = std::move(callFrames); |
| 555 *asyncStackTrace = currentAsyncStackTrace(); | 555 *asyncStackTrace = currentAsyncStackTrace(); |
| 556 } | 556 } |
| 557 | 557 |
| 558 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, | 558 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, |
| 559 const String16& callFrameId, | 559 const String16& callFrameId, |
| 560 std::unique_ptr<Array<CallFrame>>* newCallFrames, | 560 std::unique_ptr<Array<CallFrame>>* newCallFrames, |
| 561 Maybe<StackTrace>* asyncStackTrace) | 561 Maybe<StackTrace>* asyncStackTrace) |
| 562 { | 562 { |
| 563 if (!assertPaused(errorString)) | 563 if (!assertPaused(errorString)) |
| 564 return; | 564 return; |
| 565 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con
textGroupId(), callFrameId); | 565 InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->co
ntextGroupId(), callFrameId); |
| 566 if (!scope.initialize()) | 566 if (!scope.initialize()) |
| 567 return; | 567 return; |
| 568 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { | 568 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { |
| 569 *errorString = "Could not find call frame with given id"; | 569 *errorString = "Could not find call frame with given id"; |
| 570 return; | 570 return; |
| 571 } | 571 } |
| 572 | 572 |
| 573 v8::Local<v8::Value> resultValue; | 573 v8::Local<v8::Value> resultValue; |
| 574 v8::Local<v8::Boolean> result; | 574 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()) { | 575 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"; | 576 *errorString = "Internal error"; |
| 577 return; | 577 return; |
| 578 } | 578 } |
| 579 JavaScriptCallFrames frames = debugger().currentCallFrames(); | 579 JavaScriptCallFrames frames = m_inspector->currentCallFrames(); |
| 580 m_pausedCallFrames.swap(frames); | 580 m_pausedCallFrames.swap(frames); |
| 581 | 581 |
| 582 *newCallFrames = currentCallFrames(errorString); | 582 *newCallFrames = currentCallFrames(errorString); |
| 583 if (!*newCallFrames) | 583 if (!*newCallFrames) |
| 584 return; | 584 return; |
| 585 *asyncStackTrace = currentAsyncStackTrace(); | 585 *asyncStackTrace = currentAsyncStackTrace(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
riptId, String16* scriptSource) | 588 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
riptId, String16* scriptSource) |
| 589 { | 589 { |
| 590 if (!checkEnabled(error)) | 590 if (!checkEnabled(error)) |
| 591 return; | 591 return; |
| 592 ScriptsMap::iterator it = m_scripts.find(scriptId); | 592 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 593 if (it == m_scripts.end()) { | 593 if (it == m_scripts.end()) { |
| 594 *error = "No script for id: " + scriptId; | 594 *error = "No script for id: " + scriptId; |
| 595 return; | 595 return; |
| 596 } | 596 } |
| 597 v8::HandleScope handles(m_isolate); | 597 v8::HandleScope handles(m_isolate); |
| 598 *scriptSource = toProtocolString(it->second->source(m_isolate)); | 598 *scriptSource = toProtocolString(it->second->source(m_isolate)); |
| 599 } | 599 } |
| 600 | 600 |
| 601 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas
on, std::unique_ptr<protocol::DictionaryValue> data) | 601 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas
on, std::unique_ptr<protocol::DictionaryValue> data) |
| 602 { | 602 { |
| 603 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc
heduled || debugger().isPaused() || !debugger().breakpointsActivated()) | 603 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc
heduled || m_inspector->isPaused() || !m_inspector->breakpointsActivated()) |
| 604 return; | 604 return; |
| 605 m_breakReason = breakReason; | 605 m_breakReason = breakReason; |
| 606 m_breakAuxData = std::move(data); | 606 m_breakAuxData = std::move(data); |
| 607 m_pausingOnNativeEvent = true; | 607 m_pausingOnNativeEvent = true; |
| 608 m_skipNextDebuggerStepOut = false; | 608 m_skipNextDebuggerStepOut = false; |
| 609 debugger().setPauseOnNextStatement(true); | 609 m_inspector->setPauseOnNextStatement(true); |
| 610 } | 610 } |
| 611 | 611 |
| 612 void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() | 612 void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() |
| 613 { | 613 { |
| 614 DCHECK(enabled()); | 614 DCHECK(enabled()); |
| 615 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || deb
ugger().isPaused()) | 615 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || m_i
nspector->isPaused()) |
| 616 return; | 616 return; |
| 617 clearBreakDetails(); | 617 clearBreakDetails(); |
| 618 m_pausingOnNativeEvent = false; | 618 m_pausingOnNativeEvent = false; |
| 619 m_skippedStepFrameCount = 0; | 619 m_skippedStepFrameCount = 0; |
| 620 m_recursionLevelForStepFrame = 0; | 620 m_recursionLevelForStepFrame = 0; |
| 621 debugger().setPauseOnNextStatement(true); | 621 m_inspector->setPauseOnNextStatement(true); |
| 622 } | 622 } |
| 623 | 623 |
| 624 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() | 624 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() |
| 625 { | 625 { |
| 626 if (m_javaScriptPauseScheduled || debugger().isPaused()) | 626 if (m_javaScriptPauseScheduled || m_inspector->isPaused()) |
| 627 return; | 627 return; |
| 628 clearBreakDetails(); | 628 clearBreakDetails(); |
| 629 m_pausingOnNativeEvent = false; | 629 m_pausingOnNativeEvent = false; |
| 630 debugger().setPauseOnNextStatement(false); | 630 m_inspector->setPauseOnNextStatement(false); |
| 631 } | 631 } |
| 632 | 632 |
| 633 void V8DebuggerAgentImpl::pause(ErrorString* errorString) | 633 void V8DebuggerAgentImpl::pause(ErrorString* errorString) |
| 634 { | 634 { |
| 635 if (!checkEnabled(errorString)) | 635 if (!checkEnabled(errorString)) |
| 636 return; | 636 return; |
| 637 if (m_javaScriptPauseScheduled || debugger().isPaused()) | 637 if (m_javaScriptPauseScheduled || m_inspector->isPaused()) |
| 638 return; | 638 return; |
| 639 clearBreakDetails(); | 639 clearBreakDetails(); |
| 640 m_javaScriptPauseScheduled = true; | 640 m_javaScriptPauseScheduled = true; |
| 641 m_scheduledDebuggerStep = NoStep; | 641 m_scheduledDebuggerStep = NoStep; |
| 642 m_skippedStepFrameCount = 0; | 642 m_skippedStepFrameCount = 0; |
| 643 m_steppingFromFramework = false; | 643 m_steppingFromFramework = false; |
| 644 debugger().setPauseOnNextStatement(true); | 644 m_inspector->setPauseOnNextStatement(true); |
| 645 } | 645 } |
| 646 | 646 |
| 647 void V8DebuggerAgentImpl::resume(ErrorString* errorString) | 647 void V8DebuggerAgentImpl::resume(ErrorString* errorString) |
| 648 { | 648 { |
| 649 if (!assertPaused(errorString)) | 649 if (!assertPaused(errorString)) |
| 650 return; | 650 return; |
| 651 m_scheduledDebuggerStep = NoStep; | 651 m_scheduledDebuggerStep = NoStep; |
| 652 m_steppingFromFramework = false; | 652 m_steppingFromFramework = false; |
| 653 m_session->releaseObjectGroup(backtraceObjectGroup); | 653 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 654 debugger().continueProgram(); | 654 m_inspector->continueProgram(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) | 657 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) |
| 658 { | 658 { |
| 659 if (!assertPaused(errorString)) | 659 if (!assertPaused(errorString)) |
| 660 return; | 660 return; |
| 661 // StepOver at function return point should fallback to StepInto. | 661 // StepOver at function return point should fallback to StepInto. |
| 662 JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrame
s[0].get() : nullptr; | 662 JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrame
s[0].get() : nullptr; |
| 663 if (frame && frame->isAtReturn()) { | 663 if (frame && frame->isAtReturn()) { |
| 664 stepInto(errorString); | 664 stepInto(errorString); |
| 665 return; | 665 return; |
| 666 } | 666 } |
| 667 m_scheduledDebuggerStep = StepOver; | 667 m_scheduledDebuggerStep = StepOver; |
| 668 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 668 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 669 m_session->releaseObjectGroup(backtraceObjectGroup); | 669 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 670 debugger().stepOverStatement(); | 670 m_inspector->stepOverStatement(); |
| 671 } | 671 } |
| 672 | 672 |
| 673 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) | 673 void V8DebuggerAgentImpl::stepInto(ErrorString* errorString) |
| 674 { | 674 { |
| 675 if (!assertPaused(errorString)) | 675 if (!assertPaused(errorString)) |
| 676 return; | 676 return; |
| 677 m_scheduledDebuggerStep = StepInto; | 677 m_scheduledDebuggerStep = StepInto; |
| 678 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 678 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 679 m_session->releaseObjectGroup(backtraceObjectGroup); | 679 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 680 debugger().stepIntoStatement(); | 680 m_inspector->stepIntoStatement(); |
| 681 } | 681 } |
| 682 | 682 |
| 683 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) | 683 void V8DebuggerAgentImpl::stepOut(ErrorString* errorString) |
| 684 { | 684 { |
| 685 if (!assertPaused(errorString)) | 685 if (!assertPaused(errorString)) |
| 686 return; | 686 return; |
| 687 m_scheduledDebuggerStep = StepOut; | 687 m_scheduledDebuggerStep = StepOut; |
| 688 m_skipNextDebuggerStepOut = false; | 688 m_skipNextDebuggerStepOut = false; |
| 689 m_recursionLevelForStepOut = 1; | 689 m_recursionLevelForStepOut = 1; |
| 690 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); | 690 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); |
| 691 m_session->releaseObjectGroup(backtraceObjectGroup); | 691 m_session->releaseObjectGroup(backtraceObjectGroup); |
| 692 debugger().stepOutOfFunction(); | 692 m_inspector->stepOutOfFunction(); |
| 693 } | 693 } |
| 694 | 694 |
| 695 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring16& stringPauseState) | 695 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring16& stringPauseState) |
| 696 { | 696 { |
| 697 if (!checkEnabled(errorString)) | 697 if (!checkEnabled(errorString)) |
| 698 return; | 698 return; |
| 699 V8DebuggerImpl::PauseOnExceptionsState pauseState; | 699 V8InspectorImpl::PauseOnExceptionsState pauseState; |
| 700 if (stringPauseState == "none") { | 700 if (stringPauseState == "none") { |
| 701 pauseState = V8DebuggerImpl::DontPauseOnExceptions; | 701 pauseState = V8InspectorImpl::DontPauseOnExceptions; |
| 702 } else if (stringPauseState == "all") { | 702 } else if (stringPauseState == "all") { |
| 703 pauseState = V8DebuggerImpl::PauseOnAllExceptions; | 703 pauseState = V8InspectorImpl::PauseOnAllExceptions; |
| 704 } else if (stringPauseState == "uncaught") { | 704 } else if (stringPauseState == "uncaught") { |
| 705 pauseState = V8DebuggerImpl::PauseOnUncaughtExceptions; | 705 pauseState = V8InspectorImpl::PauseOnUncaughtExceptions; |
| 706 } else { | 706 } else { |
| 707 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; | 707 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; |
| 708 return; | 708 return; |
| 709 } | 709 } |
| 710 setPauseOnExceptionsImpl(errorString, pauseState); | 710 setPauseOnExceptionsImpl(errorString, pauseState); |
| 711 } | 711 } |
| 712 | 712 |
| 713 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int
pauseState) | 713 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int
pauseState) |
| 714 { | 714 { |
| 715 debugger().setPauseOnExceptionsState(static_cast<V8DebuggerImpl::PauseOnExce
ptionsState>(pauseState)); | 715 m_inspector->setPauseOnExceptionsState(static_cast<V8InspectorImpl::PauseOnE
xceptionsState>(pauseState)); |
| 716 if (debugger().getPauseOnExceptionsState() != pauseState) | 716 if (m_inspector->getPauseOnExceptionsState() != pauseState) |
| 717 *errorString = "Internal error. Could not change pause on exceptions sta
te"; | 717 *errorString = "Internal error. Could not change pause on exceptions sta
te"; |
| 718 else | 718 else |
| 719 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseSta
te); | 719 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseSta
te); |
| 720 } | 720 } |
| 721 | 721 |
| 722 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, | 722 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, |
| 723 const String16& callFrameId, | 723 const String16& callFrameId, |
| 724 const String16& expression, | 724 const String16& expression, |
| 725 const Maybe<String16>& objectGroup, | 725 const Maybe<String16>& objectGroup, |
| 726 const Maybe<bool>& includeCommandLineAPI, | 726 const Maybe<bool>& includeCommandLineAPI, |
| 727 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, | 727 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, |
| 728 const Maybe<bool>& returnByValue, | 728 const Maybe<bool>& returnByValue, |
| 729 const Maybe<bool>& generatePreview, | 729 const Maybe<bool>& generatePreview, |
| 730 std::unique_ptr<RemoteObject>* result, | 730 std::unique_ptr<RemoteObject>* result, |
| 731 Maybe<bool>* wasThrown, | 731 Maybe<bool>* wasThrown, |
| 732 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) | 732 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
| 733 { | 733 { |
| 734 if (!assertPaused(errorString)) | 734 if (!assertPaused(errorString)) |
| 735 return; | 735 return; |
| 736 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con
textGroupId(), callFrameId); | 736 InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->co
ntextGroupId(), callFrameId); |
| 737 if (!scope.initialize()) | 737 if (!scope.initialize()) |
| 738 return; | 738 return; |
| 739 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { | 739 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { |
| 740 *errorString = "Could not find call frame with given id"; | 740 *errorString = "Could not find call frame with given id"; |
| 741 return; | 741 return; |
| 742 } | 742 } |
| 743 | 743 |
| 744 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI()
) | 744 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI()
) |
| 745 return; | 745 return; |
| 746 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) | 746 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 765 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, | 765 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, |
| 766 int scopeNumber, | 766 int scopeNumber, |
| 767 const String16& variableName, | 767 const String16& variableName, |
| 768 std::unique_ptr<protocol::Runtime::CallArgument> newValueArgument, | 768 std::unique_ptr<protocol::Runtime::CallArgument> newValueArgument, |
| 769 const String16& callFrameId) | 769 const String16& callFrameId) |
| 770 { | 770 { |
| 771 if (!checkEnabled(errorString)) | 771 if (!checkEnabled(errorString)) |
| 772 return; | 772 return; |
| 773 if (!assertPaused(errorString)) | 773 if (!assertPaused(errorString)) |
| 774 return; | 774 return; |
| 775 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con
textGroupId(), callFrameId); | 775 InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->co
ntextGroupId(), callFrameId); |
| 776 if (!scope.initialize()) | 776 if (!scope.initialize()) |
| 777 return; | 777 return; |
| 778 | 778 |
| 779 v8::Local<v8::Value> newValue; | 779 v8::Local<v8::Value> newValue; |
| 780 if (!scope.injectedScript()->resolveCallArgument(errorString, newValueArgume
nt.get()).ToLocal(&newValue)) | 780 if (!scope.injectedScript()->resolveCallArgument(errorString, newValueArgume
nt.get()).ToLocal(&newValue)) |
| 781 return; | 781 return; |
| 782 | 782 |
| 783 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { | 783 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { |
| 784 *errorString = "Could not find call frame with given id"; | 784 *errorString = "Could not find call frame with given id"; |
| 785 return; | 785 return; |
| 786 } | 786 } |
| 787 v8::MaybeLocal<v8::Value> result = m_pausedCallFrames[scope.frameOrdinal()]-
>setVariableValue(scopeNumber, toV8String(m_isolate, variableName), newValue); | 787 v8::MaybeLocal<v8::Value> result = m_pausedCallFrames[scope.frameOrdinal()]-
>setVariableValue(scopeNumber, toV8String(m_isolate, variableName), newValue); |
| 788 if (scope.tryCatch().HasCaught() || result.IsEmpty()) { | 788 if (scope.tryCatch().HasCaught() || result.IsEmpty()) { |
| 789 *errorString = "Internal error"; | 789 *errorString = "Internal error"; |
| 790 return; | 790 return; |
| 791 } | 791 } |
| 792 } | 792 } |
| 793 | 793 |
| 794 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) | 794 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) |
| 795 { | 795 { |
| 796 if (!checkEnabled(errorString)) | 796 if (!checkEnabled(errorString)) |
| 797 return; | 797 return; |
| 798 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, depth); | 798 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, depth); |
| 799 m_debugger->setAsyncCallStackDepth(this, depth); | 799 m_inspector->setAsyncCallStackDepth(this, depth); |
| 800 } | 800 } |
| 801 | 801 |
| 802 void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni
que_ptr<protocol::Array<String16>> patterns) | 802 void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni
que_ptr<protocol::Array<String16>> patterns) |
| 803 { | 803 { |
| 804 if (!patterns->length()) { | 804 if (!patterns->length()) { |
| 805 m_blackboxPattern = nullptr; | 805 m_blackboxPattern = nullptr; |
| 806 m_state->remove(DebuggerAgentState::blackboxPattern); | 806 m_state->remove(DebuggerAgentState::blackboxPattern); |
| 807 return; | 807 return; |
| 808 } | 808 } |
| 809 | 809 |
| 810 String16Builder patternBuilder; | 810 String16Builder patternBuilder; |
| 811 patternBuilder.append('('); | 811 patternBuilder.append('('); |
| 812 for (size_t i = 0; i < patterns->length() - 1; ++i) { | 812 for (size_t i = 0; i < patterns->length() - 1; ++i) { |
| 813 patternBuilder.append(patterns->get(i)); | 813 patternBuilder.append(patterns->get(i)); |
| 814 patternBuilder.append("|"); | 814 patternBuilder.append("|"); |
| 815 } | 815 } |
| 816 patternBuilder.append(patterns->get(patterns->length() - 1)); | 816 patternBuilder.append(patterns->get(patterns->length() - 1)); |
| 817 patternBuilder.append(')'); | 817 patternBuilder.append(')'); |
| 818 String16 pattern = patternBuilder.toString(); | 818 String16 pattern = patternBuilder.toString(); |
| 819 if (!setBlackboxPattern(errorString, pattern)) | 819 if (!setBlackboxPattern(errorString, pattern)) |
| 820 return; | 820 return; |
| 821 m_state->setString(DebuggerAgentState::blackboxPattern, pattern); | 821 m_state->setString(DebuggerAgentState::blackboxPattern, pattern); |
| 822 } | 822 } |
| 823 | 823 |
| 824 bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const Str
ing16& pattern) | 824 bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const Str
ing16& pattern) |
| 825 { | 825 { |
| 826 std::unique_ptr<V8Regex> regex(new V8Regex(m_debugger, pattern, true /** cas
eSensitive */, false /** multiline */)); | 826 std::unique_ptr<V8Regex> regex(new V8Regex(m_inspector, pattern, true /** ca
seSensitive */, false /** multiline */)); |
| 827 if (!regex->isValid()) { | 827 if (!regex->isValid()) { |
| 828 *errorString = "Pattern parser error: " + regex->errorMessage(); | 828 *errorString = "Pattern parser error: " + regex->errorMessage(); |
| 829 return false; | 829 return false; |
| 830 } | 830 } |
| 831 m_blackboxPattern = std::move(regex); | 831 m_blackboxPattern = std::move(regex); |
| 832 return true; | 832 return true; |
| 833 } | 833 } |
| 834 | 834 |
| 835 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16
& scriptId, | 835 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16
& scriptId, |
| 836 std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> inPosit
ions) | 836 std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> inPosit
ions) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 schedulePauseOnNextStatementIfSteppingInto(); | 881 schedulePauseOnNextStatementIfSteppingInto(); |
| 882 } | 882 } |
| 883 | 883 |
| 884 void V8DebuggerAgentImpl::didExecuteScript() | 884 void V8DebuggerAgentImpl::didExecuteScript() |
| 885 { | 885 { |
| 886 changeJavaScriptRecursionLevel(-1); | 886 changeJavaScriptRecursionLevel(-1); |
| 887 } | 887 } |
| 888 | 888 |
| 889 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) | 889 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) |
| 890 { | 890 { |
| 891 if (m_javaScriptPauseScheduled && !m_skipAllPauses && !debugger().isPaused()
) { | 891 if (m_javaScriptPauseScheduled && !m_skipAllPauses && !m_inspector->isPaused
()) { |
| 892 // Do not ever loose user's pause request until we have actually paused. | 892 // Do not ever loose user's pause request until we have actually paused. |
| 893 debugger().setPauseOnNextStatement(true); | 893 m_inspector->setPauseOnNextStatement(true); |
| 894 } | 894 } |
| 895 if (m_scheduledDebuggerStep == StepOut) { | 895 if (m_scheduledDebuggerStep == StepOut) { |
| 896 m_recursionLevelForStepOut += step; | 896 m_recursionLevelForStepOut += step; |
| 897 if (!m_recursionLevelForStepOut) { | 897 if (!m_recursionLevelForStepOut) { |
| 898 // When StepOut crosses a task boundary (i.e. js -> blink_c++) from
where it was requested, | 898 // 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. | 899 // switch stepping to step into a next JS task, as if we exited to a
blackboxed framework. |
| 900 m_scheduledDebuggerStep = StepInto; | 900 m_scheduledDebuggerStep = StepInto; |
| 901 m_skipNextDebuggerStepOut = false; | 901 m_skipNextDebuggerStepOut = false; |
| 902 } | 902 } |
| 903 } | 903 } |
| 904 if (m_recursionLevelForStepFrame) { | 904 if (m_recursionLevelForStepFrame) { |
| 905 m_recursionLevelForStepFrame += step; | 905 m_recursionLevelForStepFrame += step; |
| 906 if (!m_recursionLevelForStepFrame) { | 906 if (!m_recursionLevelForStepFrame) { |
| 907 // We have walked through a blackboxed framework and got back to whe
re we started. | 907 // 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, | 908 // If there was no stepping scheduled, we should cancel the stepping
explicitly, |
| 909 // since there may be a scheduled StepFrame left. | 909 // 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, | 910 // 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 | 911 // whereas if we were stepping out, we should continue doing so afte
r debugger pauses |
| 912 // from the old StepFrame. | 912 // from the old StepFrame. |
| 913 m_skippedStepFrameCount = 0; | 913 m_skippedStepFrameCount = 0; |
| 914 if (m_scheduledDebuggerStep == NoStep) | 914 if (m_scheduledDebuggerStep == NoStep) |
| 915 debugger().clearStepping(); | 915 m_inspector->clearStepping(); |
| 916 else if (m_scheduledDebuggerStep == StepOut) | 916 else if (m_scheduledDebuggerStep == StepOut) |
| 917 m_skipNextDebuggerStepOut = true; | 917 m_skipNextDebuggerStepOut = true; |
| 918 } | 918 } |
| 919 } | 919 } |
| 920 } | 920 } |
| 921 | 921 |
| 922 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
ring* errorString) | 922 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt
ring* errorString) |
| 923 { | 923 { |
| 924 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) | 924 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) |
| 925 return Array<CallFrame>::create(); | 925 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); | 977 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro
tocolValue(debuggerContext, objects).get(), &errorSupport); |
| 978 if (hasInternalError(errorString, !callFrames)) | 978 if (hasInternalError(errorString, !callFrames)) |
| 979 return Array<CallFrame>::create(); | 979 return Array<CallFrame>::create(); |
| 980 return callFrames; | 980 return callFrames; |
| 981 } | 981 } |
| 982 | 982 |
| 983 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() | 983 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() |
| 984 { | 984 { |
| 985 if (m_pausedContext.IsEmpty()) | 985 if (m_pausedContext.IsEmpty()) |
| 986 return nullptr; | 986 return nullptr; |
| 987 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); | 987 V8StackTraceImpl* stackTrace = m_inspector->currentAsyncCallChain(); |
| 988 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) : nu
llptr; | 988 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_inspector) : n
ullptr; |
| 989 } | 989 } |
| 990 | 990 |
| 991 void V8DebuggerAgentImpl::didParseSource(std::unique_ptr<V8DebuggerScript> scrip
t, bool success) | 991 void V8DebuggerAgentImpl::didParseSource(std::unique_ptr<V8DebuggerScript> scrip
t, bool success) |
| 992 { | 992 { |
| 993 v8::HandleScope handles(m_isolate); | 993 v8::HandleScope handles(m_isolate); |
| 994 String16 scriptSource = toProtocolString(script->source(m_isolate)); | 994 String16 scriptSource = toProtocolString(script->source(m_isolate)); |
| 995 bool isDeprecatedSourceURL = false; | 995 bool isDeprecatedSourceURL = false; |
| 996 if (!success) | 996 if (!success) |
| 997 script->setSourceURL(findSourceURL(scriptSource, false, &isDeprecatedSou
rceURL)); | 997 script->setSourceURL(findSourceURL(scriptSource, false, &isDeprecatedSou
rceURL)); |
| 998 else if (script->hasSourceURL()) | 998 else if (script->hasSourceURL()) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 if (!breakpointsCookie) | 1032 if (!breakpointsCookie) |
| 1033 return; | 1033 return; |
| 1034 | 1034 |
| 1035 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { | 1035 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { |
| 1036 auto cookie = breakpointsCookie->at(i); | 1036 auto cookie = breakpointsCookie->at(i); |
| 1037 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue:
:cast(cookie.second); | 1037 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue:
:cast(cookie.second); |
| 1038 bool isRegex; | 1038 bool isRegex; |
| 1039 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); | 1039 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); |
| 1040 String16 url; | 1040 String16 url; |
| 1041 breakpointObject->getString(DebuggerAgentState::url, &url); | 1041 breakpointObject->getString(DebuggerAgentState::url, &url); |
| 1042 if (!matches(m_debugger, scriptURL, url, isRegex)) | 1042 if (!matches(m_inspector, scriptURL, url, isRegex)) |
| 1043 continue; | 1043 continue; |
| 1044 ScriptBreakpoint breakpoint; | 1044 ScriptBreakpoint breakpoint; |
| 1045 breakpointObject->getInteger(DebuggerAgentState::lineNumber, &breakpoint
.lineNumber); | 1045 breakpointObject->getInteger(DebuggerAgentState::lineNumber, &breakpoint
.lineNumber); |
| 1046 breakpointObject->getInteger(DebuggerAgentState::columnNumber, &breakpoi
nt.columnNumber); | 1046 breakpointObject->getInteger(DebuggerAgentState::columnNumber, &breakpoi
nt.columnNumber); |
| 1047 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); | 1047 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); |
| 1048 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi
nt(cookie.first, scriptId, breakpoint, UserBreakpointSource); | 1048 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi
nt(cookie.first, scriptId, breakpoint, UserBreakpointSource); |
| 1049 if (location) | 1049 if (location) |
| 1050 m_frontend.breakpointResolved(cookie.first, std::move(location)); | 1050 m_frontend.breakpointResolved(cookie.first, std::move(location)); |
| 1051 } | 1051 } |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>&
hitBreakpoints, bool isPromiseRejection) | 1054 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>&
hitBreakpoints, bool isPromiseRejection) |
| 1055 { | 1055 { |
| 1056 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); | 1056 JavaScriptCallFrames callFrames = m_inspector->currentCallFrames(1); |
| 1057 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin()
->get() : nullptr; | 1057 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin()
->get() : nullptr; |
| 1058 | 1058 |
| 1059 // Skip pause in internal scripts (e.g. InjectedScriptSource.js). | 1059 // Skip pause in internal scripts (e.g. InjectedScriptSource.js). |
| 1060 if (topCallFrame) { | 1060 if (topCallFrame) { |
| 1061 ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(topCallFr
ame->sourceID())); | 1061 ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(topCallFr
ame->sourceID())); |
| 1062 if (it != m_scripts.end() && it->second->isInternalScript()) | 1062 if (it != m_scripts.end() && it->second->isInternalScript()) |
| 1063 return RequestStepFrame; | 1063 return RequestStepFrame; |
| 1064 } | 1064 } |
| 1065 | 1065 |
| 1066 V8DebuggerAgentImpl::SkipPauseRequest result; | 1066 V8DebuggerAgentImpl::SkipPauseRequest result; |
| 1067 if (m_skipAllPauses) | 1067 if (m_skipAllPauses) |
| 1068 result = RequestContinue; | 1068 result = RequestContinue; |
| 1069 else if (!hitBreakpoints.empty()) | 1069 else if (!hitBreakpoints.empty()) |
| 1070 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. | 1070 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. |
| 1071 else if (!exception.IsEmpty()) | 1071 else if (!exception.IsEmpty()) |
| 1072 result = shouldSkipExceptionPause(topCallFrame); | 1072 result = shouldSkipExceptionPause(topCallFrame); |
| 1073 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) | 1073 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) |
| 1074 result = shouldSkipStepPause(topCallFrame); | 1074 result = shouldSkipStepPause(topCallFrame); |
| 1075 else | 1075 else |
| 1076 result = RequestNoSkip; | 1076 result = RequestNoSkip; |
| 1077 | 1077 |
| 1078 m_skipNextDebuggerStepOut = false; | 1078 m_skipNextDebuggerStepOut = false; |
| 1079 if (result != RequestNoSkip) | 1079 if (result != RequestNoSkip) |
| 1080 return result; | 1080 return result; |
| 1081 // Skip pauses inside V8 internal scripts and on syntax errors. | 1081 // Skip pauses inside V8 internal scripts and on syntax errors. |
| 1082 if (!topCallFrame) | 1082 if (!topCallFrame) |
| 1083 return RequestContinue; | 1083 return RequestContinue; |
| 1084 | 1084 |
| 1085 DCHECK(m_pausedContext.IsEmpty()); | 1085 DCHECK(m_pausedContext.IsEmpty()); |
| 1086 JavaScriptCallFrames frames = debugger().currentCallFrames(); | 1086 JavaScriptCallFrames frames = m_inspector->currentCallFrames(); |
| 1087 m_pausedCallFrames.swap(frames); | 1087 m_pausedCallFrames.swap(frames); |
| 1088 m_pausedContext.Reset(m_isolate, context); | 1088 m_pausedContext.Reset(m_isolate, context); |
| 1089 v8::HandleScope handles(m_isolate); | 1089 v8::HandleScope handles(m_isolate); |
| 1090 | 1090 |
| 1091 if (!exception.IsEmpty()) { | 1091 if (!exception.IsEmpty()) { |
| 1092 ErrorString ignored; | 1092 ErrorString ignored; |
| 1093 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored,
V8DebuggerImpl::contextId(context)); | 1093 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored,
V8InspectorImpl::contextId(context)); |
| 1094 if (injectedScript) { | 1094 if (injectedScript) { |
| 1095 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea
sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; | 1095 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea
sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; |
| 1096 ErrorString errorString; | 1096 ErrorString errorString; |
| 1097 auto obj = injectedScript->wrapObject(&errorString, exception, backt
raceObjectGroup); | 1097 auto obj = injectedScript->wrapObject(&errorString, exception, backt
raceObjectGroup); |
| 1098 m_breakAuxData = obj ? obj->serialize() : nullptr; | 1098 m_breakAuxData = obj ? obj->serialize() : nullptr; |
| 1099 // m_breakAuxData might be null after this. | 1099 // m_breakAuxData might be null after this. |
| 1100 } | 1100 } |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(
); | 1103 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(
); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1117 ErrorString errorString; | 1117 ErrorString errorString; |
| 1118 m_frontend.paused(currentCallFrames(&errorString), m_breakReason, std::move(
m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace()); | 1118 m_frontend.paused(currentCallFrames(&errorString), m_breakReason, std::move(
m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace()); |
| 1119 m_scheduledDebuggerStep = NoStep; | 1119 m_scheduledDebuggerStep = NoStep; |
| 1120 m_javaScriptPauseScheduled = false; | 1120 m_javaScriptPauseScheduled = false; |
| 1121 m_steppingFromFramework = false; | 1121 m_steppingFromFramework = false; |
| 1122 m_pausingOnNativeEvent = false; | 1122 m_pausingOnNativeEvent = false; |
| 1123 m_skippedStepFrameCount = 0; | 1123 m_skippedStepFrameCount = 0; |
| 1124 m_recursionLevelForStepFrame = 0; | 1124 m_recursionLevelForStepFrame = 0; |
| 1125 | 1125 |
| 1126 if (!m_continueToLocationBreakpointId.isEmpty()) { | 1126 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 1127 debugger().removeBreakpoint(m_continueToLocationBreakpointId); | 1127 m_inspector->removeBreakpoint(m_continueToLocationBreakpointId); |
| 1128 m_continueToLocationBreakpointId = ""; | 1128 m_continueToLocationBreakpointId = ""; |
| 1129 } | 1129 } |
| 1130 return result; | 1130 return result; |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 void V8DebuggerAgentImpl::didContinue() | 1133 void V8DebuggerAgentImpl::didContinue() |
| 1134 { | 1134 { |
| 1135 m_pausedContext.Reset(); | 1135 m_pausedContext.Reset(); |
| 1136 JavaScriptCallFrames emptyCallFrames; | 1136 JavaScriptCallFrames emptyCallFrames; |
| 1137 m_pausedCallFrames.swap(emptyCallFrames); | 1137 m_pausedCallFrames.swap(emptyCallFrames); |
| 1138 clearBreakDetails(); | 1138 clearBreakDetails(); |
| 1139 m_frontend.resumed(); | 1139 m_frontend.resumed(); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_
ptr<protocol::DictionaryValue> data) | 1142 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_
ptr<protocol::DictionaryValue> data) |
| 1143 { | 1143 { |
| 1144 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent
CallStackEmptyOrBlackboxed() || !debugger().breakpointsActivated()) | 1144 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent
CallStackEmptyOrBlackboxed() || !m_inspector->breakpointsActivated()) |
| 1145 return; | 1145 return; |
| 1146 m_breakReason = breakReason; | 1146 m_breakReason = breakReason; |
| 1147 m_breakAuxData = std::move(data); | 1147 m_breakAuxData = std::move(data); |
| 1148 m_scheduledDebuggerStep = NoStep; | 1148 m_scheduledDebuggerStep = NoStep; |
| 1149 m_steppingFromFramework = false; | 1149 m_steppingFromFramework = false; |
| 1150 m_pausingOnNativeEvent = false; | 1150 m_pausingOnNativeEvent = false; |
| 1151 debugger().breakProgram(); | 1151 m_inspector->breakProgram(); |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, s
td::unique_ptr<protocol::DictionaryValue> data) | 1154 void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, s
td::unique_ptr<protocol::DictionaryValue> data) |
| 1155 { | 1155 { |
| 1156 if (!enabled() || m_debugger->getPauseOnExceptionsState() == V8DebuggerImpl:
:DontPauseOnExceptions) | 1156 if (!enabled() || m_inspector->getPauseOnExceptionsState() == V8InspectorImp
l::DontPauseOnExceptions) |
| 1157 return; | 1157 return; |
| 1158 breakProgram(breakReason, std::move(data)); | 1158 breakProgram(breakReason, std::move(data)); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) | 1161 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) |
| 1162 { | 1162 { |
| 1163 if (m_pausedContext.IsEmpty()) { | 1163 if (m_pausedContext.IsEmpty()) { |
| 1164 *errorString = "Can only perform operation while paused."; | 1164 *errorString = "Can only perform operation while paused."; |
| 1165 return false; | 1165 return false; |
| 1166 } | 1166 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1189 { | 1189 { |
| 1190 if (!enabled()) | 1190 if (!enabled()) |
| 1191 return; | 1191 return; |
| 1192 m_scheduledDebuggerStep = NoStep; | 1192 m_scheduledDebuggerStep = NoStep; |
| 1193 m_scripts.clear(); | 1193 m_scripts.clear(); |
| 1194 m_blackboxedPositions.clear(); | 1194 m_blackboxedPositions.clear(); |
| 1195 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1195 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 } // namespace blink | 1198 } // namespace blink |
| OLD | NEW |