Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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(0) | |
| 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 Loading... | |
| 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 = nullptr; | |
| 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 do { |
| 1075 didCreateAsyncCallChain(chain.get()); | 1078 ++m_lastAsyncOperationId; |
| 1076 return chain.release(); | 1079 if (m_lastAsyncOperationId <= 0) |
| 1077 } | 1080 m_lastAsyncOperationId = 1; |
| 1078 | 1081 } while (m_asyncOperations.contains(m_lastAsyncOperationId)); |
| 1079 void InspectorDebuggerAgent::didCreateAsyncCallChain(AsyncCallChain* chain) | 1082 m_asyncOperations.set(m_lastAsyncOperationId, chain); |
|
aandrey
2015/01/21 12:51:27
there should be corresponding m_asyncOperations.re
yurys
2015/01/21 13:05:22
Good catch, thank you! Please take a look at the f
| |
| 1080 { | 1083 if (m_performingAsyncStepIn) { |
| 1081 if (!m_performingAsyncStepIn) | 1084 if (m_inAsyncOperationForStepInto || m_asyncOperationsForStepInto.isEmpt y()) |
| 1082 return; | 1085 m_asyncOperationsForStepInto.add(m_lastAsyncOperationId); |
| 1083 if (m_inAsyncOperationForStepInto || m_asyncOperationsForStepInto.isEmpty()) | 1086 } |
| 1084 m_asyncOperationsForStepInto.add(chain); | 1087 return m_lastAsyncOperationId; |
| 1085 } | 1088 } |
| 1086 | 1089 |
| 1087 void InspectorDebuggerAgent::traceAsyncCallbackCompleted() | 1090 void InspectorDebuggerAgent::traceAsyncCallbackCompleted() |
| 1088 { | 1091 { |
| 1089 if (!m_nestedAsyncCallCount) | 1092 if (!m_nestedAsyncCallCount) |
| 1090 return; | 1093 return; |
| 1091 ASSERT(m_currentAsyncCallChain); | 1094 ASSERT(m_currentAsyncCallChain); |
| 1092 --m_nestedAsyncCallCount; | 1095 --m_nestedAsyncCallCount; |
| 1093 if (!m_nestedAsyncCallCount) { | 1096 if (!m_nestedAsyncCallCount) { |
| 1094 m_currentAsyncCallChain.clear(); | 1097 m_currentAsyncCallChain.clear(); |
| 1095 if (!m_performingAsyncStepIn) | 1098 if (!m_performingAsyncStepIn) |
| 1096 return; | 1099 return; |
| 1097 if (!m_inAsyncOperationForStepInto) | 1100 if (!m_inAsyncOperationForStepInto) |
| 1098 return; | 1101 return; |
| 1099 m_inAsyncOperationForStepInto = false; | 1102 m_inAsyncOperationForStepInto = false; |
| 1100 m_scheduledDebuggerStep = NoStep; | 1103 m_scheduledDebuggerStep = NoStep; |
| 1101 scriptDebugServer().setPauseOnNextStatement(false); | 1104 scriptDebugServer().setPauseOnNextStatement(false); |
| 1102 if (m_asyncOperationsForStepInto.isEmpty()) | 1105 if (m_asyncOperationsForStepInto.isEmpty()) |
| 1103 clearStepIntoAsync(); | 1106 clearStepIntoAsync(); |
| 1104 } | 1107 } |
| 1105 } | 1108 } |
| 1106 | 1109 |
| 1107 void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, Pa ssRefPtrWillBeRawPtr<AsyncCallChain> chain) | 1110 void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, in t operationId) |
| 1108 { | 1111 { |
| 1112 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId); | |
| 1113 AsyncCallChain* chain = operationId > 0 ? m_asyncOperations.get(operationId) : nullptr; | |
| 1109 int recursionLevel = V8RecursionScope::recursionLevel(isolate); | 1114 int recursionLevel = V8RecursionScope::recursionLevel(isolate); |
| 1110 if (chain && (!recursionLevel || (recursionLevel == 1 && Microtask::performi ngCheckpoint(isolate)))) { | 1115 if (chain && (!recursionLevel || (recursionLevel == 1 && Microtask::performi ngCheckpoint(isolate)))) { |
| 1111 // Current AsyncCallChain corresponds to the bottommost JS call frame. | 1116 // Current AsyncCallChain corresponds to the bottommost JS call frame. |
| 1112 m_currentAsyncCallChain = chain; | 1117 m_currentAsyncCallChain = chain; |
| 1113 m_nestedAsyncCallCount = 1; | 1118 m_nestedAsyncCallCount = 1; |
| 1114 if (!m_performingAsyncStepIn) | 1119 if (!m_performingAsyncStepIn) |
| 1115 return; | 1120 return; |
| 1116 if (!m_asyncOperationsForStepInto.contains(m_currentAsyncCallChain.get() )) | 1121 if (!m_asyncOperationsForStepInto.contains(operationId)) |
| 1117 return; | 1122 return; |
| 1118 m_inAsyncOperationForStepInto = true; | 1123 m_inAsyncOperationForStepInto = true; |
| 1119 m_scheduledDebuggerStep = StepInto; | 1124 m_scheduledDebuggerStep = StepInto; |
| 1120 m_skippedStepFrameCount = 0; | 1125 m_skippedStepFrameCount = 0; |
| 1121 m_recursionLevelForStepFrame = 0; | 1126 m_recursionLevelForStepFrame = 0; |
| 1122 scriptDebugServer().setPauseOnNextStatement(true); | 1127 scriptDebugServer().setPauseOnNextStatement(true); |
| 1123 } else { | 1128 } else { |
| 1124 if (m_currentAsyncCallChain) | 1129 if (m_currentAsyncCallChain) |
| 1125 ++m_nestedAsyncCallCount; | 1130 ++m_nestedAsyncCallCount; |
| 1126 } | 1131 } |
| 1127 } | 1132 } |
| 1128 | 1133 |
| 1129 void InspectorDebuggerAgent::traceAsyncOperationCompleted(AsyncCallChain* chain) | 1134 void InspectorDebuggerAgent::traceAsyncOperationCompleted(int operationId) |
| 1130 { | 1135 { |
| 1136 ASSERT(operationId > 0 || operationId == unknownAsyncOperationId); | |
| 1131 if (!m_performingAsyncStepIn) | 1137 if (!m_performingAsyncStepIn) |
| 1132 return; | 1138 return; |
| 1133 m_asyncOperationsForStepInto.remove(chain); | 1139 if (operationId > 0) |
| 1140 m_asyncOperationsForStepInto.remove(operationId); | |
| 1134 if (!m_inAsyncOperationForStepInto && m_asyncOperationsForStepInto.isEmpty() ) | 1141 if (!m_inAsyncOperationForStepInto && m_asyncOperationsForStepInto.isEmpty() ) |
| 1135 clearStepIntoAsync(); | 1142 clearStepIntoAsync(); |
| 1136 } | 1143 } |
| 1137 | 1144 |
| 1138 void InspectorDebuggerAgent::resetAsyncCallTracker() | 1145 void InspectorDebuggerAgent::resetAsyncCallTracker() |
| 1139 { | 1146 { |
| 1140 m_currentAsyncCallChain.clear(); | 1147 m_currentAsyncCallChain.clear(); |
| 1141 m_nestedAsyncCallCount = 0; | 1148 m_nestedAsyncCallCount = 0; |
| 1142 for (auto& listener: m_asyncCallTrackingListeners) | 1149 for (auto& listener: m_asyncCallTrackingListeners) |
| 1143 listener->resetAsyncCallChains(); | 1150 listener->resetAsyncCallChains(); |
| 1151 m_asyncOperations.clear(); | |
| 1144 } | 1152 } |
| 1145 | 1153 |
| 1146 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text) | 1154 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text) |
| 1147 { | 1155 { |
| 1148 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) { | 1156 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) { |
| 1149 RefPtr<JSONObject> directive = JSONObject::create(); | 1157 RefPtr<JSONObject> directive = JSONObject::create(); |
| 1150 directive->setString("directiveText", directiveText); | 1158 directive->setString("directiveText", directiveText); |
| 1151 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release()); | 1159 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release()); |
| 1152 } | 1160 } |
| 1153 } | 1161 } |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1538 visitor->trace(m_v8AsyncCallTracker); | 1546 visitor->trace(m_v8AsyncCallTracker); |
| 1539 visitor->trace(m_promiseTracker); | 1547 visitor->trace(m_promiseTracker); |
| 1540 visitor->trace(m_asyncOperationsForStepInto); | 1548 visitor->trace(m_asyncOperationsForStepInto); |
| 1541 visitor->trace(m_currentAsyncCallChain); | 1549 visitor->trace(m_currentAsyncCallChain); |
| 1542 visitor->trace(m_asyncCallTrackingListeners); | 1550 visitor->trace(m_asyncCallTrackingListeners); |
| 1543 #endif | 1551 #endif |
| 1544 InspectorBaseAgent::trace(visitor); | 1552 InspectorBaseAgent::trace(visitor); |
| 1545 } | 1553 } |
| 1546 | 1554 |
| 1547 } // namespace blink | 1555 } // namespace blink |
| OLD | NEW |