| 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" |
| 11 #include "platform/v8_inspector/InspectedContext.h" | 11 #include "platform/v8_inspector/InspectedContext.h" |
| 12 #include "platform/v8_inspector/JavaScriptCallFrame.h" | 12 #include "platform/v8_inspector/JavaScriptCallFrame.h" |
| 13 #include "platform/v8_inspector/MuteConsoleScope.h" | 13 #include "platform/v8_inspector/MuteConsoleScope.h" |
| 14 #include "platform/v8_inspector/RemoteObjectId.h" | 14 #include "platform/v8_inspector/RemoteObjectId.h" |
| 15 #include "platform/v8_inspector/ScriptBreakpoint.h" | 15 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 16 #include "platform/v8_inspector/V8AsyncCallTracker.h" | |
| 17 #include "platform/v8_inspector/V8InspectorConnectionImpl.h" | 16 #include "platform/v8_inspector/V8InspectorConnectionImpl.h" |
| 18 #include "platform/v8_inspector/V8Regex.h" | 17 #include "platform/v8_inspector/V8Regex.h" |
| 19 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 18 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
| 20 #include "platform/v8_inspector/V8StackTraceImpl.h" | 19 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 21 #include "platform/v8_inspector/V8StringUtil.h" | 20 #include "platform/v8_inspector/V8StringUtil.h" |
| 22 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" | 21 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" |
| 23 #include "platform/v8_inspector/public/V8Debugger.h" | 22 #include "platform/v8_inspector/public/V8Debugger.h" |
| 24 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 23 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
| 25 #include "platform/v8_inspector/public/V8ToProtocolValue.h" | 24 #include "platform/v8_inspector/public/V8ToProtocolValue.h" |
| 26 | 25 |
| 27 using blink::protocol::Array; | 26 using blink::protocol::Array; |
| 28 using blink::protocol::Maybe; | 27 using blink::protocol::Maybe; |
| 29 using blink::protocol::Debugger::BreakpointId; | 28 using blink::protocol::Debugger::BreakpointId; |
| 30 using blink::protocol::Debugger::CallFrame; | 29 using blink::protocol::Debugger::CallFrame; |
| 31 using blink::protocol::Debugger::CollectionEntry; | 30 using blink::protocol::Debugger::CollectionEntry; |
| 32 using blink::protocol::Runtime::ExceptionDetails; | 31 using blink::protocol::Runtime::ExceptionDetails; |
| 33 using blink::protocol::Debugger::FunctionDetails; | 32 using blink::protocol::Debugger::FunctionDetails; |
| 34 using blink::protocol::Debugger::GeneratorObjectDetails; | 33 using blink::protocol::Debugger::GeneratorObjectDetails; |
| 35 using blink::protocol::Runtime::ScriptId; | 34 using blink::protocol::Runtime::ScriptId; |
| 36 using blink::protocol::Runtime::StackTrace; | 35 using blink::protocol::Runtime::StackTrace; |
| 37 using blink::protocol::Runtime::RemoteObject; | 36 using blink::protocol::Runtime::RemoteObject; |
| 38 | 37 |
| 38 namespace { |
| 39 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; |
| 40 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; |
| 41 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; |
| 42 } |
| 43 |
| 39 namespace blink { | 44 namespace blink { |
| 40 | 45 |
| 41 namespace DebuggerAgentState { | 46 namespace DebuggerAgentState { |
| 42 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; | 47 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; |
| 43 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; | 48 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; |
| 44 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; | 49 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; |
| 45 | 50 |
| 46 // Breakpoint properties. | 51 // Breakpoint properties. |
| 47 static const char url[] = "url"; | 52 static const char url[] = "url"; |
| 48 static const char isRegex[] = "isRegex"; | 53 static const char isRegex[] = "isRegex"; |
| 49 static const char lineNumber[] = "lineNumber"; | 54 static const char lineNumber[] = "lineNumber"; |
| 50 static const char columnNumber[] = "columnNumber"; | 55 static const char columnNumber[] = "columnNumber"; |
| 51 static const char condition[] = "condition"; | 56 static const char condition[] = "condition"; |
| 52 static const char skipAllPauses[] = "skipAllPauses"; | 57 static const char skipAllPauses[] = "skipAllPauses"; |
| 53 | 58 |
| 54 } // namespace DebuggerAgentState; | 59 } // namespace DebuggerAgentState; |
| 55 | 60 |
| 56 static const int maxSkipStepFrameCount = 128; | 61 static const int maxSkipStepFrameCount = 128; |
| 57 | 62 |
| 58 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace"; | 63 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace"; |
| 59 | 64 |
| 60 const int V8DebuggerAgent::unknownAsyncOperationId = 0; | |
| 61 | |
| 62 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) | 65 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) |
| 63 { | 66 { |
| 64 switch (source) { | 67 switch (source) { |
| 65 case V8DebuggerAgentImpl::UserBreakpointSource: | 68 case V8DebuggerAgentImpl::UserBreakpointSource: |
| 66 break; | 69 break; |
| 67 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: | 70 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: |
| 68 return ":debug"; | 71 return ":debug"; |
| 69 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: | 72 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: |
| 70 return ":monitor"; | 73 return ":monitor"; |
| 71 } | 74 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) | 173 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) |
| 171 , m_scheduledDebuggerStep(NoStep) | 174 , m_scheduledDebuggerStep(NoStep) |
| 172 , m_skipNextDebuggerStepOut(false) | 175 , m_skipNextDebuggerStepOut(false) |
| 173 , m_javaScriptPauseScheduled(false) | 176 , m_javaScriptPauseScheduled(false) |
| 174 , m_steppingFromFramework(false) | 177 , m_steppingFromFramework(false) |
| 175 , m_pausingOnNativeEvent(false) | 178 , m_pausingOnNativeEvent(false) |
| 176 , m_skippedStepFrameCount(0) | 179 , m_skippedStepFrameCount(0) |
| 177 , m_recursionLevelForStepOut(0) | 180 , m_recursionLevelForStepOut(0) |
| 178 , m_recursionLevelForStepFrame(0) | 181 , m_recursionLevelForStepFrame(0) |
| 179 , m_skipAllPauses(false) | 182 , m_skipAllPauses(false) |
| 180 , m_lastAsyncOperationId(0) | |
| 181 , m_maxAsyncCallStackDepth(0) | 183 , m_maxAsyncCallStackDepth(0) |
| 182 , m_currentAsyncCallChain(nullptr) | |
| 183 , m_nestedAsyncCallCount(0) | |
| 184 , m_currentAsyncOperationId(unknownAsyncOperationId) | |
| 185 , m_pendingTraceAsyncOperationCompleted(false) | |
| 186 { | 184 { |
| 187 m_connection->setDebuggerAgent(this); | 185 m_connection->setDebuggerAgent(this); |
| 188 | |
| 189 // FIXME: remove once InjectedScriptManager moves to v8. | |
| 190 m_v8AsyncCallTracker = V8AsyncCallTracker::create(this); | |
| 191 clearBreakDetails(); | 186 clearBreakDetails(); |
| 192 } | 187 } |
| 193 | 188 |
| 194 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() | 189 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() |
| 195 { | 190 { |
| 196 m_connection->setDebuggerAgent(nullptr); | 191 m_connection->setDebuggerAgent(nullptr); |
| 197 } | 192 } |
| 198 | 193 |
| 199 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) | 194 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) |
| 200 { | 195 { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 m_skippedStepFrameCount = 0; | 251 m_skippedStepFrameCount = 0; |
| 257 m_recursionLevelForStepFrame = 0; | 252 m_recursionLevelForStepFrame = 0; |
| 258 m_skipAllPauses = false; | 253 m_skipAllPauses = false; |
| 259 m_enabled = false; | 254 m_enabled = false; |
| 260 } | 255 } |
| 261 | 256 |
| 262 void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth) | 257 void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth) |
| 263 { | 258 { |
| 264 if (depth <= 0) { | 259 if (depth <= 0) { |
| 265 m_maxAsyncCallStackDepth = 0; | 260 m_maxAsyncCallStackDepth = 0; |
| 266 resetAsyncCallTracker(); | 261 allAsyncTasksCanceled(); |
| 267 } else { | 262 } else { |
| 268 m_maxAsyncCallStackDepth = depth; | 263 m_maxAsyncCallStackDepth = depth; |
| 269 } | 264 } |
| 270 m_v8AsyncCallTracker->asyncCallTrackingStateChanged(m_maxAsyncCallStackDepth
); | |
| 271 } | 265 } |
| 272 | 266 |
| 273 void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state) | 267 void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state) |
| 274 { | 268 { |
| 275 m_state = state; | 269 m_state = state; |
| 276 } | 270 } |
| 277 | 271 |
| 278 void V8DebuggerAgentImpl::clearFrontend() | 272 void V8DebuggerAgentImpl::clearFrontend() |
| 279 { | 273 { |
| 280 ErrorString error; | 274 ErrorString error; |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 { | 832 { |
| 839 if (m_javaScriptPauseScheduled || isPaused()) | 833 if (m_javaScriptPauseScheduled || isPaused()) |
| 840 return; | 834 return; |
| 841 clearBreakDetails(); | 835 clearBreakDetails(); |
| 842 m_pausingOnNativeEvent = false; | 836 m_pausingOnNativeEvent = false; |
| 843 debugger().setPauseOnNextStatement(false); | 837 debugger().setPauseOnNextStatement(false); |
| 844 } | 838 } |
| 845 | 839 |
| 846 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const | 840 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const |
| 847 { | 841 { |
| 848 return trackingAsyncCalls(); | 842 return m_maxAsyncCallStackDepth; |
| 849 } | 843 } |
| 850 | 844 |
| 851 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont
ext, const String16& eventType, const String16& eventName, int id) | 845 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont
ext, const String16& eventType, const String16& eventName, int id) |
| 852 { | 846 { |
| 853 ASSERT(trackingAsyncCalls()); | 847 ASSERT(m_maxAsyncCallStackDepth); |
| 854 m_v8AsyncCallTracker->didReceiveV8AsyncTaskEvent(context, eventType, eventNa
me, id); | 848 // The scopes for the ids are defined by the eventName namespaces. There are
currently two namespaces: "Object." and "Promise.". |
| 849 void* ptr = reinterpret_cast<void*>(id * 4 + (eventName[0] == 'P' ? 2 : 0) +
1); |
| 850 if (eventType == v8AsyncTaskEventEnqueue) |
| 851 asyncTaskScheduled(eventName, ptr, false); |
| 852 else if (eventType == v8AsyncTaskEventWillHandle) |
| 853 asyncTaskStarted(ptr); |
| 854 else if (eventType == v8AsyncTaskEventDidHandle) |
| 855 asyncTaskFinished(ptr); |
| 856 else |
| 857 ASSERT_NOT_REACHED(); |
| 855 } | 858 } |
| 856 | 859 |
| 857 void V8DebuggerAgentImpl::pause(ErrorString* errorString) | 860 void V8DebuggerAgentImpl::pause(ErrorString* errorString) |
| 858 { | 861 { |
| 859 if (!checkEnabled(errorString)) | 862 if (!checkEnabled(errorString)) |
| 860 return; | 863 return; |
| 861 if (m_javaScriptPauseScheduled || isPaused()) | 864 if (m_javaScriptPauseScheduled || isPaused()) |
| 862 return; | 865 return; |
| 863 clearBreakDetails(); | 866 clearBreakDetails(); |
| 864 m_javaScriptPauseScheduled = true; | 867 m_javaScriptPauseScheduled = true; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 } | 1045 } |
| 1043 | 1046 |
| 1044 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) | 1047 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) |
| 1045 { | 1048 { |
| 1046 if (!checkEnabled(errorString)) | 1049 if (!checkEnabled(errorString)) |
| 1047 return; | 1050 return; |
| 1048 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); | 1051 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); |
| 1049 internalSetAsyncCallStackDepth(depth); | 1052 internalSetAsyncCallStackDepth(depth); |
| 1050 } | 1053 } |
| 1051 | 1054 |
| 1052 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String16& description
) | 1055 void V8DebuggerAgentImpl::asyncTaskScheduled(const String16& taskName, void* tas
k, bool recurring) |
| 1053 { | 1056 { |
| 1057 if (!m_maxAsyncCallStackDepth) |
| 1058 return; |
| 1054 v8::HandleScope scope(m_isolate); | 1059 v8::HandleScope scope(m_isolate); |
| 1055 OwnPtr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8StackTrac
e::maxCallStackSizeToCapture, description); | 1060 OwnPtr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8StackTrac
e::maxCallStackSizeToCapture, taskName); |
| 1056 | 1061 if (chain) { |
| 1057 do { | 1062 m_asyncTaskStacks.set(task, chain.release()); |
| 1058 ++m_lastAsyncOperationId; | 1063 if (recurring) |
| 1059 if (m_lastAsyncOperationId <= 0) | 1064 m_recurringTasks.add(task); |
| 1060 m_lastAsyncOperationId = 1; | |
| 1061 } while (m_asyncOperations.contains(m_lastAsyncOperationId)); | |
| 1062 | |
| 1063 if (chain) | |
| 1064 m_asyncOperations.set(m_lastAsyncOperationId, chain.release()); | |
| 1065 | |
| 1066 return m_lastAsyncOperationId; | |
| 1067 } | |
| 1068 | |
| 1069 void V8DebuggerAgentImpl::traceAsyncCallbackStarting(int operationId) | |
| 1070 { | |
| 1071 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId); | |
| 1072 V8StackTraceImpl* chain = operationId > 0 ? m_asyncOperations.get(operationI
d) : nullptr; | |
| 1073 // FIXME: extract recursion check into a delegate. | |
| 1074 bool hasRecursionLevel = m_debugger->client()->hasRecursionLevel(); | |
| 1075 if (chain && !hasRecursionLevel) { | |
| 1076 // There can be still an old m_currentAsyncCallChain set if we start run
ning Microtasks | |
| 1077 // right after executing a JS callback but before the corresponding trac
eAsyncCallbackCompleted(). | |
| 1078 // In this case just call traceAsyncCallbackCompleted() now, and the sub
sequent ones will be ignored. | |
| 1079 // | |
| 1080 // The nested levels count may be greater than 1, for example, when even
ts are guarded via custom | |
| 1081 // traceAsync* calls, like in window.postMessage(). In this case there w
ill be a willHandleEvent | |
| 1082 // instrumentation with unknownAsyncOperationId bumping up the nested le
vels count. | |
| 1083 if (m_currentAsyncCallChain) { | |
| 1084 ASSERT(m_nestedAsyncCallCount >= 1); | |
| 1085 m_nestedAsyncCallCount = 1; | |
| 1086 traceAsyncCallbackCompleted(); | |
| 1087 } | |
| 1088 | |
| 1089 // Current AsyncCallChain corresponds to the bottommost JS call frame. | |
| 1090 ASSERT(!m_currentAsyncCallChain); | |
| 1091 m_currentAsyncCallChain = chain->clone(); | |
| 1092 m_currentAsyncOperationId = operationId; | |
| 1093 m_pendingTraceAsyncOperationCompleted = false; | |
| 1094 m_nestedAsyncCallCount = 1; | |
| 1095 } else { | |
| 1096 if (m_currentAsyncCallChain) | |
| 1097 ++m_nestedAsyncCallCount; | |
| 1098 } | 1065 } |
| 1099 } | 1066 } |
| 1100 | 1067 |
| 1101 void V8DebuggerAgentImpl::traceAsyncCallbackCompleted() | 1068 void V8DebuggerAgentImpl::asyncTaskCanceled(void* task) |
| 1102 { | 1069 { |
| 1103 if (!m_nestedAsyncCallCount) | 1070 if (!m_maxAsyncCallStackDepth) |
| 1104 return; | 1071 return; |
| 1105 ASSERT(m_currentAsyncCallChain); | 1072 m_asyncTaskStacks.remove(task); |
| 1106 --m_nestedAsyncCallCount; | 1073 m_recurringTasks.remove(task); |
| 1107 if (!m_nestedAsyncCallCount) | |
| 1108 clearCurrentAsyncOperation(); | |
| 1109 } | 1074 } |
| 1110 | 1075 |
| 1111 void V8DebuggerAgentImpl::traceAsyncOperationCompleted(int operationId) | 1076 void V8DebuggerAgentImpl::asyncTaskStarted(void* task) |
| 1112 { | 1077 { |
| 1113 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId); | 1078 // Not enabled, return. |
| 1114 if (operationId > 0) { | 1079 if (!m_maxAsyncCallStackDepth) |
| 1115 if (m_currentAsyncOperationId == operationId) { | 1080 return; |
| 1116 if (m_pendingTraceAsyncOperationCompleted) { | 1081 |
| 1117 m_pendingTraceAsyncOperationCompleted = false; | 1082 #if ENABLE(ASSERT) |
| 1118 } else { | 1083 m_currentTasks.append(task); |
| 1119 // Delay traceAsyncOperationCompleted() until the last async cal
lback (being currently executed) is done. | 1084 #endif |
| 1120 m_pendingTraceAsyncOperationCompleted = true; | 1085 |
| 1121 return; | 1086 V8StackTraceImpl* stack = m_asyncTaskStacks.get(task); |
| 1122 } | 1087 // Needs to support following order of events: |
| 1123 } | 1088 // - asyncTaskScheduled |
| 1124 m_asyncOperations.remove(operationId); | 1089 // <-- attached here --> |
| 1125 } | 1090 // - asyncTaskStarted |
| 1091 // - asyncTaskCanceled <-- canceled before finished |
| 1092 // <-- async stack requested here --> |
| 1093 // - asyncTaskFinished |
| 1094 m_currentStacks.append(stack ? stack->clone() : nullptr); |
| 1126 } | 1095 } |
| 1127 | 1096 |
| 1128 void V8DebuggerAgentImpl::clearCurrentAsyncOperation() | 1097 void V8DebuggerAgentImpl::asyncTaskFinished(void* task) |
| 1129 { | 1098 { |
| 1130 if (m_pendingTraceAsyncOperationCompleted && m_currentAsyncOperationId != un
knownAsyncOperationId) | 1099 if (!m_maxAsyncCallStackDepth) |
| 1131 traceAsyncOperationCompleted(m_currentAsyncOperationId); | 1100 return; |
| 1101 // We could start instrumenting half way and the stack is empty. |
| 1102 if (!m_currentStacks.size()) |
| 1103 return; |
| 1132 | 1104 |
| 1133 m_currentAsyncOperationId = unknownAsyncOperationId; | 1105 #if ENABLE(ASSERT) |
| 1134 m_pendingTraceAsyncOperationCompleted = false; | 1106 ASSERT(m_currentTasks.last() == task); |
| 1135 m_nestedAsyncCallCount = 0; | 1107 m_currentTasks.removeLast(); |
| 1136 m_currentAsyncCallChain.clear(); | 1108 #endif |
| 1109 |
| 1110 m_currentStacks.removeLast(); |
| 1111 if (!m_recurringTasks.contains(task)) |
| 1112 m_asyncTaskStacks.remove(task); |
| 1137 } | 1113 } |
| 1138 | 1114 |
| 1139 void V8DebuggerAgentImpl::resetAsyncCallTracker() | 1115 void V8DebuggerAgentImpl::allAsyncTasksCanceled() |
| 1140 { | 1116 { |
| 1141 clearCurrentAsyncOperation(); | 1117 m_asyncTaskStacks.clear(); |
| 1142 m_v8AsyncCallTracker->resetAsyncOperations(); | 1118 m_recurringTasks.clear(); |
| 1143 m_asyncOperations.clear(); | 1119 m_currentStacks.clear(); |
| 1120 |
| 1121 #if ENABLE(ASSERT) |
| 1122 m_currentTasks.clear(); |
| 1123 #endif |
| 1144 } | 1124 } |
| 1145 | 1125 |
| 1146 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16
& scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPo
sitions) | 1126 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16
& scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPo
sitions) |
| 1147 { | 1127 { |
| 1148 if (!m_scripts.contains(scriptId)) { | 1128 if (!m_scripts.contains(scriptId)) { |
| 1149 *error = "No script with passed id."; | 1129 *error = "No script with passed id."; |
| 1150 return; | 1130 return; |
| 1151 } | 1131 } |
| 1152 | 1132 |
| 1153 if (!inPositions->length()) { | 1133 if (!inPositions->length()) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 | 1265 |
| 1286 protocol::ErrorSupport errorSupport; | 1266 protocol::ErrorSupport errorSupport; |
| 1287 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu
e(context, objects).get(), &errorSupport); | 1267 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu
e(context, objects).get(), &errorSupport); |
| 1288 if (hasInternalError(errorString, !callFrames)) | 1268 if (hasInternalError(errorString, !callFrames)) |
| 1289 return Array<CallFrame>::create(); | 1269 return Array<CallFrame>::create(); |
| 1290 return callFrames.release(); | 1270 return callFrames.release(); |
| 1291 } | 1271 } |
| 1292 | 1272 |
| 1293 PassOwnPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() | 1273 PassOwnPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() |
| 1294 { | 1274 { |
| 1295 if (m_pausedContext.IsEmpty() || !trackingAsyncCalls() || !m_currentAsyncCal
lChain) | 1275 if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentStac
ks.size() || !m_currentStacks.last()) |
| 1296 return nullptr; | 1276 return nullptr; |
| 1297 | 1277 |
| 1298 return m_currentAsyncCallChain->buildInspectorObjectForTail(this); | 1278 return m_currentStacks.last()->buildInspectorObjectForTail(this); |
| 1299 } | 1279 } |
| 1300 | 1280 |
| 1301 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain() | 1281 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain() |
| 1302 { | 1282 { |
| 1303 return trackingAsyncCalls() ? m_currentAsyncCallChain.get() : nullptr; | 1283 if (!m_currentStacks.size()) |
| 1284 return nullptr; |
| 1285 return m_currentStacks.last().get(); |
| 1304 } | 1286 } |
| 1305 | 1287 |
| 1306 void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr
ipt) | 1288 void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr
ipt) |
| 1307 { | 1289 { |
| 1308 V8DebuggerScript script = parsedScript.script; | 1290 V8DebuggerScript script = parsedScript.script; |
| 1309 | 1291 |
| 1310 bool isDeprecatedSourceURL = false; | 1292 bool isDeprecatedSourceURL = false; |
| 1311 if (!parsedScript.success) | 1293 if (!parsedScript.success) |
| 1312 script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(),
false, &isDeprecatedSourceURL)); | 1294 script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(),
false, &isDeprecatedSourceURL)); |
| 1313 else if (script.hasSourceURL()) | 1295 else if (script.hasSourceURL()) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 } | 1485 } |
| 1504 | 1486 |
| 1505 void V8DebuggerAgentImpl::reset() | 1487 void V8DebuggerAgentImpl::reset() |
| 1506 { | 1488 { |
| 1507 if (!enabled()) | 1489 if (!enabled()) |
| 1508 return; | 1490 return; |
| 1509 m_scheduledDebuggerStep = NoStep; | 1491 m_scheduledDebuggerStep = NoStep; |
| 1510 m_scripts.clear(); | 1492 m_scripts.clear(); |
| 1511 m_blackboxedPositions.clear(); | 1493 m_blackboxedPositions.clear(); |
| 1512 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1494 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1513 resetAsyncCallTracker(); | 1495 allAsyncTasksCanceled(); |
| 1514 } | 1496 } |
| 1515 | 1497 |
| 1516 } // namespace blink | 1498 } // namespace blink |
| OLD | NEW |