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

Side by Side Diff: src/inspector/v8-debugger.cc

Issue 2868493002: [inspector] use creation stack trace as parent for async call chains (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | src/inspector/v8-stack-trace-impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 asyncTaskStartedForStepping(task); 676 asyncTaskStartedForStepping(task);
677 break; 677 break;
678 case v8::debug::kDebugDidHandle: 678 case v8::debug::kDebugDidHandle:
679 asyncTaskFinishedForStack(task); 679 asyncTaskFinishedForStack(task);
680 asyncTaskFinishedForStepping(task); 680 asyncTaskFinishedForStepping(task);
681 break; 681 break;
682 } 682 }
683 } 683 }
684 684
685 std::shared_ptr<AsyncStackTrace> V8Debugger::currentAsyncParent() { 685 std::shared_ptr<AsyncStackTrace> V8Debugger::currentAsyncParent() {
686 // TODO(kozyatinskiy): implement creation chain as parent without hack.
687 if (!m_currentAsyncCreation.empty() && m_currentAsyncCreation.back()) {
688 return m_currentAsyncCreation.back();
689 }
686 return m_currentAsyncParent.empty() ? nullptr : m_currentAsyncParent.back(); 690 return m_currentAsyncParent.empty() ? nullptr : m_currentAsyncParent.back();
687 } 691 }
688 692
689 std::shared_ptr<AsyncStackTrace> V8Debugger::currentAsyncCreation() { 693 std::shared_ptr<AsyncStackTrace> V8Debugger::currentAsyncCreation() {
690 return m_currentAsyncCreation.empty() ? nullptr 694 return nullptr;
691 : m_currentAsyncCreation.back();
692 } 695 }
693 696
694 void V8Debugger::compileDebuggerScript() { 697 void V8Debugger::compileDebuggerScript() {
695 if (!m_debuggerScript.IsEmpty()) { 698 if (!m_debuggerScript.IsEmpty()) {
696 UNREACHABLE(); 699 UNREACHABLE();
697 return; 700 return;
698 } 701 }
699 702
700 v8::HandleScope scope(m_isolate); 703 v8::HandleScope scope(m_isolate);
701 v8::Context::Scope contextScope(debuggerContext()); 704 v8::Context::Scope contextScope(debuggerContext());
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) return; 852 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) return;
850 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; 853 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth;
851 if (!maxAsyncCallStackDepth) allAsyncTasksCanceled(); 854 if (!maxAsyncCallStackDepth) allAsyncTasksCanceled();
852 } 855 }
853 856
854 void V8Debugger::asyncTaskCreatedForStack(void* task, void* parentTask) { 857 void V8Debugger::asyncTaskCreatedForStack(void* task, void* parentTask) {
855 if (!m_maxAsyncCallStackDepth) return; 858 if (!m_maxAsyncCallStackDepth) return;
856 if (parentTask) m_parentTask[task] = parentTask; 859 if (parentTask) m_parentTask[task] = parentTask;
857 v8::HandleScope scope(m_isolate); 860 v8::HandleScope scope(m_isolate);
858 std::shared_ptr<AsyncStackTrace> asyncCreation = 861 std::shared_ptr<AsyncStackTrace> asyncCreation =
859 AsyncStackTrace::capture(this, currentContextGroupId(), String16(), 1); 862 AsyncStackTrace::capture(this, currentContextGroupId(), String16(),
863 V8StackTraceImpl::maxCallStackSizeToCapture);
860 // Passing one as maxStackSize forces no async chain for the new stack. 864 // Passing one as maxStackSize forces no async chain for the new stack.
861 if (asyncCreation && !asyncCreation->isEmpty()) { 865 if (asyncCreation && !asyncCreation->isEmpty()) {
862 m_asyncTaskCreationStacks[task] = asyncCreation; 866 m_asyncTaskCreationStacks[task] = asyncCreation;
863 m_allAsyncStacks.push_back(std::move(asyncCreation)); 867 m_allAsyncStacks.push_back(std::move(asyncCreation));
864 ++m_asyncStacksCount; 868 ++m_asyncStacksCount;
865 collectOldAsyncStacksIfNeeded(); 869 collectOldAsyncStacksIfNeeded();
866 } 870 }
867 } 871 }
868 872
869 void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task, 873 void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find( 929 AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find(
926 parentIt == m_parentTask.end() ? task : parentIt->second); 930 parentIt == m_parentTask.end() ? task : parentIt->second);
927 if (stackIt != m_asyncTaskStacks.end()) { 931 if (stackIt != m_asyncTaskStacks.end()) {
928 m_currentAsyncParent.push_back(stackIt->second.lock()); 932 m_currentAsyncParent.push_back(stackIt->second.lock());
929 } else { 933 } else {
930 m_currentAsyncParent.emplace_back(); 934 m_currentAsyncParent.emplace_back();
931 } 935 }
932 auto itCreation = m_asyncTaskCreationStacks.find(task); 936 auto itCreation = m_asyncTaskCreationStacks.find(task);
933 if (itCreation != m_asyncTaskCreationStacks.end()) { 937 if (itCreation != m_asyncTaskCreationStacks.end()) {
934 m_currentAsyncCreation.push_back(itCreation->second.lock()); 938 m_currentAsyncCreation.push_back(itCreation->second.lock());
939 // TODO(kozyatinskiy): implement it without hack.
940 if (m_currentAsyncParent.back()) {
941 m_currentAsyncCreation.back()->setDescription(
942 m_currentAsyncParent.back()->description());
dgozman 2017/05/05 23:24:31 Also clear m_currentAsyncParent.back().
kozy 2017/05/09 06:29:13 Done.
943 }
935 } else { 944 } else {
936 m_currentAsyncCreation.emplace_back(); 945 m_currentAsyncCreation.emplace_back();
937 } 946 }
938 } 947 }
939 948
940 void V8Debugger::asyncTaskFinishedForStack(void* task) { 949 void V8Debugger::asyncTaskFinishedForStack(void* task) {
941 if (!m_maxAsyncCallStackDepth) return; 950 if (!m_maxAsyncCallStackDepth) return;
942 // We could start instrumenting half way and the stack is empty. 951 // We could start instrumenting half way and the stack is empty.
943 if (!m_currentTasks.size()) return; 952 if (!m_currentTasks.size()) return;
944 DCHECK(m_currentTasks.back() == task); 953 DCHECK(m_currentTasks.back() == task);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); 1091 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount);
1083 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); 1092 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size());
1084 fprintf(stdout, "Created async tasks: %zu\n", 1093 fprintf(stdout, "Created async tasks: %zu\n",
1085 m_asyncTaskCreationStacks.size()); 1094 m_asyncTaskCreationStacks.size());
1086 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); 1095 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size());
1087 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); 1096 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size());
1088 fprintf(stdout, "\n"); 1097 fprintf(stdout, "\n");
1089 } 1098 }
1090 1099
1091 } // namespace v8_inspector 1100 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « no previous file | src/inspector/v8-stack-trace-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698