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

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

Issue 1857713004: DevTools: simplify the async instrumentation harness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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"
11 #include "platform/v8_inspector/InjectedScriptHost.h" 11 #include "platform/v8_inspector/InjectedScriptHost.h"
12 #include "platform/v8_inspector/InjectedScriptManager.h" 12 #include "platform/v8_inspector/InjectedScriptManager.h"
13 #include "platform/v8_inspector/JavaScriptCallFrame.h" 13 #include "platform/v8_inspector/JavaScriptCallFrame.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/V8Regex.h" 16 #include "platform/v8_inspector/V8Regex.h"
18 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 17 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
19 #include "platform/v8_inspector/V8StackTraceImpl.h" 18 #include "platform/v8_inspector/V8StackTraceImpl.h"
20 #include "platform/v8_inspector/V8StringUtil.h" 19 #include "platform/v8_inspector/V8StringUtil.h"
21 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" 20 #include "platform/v8_inspector/public/V8ContentSearchUtil.h"
22 #include "platform/v8_inspector/public/V8Debugger.h" 21 #include "platform/v8_inspector/public/V8Debugger.h"
23 #include "platform/v8_inspector/public/V8DebuggerClient.h" 22 #include "platform/v8_inspector/public/V8DebuggerClient.h"
24 #include "platform/v8_inspector/public/V8ToProtocolValue.h" 23 #include "platform/v8_inspector/public/V8ToProtocolValue.h"
25 24
26 using blink::protocol::Array; 25 using blink::protocol::Array;
27 using blink::protocol::Maybe; 26 using blink::protocol::Maybe;
28 using blink::protocol::Debugger::BreakpointId; 27 using blink::protocol::Debugger::BreakpointId;
29 using blink::protocol::Debugger::CallFrame; 28 using blink::protocol::Debugger::CallFrame;
30 using blink::protocol::Debugger::CollectionEntry; 29 using blink::protocol::Debugger::CollectionEntry;
31 using blink::protocol::Runtime::ExceptionDetails; 30 using blink::protocol::Runtime::ExceptionDetails;
32 using blink::protocol::Debugger::FunctionDetails; 31 using blink::protocol::Debugger::FunctionDetails;
33 using blink::protocol::Debugger::GeneratorObjectDetails; 32 using blink::protocol::Debugger::GeneratorObjectDetails;
34 using blink::protocol::Runtime::ScriptId; 33 using blink::protocol::Runtime::ScriptId;
35 using blink::protocol::Runtime::StackTrace; 34 using blink::protocol::Runtime::StackTrace;
36 using blink::protocol::Runtime::RemoteObject; 35 using blink::protocol::Runtime::RemoteObject;
37 36
37 namespace {
38 static const char v8AsyncTaskEventEnqueue[] = "enqueue";
39 static const char v8AsyncTaskEventWillHandle[] = "willHandle";
40 static const char v8AsyncTaskEventDidHandle[] = "didHandle";
41 }
42
38 namespace blink { 43 namespace blink {
39 44
40 namespace DebuggerAgentState { 45 namespace DebuggerAgentState {
41 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; 46 static const char javaScriptBreakpoints[] = "javaScriptBreakopints";
42 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; 47 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState";
43 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; 48 static const char asyncCallStackDepth[] = "asyncCallStackDepth";
44 49
45 // Breakpoint properties. 50 // Breakpoint properties.
46 static const char url[] = "url"; 51 static const char url[] = "url";
47 static const char isRegex[] = "isRegex"; 52 static const char isRegex[] = "isRegex";
48 static const char lineNumber[] = "lineNumber"; 53 static const char lineNumber[] = "lineNumber";
49 static const char columnNumber[] = "columnNumber"; 54 static const char columnNumber[] = "columnNumber";
50 static const char condition[] = "condition"; 55 static const char condition[] = "condition";
51 static const char skipAllPauses[] = "skipAllPauses"; 56 static const char skipAllPauses[] = "skipAllPauses";
52 57
53 } // namespace DebuggerAgentState; 58 } // namespace DebuggerAgentState;
54 59
55 static const int maxSkipStepFrameCount = 128; 60 static const int maxSkipStepFrameCount = 128;
56 61
57 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace"; 62 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace";
58 63
59 const int V8DebuggerAgent::unknownAsyncOperationId = 0;
60
61 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) 64 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source)
62 { 65 {
63 switch (source) { 66 switch (source) {
64 case V8DebuggerAgentImpl::UserBreakpointSource: 67 case V8DebuggerAgentImpl::UserBreakpointSource:
65 break; 68 break;
66 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: 69 case V8DebuggerAgentImpl::DebugCommandBreakpointSource:
67 return ":debug"; 70 return ":debug";
68 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: 71 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource:
69 return ":monitor"; 72 return ":monitor";
70 } 73 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 .setLineNumber(lineNumber) 155 .setLineNumber(lineNumber)
153 .setColumnNumber(columnNumber).build(); 156 .setColumnNumber(columnNumber).build();
154 } 157 }
155 158
156 PassOwnPtr<V8DebuggerAgent> V8DebuggerAgent::create(V8RuntimeAgent* runtimeAgent ) 159 PassOwnPtr<V8DebuggerAgent> V8DebuggerAgent::create(V8RuntimeAgent* runtimeAgent )
157 { 160 {
158 V8RuntimeAgentImpl* runtimeAgentImpl = static_cast<V8RuntimeAgentImpl*>(runt imeAgent); 161 V8RuntimeAgentImpl* runtimeAgentImpl = static_cast<V8RuntimeAgentImpl*>(runt imeAgent);
159 return adoptPtr(new V8DebuggerAgentImpl(runtimeAgentImpl->getInjectedScriptM anager(), runtimeAgentImpl->debugger(), runtimeAgentImpl->contextGroupId())); 162 return adoptPtr(new V8DebuggerAgentImpl(runtimeAgentImpl->getInjectedScriptM anager(), runtimeAgentImpl->debugger(), runtimeAgentImpl->contextGroupId()));
160 } 163 }
161 164
165 void V8DebuggerAgent::asyncTaskStarted(void* task)
dgozman 2016/04/05 01:09:49 Remove.
166 {
167 }
168
169 void V8DebuggerAgent::asyncTaskFinished(void* task)
170 {
171 }
172
162 V8DebuggerAgentImpl::V8DebuggerAgentImpl(InjectedScriptManager* injectedScriptMa nager, V8DebuggerImpl* debugger, int contextGroupId) 173 V8DebuggerAgentImpl::V8DebuggerAgentImpl(InjectedScriptManager* injectedScriptMa nager, V8DebuggerImpl* debugger, int contextGroupId)
163 : m_injectedScriptManager(injectedScriptManager) 174 : m_injectedScriptManager(injectedScriptManager)
164 , m_debugger(debugger) 175 , m_debugger(debugger)
165 , m_contextGroupId(contextGroupId) 176 , m_contextGroupId(contextGroupId)
166 , m_enabled(false) 177 , m_enabled(false)
167 , m_state(nullptr) 178 , m_state(nullptr)
168 , m_frontend(nullptr) 179 , m_frontend(nullptr)
169 , m_isolate(debugger->isolate()) 180 , m_isolate(debugger->isolate())
170 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) 181 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other)
171 , m_scheduledDebuggerStep(NoStep) 182 , m_scheduledDebuggerStep(NoStep)
172 , m_skipNextDebuggerStepOut(false) 183 , m_skipNextDebuggerStepOut(false)
173 , m_javaScriptPauseScheduled(false) 184 , m_javaScriptPauseScheduled(false)
174 , m_steppingFromFramework(false) 185 , m_steppingFromFramework(false)
175 , m_pausingOnNativeEvent(false) 186 , m_pausingOnNativeEvent(false)
176 , m_skippedStepFrameCount(0) 187 , m_skippedStepFrameCount(0)
177 , m_recursionLevelForStepOut(0) 188 , m_recursionLevelForStepOut(0)
178 , m_recursionLevelForStepFrame(0) 189 , m_recursionLevelForStepFrame(0)
179 , m_skipAllPauses(false) 190 , m_skipAllPauses(false)
180 , m_lastAsyncOperationId(0)
181 , m_maxAsyncCallStackDepth(0) 191 , m_maxAsyncCallStackDepth(0)
182 , m_currentAsyncCallChain(nullptr)
183 , m_nestedAsyncCallCount(0)
184 , m_currentAsyncOperationId(unknownAsyncOperationId)
185 , m_pendingTraceAsyncOperationCompleted(false)
186 { 192 {
187 ASSERT(contextGroupId); 193 ASSERT(contextGroupId);
188 m_injectedScriptManager->injectedScriptHost()->setDebuggerAgent(this); 194 m_injectedScriptManager->injectedScriptHost()->setDebuggerAgent(this);
189
190 // FIXME: remove once InjectedScriptManager moves to v8.
191 m_v8AsyncCallTracker = V8AsyncCallTracker::create(this);
192 clearBreakDetails(); 195 clearBreakDetails();
193 } 196 }
194 197
195 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() 198 V8DebuggerAgentImpl::~V8DebuggerAgentImpl()
196 { 199 {
197 } 200 }
198 201
199 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString) 202 bool V8DebuggerAgentImpl::checkEnabled(ErrorString* errorString)
200 { 203 {
201 if (enabled()) 204 if (enabled())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 m_skippedStepFrameCount = 0; 259 m_skippedStepFrameCount = 0;
257 m_recursionLevelForStepFrame = 0; 260 m_recursionLevelForStepFrame = 0;
258 m_skipAllPauses = false; 261 m_skipAllPauses = false;
259 m_enabled = false; 262 m_enabled = false;
260 } 263 }
261 264
262 void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth) 265 void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth)
263 { 266 {
264 if (depth <= 0) { 267 if (depth <= 0) {
265 m_maxAsyncCallStackDepth = 0; 268 m_maxAsyncCallStackDepth = 0;
266 resetAsyncCallTracker(); 269 resetAsyncCallStacks();
267 } else { 270 } else {
268 m_maxAsyncCallStackDepth = depth; 271 m_maxAsyncCallStackDepth = depth;
269 } 272 }
270 m_v8AsyncCallTracker->asyncCallTrackingStateChanged(m_maxAsyncCallStackDepth );
271 } 273 }
272 274
273 void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state) 275 void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state)
274 { 276 {
275 m_state = state; 277 m_state = state;
276 } 278 }
277 279
278 void V8DebuggerAgentImpl::clearFrontend() 280 void V8DebuggerAgentImpl::clearFrontend()
279 { 281 {
280 ErrorString error; 282 ErrorString error;
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 { 840 {
839 if (m_javaScriptPauseScheduled || isPaused()) 841 if (m_javaScriptPauseScheduled || isPaused())
840 return; 842 return;
841 clearBreakDetails(); 843 clearBreakDetails();
842 m_pausingOnNativeEvent = false; 844 m_pausingOnNativeEvent = false;
843 debugger().setPauseOnNextStatement(false); 845 debugger().setPauseOnNextStatement(false);
844 } 846 }
845 847
846 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const 848 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const
847 { 849 {
848 return trackingAsyncCalls(); 850 return m_maxAsyncCallStackDepth;
849 } 851 }
850 852
851 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont ext, const String16& eventType, const String16& eventName, int id) 853 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont ext, const String16& eventType, const String16& eventName, int id)
852 { 854 {
855 ASSERT(m_maxAsyncCallStackDepth);
856 void* ptr = reinterpret_cast<void*> (id * 2 + 1);
853 ASSERT(trackingAsyncCalls()); 857 ASSERT(trackingAsyncCalls());
854 m_v8AsyncCallTracker->didReceiveV8AsyncTaskEvent(context, eventType, eventNa me, id); 858 if (eventType == v8AsyncTaskEventEnqueue)
859 scheduleAsyncTask(eventName, ptr, false);
860 else if (eventType == v8AsyncTaskEventWillHandle)
861 asyncTaskStarted(ptr);
862 else if (eventType == v8AsyncTaskEventDidHandle)
863 asyncTaskFinished(ptr);
864 else
865 ASSERT_NOT_REACHED();
855 } 866 }
856 867
857 void V8DebuggerAgentImpl::pause(ErrorString* errorString) 868 void V8DebuggerAgentImpl::pause(ErrorString* errorString)
858 { 869 {
859 if (!checkEnabled(errorString)) 870 if (!checkEnabled(errorString))
860 return; 871 return;
861 if (m_javaScriptPauseScheduled || isPaused()) 872 if (m_javaScriptPauseScheduled || isPaused())
862 return; 873 return;
863 clearBreakDetails(); 874 clearBreakDetails();
864 m_javaScriptPauseScheduled = true; 875 m_javaScriptPauseScheduled = true;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 } 1051 }
1041 1052
1042 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth) 1053 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth)
1043 { 1054 {
1044 if (!checkEnabled(errorString)) 1055 if (!checkEnabled(errorString))
1045 return; 1056 return;
1046 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); 1057 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth);
1047 internalSetAsyncCallStackDepth(depth); 1058 internalSetAsyncCallStackDepth(depth);
1048 } 1059 }
1049 1060
1050 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String16& description ) 1061 void V8DebuggerAgentImpl::scheduleAsyncTask(const String16& taskName, void* task , bool recurring)
1051 { 1062 {
1052 v8::HandleScope scope(m_isolate); 1063 v8::HandleScope scope(m_isolate);
1053 OwnPtr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8StackTrac e::maxCallStackSizeToCapture, description); 1064 OwnPtr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8StackTrac e::maxCallStackSizeToCapture, taskName);
1054
1055 do {
1056 ++m_lastAsyncOperationId;
1057 if (m_lastAsyncOperationId <= 0)
1058 m_lastAsyncOperationId = 1;
1059 } while (m_asyncOperations.contains(m_lastAsyncOperationId));
1060
1061 if (chain) 1065 if (chain)
1062 m_asyncOperations.set(m_lastAsyncOperationId, chain.release()); 1066 m_asyncTaskStacks.set(task, chain.release());
1063
1064 return m_lastAsyncOperationId;
1065 } 1067 }
1066 1068
1067 void V8DebuggerAgentImpl::traceAsyncCallbackStarting(int operationId) 1069 void V8DebuggerAgentImpl::cancelAsyncTask(void* task)
1068 { 1070 {
1069 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId); 1071 m_asyncTaskStacks.remove(task);
1070 V8StackTraceImpl* chain = operationId > 0 ? m_asyncOperations.get(operationI d) : nullptr;
1071 // FIXME: extract recursion check into a delegate.
1072 bool hasRecursionLevel = m_debugger->client()->hasRecursionLevel();
1073 if (chain && !hasRecursionLevel) {
1074 // There can be still an old m_currentAsyncCallChain set if we start run ning Microtasks
1075 // right after executing a JS callback but before the corresponding trac eAsyncCallbackCompleted().
1076 // In this case just call traceAsyncCallbackCompleted() now, and the sub sequent ones will be ignored.
1077 //
1078 // The nested levels count may be greater than 1, for example, when even ts are guarded via custom
1079 // traceAsync* calls, like in window.postMessage(). In this case there w ill be a willHandleEvent
1080 // instrumentation with unknownAsyncOperationId bumping up the nested le vels count.
1081 if (m_currentAsyncCallChain) {
1082 ASSERT(m_nestedAsyncCallCount >= 1);
1083 m_nestedAsyncCallCount = 1;
1084 traceAsyncCallbackCompleted();
1085 }
1086
1087 // Current AsyncCallChain corresponds to the bottommost JS call frame.
1088 ASSERT(!m_currentAsyncCallChain);
1089 m_currentAsyncCallChain = chain->clone();
1090 m_currentAsyncOperationId = operationId;
1091 m_pendingTraceAsyncOperationCompleted = false;
1092 m_nestedAsyncCallCount = 1;
1093 } else {
1094 if (m_currentAsyncCallChain)
1095 ++m_nestedAsyncCallCount;
1096 }
1097 } 1072 }
1098 1073
1099 void V8DebuggerAgentImpl::traceAsyncCallbackCompleted() 1074 void V8DebuggerAgentImpl::cancelAllAsyncTasks()
1100 { 1075 {
1101 if (!m_nestedAsyncCallCount) 1076 m_asyncTaskStacks.clear();
1102 return;
1103 ASSERT(m_currentAsyncCallChain);
1104 --m_nestedAsyncCallCount;
1105 if (!m_nestedAsyncCallCount)
1106 clearCurrentAsyncOperation();
1107 } 1077 }
1108 1078
1109 void V8DebuggerAgentImpl::traceAsyncOperationCompleted(int operationId) 1079 void V8DebuggerAgentImpl::asyncTaskStarted(void* task)
1110 { 1080 {
1111 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId); 1081 m_currentTasks.append(task);
1112 if (operationId > 0) {
1113 if (m_currentAsyncOperationId == operationId) {
1114 if (m_pendingTraceAsyncOperationCompleted) {
1115 m_pendingTraceAsyncOperationCompleted = false;
1116 } else {
1117 // Delay traceAsyncOperationCompleted() until the last async cal lback (being currently executed) is done.
1118 m_pendingTraceAsyncOperationCompleted = true;
1119 return;
1120 }
1121 }
1122 m_asyncOperations.remove(operationId);
1123 }
1124 } 1082 }
1125 1083
1126 void V8DebuggerAgentImpl::clearCurrentAsyncOperation() 1084 void V8DebuggerAgentImpl::asyncTaskFinished(void* task)
1127 { 1085 {
1128 if (m_pendingTraceAsyncOperationCompleted && m_currentAsyncOperationId != un knownAsyncOperationId) 1086 ASSERT(m_currentTasks.size() && m_currentTasks.last() == task);
1129 traceAsyncOperationCompleted(m_currentAsyncOperationId); 1087 m_currentTasks.removeLast();
1130 1088 m_asyncTaskStacks.remove(task);
1131 m_currentAsyncOperationId = unknownAsyncOperationId;
1132 m_pendingTraceAsyncOperationCompleted = false;
1133 m_nestedAsyncCallCount = 0;
1134 m_currentAsyncCallChain.clear();
1135 } 1089 }
1136 1090
1137 void V8DebuggerAgentImpl::resetAsyncCallTracker() 1091 void V8DebuggerAgentImpl::resetAsyncCallStacks()
1138 { 1092 {
1139 clearCurrentAsyncOperation(); 1093 m_asyncTaskStacks.clear();
1140 m_v8AsyncCallTracker->resetAsyncOperations();
1141 m_asyncOperations.clear();
1142 } 1094 }
1143 1095
1144 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16 & scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPo sitions) 1096 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16 & scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPo sitions)
1145 { 1097 {
1146 if (!m_scripts.contains(scriptId)) { 1098 if (!m_scripts.contains(scriptId)) {
1147 *error = "No script with passed id."; 1099 *error = "No script with passed id.";
1148 return; 1100 return;
1149 } 1101 }
1150 1102
1151 if (!inPositions->length()) { 1103 if (!inPositions->length()) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 1236
1285 protocol::ErrorSupport errorSupport; 1237 protocol::ErrorSupport errorSupport;
1286 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu e(context, objects).get(), &errorSupport); 1238 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu e(context, objects).get(), &errorSupport);
1287 if (hasInternalError(errorString, !callFrames)) 1239 if (hasInternalError(errorString, !callFrames))
1288 return Array<CallFrame>::create(); 1240 return Array<CallFrame>::create();
1289 return callFrames.release(); 1241 return callFrames.release();
1290 } 1242 }
1291 1243
1292 PassOwnPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() 1244 PassOwnPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace()
1293 { 1245 {
1294 if (m_pausedContext.IsEmpty() || !trackingAsyncCalls() || !m_currentAsyncCal lChain) 1246 if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentTask s.size())
1295 return nullptr; 1247 return nullptr;
1296 1248
1297 return m_currentAsyncCallChain->buildInspectorObjectForTail(this); 1249 return m_asyncTaskStacks.get(m_currentTasks.last())->buildInspectorObjectFor Tail(this);
1298 } 1250 }
1299 1251
1300 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain() 1252 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain()
1301 { 1253 {
1302 return trackingAsyncCalls() ? m_currentAsyncCallChain.get() : nullptr; 1254 if (!m_currentTasks.size())
1255 return nullptr;
1256 return m_asyncTaskStacks.get(m_currentTasks.last());
1303 } 1257 }
1304 1258
1305 void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr ipt) 1259 void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr ipt)
1306 { 1260 {
1307 V8DebuggerScript script = parsedScript.script; 1261 V8DebuggerScript script = parsedScript.script;
1308 1262
1309 bool isDeprecatedSourceURL = false; 1263 bool isDeprecatedSourceURL = false;
1310 if (!parsedScript.success) 1264 if (!parsedScript.success)
1311 script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL)); 1265 script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL));
1312 else if (script.hasSourceURL()) 1266 else if (script.hasSourceURL())
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1455 }
1502 1456
1503 void V8DebuggerAgentImpl::reset() 1457 void V8DebuggerAgentImpl::reset()
1504 { 1458 {
1505 if (!enabled()) 1459 if (!enabled())
1506 return; 1460 return;
1507 m_scheduledDebuggerStep = NoStep; 1461 m_scheduledDebuggerStep = NoStep;
1508 m_scripts.clear(); 1462 m_scripts.clear();
1509 m_blackboxedPositions.clear(); 1463 m_blackboxedPositions.clear();
1510 m_breakpointIdToDebuggerBreakpointIds.clear(); 1464 m_breakpointIdToDebuggerBreakpointIds.clear();
1511 resetAsyncCallTracker(); 1465 resetAsyncCallStacks();
1512 } 1466 }
1513 1467
1514 } // namespace blink 1468 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698