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

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

Issue 2001893002: DevTools: expose raw pointers in protocol collections, s/ASSERT/DCHECK/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 #include "platform/v8_inspector/InjectedScript.h" 9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InspectedContext.h" 10 #include "platform/v8_inspector/InspectedContext.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 { 216 {
217 if (enabled()) 217 if (enabled())
218 return; 218 return;
219 219
220 if (!m_session->client()->canExecuteScripts()) { 220 if (!m_session->client()->canExecuteScripts()) {
221 *errorString = "Script execution is prohibited"; 221 *errorString = "Script execution is prohibited";
222 return; 222 return;
223 } 223 }
224 224
225 enable(); 225 enable();
226 ASSERT(m_frontend); 226 DCHECK(m_frontend);
227 } 227 }
228 228
229 void V8DebuggerAgentImpl::disable(ErrorString*) 229 void V8DebuggerAgentImpl::disable(ErrorString*)
230 { 230 {
231 if (!enabled()) 231 if (!enabled())
232 return; 232 return;
233 m_session->changeInstrumentationCounter(-1); 233 m_session->changeInstrumentationCounter(-1);
234 234
235 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict ionaryValue::create()); 235 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict ionaryValue::create());
236 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp l::DontPauseOnExceptions); 236 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp l::DontPauseOnExceptions);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state) 275 void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state)
276 { 276 {
277 m_state = state; 277 m_state = state;
278 } 278 }
279 279
280 void V8DebuggerAgentImpl::clearFrontend() 280 void V8DebuggerAgentImpl::clearFrontend()
281 { 281 {
282 ErrorString error; 282 ErrorString error;
283 disable(&error); 283 disable(&error);
284 ASSERT(m_frontend); 284 DCHECK(m_frontend);
285 m_frontend = nullptr; 285 m_frontend = nullptr;
286 } 286 }
287 287
288 void V8DebuggerAgentImpl::restore() 288 void V8DebuggerAgentImpl::restore()
289 { 289 {
290 ASSERT(!m_enabled); 290 DCHECK(!m_enabled);
291 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) 291 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false))
292 return; 292 return;
293 if (!m_session->client()->canExecuteScripts()) 293 if (!m_session->client()->canExecuteScripts())
294 return; 294 return;
295 295
296 enable(); 296 enable();
297 ErrorString error; 297 ErrorString error;
298 298
299 int pauseState = V8DebuggerImpl::DontPauseOnExceptions; 299 int pauseState = V8DebuggerImpl::DontPauseOnExceptions;
300 m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState); 300 m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState);
301 setPauseOnExceptionsImpl(&error, pauseState); 301 setPauseOnExceptionsImpl(&error, pauseState);
302 ASSERT(error.isEmpty()); 302 DCHECK(error.isEmpty());
303 303
304 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses , false); 304 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses , false);
305 305
306 int asyncCallStackDepth = 0; 306 int asyncCallStackDepth = 0;
307 m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackD epth); 307 m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackD epth);
308 internalSetAsyncCallStackDepth(asyncCallStackDepth); 308 internalSetAsyncCallStackDepth(asyncCallStackDepth);
309 309
310 String16 blackboxPattern; 310 String16 blackboxPattern;
311 if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern )) { 311 if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern )) {
312 if (!setBlackboxPattern(&error, blackboxPattern)) 312 if (!setBlackboxPattern(&error, blackboxPattern))
313 ASSERT_NOT_REACHED(); 313 NOTREACHED();
314 } 314 }
315 } 315 }
316 316
317 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac tive) 317 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac tive)
318 { 318 {
319 if (!checkEnabled(errorString)) 319 if (!checkEnabled(errorString))
320 return; 320 return;
321 debugger().setBreakpointsActivated(active); 321 debugger().setBreakpointsActivated(active);
322 } 322 }
323 323
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (!checkEnabled(errorString)) 441 if (!checkEnabled(errorString))
442 return; 442 return;
443 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints); 443 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints);
444 if (breakpointsCookie) 444 if (breakpointsCookie)
445 breakpointsCookie->remove(breakpointId); 445 breakpointsCookie->remove(breakpointId);
446 removeBreakpoint(breakpointId); 446 removeBreakpoint(breakpointId);
447 } 447 }
448 448
449 void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) 449 void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId)
450 { 450 {
451 ASSERT(enabled()); 451 DCHECK(enabled());
452 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); 452 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId);
453 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e nd()) 453 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e nd())
454 return; 454 return;
455 protocol::Vector<String16>* ids = debuggerBreakpointIdsIterator->second; 455 protocol::Vector<String16>* ids = debuggerBreakpointIdsIterator->second;
456 for (size_t i = 0; i < ids->size(); ++i) { 456 for (size_t i = 0; i < ids->size(); ++i) {
457 const String16& debuggerBreakpointId = ids->at(i); 457 const String16& debuggerBreakpointId = ids->at(i);
458 458
459 debugger().removeBreakpoint(debuggerBreakpointId); 459 debugger().removeBreakpoint(debuggerBreakpointId);
460 m_serverBreakpoints.remove(debuggerBreakpointId); 460 m_serverBreakpoints.remove(debuggerBreakpointId);
461 } 461 }
(...skipping 29 matching lines...) Expand all
491 return; 491 return;
492 m_pausedCallFrames.swap(debugger().currentCallFrames()); 492 m_pausedCallFrames.swap(debugger().currentCallFrames());
493 *callFrames = currentCallFrames(errorString); 493 *callFrames = currentCallFrames(errorString);
494 if (!*callFrames) 494 if (!*callFrames)
495 return; 495 return;
496 *asyncStackTrace = currentAsyncStackTrace(); 496 *asyncStackTrace = currentAsyncStackTrace();
497 } 497 }
498 498
499 bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() 499 bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed()
500 { 500 {
501 ASSERT(enabled()); 501 DCHECK(enabled());
502 JavaScriptCallFrames callFrames = debugger().currentCallFrames(); 502 JavaScriptCallFrames callFrames = debugger().currentCallFrames();
503 for (size_t index = 0; index < callFrames.size(); ++index) { 503 for (size_t index = 0; index < callFrames.size(); ++index) {
504 if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) 504 if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index]))
505 return false; 505 return false;
506 } 506 }
507 return true; 507 return true;
508 } 508 }
509 509
510 bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed() 510 bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed()
511 { 511 {
512 ASSERT(enabled()); 512 DCHECK(enabled());
513 return isCallFrameWithUnknownScriptOrBlackboxed(m_pausedCallFrames.size() ? m_pausedCallFrames[0].get() : nullptr); 513 return isCallFrameWithUnknownScriptOrBlackboxed(m_pausedCallFrames.size() ? m_pausedCallFrames[0] : nullptr);
514 } 514 }
515 515
516 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame) 516 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame)
517 { 517 {
518 if (!frame) 518 if (!frame)
519 return true; 519 return true;
520 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID()) ); 520 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID()) );
521 if (it == m_scripts.end()) { 521 if (it == m_scripts.end()) {
522 // Unknown scripts are blackboxed. 522 // Unknown scripts are blackboxed.
523 return true; 523 return true;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 if (!m_skippedStepFrameCount) 567 if (!m_skippedStepFrameCount)
568 m_recursionLevelForStepFrame = 1; 568 m_recursionLevelForStepFrame = 1;
569 569
570 ++m_skippedStepFrameCount; 570 ++m_skippedStepFrameCount;
571 return RequestStepFrame; 571 return RequestStepFrame;
572 } 572 }
573 573
574 PassOwnPtr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakpoint( const String16& breakpointId, const String16& scriptId, const ScriptBreakpoint& breakpoint, BreakpointSource source) 574 PassOwnPtr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakpoint( const String16& breakpointId, const String16& scriptId, const ScriptBreakpoint& breakpoint, BreakpointSource source)
575 { 575 {
576 ASSERT(enabled()); 576 DCHECK(enabled());
577 // FIXME: remove these checks once crbug.com/520702 is resolved. 577 // FIXME: remove these checks once crbug.com/520702 is resolved.
578 RELEASE_ASSERT(!breakpointId.isEmpty()); 578 CHECK(!breakpointId.isEmpty());
579 RELEASE_ASSERT(!scriptId.isEmpty()); 579 CHECK(!scriptId.isEmpty());
580 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); 580 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId);
581 if (scriptIterator == m_scripts.end()) 581 if (scriptIterator == m_scripts.end())
582 return nullptr; 582 return nullptr;
583 V8DebuggerScript* script = scriptIterator->second; 583 V8DebuggerScript* script = scriptIterator->second;
584 if (breakpoint.lineNumber < script->startLine() || script->endLine() < break point.lineNumber) 584 if (breakpoint.lineNumber < script->startLine() || script->endLine() < break point.lineNumber)
585 return nullptr; 585 return nullptr;
586 586
587 int actualLineNumber; 587 int actualLineNumber;
588 int actualColumnNumber; 588 int actualColumnNumber;
589 String16 debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoin t, &actualLineNumber, &actualColumnNumber, false); 589 String16 debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoin t, &actualLineNumber, &actualColumnNumber, false);
590 if (debuggerBreakpointId.isEmpty()) 590 if (debuggerBreakpointId.isEmpty())
591 return nullptr; 591 return nullptr;
592 592
593 m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, s ource)); 593 m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, s ource));
594 RELEASE_ASSERT(!breakpointId.isEmpty()); 594 CHECK(!breakpointId.isEmpty());
595 if (!m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) 595 if (!m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId))
596 m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, protocol::Vector <String16>()); 596 m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, protocol::Vector <String16>());
597 597
598 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); 598 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId);
599 debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId); 599 debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId);
600 600
601 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ; 601 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ;
602 } 602 }
603 603
604 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query, 604 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId); 649 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId);
650 if (!scope.initialize()) 650 if (!scope.initialize())
651 return; 651 return;
652 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { 652 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) {
653 *errorString = "Could not find call frame with given id"; 653 *errorString = "Could not find call frame with given id";
654 return; 654 return;
655 } 655 }
656 656
657 v8::Local<v8::Value> resultValue; 657 v8::Local<v8::Value> resultValue;
658 v8::Local<v8::Boolean> result; 658 v8::Local<v8::Boolean> result;
659 if (!m_pausedCallFrames[scope.frameOrdinal()].get()->restart().ToLocal(&resu ltValue) || scope.tryCatch().HasCaught() || !resultValue->ToBoolean(scope.contex t()).ToLocal(&result) || !result->Value()) { 659 if (!m_pausedCallFrames[scope.frameOrdinal()]->restart().ToLocal(&resultValu e) || scope.tryCatch().HasCaught() || !resultValue->ToBoolean(scope.context()).T oLocal(&result) || !result->Value()) {
660 *errorString = "Internal error"; 660 *errorString = "Internal error";
661 return; 661 return;
662 } 662 }
663 m_pausedCallFrames.swap(debugger().currentCallFrames()); 663 m_pausedCallFrames.swap(debugger().currentCallFrames());
664 664
665 *newCallFrames = currentCallFrames(errorString); 665 *newCallFrames = currentCallFrames(errorString);
666 if (!*newCallFrames) 666 if (!*newCallFrames)
667 return; 667 return;
668 *asyncStackTrace = currentAsyncStackTrace(); 668 *asyncStackTrace = currentAsyncStackTrace();
669 } 669 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 return; 785 return;
786 m_breakReason = breakReason; 786 m_breakReason = breakReason;
787 m_breakAuxData = std::move(data); 787 m_breakAuxData = std::move(data);
788 m_pausingOnNativeEvent = true; 788 m_pausingOnNativeEvent = true;
789 m_skipNextDebuggerStepOut = false; 789 m_skipNextDebuggerStepOut = false;
790 debugger().setPauseOnNextStatement(true); 790 debugger().setPauseOnNextStatement(true);
791 } 791 }
792 792
793 void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto() 793 void V8DebuggerAgentImpl::schedulePauseOnNextStatementIfSteppingInto()
794 { 794 {
795 ASSERT(enabled()); 795 DCHECK(enabled());
796 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || deb ugger().isPaused()) 796 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || deb ugger().isPaused())
797 return; 797 return;
798 clearBreakDetails(); 798 clearBreakDetails();
799 m_pausingOnNativeEvent = false; 799 m_pausingOnNativeEvent = false;
800 m_skippedStepFrameCount = 0; 800 m_skippedStepFrameCount = 0;
801 m_recursionLevelForStepFrame = 0; 801 m_recursionLevelForStepFrame = 0;
802 debugger().setPauseOnNextStatement(true); 802 debugger().setPauseOnNextStatement(true);
803 } 803 }
804 804
805 void V8DebuggerAgentImpl::cancelPauseOnNextStatement() 805 void V8DebuggerAgentImpl::cancelPauseOnNextStatement()
806 { 806 {
807 if (m_javaScriptPauseScheduled || debugger().isPaused()) 807 if (m_javaScriptPauseScheduled || debugger().isPaused())
808 return; 808 return;
809 clearBreakDetails(); 809 clearBreakDetails();
810 m_pausingOnNativeEvent = false; 810 m_pausingOnNativeEvent = false;
811 debugger().setPauseOnNextStatement(false); 811 debugger().setPauseOnNextStatement(false);
812 } 812 }
813 813
814 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const 814 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const
815 { 815 {
816 return m_maxAsyncCallStackDepth; 816 return m_maxAsyncCallStackDepth;
817 } 817 }
818 818
819 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont ext, const String16& eventType, const String16& eventName, int id) 819 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont ext, const String16& eventType, const String16& eventName, int id)
820 { 820 {
821 ASSERT(m_maxAsyncCallStackDepth); 821 DCHECK(m_maxAsyncCallStackDepth);
822 // The scopes for the ids are defined by the eventName namespaces. There are currently two namespaces: "Object." and "Promise.". 822 // The scopes for the ids are defined by the eventName namespaces. There are currently two namespaces: "Object." and "Promise.".
823 void* ptr = reinterpret_cast<void*>(id * 4 + (eventName[0] == 'P' ? 2 : 0) + 1); 823 void* ptr = reinterpret_cast<void*>(id * 4 + (eventName[0] == 'P' ? 2 : 0) + 1);
824 if (eventType == v8AsyncTaskEventEnqueue) 824 if (eventType == v8AsyncTaskEventEnqueue)
825 asyncTaskScheduled(eventName, ptr, false); 825 asyncTaskScheduled(eventName, ptr, false);
826 else if (eventType == v8AsyncTaskEventWillHandle) 826 else if (eventType == v8AsyncTaskEventWillHandle)
827 asyncTaskStarted(ptr); 827 asyncTaskStarted(ptr);
828 else if (eventType == v8AsyncTaskEventDidHandle) 828 else if (eventType == v8AsyncTaskEventDidHandle)
829 asyncTaskFinished(ptr); 829 asyncTaskFinished(ptr);
830 else 830 else
831 ASSERT_NOT_REACHED(); 831 NOTREACHED();
832 } 832 }
833 833
834 void V8DebuggerAgentImpl::pause(ErrorString* errorString) 834 void V8DebuggerAgentImpl::pause(ErrorString* errorString)
835 { 835 {
836 if (!checkEnabled(errorString)) 836 if (!checkEnabled(errorString))
837 return; 837 return;
838 if (m_javaScriptPauseScheduled || debugger().isPaused()) 838 if (m_javaScriptPauseScheduled || debugger().isPaused())
839 return; 839 return;
840 clearBreakDetails(); 840 clearBreakDetails();
841 m_javaScriptPauseScheduled = true; 841 m_javaScriptPauseScheduled = true;
(...skipping 11 matching lines...) Expand all
853 m_steppingFromFramework = false; 853 m_steppingFromFramework = false;
854 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); 854 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup);
855 debugger().continueProgram(); 855 debugger().continueProgram();
856 } 856 }
857 857
858 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) 858 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString)
859 { 859 {
860 if (!assertPaused(errorString)) 860 if (!assertPaused(errorString))
861 return; 861 return;
862 // StepOver at function return point should fallback to StepInto. 862 // StepOver at function return point should fallback to StepInto.
863 JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[ 0].get() : nullptr; 863 JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[ 0] : nullptr;
864 if (frame && frame->isAtReturn()) { 864 if (frame && frame->isAtReturn()) {
865 stepInto(errorString); 865 stepInto(errorString);
866 return; 866 return;
867 } 867 }
868 m_scheduledDebuggerStep = StepOver; 868 m_scheduledDebuggerStep = StepOver;
869 m_steppingFromFramework = isTopPausedCallFrameBlackboxed(); 869 m_steppingFromFramework = isTopPausedCallFrameBlackboxed();
870 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup); 870 m_session->releaseObjectGroup(V8InspectorSession::backtraceObjectGroup);
871 debugger().stepOverStatement(); 871 debugger().stepOverStatement();
872 } 872 }
873 873
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { 940 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) {
941 *errorString = "Could not find call frame with given id"; 941 *errorString = "Could not find call frame with given id";
942 return; 942 return;
943 } 943 }
944 944
945 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI() ) 945 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI() )
946 return; 946 return;
947 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) 947 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false))
948 scope.ignoreExceptionsAndMuteConsole(); 948 scope.ignoreExceptionsAndMuteConsole();
949 949
950 v8::MaybeLocal<v8::Value> maybeResultValue = m_pausedCallFrames[scope.frameO rdinal()].get()->evaluate(toV8String(m_isolate, expression)); 950 v8::MaybeLocal<v8::Value> maybeResultValue = m_pausedCallFrames[scope.frameO rdinal()]->evaluate(toV8String(m_isolate, expression));
951 951
952 // Re-initialize after running client's code, as it could have destroyed con text or session. 952 // Re-initialize after running client's code, as it could have destroyed con text or session.
953 if (!scope.initialize()) 953 if (!scope.initialize())
954 return; 954 return;
955 scope.injectedScript()->wrapEvaluateResult(errorString, 955 scope.injectedScript()->wrapEvaluateResult(errorString,
956 maybeResultValue, 956 maybeResultValue,
957 scope.tryCatch(), 957 scope.tryCatch(),
958 objectGroup.fromMaybe(""), 958 objectGroup.fromMaybe(""),
959 returnByValue.fromMaybe(false), 959 returnByValue.fromMaybe(false),
960 generatePreview.fromMaybe(false), 960 generatePreview.fromMaybe(false),
(...skipping 17 matching lines...) Expand all
978 return; 978 return;
979 979
980 v8::Local<v8::Value> newValue; 980 v8::Local<v8::Value> newValue;
981 if (!scope.injectedScript()->resolveCallArgument(errorString, newValueArgume nt.get()).ToLocal(&newValue)) 981 if (!scope.injectedScript()->resolveCallArgument(errorString, newValueArgume nt.get()).ToLocal(&newValue))
982 return; 982 return;
983 983
984 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { 984 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) {
985 *errorString = "Could not find call frame with given id"; 985 *errorString = "Could not find call frame with given id";
986 return; 986 return;
987 } 987 }
988 v8::MaybeLocal<v8::Value> result = m_pausedCallFrames[scope.frameOrdinal()]. get()->setVariableValue(scopeNumber, toV8String(m_isolate, variableName), newVal ue); 988 v8::MaybeLocal<v8::Value> result = m_pausedCallFrames[scope.frameOrdinal()]- >setVariableValue(scopeNumber, toV8String(m_isolate, variableName), newValue);
989 if (scope.tryCatch().HasCaught() || result.IsEmpty()) { 989 if (scope.tryCatch().HasCaught() || result.IsEmpty()) {
990 *errorString = "Internal error"; 990 *errorString = "Internal error";
991 return; 991 return;
992 } 992 }
993 } 993 }
994 994
995 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth) 995 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth)
996 { 996 {
997 if (!checkEnabled(errorString)) 997 if (!checkEnabled(errorString))
998 return; 998 return;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 1044
1045 void V8DebuggerAgentImpl::asyncTaskFinished(void* task) 1045 void V8DebuggerAgentImpl::asyncTaskFinished(void* task)
1046 { 1046 {
1047 if (!m_maxAsyncCallStackDepth) 1047 if (!m_maxAsyncCallStackDepth)
1048 return; 1048 return;
1049 // We could start instrumenting half way and the stack is empty. 1049 // We could start instrumenting half way and the stack is empty.
1050 if (!m_currentStacks.size()) 1050 if (!m_currentStacks.size())
1051 return; 1051 return;
1052 1052
1053 #if ENABLE(ASSERT) 1053 #if ENABLE(ASSERT)
1054 ASSERT(m_currentTasks.last() == task); 1054 DCHECK(m_currentTasks.last() == task);
1055 m_currentTasks.removeLast(); 1055 m_currentTasks.removeLast();
1056 #endif 1056 #endif
1057 1057
1058 m_currentStacks.removeLast(); 1058 m_currentStacks.removeLast();
1059 if (!m_recurringTasks.contains(task)) 1059 if (!m_recurringTasks.contains(task))
1060 m_asyncTaskStacks.remove(task); 1060 m_asyncTaskStacks.remove(task);
1061 } 1061 }
1062 1062
1063 void V8DebuggerAgentImpl::allAsyncTasksCanceled() 1063 void V8DebuggerAgentImpl::allAsyncTasksCanceled()
1064 { 1064 {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 // Context has been reported as removed while on pause. 1199 // Context has been reported as removed while on pause.
1200 return Array<CallFrame>::create(); 1200 return Array<CallFrame>::create();
1201 } 1201 }
1202 1202
1203 v8::HandleScope handles(m_isolate); 1203 v8::HandleScope handles(m_isolate);
1204 v8::Local<v8::Context> context = topFrameInjectedScript->context()->context( ); 1204 v8::Local<v8::Context> context = topFrameInjectedScript->context()->context( );
1205 v8::Context::Scope contextScope(context); 1205 v8::Context::Scope contextScope(context);
1206 1206
1207 v8::Local<v8::Array> objects = v8::Array::New(m_isolate); 1207 v8::Local<v8::Array> objects = v8::Array::New(m_isolate);
1208 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++fr ameOrdinal) { 1208 for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++fr ameOrdinal) {
1209 JavaScriptCallFrame* currentCallFrame = m_pausedCallFrames[frameOrdinal] .get(); 1209 JavaScriptCallFrame* currentCallFrame = m_pausedCallFrames[frameOrdinal] ;
1210 1210
1211 v8::Local<v8::Object> details = currentCallFrame->details(); 1211 v8::Local<v8::Object> details = currentCallFrame->details();
1212 if (hasInternalError(errorString, details.IsEmpty())) 1212 if (hasInternalError(errorString, details.IsEmpty()))
1213 return Array<CallFrame>::create(); 1213 return Array<CallFrame>::create();
1214 1214
1215 int contextId = currentCallFrame->contextId(); 1215 int contextId = currentCallFrame->contextId();
1216 InjectedScript* injectedScript = contextId ? m_session->findInjectedScri pt(&ignored, contextId) : nullptr; 1216 InjectedScript* injectedScript = contextId ? m_session->findInjectedScri pt(&ignored, contextId) : nullptr;
1217 if (!injectedScript) 1217 if (!injectedScript)
1218 injectedScript = topFrameInjectedScript; 1218 injectedScript = topFrameInjectedScript;
1219 1219
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentStac ks.size() || !m_currentStacks.last()) 1252 if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentStac ks.size() || !m_currentStacks.last())
1253 return nullptr; 1253 return nullptr;
1254 1254
1255 return m_currentStacks.last()->buildInspectorObjectForTail(this); 1255 return m_currentStacks.last()->buildInspectorObjectForTail(this);
1256 } 1256 }
1257 1257
1258 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain() 1258 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain()
1259 { 1259 {
1260 if (!m_currentStacks.size()) 1260 if (!m_currentStacks.size())
1261 return nullptr; 1261 return nullptr;
1262 return m_currentStacks.last().get(); 1262 return m_currentStacks.last();
1263 } 1263 }
1264 1264
1265 void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr ipt) 1265 void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr ipt)
1266 { 1266 {
1267 V8DebuggerScript script = parsedScript.script; 1267 V8DebuggerScript script = parsedScript.script;
1268 1268
1269 bool isDeprecatedSourceURL = false; 1269 bool isDeprecatedSourceURL = false;
1270 if (!parsedScript.success) 1270 if (!parsedScript.success)
1271 script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL)); 1271 script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL));
1272 else if (script.hasSourceURL()) 1272 else if (script.hasSourceURL())
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition); 1324 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition);
1325 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie .first, parsedScript.scriptId, breakpoint, UserBreakpointSource); 1325 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie .first, parsedScript.scriptId, breakpoint, UserBreakpointSource);
1326 if (location) 1326 if (location)
1327 m_frontend->breakpointResolved(cookie.first, std::move(location)); 1327 m_frontend->breakpointResolved(cookie.first, std::move(location));
1328 } 1328 }
1329 } 1329 }
1330 1330
1331 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const protocol::Vector<Strin g16>& hitBreakpoints, bool isPromiseRejection) 1331 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const protocol::Vector<Strin g16>& hitBreakpoints, bool isPromiseRejection)
1332 { 1332 {
1333 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); 1333 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1);
1334 JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0].ge t() : nullptr; 1334 JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0] : nullptr;
1335 1335
1336 V8DebuggerAgentImpl::SkipPauseRequest result; 1336 V8DebuggerAgentImpl::SkipPauseRequest result;
1337 if (m_skipAllPauses) 1337 if (m_skipAllPauses)
1338 result = RequestContinue; 1338 result = RequestContinue;
1339 else if (!hitBreakpoints.isEmpty()) 1339 else if (!hitBreakpoints.isEmpty())
1340 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i n frameworks. 1340 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i n frameworks.
1341 else if (!exception.IsEmpty()) 1341 else if (!exception.IsEmpty())
1342 result = shouldSkipExceptionPause(topCallFrame); 1342 result = shouldSkipExceptionPause(topCallFrame);
1343 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled || m_pausingOnNativeEvent) 1343 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled || m_pausingOnNativeEvent)
1344 result = shouldSkipStepPause(topCallFrame); 1344 result = shouldSkipStepPause(topCallFrame);
1345 else 1345 else
1346 result = RequestNoSkip; 1346 result = RequestNoSkip;
1347 1347
1348 m_skipNextDebuggerStepOut = false; 1348 m_skipNextDebuggerStepOut = false;
1349 if (result != RequestNoSkip) 1349 if (result != RequestNoSkip)
1350 return result; 1350 return result;
1351 // Skip pauses inside V8 internal scripts and on syntax errors. 1351 // Skip pauses inside V8 internal scripts and on syntax errors.
1352 if (!topCallFrame) 1352 if (!topCallFrame)
1353 return RequestContinue; 1353 return RequestContinue;
1354 1354
1355 ASSERT(m_pausedContext.IsEmpty()); 1355 DCHECK(m_pausedContext.IsEmpty());
1356 m_pausedCallFrames.swap(debugger().currentCallFrames()); 1356 m_pausedCallFrames.swap(debugger().currentCallFrames());
1357 m_pausedContext.Reset(m_isolate, context); 1357 m_pausedContext.Reset(m_isolate, context);
1358 v8::HandleScope handles(m_isolate); 1358 v8::HandleScope handles(m_isolate);
1359 1359
1360 if (!exception.IsEmpty()) { 1360 if (!exception.IsEmpty()) {
1361 ErrorString ignored; 1361 ErrorString ignored;
1362 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(context)); 1362 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(context));
1363 if (injectedScript) { 1363 if (injectedScript) {
1364 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; 1364 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception;
1365 ErrorString errorString; 1365 ErrorString errorString;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 if (!enabled()) 1459 if (!enabled())
1460 return; 1460 return;
1461 m_scheduledDebuggerStep = NoStep; 1461 m_scheduledDebuggerStep = NoStep;
1462 m_scripts.clear(); 1462 m_scripts.clear();
1463 m_blackboxedPositions.clear(); 1463 m_blackboxedPositions.clear();
1464 m_breakpointIdToDebuggerBreakpointIds.clear(); 1464 m_breakpointIdToDebuggerBreakpointIds.clear();
1465 allAsyncTasksCanceled(); 1465 allAsyncTasksCanceled();
1466 } 1466 }
1467 1467
1468 } // namespace blink 1468 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698