| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 413 |
| 414 m_debugger->removeBreakpoint(debuggerBreakpointId); | 414 m_debugger->removeBreakpoint(debuggerBreakpointId); |
| 415 m_serverBreakpoints.erase(debuggerBreakpointId); | 415 m_serverBreakpoints.erase(debuggerBreakpointId); |
| 416 } | 416 } |
| 417 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); | 417 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); |
| 418 } | 418 } |
| 419 | 419 |
| 420 Response V8DebuggerAgentImpl::getPossibleBreakpoints( | 420 Response V8DebuggerAgentImpl::getPossibleBreakpoints( |
| 421 std::unique_ptr<protocol::Debugger::Location> start, | 421 std::unique_ptr<protocol::Debugger::Location> start, |
| 422 Maybe<protocol::Debugger::Location> end, Maybe<bool> restrictToFunction, | 422 Maybe<protocol::Debugger::Location> end, Maybe<bool> restrictToFunction, |
| 423 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { | 423 std::unique_ptr<protocol::Array<protocol::Debugger::BreakLocation>>* |
| 424 locations) { |
| 424 String16 scriptId = start->getScriptId(); | 425 String16 scriptId = start->getScriptId(); |
| 425 | 426 |
| 426 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) | 427 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) |
| 427 return Response::Error( | 428 return Response::Error( |
| 428 "start.lineNumber and start.columnNumber should be >= 0"); | 429 "start.lineNumber and start.columnNumber should be >= 0"); |
| 429 | 430 |
| 430 v8::debug::Location v8Start(start->getLineNumber(), | 431 v8::debug::Location v8Start(start->getLineNumber(), |
| 431 start->getColumnNumber(0)); | 432 start->getColumnNumber(0)); |
| 432 v8::debug::Location v8End; | 433 v8::debug::Location v8End; |
| 433 if (end.isJust()) { | 434 if (end.isJust()) { |
| 434 if (end.fromJust()->getScriptId() != scriptId) | 435 if (end.fromJust()->getScriptId() != scriptId) |
| 435 return Response::Error("Locations should contain the same scriptId"); | 436 return Response::Error("Locations should contain the same scriptId"); |
| 436 int line = end.fromJust()->getLineNumber(); | 437 int line = end.fromJust()->getLineNumber(); |
| 437 int column = end.fromJust()->getColumnNumber(0); | 438 int column = end.fromJust()->getColumnNumber(0); |
| 438 if (line < 0 || column < 0) | 439 if (line < 0 || column < 0) |
| 439 return Response::Error( | 440 return Response::Error( |
| 440 "end.lineNumber and end.columnNumber should be >= 0"); | 441 "end.lineNumber and end.columnNumber should be >= 0"); |
| 441 v8End = v8::debug::Location(line, column); | 442 v8End = v8::debug::Location(line, column); |
| 442 } | 443 } |
| 443 auto it = m_scripts.find(scriptId); | 444 auto it = m_scripts.find(scriptId); |
| 444 if (it == m_scripts.end()) return Response::Error("Script not found"); | 445 if (it == m_scripts.end()) return Response::Error("Script not found"); |
| 445 | 446 |
| 446 std::vector<v8::debug::Location> v8Locations; | 447 std::vector<v8::debug::BreakLocation> v8Locations; |
| 447 if (!it->second->getPossibleBreakpoints( | 448 if (!it->second->getPossibleBreakpoints( |
| 448 v8Start, v8End, restrictToFunction.fromMaybe(false), &v8Locations)) | 449 v8Start, v8End, restrictToFunction.fromMaybe(false), &v8Locations)) { |
| 449 return Response::InternalError(); | 450 return Response::InternalError(); |
| 451 } |
| 450 | 452 |
| 451 *locations = protocol::Array<protocol::Debugger::Location>::create(); | 453 *locations = protocol::Array<protocol::Debugger::BreakLocation>::create(); |
| 452 for (size_t i = 0; i < v8Locations.size(); ++i) { | 454 for (size_t i = 0; i < v8Locations.size(); ++i) { |
| 453 (*locations) | 455 std::unique_ptr<protocol::Debugger::BreakLocation> breakLocation = |
| 454 ->addItem(protocol::Debugger::Location::create() | 456 protocol::Debugger::BreakLocation::create() |
| 455 .setScriptId(scriptId) | 457 .setScriptId(scriptId) |
| 456 .setLineNumber(v8Locations[i].GetLineNumber()) | 458 .setLineNumber(v8Locations[i].GetLineNumber()) |
| 457 .setColumnNumber(v8Locations[i].GetColumnNumber()) | 459 .setColumnNumber(v8Locations[i].GetColumnNumber()) |
| 458 .build()); | 460 .build(); |
| 461 if (v8Locations[i].IsCall()) { |
| 462 breakLocation->setType(protocol::Debugger::BreakLocation::TypeEnum::Call); |
| 463 } else if (v8Locations[i].IsReturn()) { |
| 464 breakLocation->setType( |
| 465 protocol::Debugger::BreakLocation::TypeEnum::Return); |
| 466 } else if (v8Locations[i].IsDebuggerStatement()) { |
| 467 breakLocation->setType( |
| 468 protocol::Debugger::BreakLocation::TypeEnum::DebuggerStatement); |
| 469 } |
| 470 (*locations)->addItem(std::move(breakLocation)); |
| 459 } | 471 } |
| 460 return Response::OK(); | 472 return Response::OK(); |
| 461 } | 473 } |
| 462 | 474 |
| 463 Response V8DebuggerAgentImpl::continueToLocation( | 475 Response V8DebuggerAgentImpl::continueToLocation( |
| 464 std::unique_ptr<protocol::Debugger::Location> location) { | 476 std::unique_ptr<protocol::Debugger::Location> location) { |
| 465 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 477 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
| 466 if (!m_continueToLocationBreakpointId.isEmpty()) { | 478 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 467 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 479 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
| 468 m_continueToLocationBreakpointId = ""; | 480 m_continueToLocationBreakpointId = ""; |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 void V8DebuggerAgentImpl::reset() { | 1302 void V8DebuggerAgentImpl::reset() { |
| 1291 if (!enabled()) return; | 1303 if (!enabled()) return; |
| 1292 m_scheduledDebuggerStep = NoStep; | 1304 m_scheduledDebuggerStep = NoStep; |
| 1293 m_blackboxedPositions.clear(); | 1305 m_blackboxedPositions.clear(); |
| 1294 resetBlackboxedStateCache(); | 1306 resetBlackboxedStateCache(); |
| 1295 m_scripts.clear(); | 1307 m_scripts.clear(); |
| 1296 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1308 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1297 } | 1309 } |
| 1298 | 1310 |
| 1299 } // namespace v8_inspector | 1311 } // namespace v8_inspector |
| OLD | NEW |