| 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(); |
| 450 | 451 |
| 451 *locations = protocol::Array<protocol::Debugger::Location>::create(); | 452 *locations = protocol::Array<protocol::Debugger::BreakLocation>::create(); |
| 452 for (size_t i = 0; i < v8Locations.size(); ++i) { | 453 for (size_t i = 0; i < v8Locations.size(); ++i) { |
| 453 (*locations) | 454 std::unique_ptr<protocol::Debugger::Location> location = |
| 454 ->addItem(protocol::Debugger::Location::create() | 455 protocol::Debugger::Location::create() |
| 455 .setScriptId(scriptId) | 456 .setScriptId(scriptId) |
| 456 .setLineNumber(v8Locations[i].GetLineNumber()) | 457 .setLineNumber(v8Locations[i].GetLocation().GetLineNumber()) |
| 457 .setColumnNumber(v8Locations[i].GetColumnNumber()) | 458 .setColumnNumber(v8Locations[i].GetLocation().GetColumnNumber()) |
| 458 .build()); | 459 .build(); |
| 460 std::unique_ptr<protocol::Debugger::BreakLocation> breakLocation = |
| 461 protocol::Debugger::BreakLocation::create() |
| 462 .setLocation(std::move(location)) |
| 463 .build(); |
| 464 if (v8Locations[i].IsCall()) { |
| 465 breakLocation->setType(protocol::Debugger::BreakLocation::TypeEnum::Call); |
| 466 } else if (v8Locations[i].IsReturn()) { |
| 467 breakLocation->setType( |
| 468 protocol::Debugger::BreakLocation::TypeEnum::Return); |
| 469 } else if (v8Locations[i].IsDebuggerStatement()) { |
| 470 breakLocation->setType( |
| 471 protocol::Debugger::BreakLocation::TypeEnum::DebuggerStatement); |
| 472 } |
| 473 (*locations)->addItem(std::move(breakLocation)); |
| 459 } | 474 } |
| 460 return Response::OK(); | 475 return Response::OK(); |
| 461 } | 476 } |
| 462 | 477 |
| 463 Response V8DebuggerAgentImpl::continueToLocation( | 478 Response V8DebuggerAgentImpl::continueToLocation( |
| 464 std::unique_ptr<protocol::Debugger::Location> location) { | 479 std::unique_ptr<protocol::Debugger::Location> location) { |
| 465 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 480 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
| 466 if (!m_continueToLocationBreakpointId.isEmpty()) { | 481 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 467 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 482 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
| 468 m_continueToLocationBreakpointId = ""; | 483 m_continueToLocationBreakpointId = ""; |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 void V8DebuggerAgentImpl::reset() { | 1305 void V8DebuggerAgentImpl::reset() { |
| 1291 if (!enabled()) return; | 1306 if (!enabled()) return; |
| 1292 m_scheduledDebuggerStep = NoStep; | 1307 m_scheduledDebuggerStep = NoStep; |
| 1293 m_blackboxedPositions.clear(); | 1308 m_blackboxedPositions.clear(); |
| 1294 resetBlackboxedStateCache(); | 1309 resetBlackboxedStateCache(); |
| 1295 m_scripts.clear(); | 1310 m_scripts.clear(); |
| 1296 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1311 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1297 } | 1312 } |
| 1298 | 1313 |
| 1299 } // namespace v8_inspector | 1314 } // namespace v8_inspector |
| OLD | NEW |