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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 void V8Debugger::asyncTaskCanceledForStack(void* task) { | 906 void V8Debugger::asyncTaskCanceledForStack(void* task) { |
907 if (!m_maxAsyncCallStackDepth) return; | 907 if (!m_maxAsyncCallStackDepth) return; |
908 m_asyncTaskStacks.erase(task); | 908 m_asyncTaskStacks.erase(task); |
909 m_recurringTasks.erase(task); | 909 m_recurringTasks.erase(task); |
910 m_parentTask.erase(task); | 910 m_parentTask.erase(task); |
911 m_asyncTaskCreationStacks.erase(task); | 911 m_asyncTaskCreationStacks.erase(task); |
912 } | 912 } |
913 | 913 |
914 void V8Debugger::asyncTaskStartedForStack(void* task) { | 914 void V8Debugger::asyncTaskStartedForStack(void* task) { |
915 if (!m_maxAsyncCallStackDepth) return; | 915 if (!m_maxAsyncCallStackDepth) return; |
916 m_currentTasks.push_back(task); | |
917 auto parentIt = m_parentTask.find(task); | |
918 AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find( | |
919 parentIt == m_parentTask.end() ? task : parentIt->second); | |
920 // Needs to support following order of events: | 916 // Needs to support following order of events: |
921 // - asyncTaskScheduled | 917 // - asyncTaskScheduled |
922 // <-- attached here --> | 918 // <-- attached here --> |
923 // - asyncTaskStarted | 919 // - asyncTaskStarted |
924 // - asyncTaskCanceled <-- canceled before finished | 920 // - asyncTaskCanceled <-- canceled before finished |
925 // <-- async stack requested here --> | 921 // <-- async stack requested here --> |
926 // - asyncTaskFinished | 922 // - asyncTaskFinished |
927 std::weak_ptr<AsyncStackTrace> asyncParent; | 923 m_currentTasks.push_back(task); |
928 if (stackIt != m_asyncTaskStacks.end()) asyncParent = stackIt->second; | 924 auto parentIt = m_parentTask.find(task); |
| 925 AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find( |
| 926 parentIt == m_parentTask.end() ? task : parentIt->second); |
| 927 if (stackIt != m_asyncTaskStacks.end()) { |
| 928 m_currentAsyncParent.push_back(stackIt->second.lock()); |
| 929 } else { |
| 930 m_currentAsyncParent.emplace_back(); |
| 931 } |
929 auto itCreation = m_asyncTaskCreationStacks.find(task); | 932 auto itCreation = m_asyncTaskCreationStacks.find(task); |
930 if (asyncParent.lock() && itCreation != m_asyncTaskCreationStacks.end()) { | 933 if (itCreation != m_asyncTaskCreationStacks.end()) { |
931 m_currentAsyncCreation.push_back(itCreation->second.lock()); | 934 m_currentAsyncCreation.push_back(itCreation->second.lock()); |
932 } else { | 935 } else { |
933 m_currentAsyncCreation.emplace_back(); | 936 m_currentAsyncCreation.emplace_back(); |
934 } | 937 } |
935 m_currentAsyncParent.push_back(asyncParent.lock()); | |
936 } | 938 } |
937 | 939 |
938 void V8Debugger::asyncTaskFinishedForStack(void* task) { | 940 void V8Debugger::asyncTaskFinishedForStack(void* task) { |
939 if (!m_maxAsyncCallStackDepth) return; | 941 if (!m_maxAsyncCallStackDepth) return; |
940 // We could start instrumenting half way and the stack is empty. | 942 // We could start instrumenting half way and the stack is empty. |
941 if (!m_currentTasks.size()) return; | 943 if (!m_currentTasks.size()) return; |
942 DCHECK(m_currentTasks.back() == task); | 944 DCHECK(m_currentTasks.back() == task); |
943 m_currentTasks.pop_back(); | 945 m_currentTasks.pop_back(); |
944 | 946 |
945 DCHECK(m_currentAsyncParent.size() == m_currentAsyncCreation.size()); | 947 DCHECK(m_currentAsyncParent.size() == m_currentAsyncCreation.size()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 cleanupExpiredWeakPointers(m_asyncTaskCreationStacks); | 1036 cleanupExpiredWeakPointers(m_asyncTaskCreationStacks); |
1035 for (auto it = m_recurringTasks.begin(); it != m_recurringTasks.end();) { | 1037 for (auto it = m_recurringTasks.begin(); it != m_recurringTasks.end();) { |
1036 if (m_asyncTaskStacks.find(*it) == m_asyncTaskStacks.end()) { | 1038 if (m_asyncTaskStacks.find(*it) == m_asyncTaskStacks.end()) { |
1037 it = m_recurringTasks.erase(it); | 1039 it = m_recurringTasks.erase(it); |
1038 } else { | 1040 } else { |
1039 ++it; | 1041 ++it; |
1040 } | 1042 } |
1041 } | 1043 } |
1042 for (auto it = m_parentTask.begin(); it != m_parentTask.end();) { | 1044 for (auto it = m_parentTask.begin(); it != m_parentTask.end();) { |
1043 if (m_asyncTaskCreationStacks.find(it->second) == | 1045 if (m_asyncTaskCreationStacks.find(it->second) == |
1044 m_asyncTaskCreationStacks.end()) { | 1046 m_asyncTaskCreationStacks.end() && |
| 1047 m_asyncTaskStacks.find(it->second) == m_asyncTaskStacks.end()) { |
1045 it = m_parentTask.erase(it); | 1048 it = m_parentTask.erase(it); |
1046 } else { | 1049 } else { |
1047 ++it; | 1050 ++it; |
1048 } | 1051 } |
1049 } | 1052 } |
1050 cleanupExpiredWeakPointers(m_framesCache); | 1053 cleanupExpiredWeakPointers(m_framesCache); |
1051 } | 1054 } |
1052 | 1055 |
1053 std::shared_ptr<StackFrame> V8Debugger::symbolize( | 1056 std::shared_ptr<StackFrame> V8Debugger::symbolize( |
1054 v8::Local<v8::StackFrame> v8Frame) { | 1057 v8::Local<v8::StackFrame> v8Frame) { |
(...skipping 24 matching lines...) Expand all Loading... |
1079 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); | 1082 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); |
1080 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); | 1083 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); |
1081 fprintf(stdout, "Created async tasks: %zu\n", | 1084 fprintf(stdout, "Created async tasks: %zu\n", |
1082 m_asyncTaskCreationStacks.size()); | 1085 m_asyncTaskCreationStacks.size()); |
1083 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); | 1086 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); |
1084 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); | 1087 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); |
1085 fprintf(stdout, "\n"); | 1088 fprintf(stdout, "\n"); |
1086 } | 1089 } |
1087 | 1090 |
1088 } // namespace v8_inspector | 1091 } // namespace v8_inspector |
OLD | NEW |