Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

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

Powered by Google App Engine
This is Rietveld 408576698