| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/inspector/v8-debugger-agent-impl.h" | 5 #include "src/inspector/v8-debugger-agent-impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/debug/debug-interface.h" | 9 #include "src/debug/debug-interface.h" |
| 10 #include "src/inspector/injected-script.h" | 10 #include "src/inspector/injected-script.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 if (isPaused()) m_debugger->continueProgram(m_session->contextGroupId()); | 240 if (isPaused()) m_debugger->continueProgram(m_session->contextGroupId()); |
| 241 m_debugger->disable(); | 241 m_debugger->disable(); |
| 242 JavaScriptCallFrames emptyCallFrames; | 242 JavaScriptCallFrames emptyCallFrames; |
| 243 m_pausedCallFrames.swap(emptyCallFrames); | 243 m_pausedCallFrames.swap(emptyCallFrames); |
| 244 m_blackboxedPositions.clear(); | 244 m_blackboxedPositions.clear(); |
| 245 m_blackboxPattern.reset(); | 245 m_blackboxPattern.reset(); |
| 246 resetBlackboxedStateCache(); | 246 resetBlackboxedStateCache(); |
| 247 m_scripts.clear(); | 247 m_scripts.clear(); |
| 248 m_breakpointIdToDebuggerBreakpointIds.clear(); | 248 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 249 m_debugger->setAsyncCallStackDepth(this, 0); | 249 m_debugger->setAsyncCallStackDepth(this, 0); |
| 250 m_continueToLocationBreakpointId = String16(); | |
| 251 clearBreakDetails(); | 250 clearBreakDetails(); |
| 252 m_skipAllPauses = false; | 251 m_skipAllPauses = false; |
| 253 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); | 252 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); |
| 254 m_state->remove(DebuggerAgentState::blackboxPattern); | 253 m_state->remove(DebuggerAgentState::blackboxPattern); |
| 255 m_enabled = false; | 254 m_enabled = false; |
| 256 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); | 255 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); |
| 257 return Response::OK(); | 256 return Response::OK(); |
| 258 } | 257 } |
| 259 | 258 |
| 260 void V8DebuggerAgentImpl::restore() { | 259 void V8DebuggerAgentImpl::restore() { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 breakLocation->setType(breakLocationType(v8Locations[i].type())); | 478 breakLocation->setType(breakLocationType(v8Locations[i].type())); |
| 480 } | 479 } |
| 481 (*locations)->addItem(std::move(breakLocation)); | 480 (*locations)->addItem(std::move(breakLocation)); |
| 482 } | 481 } |
| 483 return Response::OK(); | 482 return Response::OK(); |
| 484 } | 483 } |
| 485 | 484 |
| 486 Response V8DebuggerAgentImpl::continueToLocation( | 485 Response V8DebuggerAgentImpl::continueToLocation( |
| 487 std::unique_ptr<protocol::Debugger::Location> location) { | 486 std::unique_ptr<protocol::Debugger::Location> location) { |
| 488 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 487 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
| 489 if (!m_continueToLocationBreakpointId.isEmpty()) { | 488 if (!isPaused()) return Response::Error(kDebuggerNotPaused); |
| 490 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 489 return m_debugger->continueToLocation(m_session->contextGroupId(), |
| 491 m_continueToLocationBreakpointId = ""; | 490 std::move(location)); |
| 492 } | |
| 493 | |
| 494 ScriptBreakpoint breakpoint(location->getScriptId(), | |
| 495 location->getLineNumber(), | |
| 496 location->getColumnNumber(0), String16()); | |
| 497 | |
| 498 m_continueToLocationBreakpointId = m_debugger->setBreakpoint( | |
| 499 breakpoint, &breakpoint.line_number, &breakpoint.column_number); | |
| 500 // TODO(kozyatinskiy): Return actual line and column number. | |
| 501 return resume(); | |
| 502 } | 491 } |
| 503 | 492 |
| 504 bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId, | 493 bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId, |
| 505 const v8::debug::Location& start, | 494 const v8::debug::Location& start, |
| 506 const v8::debug::Location& end) { | 495 const v8::debug::Location& end) { |
| 507 ScriptsMap::iterator it = m_scripts.find(scriptId); | 496 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 508 if (it == m_scripts.end()) { | 497 if (it == m_scripts.end()) { |
| 509 // Unknown scripts are blackboxed. | 498 // Unknown scripts are blackboxed. |
| 510 return true; | 499 return true; |
| 511 } | 500 } |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 breakAuxData = protocol::DictionaryValue::create(); | 1215 breakAuxData = protocol::DictionaryValue::create(); |
| 1227 breakAuxData->setArray("reasons", std::move(reasons)); | 1216 breakAuxData->setArray("reasons", std::move(reasons)); |
| 1228 } | 1217 } |
| 1229 | 1218 |
| 1230 std::unique_ptr<Array<CallFrame>> protocolCallFrames; | 1219 std::unique_ptr<Array<CallFrame>> protocolCallFrames; |
| 1231 Response response = currentCallFrames(&protocolCallFrames); | 1220 Response response = currentCallFrames(&protocolCallFrames); |
| 1232 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); | 1221 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); |
| 1233 m_frontend.paused(std::move(protocolCallFrames), breakReason, | 1222 m_frontend.paused(std::move(protocolCallFrames), breakReason, |
| 1234 std::move(breakAuxData), std::move(hitBreakpointIds), | 1223 std::move(breakAuxData), std::move(hitBreakpointIds), |
| 1235 currentAsyncStackTrace()); | 1224 currentAsyncStackTrace()); |
| 1236 | |
| 1237 if (!m_continueToLocationBreakpointId.isEmpty()) { | |
| 1238 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | |
| 1239 m_continueToLocationBreakpointId = ""; | |
| 1240 } | |
| 1241 } | 1225 } |
| 1242 | 1226 |
| 1243 void V8DebuggerAgentImpl::didContinue() { | 1227 void V8DebuggerAgentImpl::didContinue() { |
| 1244 JavaScriptCallFrames emptyCallFrames; | 1228 JavaScriptCallFrames emptyCallFrames; |
| 1245 m_pausedCallFrames.swap(emptyCallFrames); | 1229 m_pausedCallFrames.swap(emptyCallFrames); |
| 1246 clearBreakDetails(); | 1230 clearBreakDetails(); |
| 1247 m_frontend.resumed(); | 1231 m_frontend.resumed(); |
| 1248 } | 1232 } |
| 1249 | 1233 |
| 1250 void V8DebuggerAgentImpl::breakProgram( | 1234 void V8DebuggerAgentImpl::breakProgram( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 | 1274 |
| 1291 void V8DebuggerAgentImpl::reset() { | 1275 void V8DebuggerAgentImpl::reset() { |
| 1292 if (!enabled()) return; | 1276 if (!enabled()) return; |
| 1293 m_blackboxedPositions.clear(); | 1277 m_blackboxedPositions.clear(); |
| 1294 resetBlackboxedStateCache(); | 1278 resetBlackboxedStateCache(); |
| 1295 m_scripts.clear(); | 1279 m_scripts.clear(); |
| 1296 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1280 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1297 } | 1281 } |
| 1298 | 1282 |
| 1299 } // namespace v8_inspector | 1283 } // namespace v8_inspector |
| OLD | NEW |