| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/inspector/v8/V8DebuggerAgentImpl.h" | 6 #include "core/inspector/v8/V8DebuggerAgentImpl.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptCallStackFactory.h" | 8 #include "bindings/core/v8/ScriptCallStackFactory.h" |
| 9 #include "bindings/core/v8/ScriptRegexp.h" | 9 #include "bindings/core/v8/ScriptRegexp.h" |
| 10 #include "bindings/core/v8/ScriptValue.h" | 10 #include "bindings/core/v8/ScriptValue.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ASSERT(contextGroupId); | 160 ASSERT(contextGroupId); |
| 161 m_v8AsyncCallTracker = V8AsyncCallTracker::create(this); | 161 m_v8AsyncCallTracker = V8AsyncCallTracker::create(this); |
| 162 m_promiseTracker = PromiseTracker::create(this, m_isolate); | 162 m_promiseTracker = PromiseTracker::create(this, m_isolate); |
| 163 clearBreakDetails(); | 163 clearBreakDetails(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() | 166 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() |
| 167 { | 167 { |
| 168 } | 168 } |
| 169 | 169 |
| 170 DEFINE_TRACE(V8DebuggerAgentImpl) | |
| 171 { | |
| 172 #if ENABLE(OILPAN) | |
| 173 visitor->trace(m_injectedScriptManager); | |
| 174 visitor->trace(m_v8AsyncCallTracker); | |
| 175 visitor->trace(m_promiseTracker); | |
| 176 visitor->trace(m_asyncOperations); | |
| 177 visitor->trace(m_currentAsyncCallChain); | |
| 178 #endif | |
| 179 } | |
| 180 | |
| 181 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) | 170 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) |
| 182 { | 171 { |
| 183 if (enabled()) | 172 if (enabled()) |
| 184 return true; | 173 return true; |
| 185 *errorString = "Debugger agent is not enabled"; | 174 *errorString = "Debugger agent is not enabled"; |
| 186 return false; | 175 return false; |
| 187 } | 176 } |
| 188 | 177 |
| 189 void V8DebuggerAgentImpl::enable() | 178 void V8DebuggerAgentImpl::enable() |
| 190 { | 179 { |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 unsigned asyncOrdinal = callFrameId.asyncStackOrdinal(); // 0 is current cal
l stack | 872 unsigned asyncOrdinal = callFrameId.asyncStackOrdinal(); // 0 is current cal
l stack |
| 884 if (!asyncOrdinal) { | 873 if (!asyncOrdinal) { |
| 885 *callStack = m_currentCallStack.Get(m_isolate); | 874 *callStack = m_currentCallStack.Get(m_isolate); |
| 886 *isAsync = false; | 875 *isAsync = false; |
| 887 return true; | 876 return true; |
| 888 } | 877 } |
| 889 if (!m_currentAsyncCallChain || asyncOrdinal < 1 || asyncOrdinal >= m_curren
tAsyncCallChain->callStacks().size()) { | 878 if (!m_currentAsyncCallChain || asyncOrdinal < 1 || asyncOrdinal >= m_curren
tAsyncCallChain->callStacks().size()) { |
| 890 *errorString = "Async call stack not found"; | 879 *errorString = "Async call stack not found"; |
| 891 return false; | 880 return false; |
| 892 } | 881 } |
| 893 RefPtrWillBeRawPtr<AsyncCallStack> asyncStack = m_currentAsyncCallChain->cal
lStacks()[asyncOrdinal - 1]; | 882 RefPtr<AsyncCallStack> asyncStack = m_currentAsyncCallChain->callStacks()[as
yncOrdinal - 1]; |
| 894 *callStack = asyncStack->callFrames(m_isolate); | 883 *callStack = asyncStack->callFrames(m_isolate); |
| 895 *isAsync = true; | 884 *isAsync = true; |
| 896 return true; | 885 return true; |
| 897 } | 886 } |
| 898 | 887 |
| 899 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, const St
ring& callFrameId, const String& expression, const String* const objectGroup, co
nst bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsA
ndMuteConsole, const bool* const returnByValue, const bool* generatePreview, Ref
Ptr<RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown, RefPtr<TypeB
uilder::Debugger::ExceptionDetails>& exceptionDetails) | 888 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, const St
ring& callFrameId, const String& expression, const String* const objectGroup, co
nst bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsA
ndMuteConsole, const bool* const returnByValue, const bool* generatePreview, Ref
Ptr<RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown, RefPtr<TypeB
uilder::Debugger::ExceptionDetails>& exceptionDetails) |
| 900 { | 889 { |
| 901 if (!isPaused() || m_currentCallStack.IsEmpty()) { | 890 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
| 902 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 891 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
| 903 return; | 892 return; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 void V8DebuggerAgentImpl::didUpdatePromise(InspectorFrontend::Debugger::EventTyp
e::Enum eventType, PassRefPtr<TypeBuilder::Debugger::PromiseDetails> promise) | 1126 void V8DebuggerAgentImpl::didUpdatePromise(InspectorFrontend::Debugger::EventTyp
e::Enum eventType, PassRefPtr<TypeBuilder::Debugger::PromiseDetails> promise) |
| 1138 { | 1127 { |
| 1139 if (m_frontend) | 1128 if (m_frontend) |
| 1140 m_frontend->promiseUpdated(eventType, promise); | 1129 m_frontend->promiseUpdated(eventType, promise); |
| 1141 } | 1130 } |
| 1142 | 1131 |
| 1143 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String& description) | 1132 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String& description) |
| 1144 { | 1133 { |
| 1145 v8::HandleScope scope(m_isolate); | 1134 v8::HandleScope scope(m_isolate); |
| 1146 v8::Local<v8::Object> callFrames = debugger().currentCallFramesForAsyncStack
(); | 1135 v8::Local<v8::Object> callFrames = debugger().currentCallFramesForAsyncStack
(); |
| 1147 RefPtrWillBeRawPtr<AsyncCallChain> chain = nullptr; | 1136 RefPtr<AsyncCallChain> chain; |
| 1148 if (callFrames.IsEmpty()) { | 1137 if (callFrames.IsEmpty()) { |
| 1149 if (m_currentAsyncCallChain) | 1138 if (m_currentAsyncCallChain) |
| 1150 chain = AsyncCallChain::create(nullptr, m_currentAsyncCallChain.get(
), m_maxAsyncCallStackDepth); | 1139 chain = AsyncCallChain::create(nullptr, m_currentAsyncCallChain.get(
), m_maxAsyncCallStackDepth); |
| 1151 } else { | 1140 } else { |
| 1152 chain = AsyncCallChain::create(adoptRefWillBeNoop(new AsyncCallStack(des
cription, callFrames)), m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth)
; | 1141 chain = AsyncCallChain::create(adoptRef(new AsyncCallStack(description,
callFrames)), m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth); |
| 1153 } | 1142 } |
| 1154 do { | 1143 do { |
| 1155 ++m_lastAsyncOperationId; | 1144 ++m_lastAsyncOperationId; |
| 1156 if (m_lastAsyncOperationId <= 0) | 1145 if (m_lastAsyncOperationId <= 0) |
| 1157 m_lastAsyncOperationId = 1; | 1146 m_lastAsyncOperationId = 1; |
| 1158 } while (m_asyncOperations.contains(m_lastAsyncOperationId)); | 1147 } while (m_asyncOperations.contains(m_lastAsyncOperationId)); |
| 1159 m_asyncOperations.set(m_lastAsyncOperationId, chain); | 1148 m_asyncOperations.set(m_lastAsyncOperationId, chain); |
| 1160 if (chain) | 1149 if (chain) |
| 1161 m_asyncOperationNotifications.add(m_lastAsyncOperationId); | 1150 m_asyncOperationNotifications.add(m_lastAsyncOperationId); |
| 1162 | 1151 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 if (m_frontend && shouldNotify) | 1251 if (m_frontend && shouldNotify) |
| 1263 m_frontend->asyncOperationCompleted(operationId); | 1252 m_frontend->asyncOperationCompleted(operationId); |
| 1264 } | 1253 } |
| 1265 | 1254 |
| 1266 void V8DebuggerAgentImpl::flushAsyncOperationEvents(ErrorString*) | 1255 void V8DebuggerAgentImpl::flushAsyncOperationEvents(ErrorString*) |
| 1267 { | 1256 { |
| 1268 if (!m_frontend) | 1257 if (!m_frontend) |
| 1269 return; | 1258 return; |
| 1270 | 1259 |
| 1271 for (int operationId : m_asyncOperationNotifications) { | 1260 for (int operationId : m_asyncOperationNotifications) { |
| 1272 RefPtrWillBeRawPtr<AsyncCallChain> chain = m_asyncOperations.get(operati
onId); | 1261 RefPtr<AsyncCallChain> chain = m_asyncOperations.get(operationId); |
| 1273 ASSERT(chain); | 1262 ASSERT(chain); |
| 1274 const AsyncCallStackVector& callStacks = chain->callStacks(); | 1263 const AsyncCallStackVector& callStacks = chain->callStacks(); |
| 1275 ASSERT(!callStacks.isEmpty()); | 1264 ASSERT(!callStacks.isEmpty()); |
| 1276 | 1265 |
| 1277 RefPtr<AsyncOperation> operation; | 1266 RefPtr<AsyncOperation> operation; |
| 1278 RefPtr<AsyncStackTrace> lastAsyncStackTrace; | 1267 RefPtr<AsyncStackTrace> lastAsyncStackTrace; |
| 1279 for (const auto& callStack : callStacks) { | 1268 for (const auto& callStack : callStacks) { |
| 1280 v8::HandleScope scope(m_isolate); | 1269 v8::HandleScope scope(m_isolate); |
| 1281 RefPtrWillBeRawPtr<ScriptCallStack> scriptCallStack = toScriptCallSt
ack(callStack->callFrames(m_isolate)); | 1270 RefPtrWillBeRawPtr<ScriptCallStack> scriptCallStack = toScriptCallSt
ack(callStack->callFrames(m_isolate)); |
| 1282 if (!scriptCallStack) | 1271 if (!scriptCallStack) |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); | 1675 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); |
| 1687 exceptionDetails->setLine(message->GetLineNumber()); | 1676 exceptionDetails->setLine(message->GetLineNumber()); |
| 1688 exceptionDetails->setColumn(message->GetStartColumn()); | 1677 exceptionDetails->setColumn(message->GetStartColumn()); |
| 1689 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); | 1678 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); |
| 1690 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) | 1679 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) |
| 1691 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt
ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); | 1680 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt
ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); |
| 1692 return exceptionDetails.release(); | 1681 return exceptionDetails.release(); |
| 1693 } | 1682 } |
| 1694 | 1683 |
| 1695 } // namespace blink | 1684 } // namespace blink |
| OLD | NEW |