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

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

Issue 1838683002: [DevTools] Debugger::currentCallFrames returns array instead linked list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wrap-with-corrrect-injected-script
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/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/IgnoreExceptionsScope.h" 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h"
10 #include "platform/v8_inspector/InjectedScript.h" 10 #include "platform/v8_inspector/InjectedScript.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 { 236 {
237 if (!enabled()) 237 if (!enabled())
238 return; 238 return;
239 239
240 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict ionaryValue::create()); 240 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict ionaryValue::create());
241 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp l::DontPauseOnExceptions); 241 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp l::DontPauseOnExceptions);
242 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, 0); 242 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, 0);
243 243
244 debugger().removeDebuggerAgent(m_contextGroupId); 244 debugger().removeDebuggerAgent(m_contextGroupId);
245 m_pausedContext.Reset(); 245 m_pausedContext.Reset();
246 m_currentCallStack.clear(); 246 Vector<OwnPtr<JavaScriptCallFrame>> emptyCallFrames;
247 m_currentCallFrames.swap(emptyCallFrames);
247 m_scripts.clear(); 248 m_scripts.clear();
248 m_blackboxedPositions.clear(); 249 m_blackboxedPositions.clear();
249 m_breakpointIdToDebuggerBreakpointIds.clear(); 250 m_breakpointIdToDebuggerBreakpointIds.clear();
250 internalSetAsyncCallStackDepth(0); 251 internalSetAsyncCallStackDepth(0);
251 m_continueToLocationBreakpointId = String16(); 252 m_continueToLocationBreakpointId = String16();
252 clearBreakDetails(); 253 clearBreakDetails();
253 m_scheduledDebuggerStep = NoStep; 254 m_scheduledDebuggerStep = NoStep;
254 m_skipNextDebuggerStepOut = false; 255 m_skipNextDebuggerStepOut = false;
255 m_javaScriptPauseScheduled = false; 256 m_javaScriptPauseScheduled = false;
256 m_steppingFromFramework = false; 257 m_steppingFromFramework = false;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 478
478 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); 479 ScriptBreakpoint breakpoint(lineNumber, columnNumber, "");
479 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); 480 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false));
480 resume(errorString); 481 resume(errorString);
481 } 482 }
482 483
483 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, OwnPtr<Array<Ca llFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace) 484 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, OwnPtr<Array<Ca llFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace)
484 { 485 {
485 if (!assertPaused(errorString)) 486 if (!assertPaused(errorString))
486 return; 487 return;
487 m_currentCallStack = debugger().currentCallFrames(); 488 m_currentCallFrames = debugger().currentCallFrames();
dgozman 2016/03/26 00:49:20 m_pausedCallFrames
kozy 2016/03/26 01:11:17 Done.
488 *callFrames = currentCallFrames(errorString); 489 *callFrames = currentCallFrames(errorString);
489 if (!*callFrames) 490 if (!*callFrames)
490 return; 491 return;
491 *asyncStackTrace = currentAsyncStackTrace(); 492 *asyncStackTrace = currentAsyncStackTrace();
492 } 493 }
493 494
494 bool V8DebuggerAgentImpl::isCallStackEmptyOrBlackboxed() 495 bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed()
495 { 496 {
496 ASSERT(enabled()); 497 ASSERT(enabled());
497 for (int index = 0; ; ++index) { 498 Vector<OwnPtr<JavaScriptCallFrame>> callFrames = debugger().currentCallFrame s();
498 OwnPtr<JavaScriptCallFrame> frame = debugger().callFrame(index); 499 for (size_t index = 0; index < callFrames.size(); ++index) {
499 if (!frame) 500 if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get()))
500 break;
501 if (!isCallFrameWithUnknownScriptOrBlackboxed(frame.get()))
502 return false; 501 return false;
503 } 502 }
504 return true; 503 return true;
505 } 504 }
506 505
507 bool V8DebuggerAgentImpl::isTopCallFrameBlackboxed() 506 bool V8DebuggerAgentImpl::isTopCallFrameBlackboxed()
dgozman 2016/03/26 00:49:21 isTopPausedFrameBlackboxed
kozy 2016/03/26 01:11:17 Done.
508 { 507 {
509 ASSERT(enabled()); 508 ASSERT(enabled());
510 return isCallFrameWithUnknownScriptOrBlackboxed(debugger().callFrame(0).get( )); 509 if (!m_currentCallFrames.size())
510 return true;
511 return isCallFrameWithUnknownScriptOrBlackboxed(m_currentCallFrames[0].get() );
511 } 512 }
512 513
513 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame) 514 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame)
514 { 515 {
515 if (!frame) 516 if (!frame)
516 return true; 517 return true;
517 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID()) ); 518 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID()) );
518 if (it == m_scripts.end()) { 519 if (it == m_scripts.end()) {
519 // Unknown scripts are blackboxed. 520 // Unknown scripts are blackboxed.
520 return true; 521 return true;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 const String16& scriptId, 610 const String16& scriptId,
610 const String16& newContent, 611 const String16& newContent,
611 const Maybe<bool>& preview, 612 const Maybe<bool>& preview,
612 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, 613 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
613 Maybe<bool>* stackChanged, 614 Maybe<bool>* stackChanged,
614 Maybe<StackTrace>* asyncStackTrace, 615 Maybe<StackTrace>* asyncStackTrace,
615 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) 616 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError)
616 { 617 {
617 if (!checkEnabled(errorString)) 618 if (!checkEnabled(errorString))
618 return; 619 return;
619 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals e), errorString, optOutCompileError, &m_currentCallStack, stackChanged)) 620 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals e), errorString, optOutCompileError, &m_currentCallFrames, stackChanged))
620 return; 621 return;
621 622
622 OwnPtr<Array<CallFrame>> callFrames = currentCallFrames(errorString); 623 OwnPtr<Array<CallFrame>> callFrames = currentCallFrames(errorString);
623 if (!callFrames) 624 if (!callFrames)
624 return; 625 return;
625 *newCallFrames = callFrames.release(); 626 *newCallFrames = callFrames.release();
626 *asyncStackTrace = currentAsyncStackTrace(); 627 *asyncStackTrace = currentAsyncStackTrace();
627 628
628 ScriptsMap::iterator it = m_scripts.find(scriptId); 629 ScriptsMap::iterator it = m_scripts.find(scriptId);
629 if (it == m_scripts.end()) 630 if (it == m_scripts.end())
630 return; 631 return;
631 it->second->setSource(newContent); 632 it->second->setSource(newContent);
632 } 633 }
633 634
634 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, 635 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString,
635 const String16& callFrameId, 636 const String16& callFrameId,
636 OwnPtr<Array<CallFrame>>* newCallFrames, 637 OwnPtr<Array<CallFrame>>* newCallFrames,
637 Maybe<StackTrace>* asyncStackTrace) 638 Maybe<StackTrace>* asyncStackTrace)
638 { 639 {
639 if (!isPaused() || !m_currentCallStack) { 640 if (!assertPaused(errorString))
640 *errorString = "Attempt to access call frame when debugger is not on pau se";
641 return; 641 return;
642 }
643 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId); 642 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId);
644 if (!remoteId) 643 if (!remoteId)
645 return; 644 return;
646 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 645 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
647 if (!injectedScript) 646 if (!injectedScript)
648 return; 647 return;
649 648
650 v8::HandleScope scope(m_isolate); 649 v8::HandleScope scope(m_isolate);
651 v8::Local<v8::Context> localContext = injectedScript->context(); 650 v8::Local<v8::Context> localContext = injectedScript->context();
652 651
653 v8::TryCatch tryCatch(m_isolate); 652 v8::TryCatch tryCatch(m_isolate);
654 653
655 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrame(remot eId->frameOrdinal()); 654 size_t frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
656 if (!javaScriptCallFrame) { 655 if (frameOrdinal >= m_currentCallFrames.size()) {
657 *errorString = "Could not find call frame with given id"; 656 *errorString = "Could not find call frame with given id";
658 return; 657 return;
659 } 658 }
660 v8::Local<v8::Value> resultValue; 659 v8::Local<v8::Value> resultValue;
661 v8::Local<v8::Boolean> result; 660 v8::Local<v8::Boolean> result;
662 if (!javaScriptCallFrame->restart().ToLocal(&resultValue) || tryCatch.HasCau ght() || !resultValue->ToBoolean(localContext).ToLocal(&result) || !result->Valu e()) { 661 if (!m_currentCallFrames[frameOrdinal].get()->restart().ToLocal(&resultValue ) || tryCatch.HasCaught() || !resultValue->ToBoolean(localContext).ToLocal(&resu lt) || !result->Value()) {
663 *errorString = "Internal error"; 662 *errorString = "Internal error";
664 return; 663 return;
665 } 664 }
666 665
667 m_currentCallStack = debugger().currentCallFrames(); 666 m_currentCallFrames = debugger().currentCallFrames();
668 667
669 *newCallFrames = currentCallFrames(errorString); 668 *newCallFrames = currentCallFrames(errorString);
670 if (!*newCallFrames) 669 if (!*newCallFrames)
671 return; 670 return;
672 *asyncStackTrace = currentAsyncStackTrace(); 671 *asyncStackTrace = currentAsyncStackTrace();
673 } 672 }
674 673
675 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc riptId, String16* scriptSource) 674 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc riptId, String16* scriptSource)
676 { 675 {
677 if (!checkEnabled(error)) 676 if (!checkEnabled(error))
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 m_steppingFromFramework = false; 884 m_steppingFromFramework = false;
886 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb jectGroup); 885 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb jectGroup);
887 debugger().continueProgram(); 886 debugger().continueProgram();
888 } 887 }
889 888
890 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) 889 void V8DebuggerAgentImpl::stepOver(ErrorString* errorString)
891 { 890 {
892 if (!assertPaused(errorString)) 891 if (!assertPaused(errorString))
893 return; 892 return;
894 // StepOver at function return point should fallback to StepInto. 893 // StepOver at function return point should fallback to StepInto.
895 OwnPtr<JavaScriptCallFrame> frame = debugger().callFrame(0); 894 JavaScriptCallFrame* frame = m_currentCallFrames.size() ? m_currentCallFrame s[0].get() : nullptr;
896 if (frame && frame->isAtReturn()) { 895 if (frame && frame->isAtReturn()) {
897 stepInto(errorString); 896 stepInto(errorString);
898 return; 897 return;
899 } 898 }
900 m_scheduledDebuggerStep = StepOver; 899 m_scheduledDebuggerStep = StepOver;
901 m_steppingFromFramework = isTopCallFrameBlackboxed(); 900 m_steppingFromFramework = isTopCallFrameBlackboxed();
902 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb jectGroup); 901 m_injectedScriptManager->releaseObjectGroup(V8DebuggerAgentImpl::backtraceOb jectGroup);
903 debugger().stepOverStatement(); 902 debugger().stepOverStatement();
904 } 903 }
905 904
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 const String16& expression, 969 const String16& expression,
971 const Maybe<String16>& objectGroup, 970 const Maybe<String16>& objectGroup,
972 const Maybe<bool>& includeCommandLineAPI, 971 const Maybe<bool>& includeCommandLineAPI,
973 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, 972 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole,
974 const Maybe<bool>& returnByValue, 973 const Maybe<bool>& returnByValue,
975 const Maybe<bool>& generatePreview, 974 const Maybe<bool>& generatePreview,
976 OwnPtr<RemoteObject>* result, 975 OwnPtr<RemoteObject>* result,
977 Maybe<bool>* wasThrown, 976 Maybe<bool>* wasThrown,
978 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) 977 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
979 { 978 {
980 if (!isPaused() || !m_currentCallStack) { 979 if (!assertPaused(errorString))
981 *errorString = "Attempt to access callframe when debugger is not on paus e";
982 return; 980 return;
983 }
984 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId); 981 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId);
985 if (!remoteId) 982 if (!remoteId)
986 return; 983 return;
987 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 984 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
988 if (!injectedScript) 985 if (!injectedScript)
989 return; 986 return;
990 987
991 v8::HandleScope scope(injectedScript->isolate()); 988 v8::HandleScope scope(injectedScript->isolate());
992 989
993 if (!injectedScript->canAccessInspectedWindow()) { 990 if (!injectedScript->canAccessInspectedWindow()) {
994 *errorString = "Can not access given context"; 991 *errorString = "Can not access given context";
995 return; 992 return;
996 } 993 }
997 994
998 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrame(remot eId->frameOrdinal()); 995 size_t frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
999 if (!javaScriptCallFrame) { 996 if (frameOrdinal >= m_currentCallFrames.size()) {
1000 *errorString = "Could not find call frame with given id"; 997 *errorString = "Could not find call frame with given id";
1001 return; 998 return;
1002 } 999 }
1003 1000
1004 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe( false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object >(); 1001 v8::MaybeLocal<v8::Object> commandLineAPI = includeCommandLineAPI.fromMaybe( false) ? injectedScript->commandLineAPI(errorString) : v8::MaybeLocal<v8::Object >();
1005 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty()) 1002 if (includeCommandLineAPI.fromMaybe(false) && commandLineAPI.IsEmpty())
1006 return; 1003 return;
1007 1004
1008 InjectedScript::ScopedGlobalObjectExtension scopeExtension(injectedScript, c ommandLineAPI); 1005 InjectedScript::ScopedGlobalObjectExtension scopeExtension(injectedScript, c ommandLineAPI);
1009 1006
1010 v8::TryCatch tryCatch(injectedScript->isolate()); 1007 v8::TryCatch tryCatch(injectedScript->isolate());
1011 1008
1012 v8::MaybeLocal<v8::Value> maybeResultValue = javaScriptCallFrame->evaluate(t oV8String(injectedScript->isolate(), expression)); 1009 v8::MaybeLocal<v8::Value> maybeResultValue = m_currentCallFrames[frameOrdina l].get()->evaluate(toV8String(injectedScript->isolate(), expression));
1013 1010
1014 // InjectedScript may be gone after any evaluate call - find it again. 1011 // InjectedScript may be gone after any evaluate call - find it again.
1015 injectedScript = m_injectedScriptManager->findInjectedScript(errorString, re moteId.get()); 1012 injectedScript = m_injectedScriptManager->findInjectedScript(errorString, re moteId.get());
1016 if (!injectedScript) 1013 if (!injectedScript)
1017 return; 1014 return;
1018 1015
1019 injectedScript->wrapEvaluateResult(errorString, 1016 injectedScript->wrapEvaluateResult(errorString,
1020 maybeResultValue, 1017 maybeResultValue,
1021 tryCatch, 1018 tryCatch,
1022 objectGroup.fromMaybe(""), 1019 objectGroup.fromMaybe(""),
1023 returnByValue.fromMaybe(false), 1020 returnByValue.fromMaybe(false),
1024 generatePreview.fromMaybe(false), 1021 generatePreview.fromMaybe(false),
1025 result, 1022 result,
1026 wasThrown, 1023 wasThrown,
1027 exceptionDetails); 1024 exceptionDetails);
1028 } 1025 }
1029 1026
1030 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, 1027 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString,
1031 int scopeNumber, 1028 int scopeNumber,
1032 const String16& variableName, 1029 const String16& variableName,
1033 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, 1030 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument,
1034 const String16& callFrameId) 1031 const String16& callFrameId)
1035 { 1032 {
1036 if (!checkEnabled(errorString)) 1033 if (!checkEnabled(errorString))
1037 return; 1034 return;
1038 if (!isPaused() || !m_currentCallStack) { 1035 if (!assertPaused(errorString))
1039 *errorString = "Attempt to access callframe when debugger is not on paus e";
1040 return; 1036 return;
1041 }
1042 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId); 1037 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c allFrameId);
1043 if (!remoteId) 1038 if (!remoteId)
1044 return; 1039 return;
1045 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 1040 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
1046 if (!injectedScript) 1041 if (!injectedScript)
1047 return; 1042 return;
1048 1043
1049 v8::HandleScope scope(m_isolate); 1044 v8::HandleScope scope(m_isolate);
1050 v8::TryCatch tryCatch(m_isolate); 1045 v8::TryCatch tryCatch(m_isolate);
1051 1046
1052 v8::Local<v8::Value> newValue; 1047 v8::Local<v8::Value> newValue;
1053 if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get() ).ToLocal(&newValue)) 1048 if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get() ).ToLocal(&newValue))
1054 return; 1049 return;
1055 1050
1056 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrame(remot eId->frameOrdinal()); 1051 size_t frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
1057 if (!javaScriptCallFrame) { 1052 if (frameOrdinal >= m_currentCallFrames.size()) {
1058 *errorString = "Could not find call frame with given id"; 1053 *errorString = "Could not find call frame with given id";
1059 return; 1054 return;
1060 } 1055 }
1061 v8::MaybeLocal<v8::Value> result = javaScriptCallFrame->setVariableValue(sco peNumber, toV8String(m_isolate, variableName), newValue); 1056 v8::MaybeLocal<v8::Value> result = m_currentCallFrames[frameOrdinal].get()-> setVariableValue(scopeNumber, toV8String(m_isolate, variableName), newValue);
1062 if (tryCatch.HasCaught() || result.IsEmpty()) { 1057 if (tryCatch.HasCaught() || result.IsEmpty()) {
1063 *errorString = "Internal error"; 1058 *errorString = "Internal error";
1064 return; 1059 return;
1065 } 1060 }
1066 } 1061 }
1067 1062
1068 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth) 1063 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth)
1069 { 1064 {
1070 if (!checkEnabled(errorString)) 1065 if (!checkEnabled(errorString))
1071 return; 1066 return;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 if (m_scheduledDebuggerStep == NoStep) 1339 if (m_scheduledDebuggerStep == NoStep)
1345 debugger().clearStepping(); 1340 debugger().clearStepping();
1346 else if (m_scheduledDebuggerStep == StepOut) 1341 else if (m_scheduledDebuggerStep == StepOut)
1347 m_skipNextDebuggerStepOut = true; 1342 m_skipNextDebuggerStepOut = true;
1348 } 1343 }
1349 } 1344 }
1350 } 1345 }
1351 1346
1352 PassOwnPtr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorString* errorString) 1347 PassOwnPtr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorString* errorString)
1353 { 1348 {
1354 if (m_pausedContext.IsEmpty() || !m_currentCallStack) 1349 if (m_pausedContext.IsEmpty() || !m_currentCallFrames.size())
1355 return Array<CallFrame>::create(); 1350 return Array<CallFrame>::create();
1356 InjectedScript* topFrameInjectedScript = m_injectedScriptManager->injectedSc riptFor(m_pausedContext.Get(m_isolate)); 1351 InjectedScript* topFrameInjectedScript = m_injectedScriptManager->injectedSc riptFor(m_pausedContext.Get(m_isolate));
1357 if (!topFrameInjectedScript) { 1352 if (!topFrameInjectedScript) {
1358 // Context has been reported as removed while on pause. 1353 // Context has been reported as removed while on pause.
1359 return Array<CallFrame>::create(); 1354 return Array<CallFrame>::create();
1360 } 1355 }
1361 1356
1362 v8::Isolate* isolate = topFrameInjectedScript->isolate(); 1357 v8::Isolate* isolate = topFrameInjectedScript->isolate();
1363 v8::HandleScope handles(isolate); 1358 v8::HandleScope handles(isolate);
1364 v8::Local<v8::Context> context = topFrameInjectedScript->context(); 1359 v8::Local<v8::Context> context = topFrameInjectedScript->context();
1365 v8::Context::Scope contextScope(context); 1360 v8::Context::Scope contextScope(context);
1366 1361
1367 JavaScriptCallFrame* currentCallFrame = m_currentCallStack.get();
1368 int callFrameIndex = 0;
1369 OwnPtr<JavaScriptCallFrame> currentCallFrameOwner;
1370 v8::Local<v8::Array> objects = v8::Array::New(isolate); 1362 v8::Local<v8::Array> objects = v8::Array::New(isolate);
1371 while (currentCallFrame) { 1363 for (size_t i = 0; i < m_currentCallFrames.size(); ++i) {
1364 JavaScriptCallFrame* currentCallFrame = m_currentCallFrames[i].get();
1365
1372 v8::Local<v8::Object> details = currentCallFrame->details(); 1366 v8::Local<v8::Object> details = currentCallFrame->details();
1373 if (hasInternalError(errorString, details.IsEmpty())) 1367 if (hasInternalError(errorString, details.IsEmpty()))
1374 return Array<CallFrame>::create(); 1368 return Array<CallFrame>::create();
1375 1369
1376 int contextId = currentCallFrame->contextId(); 1370 int contextId = currentCallFrame->contextId();
1377 InjectedScript* injectedScript = contextId ? m_injectedScriptManager->fi ndInjectedScript(errorString, contextId) : nullptr; 1371 InjectedScript* injectedScript = contextId ? m_injectedScriptManager->fi ndInjectedScript(errorString, contextId) : nullptr;
1378 if (!injectedScript) { 1372 if (!injectedScript) {
1379 *errorString = ""; 1373 *errorString = "";
1380 injectedScript = topFrameInjectedScript; 1374 injectedScript = topFrameInjectedScript;
1381 } 1375 }
1382 1376
1383 String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->cont extId(), callFrameIndex); 1377 String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->cont extId(), i);
1384 if (hasInternalError(errorString, !details->Set(context, toV8StringInter nalized(isolate, "callFrameId"), toV8String(isolate, callFrameId)).FromMaybe(fal se))) 1378 if (hasInternalError(errorString, !details->Set(context, toV8StringInter nalized(isolate, "callFrameId"), toV8String(isolate, callFrameId)).FromMaybe(fal se)))
1385 return Array<CallFrame>::create(); 1379 return Array<CallFrame>::create();
1386 1380
1387 v8::Local<v8::Value> scopeChain; 1381 v8::Local<v8::Value> scopeChain;
1388 if (hasInternalError(errorString, !details->Get(context, toV8StringInter nalized(isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray())) 1382 if (hasInternalError(errorString, !details->Get(context, toV8StringInter nalized(isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray()))
1389 return Array<CallFrame>::create(); 1383 return Array<CallFrame>::create();
1390 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>(); 1384 v8::Local<v8::Array> scopeChainArray = scopeChain.As<v8::Array>();
1391 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, t oV8StringInternalized(isolate, "object"), V8DebuggerAgentImpl::backtraceObjectGr oup)) 1385 if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, t oV8StringInternalized(isolate, "object"), V8DebuggerAgentImpl::backtraceObjectGr oup))
1392 return Array<CallFrame>::create(); 1386 return Array<CallFrame>::create();
1393 1387
1394 if (!injectedScript->wrapObjectProperty(errorString, details, toV8String Internalized(isolate, "this"), V8DebuggerAgentImpl::backtraceObjectGroup)) 1388 if (!injectedScript->wrapObjectProperty(errorString, details, toV8String Internalized(isolate, "this"), V8DebuggerAgentImpl::backtraceObjectGroup))
1395 return Array<CallFrame>::create(); 1389 return Array<CallFrame>::create();
1396 1390
1397 if (details->Has(context, toV8StringInternalized(isolate, "returnValue") ).FromMaybe(false)) { 1391 if (details->Has(context, toV8StringInternalized(isolate, "returnValue") ).FromMaybe(false)) {
1398 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(isolate, "returnValue"), V8DebuggerAgentImpl::backtraceObjectGr oup)) 1392 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(isolate, "returnValue"), V8DebuggerAgentImpl::backtraceObjectGr oup))
1399 return Array<CallFrame>::create(); 1393 return Array<CallFrame>::create();
1400 } 1394 }
1401 1395
1402 if (hasInternalError(errorString, !objects->Set(context, callFrameIndex, details).FromMaybe(false))) 1396 if (hasInternalError(errorString, !objects->Set(context, i, details).Fro mMaybe(false)))
1403 return Array<CallFrame>::create(); 1397 return Array<CallFrame>::create();
1404
1405 currentCallFrameOwner = currentCallFrame->caller();
1406 currentCallFrame = currentCallFrameOwner.get();
1407 ++callFrameIndex;
1408 } 1398 }
1409 1399
1410 protocol::ErrorSupport errorSupport; 1400 protocol::ErrorSupport errorSupport;
1411 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu e(context, objects).get(), &errorSupport); 1401 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu e(context, objects).get(), &errorSupport);
1412 if (hasInternalError(errorString, !callFrames)) 1402 if (hasInternalError(errorString, !callFrames))
1413 return Array<CallFrame>::create(); 1403 return Array<CallFrame>::create();
1414 return callFrames.release(); 1404 return callFrames.release();
1415 } 1405 }
1416 1406
1417 PassOwnPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() 1407 PassOwnPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace()
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 ScriptBreakpoint breakpoint; 1476 ScriptBreakpoint breakpoint;
1487 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber); 1477 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber);
1488 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber); 1478 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber);
1489 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition); 1479 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition);
1490 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie .first, parsedScript.scriptId, breakpoint, UserBreakpointSource); 1480 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie .first, parsedScript.scriptId, breakpoint, UserBreakpointSource);
1491 if (location) 1481 if (location)
1492 m_frontend->breakpointResolved(cookie.first, location.release()); 1482 m_frontend->breakpointResolved(cookie.first, location.release());
1493 } 1483 }
1494 } 1484 }
1495 1485
1496 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, PassOwnPtr<JavaScriptCallFrame> callFrames, v8::Local<v8::Va lue> exception, const protocol::Vector<String16>& hitBreakpoints, bool isPromise Rejection) 1486 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, Vector<OwnPtr<JavaScriptCallFrame>> callFrames, v8::Local<v8 ::Value> exception, const protocol::Vector<String16>& hitBreakpoints, bool isPro miseRejection)
1497 { 1487 {
1488 // Skip pauses inside V8 internal scripts and on syntax errors.
1489 if (!callFrames.size())
1490 return RequestContinue;
dgozman 2016/03/26 00:49:20 This is a semantic change.
kozy 2016/03/26 01:11:17 Reverted.
1491 m_currentCallFrames.swap(callFrames);
1492
1498 V8DebuggerAgentImpl::SkipPauseRequest result; 1493 V8DebuggerAgentImpl::SkipPauseRequest result;
1499 if (m_skipAllPauses) 1494 if (m_skipAllPauses)
1500 result = RequestContinue; 1495 result = RequestContinue;
1501 else if (!hitBreakpoints.isEmpty()) 1496 else if (!hitBreakpoints.isEmpty())
1502 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i n frameworks. 1497 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i n frameworks.
1503 else if (!exception.IsEmpty()) 1498 else if (!exception.IsEmpty())
1504 result = shouldSkipExceptionPause(); 1499 result = shouldSkipExceptionPause();
1505 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled || m_pausingOnNativeEvent) 1500 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled || m_pausingOnNativeEvent)
1506 result = shouldSkipStepPause(); 1501 result = shouldSkipStepPause();
1507 else 1502 else
1508 result = RequestNoSkip; 1503 result = RequestNoSkip;
1509 1504
1510 m_skipNextDebuggerStepOut = false; 1505 m_skipNextDebuggerStepOut = false;
1511 if (result != RequestNoSkip) 1506 if (result != RequestNoSkip) {
1507 Vector<OwnPtr<JavaScriptCallFrame>> callFrames;
1508 m_currentCallFrames.swap(callFrames);
1512 return result; 1509 return result;
1513 1510 }
1514 // Skip pauses inside V8 internal scripts and on syntax errors.
1515 if (!callFrames)
1516 return RequestContinue;
1517 1511
1518 ASSERT(m_pausedContext.IsEmpty()); 1512 ASSERT(m_pausedContext.IsEmpty());
1519 m_pausedContext.Reset(m_isolate, context); 1513 m_pausedContext.Reset(m_isolate, context);
1520 m_currentCallStack = callFrames;
1521 v8::HandleScope handles(m_isolate); 1514 v8::HandleScope handles(m_isolate);
1522 1515
1523 if (!exception.IsEmpty()) { 1516 if (!exception.IsEmpty()) {
1524 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context); 1517 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context);
1525 if (injectedScript) { 1518 if (injectedScript) {
1526 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; 1519 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception;
1527 ErrorString errorString; 1520 ErrorString errorString;
1528 auto obj = injectedScript->wrapObject(&errorString, exception, V8Deb uggerAgentImpl::backtraceObjectGroup); 1521 auto obj = injectedScript->wrapObject(&errorString, exception, V8Deb uggerAgentImpl::backtraceObjectGroup);
1529 m_breakAuxData = obj ? obj->serialize() : nullptr; 1522 m_breakAuxData = obj ? obj->serialize() : nullptr;
1530 // m_breakAuxData might be null after this. 1523 // m_breakAuxData might be null after this.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 if (!m_continueToLocationBreakpointId.isEmpty()) { 1558 if (!m_continueToLocationBreakpointId.isEmpty()) {
1566 debugger().removeBreakpoint(m_continueToLocationBreakpointId); 1559 debugger().removeBreakpoint(m_continueToLocationBreakpointId);
1567 m_continueToLocationBreakpointId = ""; 1560 m_continueToLocationBreakpointId = "";
1568 } 1561 }
1569 return result; 1562 return result;
1570 } 1563 }
1571 1564
1572 void V8DebuggerAgentImpl::didContinue() 1565 void V8DebuggerAgentImpl::didContinue()
1573 { 1566 {
1574 m_pausedContext.Reset(); 1567 m_pausedContext.Reset();
1575 m_currentCallStack.clear(); 1568 Vector<OwnPtr<JavaScriptCallFrame>> emptyCallFrames;
1569 m_currentCallFrames.swap(emptyCallFrames);
1576 clearBreakDetails(); 1570 clearBreakDetails();
1577 m_frontend->resumed(); 1571 m_frontend->resumed();
1578 } 1572 }
1579 1573
1580 bool V8DebuggerAgentImpl::canBreakProgram() 1574 bool V8DebuggerAgentImpl::canBreakProgram()
1581 { 1575 {
1582 return debugger().canBreakProgram(); 1576 return debugger().canBreakProgram();
1583 } 1577 }
1584 1578
1585 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, PassOwnPtr<p rotocol::DictionaryValue> data) 1579 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, PassOwnPtr<p rotocol::DictionaryValue> data)
1586 { 1580 {
1587 ASSERT(enabled()); 1581 ASSERT(enabled());
1588 if (m_skipAllPauses || !m_pausedContext.IsEmpty() || isCallStackEmptyOrBlack boxed() || !debugger().breakpointsActivated()) 1582 if (m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrentCallStackEmpty OrBlackboxed() || !debugger().breakpointsActivated())
1589 return; 1583 return;
1590 m_breakReason = breakReason; 1584 m_breakReason = breakReason;
1591 m_breakAuxData = data; 1585 m_breakAuxData = data;
1592 m_scheduledDebuggerStep = NoStep; 1586 m_scheduledDebuggerStep = NoStep;
1593 m_steppingFromFramework = false; 1587 m_steppingFromFramework = false;
1594 m_pausingOnNativeEvent = false; 1588 m_pausingOnNativeEvent = false;
1595 clearStepIntoAsync(); 1589 clearStepIntoAsync();
1596 debugger().breakProgram(); 1590 debugger().breakProgram();
1597 } 1591 }
1598 1592
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 if (!enabled()) 1636 if (!enabled())
1643 return; 1637 return;
1644 m_scheduledDebuggerStep = NoStep; 1638 m_scheduledDebuggerStep = NoStep;
1645 m_scripts.clear(); 1639 m_scripts.clear();
1646 m_blackboxedPositions.clear(); 1640 m_blackboxedPositions.clear();
1647 m_breakpointIdToDebuggerBreakpointIds.clear(); 1641 m_breakpointIdToDebuggerBreakpointIds.clear();
1648 resetAsyncCallTracker(); 1642 resetAsyncCallTracker();
1649 } 1643 }
1650 1644
1651 } // namespace blink 1645 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698