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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 const std::vector<String16>& ids = debuggerBreakpointIdsIterator->second; | 373 const std::vector<String16>& ids = debuggerBreakpointIdsIterator->second; |
374 for (size_t i = 0; i < ids.size(); ++i) { | 374 for (size_t i = 0; i < ids.size(); ++i) { |
375 const String16& debuggerBreakpointId = ids[i]; | 375 const String16& debuggerBreakpointId = ids[i]; |
376 | 376 |
377 m_debugger->removeBreakpoint(debuggerBreakpointId); | 377 m_debugger->removeBreakpoint(debuggerBreakpointId); |
378 m_serverBreakpoints.erase(debuggerBreakpointId); | 378 m_serverBreakpoints.erase(debuggerBreakpointId); |
379 } | 379 } |
380 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); | 380 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); |
381 } | 381 } |
382 | 382 |
383 void V8DebuggerAgentImpl::getPossibleBreakpoints( | |
384 ErrorString* errorString, | |
385 std::unique_ptr<protocol::Debugger::Location> start, | |
386 const Maybe<protocol::Debugger::Location>& end, | |
387 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { | |
388 String16 scriptId = start->getScriptId(); | |
389 | |
390 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) { | |
391 *errorString = "start.lineNumber and start.columnNumber should be >= 0"; | |
392 return; | |
393 } | |
394 | |
395 v8::DebugInterface::Script::Location v8Start(start->getLineNumber(), | |
396 start->getColumnNumber(0)); | |
397 v8::DebugInterface::Script::Location v8End; | |
398 if (end.isJust()) { | |
399 if (end.fromJust()->getScriptId() != scriptId) { | |
400 *errorString = "Locations should contain the same scriptId"; | |
401 return; | |
402 } | |
403 int line = end.fromJust()->getLineNumber(); | |
404 int column = end.fromJust()->getColumnNumber(0); | |
405 if (line < 0 || column < 0) { | |
406 *errorString = "end.lineNumber and end.columnNumber should be >= 0"; | |
407 return; | |
408 } | |
409 v8End = v8::DebugInterface::Script::Location(line, column); | |
410 } | |
411 auto it = m_scripts.find(scriptId); | |
412 if (it == m_scripts.end()) { | |
413 *errorString = "Script not found"; | |
414 return; | |
415 } | |
416 | |
417 std::vector<v8::DebugInterface::Script::Location> v8Locations; | |
418 if (!it->second->getPossibleBreakpoints(v8Start, v8End, &v8Locations)) { | |
419 *errorString = "Internal error"; | |
420 return; | |
421 } | |
422 | |
423 using protocol::Debugger::Location; | |
dgozman
2016/11/03 21:13:13
Please remove.
kozy
2016/11/03 22:17:13
Done.
| |
424 *locations = protocol::Array<Location>::create(); | |
425 for (size_t i = 0; i < v8Locations.size(); ++i) { | |
426 (*locations) | |
427 ->addItem(Location::create() | |
428 .setScriptId(scriptId) | |
429 .setLineNumber(v8Locations[i].GetLineNumber()) | |
430 .setColumnNumber(v8Locations[i].GetColumnNumber()) | |
431 .build()); | |
432 } | |
433 } | |
434 | |
383 void V8DebuggerAgentImpl::continueToLocation( | 435 void V8DebuggerAgentImpl::continueToLocation( |
384 ErrorString* errorString, | 436 ErrorString* errorString, |
385 std::unique_ptr<protocol::Debugger::Location> location) { | 437 std::unique_ptr<protocol::Debugger::Location> location) { |
386 if (!checkEnabled(errorString)) return; | 438 if (!checkEnabled(errorString)) return; |
387 if (!m_continueToLocationBreakpointId.isEmpty()) { | 439 if (!m_continueToLocationBreakpointId.isEmpty()) { |
388 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 440 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
389 m_continueToLocationBreakpointId = ""; | 441 m_continueToLocationBreakpointId = ""; |
390 } | 442 } |
391 | 443 |
392 String16 scriptId; | 444 String16 scriptId; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 if (!checkEnabled(errorString)) return; | 592 if (!checkEnabled(errorString)) return; |
541 | 593 |
542 v8::HandleScope handles(m_isolate); | 594 v8::HandleScope handles(m_isolate); |
543 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); | 595 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); |
544 if (!m_debugger->setScriptSource(scriptId, newSource, dryRun.fromMaybe(false), | 596 if (!m_debugger->setScriptSource(scriptId, newSource, dryRun.fromMaybe(false), |
545 errorString, optOutCompileError, | 597 errorString, optOutCompileError, |
546 &m_pausedCallFrames, stackChanged)) | 598 &m_pausedCallFrames, stackChanged)) |
547 return; | 599 return; |
548 | 600 |
549 ScriptsMap::iterator it = m_scripts.find(scriptId); | 601 ScriptsMap::iterator it = m_scripts.find(scriptId); |
550 if (it != m_scripts.end()) it->second->setSource(m_isolate, newSource); | 602 if (it != m_scripts.end()) it->second->setSource(newSource); |
551 | 603 |
552 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString); | 604 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString); |
553 if (!callFrames) return; | 605 if (!callFrames) return; |
554 *newCallFrames = std::move(callFrames); | 606 *newCallFrames = std::move(callFrames); |
555 *asyncStackTrace = currentAsyncStackTrace(); | 607 *asyncStackTrace = currentAsyncStackTrace(); |
556 } | 608 } |
557 | 609 |
558 void V8DebuggerAgentImpl::restartFrame( | 610 void V8DebuggerAgentImpl::restartFrame( |
559 ErrorString* errorString, const String16& callFrameId, | 611 ErrorString* errorString, const String16& callFrameId, |
560 std::unique_ptr<Array<CallFrame>>* newCallFrames, | 612 std::unique_ptr<Array<CallFrame>>* newCallFrames, |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1242 | 1294 |
1243 void V8DebuggerAgentImpl::reset() { | 1295 void V8DebuggerAgentImpl::reset() { |
1244 if (!enabled()) return; | 1296 if (!enabled()) return; |
1245 m_scheduledDebuggerStep = NoStep; | 1297 m_scheduledDebuggerStep = NoStep; |
1246 m_scripts.clear(); | 1298 m_scripts.clear(); |
1247 m_blackboxedPositions.clear(); | 1299 m_blackboxedPositions.clear(); |
1248 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1300 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1249 } | 1301 } |
1250 | 1302 |
1251 } // namespace v8_inspector | 1303 } // namespace v8_inspector |
OLD | NEW |