OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 "src/inspector/v8-debugger.h" | 5 #include "src/inspector/v8-debugger.h" |
6 | 6 |
7 #include "src/inspector/debugger-script.h" | 7 #include "src/inspector/debugger-script.h" |
8 #include "src/inspector/inspected-context.h" | 8 #include "src/inspector/inspected-context.h" |
9 #include "src/inspector/protocol/Protocol.h" | 9 #include "src/inspector/protocol/Protocol.h" |
10 #include "src/inspector/script-breakpoint.h" | 10 #include "src/inspector/script-breakpoint.h" |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 | 972 |
973 void V8Debugger::allAsyncTasksCanceled() { | 973 void V8Debugger::allAsyncTasksCanceled() { |
974 m_asyncTaskStacks.clear(); | 974 m_asyncTaskStacks.clear(); |
975 m_recurringTasks.clear(); | 975 m_recurringTasks.clear(); |
976 m_currentAsyncParent.clear(); | 976 m_currentAsyncParent.clear(); |
977 m_currentAsyncCreation.clear(); | 977 m_currentAsyncCreation.clear(); |
978 m_currentTasks.clear(); | 978 m_currentTasks.clear(); |
979 m_parentTask.clear(); | 979 m_parentTask.clear(); |
980 m_asyncTaskCreationStacks.clear(); | 980 m_asyncTaskCreationStacks.clear(); |
981 | 981 |
982 m_framesCache.clear(); | |
982 m_allAsyncStacks.clear(); | 983 m_allAsyncStacks.clear(); |
983 m_asyncStacksCount = 0; | 984 m_asyncStacksCount = 0; |
984 } | 985 } |
985 | 986 |
986 void V8Debugger::muteScriptParsedEvents() { | 987 void V8Debugger::muteScriptParsedEvents() { |
987 ++m_ignoreScriptParsedEventsCounter; | 988 ++m_ignoreScriptParsedEventsCounter; |
988 } | 989 } |
989 | 990 |
990 void V8Debugger::unmuteScriptParsedEvents() { | 991 void V8Debugger::unmuteScriptParsedEvents() { |
991 --m_ignoreScriptParsedEventsCounter; | 992 --m_ignoreScriptParsedEventsCounter; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1029 } | 1030 } |
1030 m_recurringTasks.swap(recurringLeft); | 1031 m_recurringTasks.swap(recurringLeft); |
1031 protocol::HashMap<void*, void*> parentLeft; | 1032 protocol::HashMap<void*, void*> parentLeft; |
1032 for (auto it : m_parentTask) { | 1033 for (auto it : m_parentTask) { |
1033 if (m_asyncTaskCreationStacks.find(it.second) == m_asyncTaskStacks.end()) { | 1034 if (m_asyncTaskCreationStacks.find(it.second) == m_asyncTaskStacks.end()) { |
1034 continue; | 1035 continue; |
1035 } | 1036 } |
1036 parentLeft.insert(it); | 1037 parentLeft.insert(it); |
1037 } | 1038 } |
1038 m_parentTask.swap(parentLeft); | 1039 m_parentTask.swap(parentLeft); |
1040 std::map<int, std::weak_ptr<StackFrame>> framesCache; | |
1041 for (auto it : m_framesCache) { | |
1042 if (!it.second.expired()) framesCache.insert(it); | |
1043 } | |
1044 m_framesCache.swap(framesCache); | |
1039 } | 1045 } |
1040 | 1046 |
1041 void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) { | 1047 void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) { |
1042 AsyncTaskToStackTrace cleanCopy; | 1048 AsyncTaskToStackTrace cleanCopy; |
1043 for (auto it : map) { | 1049 for (auto it : map) { |
1044 if (!it.second.expired()) cleanCopy.insert(it); | 1050 if (!it.second.expired()) cleanCopy.insert(it); |
1045 } | 1051 } |
1046 map.swap(cleanCopy); | 1052 map.swap(cleanCopy); |
1047 } | 1053 } |
1048 | 1054 |
1055 std::shared_ptr<StackFrame> V8Debugger::symbolize( | |
1056 v8::Local<v8::StackFrame> v8Frame) { | |
1057 auto it = m_framesCache.end(); | |
1058 int frameId = 0; | |
1059 if (m_maxAsyncCallStackDepth) { | |
dgozman
2017/04/20 16:38:21
Choose one...
kozy
2017/04/20 17:05:37
Done.
| |
1060 frameId = v8::debug::GetStackFrameId(v8Frame); | |
1061 it = m_framesCache.find(frameId); | |
1062 } | |
1063 if (it != m_framesCache.end()) return it->second.lock(); | |
dgozman
2017/04/20 16:38:21
This can return empty shared_ptr.
kozy
2017/04/20 17:05:37
Done.
| |
1064 std::shared_ptr<StackFrame> frame(new StackFrame(v8Frame)); | |
1065 // TODO(clemensh): Figure out a way to do this translation only right before | |
1066 // sending the stack trace over wire. | |
1067 if (v8Frame->IsWasm()) frame->translate(&m_wasmTranslation); | |
1068 if (m_maxAsyncCallStacks) { | |
dgozman
2017/04/20 16:38:21
...or another.
kozy
2017/04/20 17:05:37
Done.
| |
1069 m_framesCache[frameId] = frame; | |
1070 } | |
1071 return frame; | |
1072 } | |
1073 | |
1049 void V8Debugger::setMaxAsyncTaskStacksForTest(int limit) { | 1074 void V8Debugger::setMaxAsyncTaskStacksForTest(int limit) { |
1050 m_maxAsyncCallStacks = 0; | 1075 m_maxAsyncCallStacks = 0; |
1051 collectOldAsyncStacksIfNeeded(); | 1076 collectOldAsyncStacksIfNeeded(); |
1052 m_maxAsyncCallStacks = limit; | 1077 m_maxAsyncCallStacks = limit; |
1053 } | 1078 } |
1054 | 1079 |
1055 } // namespace v8_inspector | 1080 } // namespace v8_inspector |
OLD | NEW |