| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 return; | 636 return; |
| 637 } | 637 } |
| 638 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c
allFrameId); | 638 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c
allFrameId); |
| 639 if (!remoteId) | 639 if (!remoteId) |
| 640 return; | 640 return; |
| 641 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); | 641 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); |
| 642 if (!injectedScript) | 642 if (!injectedScript) |
| 643 return; | 643 return; |
| 644 | 644 |
| 645 v8::HandleScope scope(m_isolate); | 645 v8::HandleScope scope(m_isolate); |
| 646 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); | 646 v8::Local<v8::Context> localContext = injectedScript->context(); |
| 647 injectedScript->restartFrame(errorString, callStack, callFrameId); | 647 |
| 648 v8::TryCatch tryCatch(m_isolate); |
| 649 |
| 650 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop
es(remoteId->frameOrdinal()); |
| 651 if (!javaScriptCallFrame) { |
| 652 *errorString = "Could not find call frame with given id"; |
| 653 return; |
| 654 } |
| 655 v8::Local<v8::Value> resultValue; |
| 656 v8::Local<v8::Boolean> result; |
| 657 if (!javaScriptCallFrame->restart().ToLocal(&resultValue) || tryCatch.HasCau
ght() || !resultValue->ToBoolean(localContext).ToLocal(&result) || !result->Valu
e()) { |
| 658 *errorString = "Internal error"; |
| 659 return; |
| 660 } |
| 661 |
| 648 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); | 662 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); |
| 663 |
| 649 *newCallFrames = currentCallFrames(); | 664 *newCallFrames = currentCallFrames(); |
| 650 *asyncStackTrace = currentAsyncStackTrace(); | 665 *asyncStackTrace = currentAsyncStackTrace(); |
| 651 } | 666 } |
| 652 | 667 |
| 653 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
riptId, String16* scriptSource) | 668 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
riptId, String16* scriptSource) |
| 654 { | 669 { |
| 655 if (!checkEnabled(error)) | 670 if (!checkEnabled(error)) |
| 656 return; | 671 return; |
| 657 ScriptsMap::iterator it = m_scripts.find(scriptId); | 672 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 658 if (it == m_scripts.end()) { | 673 if (it == m_scripts.end()) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 v8::HandleScope scope(m_isolate); | 929 v8::HandleScope scope(m_isolate); |
| 915 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); | 930 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); |
| 916 | 931 |
| 917 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon
sole.fromMaybe(false) ? m_debugger : nullptr); | 932 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon
sole.fromMaybe(false) ? m_debugger : nullptr); |
| 918 injectedScript->evaluateOnCallFrame(errorString, callStack, callFrameId, exp
ression, objectGroup.fromMaybe(""), includeCommandLineAPI.fromMaybe(false), retu
rnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, wasThrown,
exceptionDetails); | 933 injectedScript->evaluateOnCallFrame(errorString, callStack, callFrameId, exp
ression, objectGroup.fromMaybe(""), includeCommandLineAPI.fromMaybe(false), retu
rnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, wasThrown,
exceptionDetails); |
| 919 } | 934 } |
| 920 | 935 |
| 921 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, | 936 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, |
| 922 int scopeNumber, | 937 int scopeNumber, |
| 923 const String16& variableName, | 938 const String16& variableName, |
| 924 PassOwnPtr<protocol::Runtime::CallArgument> newValue, | 939 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, |
| 925 const Maybe<String16>& callFrameId, | 940 const String16& callFrameId) |
| 926 const Maybe<String16>& functionObjectId) | |
| 927 { | 941 { |
| 928 if (!checkEnabled(errorString)) | 942 if (!checkEnabled(errorString)) |
| 929 return; | 943 return; |
| 930 InjectedScript* injectedScript = nullptr; | 944 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
| 931 if (callFrameId.isJust()) { | 945 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
| 932 if (!isPaused() || m_currentCallStack.IsEmpty()) { | |
| 933 *errorString = "Attempt to access callframe when debugger is not on
pause"; | |
| 934 return; | |
| 935 } | |
| 936 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorStrin
g, callFrameId.fromJust()); | |
| 937 if (!remoteId) | |
| 938 return; | |
| 939 injectedScript = m_injectedScriptManager->findInjectedScript(errorString
, remoteId.get()); | |
| 940 if (!injectedScript) | |
| 941 return; | |
| 942 } else if (functionObjectId.isJust()) { | |
| 943 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, fun
ctionObjectId.fromJust()); | |
| 944 if (!remoteId) | |
| 945 return; | |
| 946 injectedScript = m_injectedScriptManager->findInjectedScript(errorString
, remoteId.get()); | |
| 947 if (!injectedScript) | |
| 948 return; | |
| 949 } else { | |
| 950 *errorString = "Either call frame or function object must be specified"; | |
| 951 return; | 946 return; |
| 952 } | 947 } |
| 953 String16 newValueString = protocol::toValue(newValue.get())->toJSONString(); | 948 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(errorString, c
allFrameId); |
| 949 if (!remoteId) |
| 950 return; |
| 951 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); |
| 952 if (!injectedScript) |
| 953 return; |
| 954 |
| 954 v8::HandleScope scope(m_isolate); | 955 v8::HandleScope scope(m_isolate); |
| 955 v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); | 956 v8::TryCatch tryCatch(m_isolate); |
| 956 injectedScript->setVariableValue(errorString, currentCallStack, callFrameId,
functionObjectId, scopeNumber, variableName, newValueString); | 957 |
| 958 v8::Local<v8::Value> newValue; |
| 959 if (!injectedScript->resolveCallArgument(errorString, newValueArgument.get()
).ToLocal(&newValue)) |
| 960 return; |
| 961 |
| 962 OwnPtr<JavaScriptCallFrame> javaScriptCallFrame = debugger().callFrameNoScop
es(remoteId->frameOrdinal()); |
| 963 if (!javaScriptCallFrame) { |
| 964 *errorString = "Could not find call frame with given id"; |
| 965 return; |
| 966 } |
| 967 v8::MaybeLocal<v8::Value> result = javaScriptCallFrame->setVariableValue(sco
peNumber, toV8String(m_isolate, variableName), newValue); |
| 968 if (tryCatch.HasCaught() || result.IsEmpty()) { |
| 969 *errorString = "Internal error"; |
| 970 return; |
| 971 } |
| 957 } | 972 } |
| 958 | 973 |
| 959 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) | 974 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) |
| 960 { | 975 { |
| 961 if (!checkEnabled(errorString)) | 976 if (!checkEnabled(errorString)) |
| 962 return; | 977 return; |
| 963 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); | 978 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); |
| 964 internalSetAsyncCallStackDepth(depth); | 979 internalSetAsyncCallStackDepth(depth); |
| 965 } | 980 } |
| 966 | 981 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 m_scripts.clear(); | 1539 m_scripts.clear(); |
| 1525 m_blackboxedPositions.clear(); | 1540 m_blackboxedPositions.clear(); |
| 1526 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1541 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1527 resetAsyncCallTracker(); | 1542 resetAsyncCallTracker(); |
| 1528 m_promiseTracker->clear(); | 1543 m_promiseTracker->clear(); |
| 1529 if (m_frontend) | 1544 if (m_frontend) |
| 1530 m_frontend->globalObjectCleared(); | 1545 m_frontend->globalObjectCleared(); |
| 1531 } | 1546 } |
| 1532 | 1547 |
| 1533 } // namespace blink | 1548 } // namespace blink |
| OLD | NEW |