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

Side by Side Diff: Source/core/inspector/InspectorDebuggerAgent.cpp

Issue 855383002: DevTools: use async operation id instead of AsyncCallChain (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed assert Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 static const char skipContentScripts[] = "skipContentScripts"; 85 static const char skipContentScripts[] = "skipContentScripts";
86 static const char skipAllPauses[] = "skipAllPauses"; 86 static const char skipAllPauses[] = "skipAllPauses";
87 static const char skipAllPausesExpiresOnReload[] = "skipAllPausesExpiresOnReload "; 87 static const char skipAllPausesExpiresOnReload[] = "skipAllPausesExpiresOnReload ";
88 88
89 }; 89 };
90 90
91 static const int maxSkipStepFrameCount = 128; 91 static const int maxSkipStepFrameCount = 128;
92 92
93 const char InspectorDebuggerAgent::backtraceObjectGroup[] = "backtrace"; 93 const char InspectorDebuggerAgent::backtraceObjectGroup[] = "backtrace";
94 94
95 const int InspectorDebuggerAgent::unknownAsyncOperationId = 0;
96
95 static String breakpointIdSuffix(InspectorDebuggerAgent::BreakpointSource source ) 97 static String breakpointIdSuffix(InspectorDebuggerAgent::BreakpointSource source )
96 { 98 {
97 switch (source) { 99 switch (source) {
98 case InspectorDebuggerAgent::UserBreakpointSource: 100 case InspectorDebuggerAgent::UserBreakpointSource:
99 break; 101 break;
100 case InspectorDebuggerAgent::DebugCommandBreakpointSource: 102 case InspectorDebuggerAgent::DebugCommandBreakpointSource:
101 return ":debug"; 103 return ":debug";
102 case InspectorDebuggerAgent::MonitorCommandBreakpointSource: 104 case InspectorDebuggerAgent::MonitorCommandBreakpointSource:
103 return ":monitor"; 105 return ":monitor";
104 } 106 }
(...skipping 18 matching lines...) Expand all
123 , m_pausingOnNativeEvent(false) 125 , m_pausingOnNativeEvent(false)
124 , m_inAsyncOperationForStepInto(false) 126 , m_inAsyncOperationForStepInto(false)
125 , m_listener(nullptr) 127 , m_listener(nullptr)
126 , m_skippedStepFrameCount(0) 128 , m_skippedStepFrameCount(0)
127 , m_recursionLevelForStepOut(0) 129 , m_recursionLevelForStepOut(0)
128 , m_recursionLevelForStepFrame(0) 130 , m_recursionLevelForStepFrame(0)
129 , m_skipAllPauses(false) 131 , m_skipAllPauses(false)
130 , m_skipContentScripts(false) 132 , m_skipContentScripts(false)
131 , m_cachedSkipStackGeneration(0) 133 , m_cachedSkipStackGeneration(0)
132 , m_promiseTracker(PromiseTracker::create()) 134 , m_promiseTracker(PromiseTracker::create())
135 , m_lastAsyncOperationId(1)
aandrey 2015/01/21 08:39:45 1 -> 0
yurys 2015/01/21 08:50:04 Done.
133 , m_maxAsyncCallStackDepth(0) 136 , m_maxAsyncCallStackDepth(0)
134 , m_currentAsyncCallChain(nullptr) 137 , m_currentAsyncCallChain(nullptr)
135 , m_nestedAsyncCallCount(0) 138 , m_nestedAsyncCallCount(0)
136 , m_performingAsyncStepIn(false) 139 , m_performingAsyncStepIn(false)
137 { 140 {
138 m_v8AsyncCallTracker = V8AsyncCallTracker::create(this); 141 m_v8AsyncCallTracker = V8AsyncCallTracker::create(this);
139 } 142 }
140 143
141 InspectorDebuggerAgent::~InspectorDebuggerAgent() 144 InspectorDebuggerAgent::~InspectorDebuggerAgent()
142 { 145 {
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } 1057 }
1055 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(v alue.scriptState()); 1058 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(v alue.scriptState());
1056 promise = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); 1059 promise = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
1057 } 1060 }
1058 1061
1059 const AsyncCallChain* InspectorDebuggerAgent::currentAsyncCallChain() const 1062 const AsyncCallChain* InspectorDebuggerAgent::currentAsyncCallChain() const
1060 { 1063 {
1061 return m_currentAsyncCallChain.get(); 1064 return m_currentAsyncCallChain.get();
1062 } 1065 }
1063 1066
1064 PassRefPtrWillBeRawPtr<AsyncCallChain> InspectorDebuggerAgent::traceAsyncOperati onStarting(const String& description) 1067 int InspectorDebuggerAgent::traceAsyncOperationStarting(const String& descriptio n)
1065 { 1068 {
1066 ScriptValue callFrames = scriptDebugServer().currentCallFramesForAsyncStack( ); 1069 ScriptValue callFrames = scriptDebugServer().currentCallFramesForAsyncStack( );
1070 RefPtrWillBeRawPtr<AsyncCallChain> chain;
aandrey 2015/01/21 08:39:45 = nullptr (otherwise Oilpan will complain)
yurys 2015/01/21 08:50:05 Done.
1067 if (callFrames.isEmpty()) { 1071 if (callFrames.isEmpty()) {
1068 if (!m_currentAsyncCallChain) 1072 if (m_currentAsyncCallChain)
1069 return nullptr; 1073 chain = AsyncCallChain::create(nullptr, m_currentAsyncCallChain.get( ), m_maxAsyncCallStackDepth);
1070 RefPtrWillBeRawPtr<AsyncCallChain> chain = AsyncCallChain::create(nullpt r, m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth); 1074 } else {
1071 didCreateAsyncCallChain(chain.get()); 1075 chain = AsyncCallChain::create(adoptRefWillBeNoop(new AsyncCallStack(des cription, callFrames)), m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth) ;
1072 return chain.release(); // Propagate async call stack chain.
1073 } 1076 }
1074 RefPtrWillBeRawPtr<AsyncCallChain> chain = AsyncCallChain::create(adoptRefWi llBeNoop(new AsyncCallStack(description, callFrames)), m_currentAsyncCallChain.g et(), m_maxAsyncCallStackDepth); 1077 while (true) {
aandrey 2015/01/21 08:39:45 nit: maybe do-while loop as it was in AsyncCallTra
yurys 2015/01/21 08:50:05 Done.
1075 didCreateAsyncCallChain(chain.get()); 1078 ++m_lastAsyncOperationId;
1076 return chain.release(); 1079 if (m_lastAsyncOperationId <= 0)
1077 } 1080 m_lastAsyncOperationId = 1;
1078 1081 if (!m_asyncOperations.contains(m_lastAsyncOperationId))
1079 void InspectorDebuggerAgent::didCreateAsyncCallChain(AsyncCallChain* chain) 1082 break;
1080 { 1083 }
1081 if (!m_performingAsyncStepIn) 1084 m_asyncOperations.set(m_lastAsyncOperationId, chain);
1082 return; 1085 if (m_performingAsyncStepIn) {
1083 if (m_inAsyncOperationForStepInto || m_asyncOperationsForStepInto.isEmpty()) 1086 if (m_inAsyncOperationForStepInto || m_asyncOperationsForStepInto.isEmpt y())
1084 m_asyncOperationsForStepInto.add(chain); 1087 m_asyncOperationsForStepInto.add(m_lastAsyncOperationId);
1088 }
1089 return m_lastAsyncOperationId;
1085 } 1090 }
1086 1091
1087 void InspectorDebuggerAgent::traceAsyncCallbackCompleted() 1092 void InspectorDebuggerAgent::traceAsyncCallbackCompleted()
1088 { 1093 {
1089 if (!m_nestedAsyncCallCount) 1094 if (!m_nestedAsyncCallCount)
1090 return; 1095 return;
1091 ASSERT(m_currentAsyncCallChain); 1096 ASSERT(m_currentAsyncCallChain);
1092 --m_nestedAsyncCallCount; 1097 --m_nestedAsyncCallCount;
1093 if (!m_nestedAsyncCallCount) { 1098 if (!m_nestedAsyncCallCount) {
1094 m_currentAsyncCallChain.clear(); 1099 m_currentAsyncCallChain.clear();
1095 if (!m_performingAsyncStepIn) 1100 if (!m_performingAsyncStepIn)
1096 return; 1101 return;
1097 if (!m_inAsyncOperationForStepInto) 1102 if (!m_inAsyncOperationForStepInto)
1098 return; 1103 return;
1099 m_inAsyncOperationForStepInto = false; 1104 m_inAsyncOperationForStepInto = false;
1100 m_scheduledDebuggerStep = NoStep; 1105 m_scheduledDebuggerStep = NoStep;
1101 scriptDebugServer().setPauseOnNextStatement(false); 1106 scriptDebugServer().setPauseOnNextStatement(false);
1102 if (m_asyncOperationsForStepInto.isEmpty()) 1107 if (m_asyncOperationsForStepInto.isEmpty())
1103 clearStepIntoAsync(); 1108 clearStepIntoAsync();
1104 } 1109 }
1105 } 1110 }
1106 1111
1107 void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, Pa ssRefPtrWillBeRawPtr<AsyncCallChain> chain) 1112 void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, in t operationId)
1108 { 1113 {
1114 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId);
1115 AsyncCallChain* chain = operationId > 0 ? m_asyncOperations.get(operationId) : nullptr;
1109 int recursionLevel = V8RecursionScope::recursionLevel(isolate); 1116 int recursionLevel = V8RecursionScope::recursionLevel(isolate);
1110 if (chain && (!recursionLevel || (recursionLevel == 1 && Microtask::performi ngCheckpoint(isolate)))) { 1117 if (chain && (!recursionLevel || (recursionLevel == 1 && Microtask::performi ngCheckpoint(isolate)))) {
1111 // Current AsyncCallChain corresponds to the bottommost JS call frame. 1118 // Current AsyncCallChain corresponds to the bottommost JS call frame.
1112 m_currentAsyncCallChain = chain; 1119 m_currentAsyncCallChain = chain;
1113 m_nestedAsyncCallCount = 1; 1120 m_nestedAsyncCallCount = 1;
1114 if (!m_performingAsyncStepIn) 1121 if (!m_performingAsyncStepIn)
1115 return; 1122 return;
1116 if (!m_asyncOperationsForStepInto.contains(m_currentAsyncCallChain.get() )) 1123 if (!m_asyncOperationsForStepInto.contains(operationId))
1117 return; 1124 return;
1118 m_inAsyncOperationForStepInto = true; 1125 m_inAsyncOperationForStepInto = true;
1119 m_scheduledDebuggerStep = StepInto; 1126 m_scheduledDebuggerStep = StepInto;
1120 m_skippedStepFrameCount = 0; 1127 m_skippedStepFrameCount = 0;
1121 m_recursionLevelForStepFrame = 0; 1128 m_recursionLevelForStepFrame = 0;
1122 scriptDebugServer().setPauseOnNextStatement(true); 1129 scriptDebugServer().setPauseOnNextStatement(true);
1123 } else { 1130 } else {
1124 if (m_currentAsyncCallChain) 1131 if (m_currentAsyncCallChain)
1125 ++m_nestedAsyncCallCount; 1132 ++m_nestedAsyncCallCount;
1126 } 1133 }
1127 } 1134 }
1128 1135
1129 void InspectorDebuggerAgent::traceAsyncOperationCompleted(AsyncCallChain* chain) 1136 void InspectorDebuggerAgent::traceAsyncOperationCompleted(int operationId)
1130 { 1137 {
1138 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId);
1131 if (!m_performingAsyncStepIn) 1139 if (!m_performingAsyncStepIn)
1132 return; 1140 return;
1133 m_asyncOperationsForStepInto.remove(chain); 1141 if (operationId > 0)
1142 m_asyncOperationsForStepInto.remove(operationId);
1134 if (!m_inAsyncOperationForStepInto && m_asyncOperationsForStepInto.isEmpty() ) 1143 if (!m_inAsyncOperationForStepInto && m_asyncOperationsForStepInto.isEmpty() )
1135 clearStepIntoAsync(); 1144 clearStepIntoAsync();
1136 } 1145 }
1137 1146
1138 void InspectorDebuggerAgent::resetAsyncCallTracker() 1147 void InspectorDebuggerAgent::resetAsyncCallTracker()
1139 { 1148 {
1140 m_currentAsyncCallChain.clear(); 1149 m_currentAsyncCallChain.clear();
1141 m_nestedAsyncCallCount = 0; 1150 m_nestedAsyncCallCount = 0;
1142 for (auto& listener: m_asyncCallTrackingListeners) 1151 for (auto& listener: m_asyncCallTrackingListeners)
1143 listener->resetAsyncCallChains(); 1152 listener->resetAsyncCallChains();
1153 m_asyncOperations.clear();
1144 } 1154 }
1145 1155
1146 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text) 1156 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text)
1147 { 1157 {
1148 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) { 1158 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) {
1149 RefPtr<JSONObject> directive = JSONObject::create(); 1159 RefPtr<JSONObject> directive = JSONObject::create();
1150 directive->setString("directiveText", directiveText); 1160 directive->setString("directiveText", directiveText);
1151 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release()); 1161 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release());
1152 } 1162 }
1153 } 1163 }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 visitor->trace(m_v8AsyncCallTracker); 1548 visitor->trace(m_v8AsyncCallTracker);
1539 visitor->trace(m_promiseTracker); 1549 visitor->trace(m_promiseTracker);
1540 visitor->trace(m_asyncOperationsForStepInto); 1550 visitor->trace(m_asyncOperationsForStepInto);
1541 visitor->trace(m_currentAsyncCallChain); 1551 visitor->trace(m_currentAsyncCallChain);
1542 visitor->trace(m_asyncCallTrackingListeners); 1552 visitor->trace(m_asyncCallTrackingListeners);
1543 #endif 1553 #endif
1544 InspectorBaseAgent::trace(visitor); 1554 InspectorBaseAgent::trace(visitor);
1545 } 1555 }
1546 1556
1547 } // namespace blink 1557 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDebuggerAgent.h ('k') | Source/core/inspector/V8AsyncCallTracker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698