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...) 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 int startLine = start->getLineNumber(); | |
390 int startColumn = start->getColumnNumber(0); | |
391 int endLine = end.isJust() ? end.fromJust()->getLineNumber() : -1; | |
392 int endColumn = end.isJust() ? end.fromJust()->getColumnNumber(0) : -1; | |
393 | |
394 if (end.isJust()) { | |
395 if (end.fromJust()->getScriptId() != scriptId) { | |
396 *errorString = "Locations should contain the same scriptId"; | |
397 return; | |
398 } | |
399 } | |
400 auto it = m_scripts.find(scriptId); | |
401 if (it == m_scripts.end()) { | |
402 *errorString = "Script not found"; | |
403 return; | |
404 } | |
405 | |
406 std::vector<int> positions; | |
407 if (!it->second->getPossibleBreakpoints(startLine, startColumn, endLine, | |
408 endColumn, positions) || | |
409 positions.size() % 2) { | |
Yang
2016/11/03 08:03:26
We would not have to check this if positions conta
kozy
2016/11/03 17:26:45
Removed.
| |
410 *errorString = "Internal error"; | |
411 return; | |
412 } | |
413 | |
414 using protocol::Debugger::Location; | |
415 *locations = protocol::Array<Location>::create(); | |
416 for (size_t i = 0; i < positions.size(); i += 2) { | |
417 (*locations) | |
418 ->addItem(Location::create() | |
419 .setScriptId(scriptId) | |
420 .setLineNumber(positions[i]) | |
421 .setColumnNumber(positions[i + 1]) | |
422 .build()); | |
423 } | |
424 } | |
425 | |
383 void V8DebuggerAgentImpl::continueToLocation( | 426 void V8DebuggerAgentImpl::continueToLocation( |
384 ErrorString* errorString, | 427 ErrorString* errorString, |
385 std::unique_ptr<protocol::Debugger::Location> location) { | 428 std::unique_ptr<protocol::Debugger::Location> location) { |
386 if (!checkEnabled(errorString)) return; | 429 if (!checkEnabled(errorString)) return; |
387 if (!m_continueToLocationBreakpointId.isEmpty()) { | 430 if (!m_continueToLocationBreakpointId.isEmpty()) { |
388 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 431 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); |
389 m_continueToLocationBreakpointId = ""; | 432 m_continueToLocationBreakpointId = ""; |
390 } | 433 } |
391 | 434 |
392 String16 scriptId; | 435 String16 scriptId; |
(...skipping 147 matching lines...) Loading... | |
540 if (!checkEnabled(errorString)) return; | 583 if (!checkEnabled(errorString)) return; |
541 | 584 |
542 v8::HandleScope handles(m_isolate); | 585 v8::HandleScope handles(m_isolate); |
543 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); | 586 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); |
544 if (!m_debugger->setScriptSource(scriptId, newSource, dryRun.fromMaybe(false), | 587 if (!m_debugger->setScriptSource(scriptId, newSource, dryRun.fromMaybe(false), |
545 errorString, optOutCompileError, | 588 errorString, optOutCompileError, |
546 &m_pausedCallFrames, stackChanged)) | 589 &m_pausedCallFrames, stackChanged)) |
547 return; | 590 return; |
548 | 591 |
549 ScriptsMap::iterator it = m_scripts.find(scriptId); | 592 ScriptsMap::iterator it = m_scripts.find(scriptId); |
550 if (it != m_scripts.end()) it->second->setSource(m_isolate, newSource); | 593 if (it != m_scripts.end()) it->second->setSource(newSource); |
551 | 594 |
552 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString); | 595 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString); |
553 if (!callFrames) return; | 596 if (!callFrames) return; |
554 *newCallFrames = std::move(callFrames); | 597 *newCallFrames = std::move(callFrames); |
555 *asyncStackTrace = currentAsyncStackTrace(); | 598 *asyncStackTrace = currentAsyncStackTrace(); |
556 } | 599 } |
557 | 600 |
558 void V8DebuggerAgentImpl::restartFrame( | 601 void V8DebuggerAgentImpl::restartFrame( |
559 ErrorString* errorString, const String16& callFrameId, | 602 ErrorString* errorString, const String16& callFrameId, |
560 std::unique_ptr<Array<CallFrame>>* newCallFrames, | 603 std::unique_ptr<Array<CallFrame>>* newCallFrames, |
(...skipping 681 matching lines...) Loading... | |
1242 | 1285 |
1243 void V8DebuggerAgentImpl::reset() { | 1286 void V8DebuggerAgentImpl::reset() { |
1244 if (!enabled()) return; | 1287 if (!enabled()) return; |
1245 m_scheduledDebuggerStep = NoStep; | 1288 m_scheduledDebuggerStep = NoStep; |
1246 m_scripts.clear(); | 1289 m_scripts.clear(); |
1247 m_blackboxedPositions.clear(); | 1290 m_blackboxedPositions.clear(); |
1248 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1291 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1249 } | 1292 } |
1250 | 1293 |
1251 } // namespace v8_inspector | 1294 } // namespace v8_inspector |
OLD | NEW |