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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 const String16& debuggerBreakpointId = ids[i]; | 354 const String16& debuggerBreakpointId = ids[i]; |
355 | 355 |
356 m_debugger->removeBreakpoint(debuggerBreakpointId); | 356 m_debugger->removeBreakpoint(debuggerBreakpointId); |
357 m_serverBreakpoints.erase(debuggerBreakpointId); | 357 m_serverBreakpoints.erase(debuggerBreakpointId); |
358 } | 358 } |
359 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); | 359 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); |
360 } | 360 } |
361 | 361 |
362 Response V8DebuggerAgentImpl::getPossibleBreakpoints( | 362 Response V8DebuggerAgentImpl::getPossibleBreakpoints( |
363 std::unique_ptr<protocol::Debugger::Location> start, | 363 std::unique_ptr<protocol::Debugger::Location> start, |
364 Maybe<protocol::Debugger::Location> end, | 364 Maybe<protocol::Debugger::Location> end, Maybe<bool> restrictToFunction, |
365 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { | 365 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { |
366 String16 scriptId = start->getScriptId(); | 366 String16 scriptId = start->getScriptId(); |
367 | 367 |
368 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) | 368 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) |
369 return Response::Error( | 369 return Response::Error( |
370 "start.lineNumber and start.columnNumber should be >= 0"); | 370 "start.lineNumber and start.columnNumber should be >= 0"); |
371 | 371 |
372 v8::debug::Location v8Start(start->getLineNumber(), | 372 v8::debug::Location v8Start(start->getLineNumber(), |
373 start->getColumnNumber(0)); | 373 start->getColumnNumber(0)); |
374 v8::debug::Location v8End; | 374 v8::debug::Location v8End; |
375 if (end.isJust()) { | 375 if (end.isJust()) { |
376 if (end.fromJust()->getScriptId() != scriptId) | 376 if (end.fromJust()->getScriptId() != scriptId) |
377 return Response::Error("Locations should contain the same scriptId"); | 377 return Response::Error("Locations should contain the same scriptId"); |
378 int line = end.fromJust()->getLineNumber(); | 378 int line = end.fromJust()->getLineNumber(); |
379 int column = end.fromJust()->getColumnNumber(0); | 379 int column = end.fromJust()->getColumnNumber(0); |
380 if (line < 0 || column < 0) | 380 if (line < 0 || column < 0) |
381 return Response::Error( | 381 return Response::Error( |
382 "end.lineNumber and end.columnNumber should be >= 0"); | 382 "end.lineNumber and end.columnNumber should be >= 0"); |
383 v8End = v8::debug::Location(line, column); | 383 v8End = v8::debug::Location(line, column); |
384 } | 384 } |
385 auto it = m_scripts.find(scriptId); | 385 auto it = m_scripts.find(scriptId); |
386 if (it == m_scripts.end()) return Response::Error("Script not found"); | 386 if (it == m_scripts.end()) return Response::Error("Script not found"); |
387 | 387 |
388 std::vector<v8::debug::Location> v8Locations; | 388 std::vector<v8::debug::Location> v8Locations; |
389 if (!it->second->getPossibleBreakpoints(v8Start, v8End, &v8Locations)) | 389 if (!it->second->getPossibleBreakpoints( |
| 390 v8Start, v8End, restrictToFunction.fromMaybe(false), &v8Locations)) |
390 return Response::InternalError(); | 391 return Response::InternalError(); |
391 | 392 |
392 *locations = protocol::Array<protocol::Debugger::Location>::create(); | 393 *locations = protocol::Array<protocol::Debugger::Location>::create(); |
393 for (size_t i = 0; i < v8Locations.size(); ++i) { | 394 for (size_t i = 0; i < v8Locations.size(); ++i) { |
394 (*locations) | 395 (*locations) |
395 ->addItem(protocol::Debugger::Location::create() | 396 ->addItem(protocol::Debugger::Location::create() |
396 .setScriptId(scriptId) | 397 .setScriptId(scriptId) |
397 .setLineNumber(v8Locations[i].GetLineNumber()) | 398 .setLineNumber(v8Locations[i].GetLineNumber()) |
398 .setColumnNumber(v8Locations[i].GetColumnNumber()) | 399 .setColumnNumber(v8Locations[i].GetColumnNumber()) |
399 .build()); | 400 .build()); |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 void V8DebuggerAgentImpl::reset() { | 1223 void V8DebuggerAgentImpl::reset() { |
1223 if (!enabled()) return; | 1224 if (!enabled()) return; |
1224 m_scheduledDebuggerStep = NoStep; | 1225 m_scheduledDebuggerStep = NoStep; |
1225 m_blackboxedPositions.clear(); | 1226 m_blackboxedPositions.clear(); |
1226 resetBlackboxedStateCache(); | 1227 resetBlackboxedStateCache(); |
1227 m_scripts.clear(); | 1228 m_scripts.clear(); |
1228 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1229 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1229 } | 1230 } |
1230 | 1231 |
1231 } // namespace v8_inspector | 1232 } // namespace v8_inspector |
OLD | NEW |