| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 "platform/v8_inspector/V8DebuggerAgentImpl.h" | 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/Values.h" | 7 #include "platform/inspector_protocol/Values.h" |
| 8 #include "platform/v8_inspector/IgnoreExceptionsScope.h" | 8 #include "platform/v8_inspector/IgnoreExceptionsScope.h" |
| 9 #include "platform/v8_inspector/InjectedScript.h" | 9 #include "platform/v8_inspector/InjectedScript.h" |
| 10 #include "platform/v8_inspector/InjectedScriptHost.h" | 10 #include "platform/v8_inspector/InjectedScriptHost.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 { | 85 { |
| 86 if (a.first != b.first) | 86 if (a.first != b.first) |
| 87 return a.first < b.first; | 87 return a.first < b.first; |
| 88 return a.second < b.second; | 88 return a.second < b.second; |
| 89 } | 89 } |
| 90 | 90 |
| 91 static const LChar hexDigits[17] = "0123456789ABCDEF"; | 91 static const LChar hexDigits[17] = "0123456789ABCDEF"; |
| 92 | 92 |
| 93 static void appendUnsignedAsHex(unsigned number, String& destination) | 93 static void appendUnsignedAsHex(unsigned number, String& destination) |
| 94 { | 94 { |
| 95 Vector<LChar, 8> result; | 95 for (size_t i = 0; i < 8; ++i) { |
| 96 do { | 96 destination.append(hexDigits[number & 0xF]); |
| 97 result.prepend(hexDigits[number % 16]); | |
| 98 number >>= 4; | 97 number >>= 4; |
| 99 } while (number > 0); | 98 } |
| 100 | |
| 101 destination.append(result.data(), result.size()); | |
| 102 } | 99 } |
| 103 | 100 |
| 104 // Hash algorithm for substrings is described in "Über die Komplexität der Multi
plikation in | 101 // Hash algorithm for substrings is described in "Über die Komplexität der Multi
plikation in |
| 105 // eingeschränkten Branchingprogrammmodellen" by Woelfe. | 102 // eingeschränkten Branchingprogrammmodellen" by Woelfe. |
| 106 // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECT
ION00832000000000000000 | 103 // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECT
ION00832000000000000000 |
| 107 static String calculateHash(const String& str) | 104 static String calculateHash(const String& str) |
| 108 { | 105 { |
| 109 static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35,
0x81ABE279 }; | 106 static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35,
0x81ABE279 }; |
| 110 static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476,
0xC3D2E1F0 }; | 107 static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476,
0xC3D2E1F0 }; |
| 111 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1
1D, 0x8F462907 }; | 108 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1
1D, 0x8F462907 }; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 377 } |
| 381 if (breakpointsCookie->get(breakpointId)) { | 378 if (breakpointsCookie->get(breakpointId)) { |
| 382 *errorString = "Breakpoint at specified location already exists."; | 379 *errorString = "Breakpoint at specified location already exists."; |
| 383 return; | 380 return; |
| 384 } | 381 } |
| 385 | 382 |
| 386 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex)); | 383 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex)); |
| 387 | 384 |
| 388 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); | 385 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); |
| 389 for (auto& script : m_scripts) { | 386 for (auto& script : m_scripts) { |
| 390 if (!matches(m_debugger, script.value.sourceURL(), url, isRegex)) | 387 if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) |
| 391 continue; | 388 continue; |
| 392 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(breakp
ointId, script.key, breakpoint, UserBreakpointSource); | 389 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(breakp
ointId, script.first, breakpoint, UserBreakpointSource); |
| 393 if (location) | 390 if (location) |
| 394 (*locations)->addItem(location.release()); | 391 (*locations)->addItem(location.release()); |
| 395 } | 392 } |
| 396 | 393 |
| 397 *outBreakpointId = breakpointId; | 394 *outBreakpointId = breakpointId; |
| 398 } | 395 } |
| 399 | 396 |
| 400 static bool parseLocation(ErrorString* errorString, PassOwnPtr<protocol::Debugge
r::Location> location, String* scriptId, int* lineNumber, int* columnNumber) | 397 static bool parseLocation(ErrorString* errorString, PassOwnPtr<protocol::Debugge
r::Location> location, String* scriptId, int* lineNumber, int* columnNumber) |
| 401 { | 398 { |
| 402 *scriptId = location->getScriptId(); | 399 *scriptId = location->getScriptId(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 414 String scriptId; | 411 String scriptId; |
| 415 int lineNumber; | 412 int lineNumber; |
| 416 int columnNumber; | 413 int columnNumber; |
| 417 | 414 |
| 418 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) | 415 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) |
| 419 return; | 416 return; |
| 420 | 417 |
| 421 String condition = optionalCondition.fromMaybe(""); | 418 String condition = optionalCondition.fromMaybe(""); |
| 422 | 419 |
| 423 String breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumbe
r, UserBreakpointSource); | 420 String breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumbe
r, UserBreakpointSource); |
| 424 if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != m_breakpoint
IdToDebuggerBreakpointIds.end()) { | 421 if (m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) { |
| 425 *errorString = "Breakpoint at specified location already exists."; | 422 *errorString = "Breakpoint at specified location already exists."; |
| 426 return; | 423 return; |
| 427 } | 424 } |
| 428 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); | 425 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); |
| 429 *actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, User
BreakpointSource); | 426 *actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, User
BreakpointSource); |
| 430 if (*actualLocation) | 427 if (*actualLocation) |
| 431 *outBreakpointId = breakpointId; | 428 *outBreakpointId = breakpointId; |
| 432 else | 429 else |
| 433 *errorString = "Could not resolve breakpoint"; | 430 *errorString = "Could not resolve breakpoint"; |
| 434 } | 431 } |
| 435 | 432 |
| 436 void V8DebuggerAgentImpl::removeBreakpoint(ErrorString* errorString, const Strin
g& breakpointId) | 433 void V8DebuggerAgentImpl::removeBreakpoint(ErrorString* errorString, const Strin
g& breakpointId) |
| 437 { | 434 { |
| 438 if (!checkEnabled(errorString)) | 435 if (!checkEnabled(errorString)) |
| 439 return; | 436 return; |
| 440 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); | 437 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); |
| 441 if (breakpointsCookie) | 438 if (breakpointsCookie) |
| 442 breakpointsCookie->remove(breakpointId); | 439 breakpointsCookie->remove(breakpointId); |
| 443 removeBreakpoint(breakpointId); | 440 removeBreakpoint(breakpointId); |
| 444 } | 441 } |
| 445 | 442 |
| 446 void V8DebuggerAgentImpl::removeBreakpoint(const String& breakpointId) | 443 void V8DebuggerAgentImpl::removeBreakpoint(const String& breakpointId) |
| 447 { | 444 { |
| 448 ASSERT(enabled()); | 445 ASSERT(enabled()); |
| 449 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); | 446 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); |
| 450 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) | 447 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) |
| 451 return; | 448 return; |
| 452 for (size_t i = 0; i < debuggerBreakpointIdsIterator->value.size(); ++i) { | 449 protocol::Vector<String>* ids = debuggerBreakpointIdsIterator->second; |
| 453 const String& debuggerBreakpointId = debuggerBreakpointIdsIterator->valu
e[i]; | 450 for (size_t i = 0; i < ids->size(); ++i) { |
| 451 const String& debuggerBreakpointId = ids->at(i); |
| 452 |
| 454 debugger().removeBreakpoint(debuggerBreakpointId); | 453 debugger().removeBreakpoint(debuggerBreakpointId); |
| 455 m_serverBreakpoints.remove(debuggerBreakpointId); | 454 m_serverBreakpoints.remove(debuggerBreakpointId); |
| 456 m_muteBreakpoints.remove(debuggerBreakpointId); | |
| 457 } | 455 } |
| 458 m_breakpointIdToDebuggerBreakpointIds.remove(debuggerBreakpointIdsIterator); | 456 m_breakpointIdToDebuggerBreakpointIds.remove(breakpointId); |
| 459 } | 457 } |
| 460 | 458 |
| 461 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, | 459 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, |
| 462 PassOwnPtr<protocol::Debugger::Location> location, | 460 PassOwnPtr<protocol::Debugger::Location> location, |
| 463 const protocol::Maybe<bool>& interstateLocationOpt) | 461 const protocol::Maybe<bool>& interstateLocationOpt) |
| 464 { | 462 { |
| 465 if (!checkEnabled(errorString)) | 463 if (!checkEnabled(errorString)) |
| 466 return; | 464 return; |
| 467 if (!m_continueToLocationBreakpointId.isEmpty()) { | 465 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 468 debugger().removeBreakpoint(m_continueToLocationBreakpointId); | 466 debugger().removeBreakpoint(m_continueToLocationBreakpointId); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 return true; | 535 return true; |
| 538 ScriptsMap::iterator it = m_scripts.find(String::number(frame->sourceID())); | 536 ScriptsMap::iterator it = m_scripts.find(String::number(frame->sourceID())); |
| 539 if (it == m_scripts.end()) { | 537 if (it == m_scripts.end()) { |
| 540 // Unknown scripts are blackboxed. | 538 // Unknown scripts are blackboxed. |
| 541 return true; | 539 return true; |
| 542 } | 540 } |
| 543 auto itBlackboxedPositions = m_blackboxedPositions.find(String::number(frame
->sourceID())); | 541 auto itBlackboxedPositions = m_blackboxedPositions.find(String::number(frame
->sourceID())); |
| 544 if (itBlackboxedPositions == m_blackboxedPositions.end()) | 542 if (itBlackboxedPositions == m_blackboxedPositions.end()) |
| 545 return false; | 543 return false; |
| 546 | 544 |
| 547 const Vector<std::pair<int, int>>& ranges = itBlackboxedPositions->value; | 545 protocol::Vector<std::pair<int, int>>* ranges = itBlackboxedPositions->secon
d; |
| 548 auto itRange = std::lower_bound(ranges.begin(), ranges.end(), std::make_pair
(frame->line(), frame->column()), positionComparator); | 546 auto itRange = std::lower_bound(ranges->begin(), ranges->end(), std::make_pa
ir(frame->line(), frame->column()), positionComparator); |
| 549 // Ranges array contains positions in script where blackbox state is changed
. | 547 // Ranges array contains positions in script where blackbox state is changed
. |
| 550 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac
kboxed... | 548 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac
kboxed... |
| 551 return std::distance(ranges.begin(), itRange) % 2; | 549 return std::distance(ranges->begin(), itRange) % 2; |
| 552 } | 550 } |
| 553 | 551 |
| 554 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipExceptionPa
use() | 552 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipExceptionPa
use() |
| 555 { | 553 { |
| 556 if (m_steppingFromFramework) | 554 if (m_steppingFromFramework) |
| 557 return RequestNoSkip; | 555 return RequestNoSkip; |
| 558 if (isTopCallFrameBlackboxed()) | 556 if (isTopCallFrameBlackboxed()) |
| 559 return RequestContinue; | 557 return RequestContinue; |
| 560 return RequestNoSkip; | 558 return RequestNoSkip; |
| 561 } | 559 } |
| 562 | 560 |
| 563 bool V8DebuggerAgentImpl::isMuteBreakpointInstalled() | |
| 564 { | |
| 565 if (!m_muteBreakpoints.size()) | |
| 566 return false; | |
| 567 OwnPtr<JavaScriptCallFrame> frame = debugger().callFrameNoScopes(0); | |
| 568 if (!frame) | |
| 569 return false; | |
| 570 String sourceID = String::number(frame->sourceID()); | |
| 571 int line = frame->line(); | |
| 572 for (auto it : m_muteBreakpoints.values()) { | |
| 573 if (it.first == sourceID && it.second == line) | |
| 574 return true; | |
| 575 } | |
| 576 return false; | |
| 577 } | |
| 578 | |
| 579 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipStepPause() | 561 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipStepPause() |
| 580 { | 562 { |
| 581 if (m_steppingFromFramework) | 563 if (m_steppingFromFramework) |
| 582 return RequestNoSkip; | 564 return RequestNoSkip; |
| 583 | 565 |
| 584 if (m_skipNextDebuggerStepOut) { | 566 if (m_skipNextDebuggerStepOut) { |
| 585 m_skipNextDebuggerStepOut = false; | 567 m_skipNextDebuggerStepOut = false; |
| 586 if (m_scheduledDebuggerStep == StepOut) | 568 if (m_scheduledDebuggerStep == StepOut) |
| 587 return RequestStepOut; | 569 return RequestStepOut; |
| 588 } | 570 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 602 | 584 |
| 603 PassOwnPtr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakpoint(
const String& breakpointId, const String& scriptId, const ScriptBreakpoint& brea
kpoint, BreakpointSource source) | 585 PassOwnPtr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakpoint(
const String& breakpointId, const String& scriptId, const ScriptBreakpoint& brea
kpoint, BreakpointSource source) |
| 604 { | 586 { |
| 605 ASSERT(enabled()); | 587 ASSERT(enabled()); |
| 606 // FIXME: remove these checks once crbug.com/520702 is resolved. | 588 // FIXME: remove these checks once crbug.com/520702 is resolved. |
| 607 RELEASE_ASSERT(!breakpointId.isEmpty()); | 589 RELEASE_ASSERT(!breakpointId.isEmpty()); |
| 608 RELEASE_ASSERT(!scriptId.isEmpty()); | 590 RELEASE_ASSERT(!scriptId.isEmpty()); |
| 609 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 591 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
| 610 if (scriptIterator == m_scripts.end()) | 592 if (scriptIterator == m_scripts.end()) |
| 611 return nullptr; | 593 return nullptr; |
| 612 V8DebuggerScript& script = scriptIterator->value; | 594 V8DebuggerScript* script = scriptIterator->second; |
| 613 if (breakpoint.lineNumber < script.startLine() || script.endLine() < breakpo
int.lineNumber) | 595 if (breakpoint.lineNumber < script->startLine() || script->endLine() < break
point.lineNumber) |
| 614 return nullptr; | 596 return nullptr; |
| 615 | 597 |
| 616 int actualLineNumber; | 598 int actualLineNumber; |
| 617 int actualColumnNumber; | 599 int actualColumnNumber; |
| 618 String debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoint,
&actualLineNumber, &actualColumnNumber, false); | 600 String debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoint,
&actualLineNumber, &actualColumnNumber, false); |
| 619 if (debuggerBreakpointId.isEmpty()) | 601 if (debuggerBreakpointId.isEmpty()) |
| 620 return nullptr; | 602 return nullptr; |
| 621 | 603 |
| 622 m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, s
ource)); | 604 m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, s
ource)); |
| 623 if (breakpoint.condition == "false") | 605 RELEASE_ASSERT(!breakpointId.isEmpty()); |
| 624 m_muteBreakpoints.set(debuggerBreakpointId, std::make_pair(scriptId, bre
akpoint.lineNumber)); | 606 if (!m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) |
| 607 m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, protocol::Vector
<String>()); |
| 625 | 608 |
| 626 RELEASE_ASSERT(!breakpointId.isEmpty()); | |
| 627 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); | 609 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); |
| 628 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) | 610 debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId); |
| 629 m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, Vector<String>()
).storedValue->value.append(debuggerBreakpointId); | |
| 630 else | |
| 631 debuggerBreakpointIdsIterator->value.append(debuggerBreakpointId); | |
| 632 | 611 |
| 633 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location
::create() | 612 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location
::create() |
| 634 .setScriptId(scriptId) | 613 .setScriptId(scriptId) |
| 635 .setLineNumber(actualLineNumber) | 614 .setLineNumber(actualLineNumber) |
| 636 .setColumnNumber(actualColumnNumber).build(); | 615 .setColumnNumber(actualColumnNumber).build(); |
| 637 return location.release(); | 616 return location.release(); |
| 638 } | 617 } |
| 639 | 618 |
| 640 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String& scri
ptId, const String& query, | 619 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String& scri
ptId, const String& query, |
| 641 const Maybe<bool>& optionalCaseSensitive, | 620 const Maybe<bool>& optionalCaseSensitive, |
| 642 const Maybe<bool>& optionalIsRegex, | 621 const Maybe<bool>& optionalIsRegex, |
| 643 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results) | 622 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results) |
| 644 { | 623 { |
| 645 ScriptsMap::iterator it = m_scripts.find(scriptId); | 624 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 646 if (it != m_scripts.end()) | 625 if (it != m_scripts.end()) |
| 647 *results = V8ContentSearchUtil::searchInTextByLines(m_debugger, it->valu
e.source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromM
aybe(false)); | 626 *results = V8ContentSearchUtil::searchInTextByLines(m_debugger, it->seco
nd->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fro
mMaybe(false)); |
| 648 else | 627 else |
| 649 *error = "No script for id: " + scriptId; | 628 *error = "No script for id: " + scriptId; |
| 650 } | 629 } |
| 651 | 630 |
| 652 void V8DebuggerAgentImpl::setScriptSource(ErrorString* error, | 631 void V8DebuggerAgentImpl::setScriptSource(ErrorString* error, |
| 653 const String& scriptId, | 632 const String& scriptId, |
| 654 const String& newContent, | 633 const String& newContent, |
| 655 const Maybe<bool>& preview, | 634 const Maybe<bool>& preview, |
| 656 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 635 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
| 657 Maybe<bool>* stackChanged, | 636 Maybe<bool>* stackChanged, |
| 658 Maybe<StackTrace>* asyncStackTrace, | 637 Maybe<StackTrace>* asyncStackTrace, |
| 659 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) | 638 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) |
| 660 { | 639 { |
| 661 if (!checkEnabled(error)) | 640 if (!checkEnabled(error)) |
| 662 return; | 641 return; |
| 663 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals
e), error, optOutCompileError, &m_currentCallStack, stackChanged)) | 642 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals
e), error, optOutCompileError, &m_currentCallStack, stackChanged)) |
| 664 return; | 643 return; |
| 665 | 644 |
| 666 *newCallFrames = currentCallFrames(); | 645 *newCallFrames = currentCallFrames(); |
| 667 *asyncStackTrace = currentAsyncStackTrace(); | 646 *asyncStackTrace = currentAsyncStackTrace(); |
| 668 | 647 |
| 669 ScriptsMap::iterator it = m_scripts.find(scriptId); | 648 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 670 if (it == m_scripts.end()) | 649 if (it == m_scripts.end()) |
| 671 return; | 650 return; |
| 672 it->value.setSource(newContent); | 651 it->second->setSource(newContent); |
| 673 } | 652 } |
| 674 | 653 |
| 675 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, | 654 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, |
| 676 const String& callFrameId, | 655 const String& callFrameId, |
| 677 OwnPtr<Array<CallFrame>>* newCallFrames, | 656 OwnPtr<Array<CallFrame>>* newCallFrames, |
| 678 Maybe<StackTrace>* asyncStackTrace) | 657 Maybe<StackTrace>* asyncStackTrace) |
| 679 { | 658 { |
| 680 if (!isPaused() || m_currentCallStack.IsEmpty()) { | 659 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
| 681 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 660 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
| 682 return; | 661 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 702 | 681 |
| 703 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String& scri
ptId, String* scriptSource) | 682 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String& scri
ptId, String* scriptSource) |
| 704 { | 683 { |
| 705 if (!checkEnabled(error)) | 684 if (!checkEnabled(error)) |
| 706 return; | 685 return; |
| 707 ScriptsMap::iterator it = m_scripts.find(scriptId); | 686 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 708 if (it == m_scripts.end()) { | 687 if (it == m_scripts.end()) { |
| 709 *error = "No script for id: " + scriptId; | 688 *error = "No script for id: " + scriptId; |
| 710 return; | 689 return; |
| 711 } | 690 } |
| 712 *scriptSource = it->value.source(); | 691 *scriptSource = it->second->source(); |
| 713 } | 692 } |
| 714 | 693 |
| 715 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
ing& functionId, OwnPtr<FunctionDetails>* details) | 694 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
ing& functionId, OwnPtr<FunctionDetails>* details) |
| 716 { | 695 { |
| 717 if (!checkEnabled(errorString)) | 696 if (!checkEnabled(errorString)) |
| 718 return; | 697 return; |
| 719 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId); | 698 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId); |
| 720 if (!remoteId) { | 699 if (!remoteId) { |
| 721 *errorString = "Invalid object id"; | 700 *errorString = "Invalid object id"; |
| 722 return; | 701 return; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 } | 1146 } |
| 1168 if (m_frontend && shouldNotify) | 1147 if (m_frontend && shouldNotify) |
| 1169 m_frontend->asyncOperationCompleted(operationId); | 1148 m_frontend->asyncOperationCompleted(operationId); |
| 1170 } | 1149 } |
| 1171 | 1150 |
| 1172 void V8DebuggerAgentImpl::flushAsyncOperationEvents(ErrorString*) | 1151 void V8DebuggerAgentImpl::flushAsyncOperationEvents(ErrorString*) |
| 1173 { | 1152 { |
| 1174 if (!m_frontend) | 1153 if (!m_frontend) |
| 1175 return; | 1154 return; |
| 1176 | 1155 |
| 1177 for (int operationId : m_asyncOperationNotifications) { | 1156 for (auto& operationId : m_asyncOperationNotifications) { |
| 1178 V8StackTraceImpl* chain = m_asyncOperations.get(operationId); | 1157 V8StackTraceImpl* chain = m_asyncOperations.get(operationId.first); |
| 1179 ASSERT(chain); | 1158 ASSERT(chain); |
| 1180 if (!chain->isEmpty()) { | 1159 if (!chain->isEmpty()) { |
| 1181 OwnPtr<AsyncOperation> operation = AsyncOperation::create() | 1160 OwnPtr<AsyncOperation> operation = AsyncOperation::create() |
| 1182 .setId(operationId) | 1161 .setId(operationId.first) |
| 1183 .setStack(chain->buildInspectorObject()).build(); | 1162 .setStack(chain->buildInspectorObject()).build(); |
| 1184 m_frontend->asyncOperationStarted(operation.release()); | 1163 m_frontend->asyncOperationStarted(operation.release()); |
| 1185 } | 1164 } |
| 1186 } | 1165 } |
| 1187 | 1166 |
| 1188 m_asyncOperationNotifications.clear(); | 1167 m_asyncOperationNotifications.clear(); |
| 1189 } | 1168 } |
| 1190 | 1169 |
| 1191 void V8DebuggerAgentImpl::clearCurrentAsyncOperation() | 1170 void V8DebuggerAgentImpl::clearCurrentAsyncOperation() |
| 1192 { | 1171 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 } | 1213 } |
| 1235 if (operationId <= 0) { | 1214 if (operationId <= 0) { |
| 1236 *errorString = "Wrong async operation id."; | 1215 *errorString = "Wrong async operation id."; |
| 1237 return; | 1216 return; |
| 1238 } | 1217 } |
| 1239 m_asyncOperationBreakpoints.remove(operationId); | 1218 m_asyncOperationBreakpoints.remove(operationId); |
| 1240 } | 1219 } |
| 1241 | 1220 |
| 1242 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String&
scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPosi
tions) | 1221 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String&
scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPosi
tions) |
| 1243 { | 1222 { |
| 1244 ScriptsMap::iterator it = m_scripts.find(scriptId); | 1223 if (!m_scripts.contains(scriptId)) { |
| 1245 if (it == m_scripts.end()) { | |
| 1246 *error = "No script with passed id."; | 1224 *error = "No script with passed id."; |
| 1247 return; | 1225 return; |
| 1248 } | 1226 } |
| 1249 | 1227 |
| 1250 if (!inPositions->length()) { | 1228 if (!inPositions->length()) { |
| 1251 m_blackboxedPositions.remove(scriptId); | 1229 m_blackboxedPositions.remove(scriptId); |
| 1252 return; | 1230 return; |
| 1253 } | 1231 } |
| 1254 | 1232 |
| 1255 Vector<std::pair<int, int>> positions(inPositions->length()); | 1233 protocol::Vector<std::pair<int, int>> positions(inPositions->length()); |
| 1256 for (size_t i = 0; i < positions.size(); ++i) { | 1234 for (size_t i = 0; i < positions.size(); ++i) { |
| 1257 protocol::Debugger::ScriptPosition* position = inPositions->get(i); | 1235 protocol::Debugger::ScriptPosition* position = inPositions->get(i); |
| 1258 if (position->getLine() < 0) { | 1236 if (position->getLine() < 0) { |
| 1259 *error = "Position missing 'line' or 'line' < 0."; | 1237 *error = "Position missing 'line' or 'line' < 0."; |
| 1260 return; | 1238 return; |
| 1261 } | 1239 } |
| 1262 if (position->getColumn() < 0) { | 1240 if (position->getColumn() < 0) { |
| 1263 *error = "Position missing 'column' or 'column' < 0."; | 1241 *error = "Position missing 'column' or 'column' < 0."; |
| 1264 return; | 1242 return; |
| 1265 } | 1243 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 ScriptBreakpoint breakpoint; | 1397 ScriptBreakpoint breakpoint; |
| 1420 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.
lineNumber); | 1398 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.
lineNumber); |
| 1421 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin
t.columnNumber); | 1399 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin
t.columnNumber); |
| 1422 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); | 1400 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); |
| 1423 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie
.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); | 1401 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie
.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); |
| 1424 if (location) | 1402 if (location) |
| 1425 m_frontend->breakpointResolved(cookie.first, location.release()); | 1403 m_frontend->breakpointResolved(cookie.first, location.release()); |
| 1426 } | 1404 } |
| 1427 } | 1405 } |
| 1428 | 1406 |
| 1429 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> excep
tion, const Vector<String>& hitBreakpoints, bool isPromiseRejection) | 1407 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> excep
tion, const protocol::Vector<String>& hitBreakpoints, bool isPromiseRejection) |
| 1430 { | 1408 { |
| 1431 if (isMuteBreakpointInstalled()) | |
| 1432 return RequestContinue; | |
| 1433 | |
| 1434 V8DebuggerAgentImpl::SkipPauseRequest result; | 1409 V8DebuggerAgentImpl::SkipPauseRequest result; |
| 1435 if (m_skipAllPauses) | 1410 if (m_skipAllPauses) |
| 1436 result = RequestContinue; | 1411 result = RequestContinue; |
| 1437 else if (!hitBreakpoints.isEmpty()) | 1412 else if (!hitBreakpoints.isEmpty()) |
| 1438 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. | 1413 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. |
| 1439 else if (!exception.IsEmpty()) | 1414 else if (!exception.IsEmpty()) |
| 1440 result = shouldSkipExceptionPause(); | 1415 result = shouldSkipExceptionPause(); |
| 1441 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) | 1416 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) |
| 1442 result = shouldSkipStepPause(); | 1417 result = shouldSkipStepPause(); |
| 1443 else | 1418 else |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1468 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation; | 1443 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation; |
| 1469 m_breakAuxData = protocol::DictionaryValue::create(); | 1444 m_breakAuxData = protocol::DictionaryValue::create(); |
| 1470 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId); | 1445 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId); |
| 1471 } | 1446 } |
| 1472 | 1447 |
| 1473 OwnPtr<Array<String>> hitBreakpointIds = Array<String>::create(); | 1448 OwnPtr<Array<String>> hitBreakpointIds = Array<String>::create(); |
| 1474 | 1449 |
| 1475 for (const auto& point : hitBreakpoints) { | 1450 for (const auto& point : hitBreakpoints) { |
| 1476 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); | 1451 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); |
| 1477 if (breakpointIterator != m_serverBreakpoints.end()) { | 1452 if (breakpointIterator != m_serverBreakpoints.end()) { |
| 1478 const String& localId = breakpointIterator->value.first; | 1453 const String& localId = breakpointIterator->second->first; |
| 1479 hitBreakpointIds->addItem(localId); | 1454 hitBreakpointIds->addItem(localId); |
| 1480 | 1455 |
| 1481 BreakpointSource source = breakpointIterator->value.second; | 1456 BreakpointSource source = breakpointIterator->second->second; |
| 1482 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other &
& source == DebugCommandBreakpointSource) | 1457 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other &
& source == DebugCommandBreakpointSource) |
| 1483 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom
mand; | 1458 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom
mand; |
| 1484 } | 1459 } |
| 1485 } | 1460 } |
| 1486 | 1461 |
| 1487 if (!m_asyncOperationNotifications.isEmpty()) | 1462 if (!m_asyncOperationNotifications.isEmpty()) |
| 1488 flushAsyncOperationEvents(nullptr); | 1463 flushAsyncOperationEvents(nullptr); |
| 1489 | 1464 |
| 1490 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData.releas
e(), hitBreakpointIds.release(), currentAsyncStackTrace()); | 1465 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData.releas
e(), hitBreakpointIds.release(), currentAsyncStackTrace()); |
| 1491 m_scheduledDebuggerStep = NoStep; | 1466 m_scheduledDebuggerStep = NoStep; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 m_scripts.clear(); | 1552 m_scripts.clear(); |
| 1578 m_blackboxedPositions.clear(); | 1553 m_blackboxedPositions.clear(); |
| 1579 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1554 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1580 resetAsyncCallTracker(); | 1555 resetAsyncCallTracker(); |
| 1581 m_promiseTracker->clear(); | 1556 m_promiseTracker->clear(); |
| 1582 if (m_frontend) | 1557 if (m_frontend) |
| 1583 m_frontend->globalObjectCleared(); | 1558 m_frontend->globalObjectCleared(); |
| 1584 } | 1559 } |
| 1585 | 1560 |
| 1586 } // namespace blink | 1561 } // namespace blink |
| OLD | NEW |