| 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 asyncTaskFinishedForStepping(task); | 679 asyncTaskFinishedForStepping(task); |
| 680 break; | 680 break; |
| 681 } | 681 } |
| 682 } | 682 } |
| 683 | 683 |
| 684 V8StackTraceImpl* V8Debugger::currentAsyncCallChain() { | 684 V8StackTraceImpl* V8Debugger::currentAsyncCallChain() { |
| 685 if (!m_currentStacks.size()) return nullptr; | 685 if (!m_currentStacks.size()) return nullptr; |
| 686 return m_currentStacks.back().get(); | 686 return m_currentStacks.back().get(); |
| 687 } | 687 } |
| 688 | 688 |
| 689 V8StackTraceImpl* V8Debugger::currentAsyncTaskCreationStack() { |
| 690 if (!m_currentCreationStacks.size()) return nullptr; |
| 691 return m_currentCreationStacks.back().get(); |
| 692 } |
| 693 |
| 689 void V8Debugger::compileDebuggerScript() { | 694 void V8Debugger::compileDebuggerScript() { |
| 690 if (!m_debuggerScript.IsEmpty()) { | 695 if (!m_debuggerScript.IsEmpty()) { |
| 691 UNREACHABLE(); | 696 UNREACHABLE(); |
| 692 return; | 697 return; |
| 693 } | 698 } |
| 694 | 699 |
| 695 v8::HandleScope scope(m_isolate); | 700 v8::HandleScope scope(m_isolate); |
| 696 v8::Context::Scope contextScope(debuggerContext()); | 701 v8::Context::Scope contextScope(debuggerContext()); |
| 697 | 702 |
| 698 v8::Local<v8::String> scriptValue = | 703 v8::Local<v8::String> scriptValue = |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 // <-- attached here --> | 937 // <-- attached here --> |
| 933 // - asyncTaskStarted | 938 // - asyncTaskStarted |
| 934 // - asyncTaskCanceled <-- canceled before finished | 939 // - asyncTaskCanceled <-- canceled before finished |
| 935 // <-- async stack requested here --> | 940 // <-- async stack requested here --> |
| 936 // - asyncTaskFinished | 941 // - asyncTaskFinished |
| 937 std::unique_ptr<V8StackTraceImpl> stack; | 942 std::unique_ptr<V8StackTraceImpl> stack; |
| 938 if (stackIt != m_asyncTaskStacks.end() && stackIt->second) | 943 if (stackIt != m_asyncTaskStacks.end() && stackIt->second) |
| 939 stack = stackIt->second->cloneImpl(); | 944 stack = stackIt->second->cloneImpl(); |
| 940 auto itCreation = m_asyncTaskCreationStacks.find(task); | 945 auto itCreation = m_asyncTaskCreationStacks.find(task); |
| 941 if (stack && itCreation != m_asyncTaskCreationStacks.end()) { | 946 if (stack && itCreation != m_asyncTaskCreationStacks.end()) { |
| 942 stack->setCreation(itCreation->second->cloneImpl()); | 947 m_currentCreationStacks.push_back(itCreation->second->cloneImpl()); |
| 948 } else { |
| 949 m_currentCreationStacks.push_back(nullptr); |
| 943 } | 950 } |
| 944 m_currentStacks.push_back(std::move(stack)); | 951 m_currentStacks.push_back(std::move(stack)); |
| 945 } | 952 } |
| 946 | 953 |
| 947 void V8Debugger::asyncTaskFinishedForStack(void* task) { | 954 void V8Debugger::asyncTaskFinishedForStack(void* task) { |
| 948 if (!m_maxAsyncCallStackDepth) return; | 955 if (!m_maxAsyncCallStackDepth) return; |
| 949 // We could start instrumenting half way and the stack is empty. | 956 // We could start instrumenting half way and the stack is empty. |
| 950 if (!m_currentStacks.size()) return; | 957 if (!m_currentStacks.size()) return; |
| 951 | |
| 952 DCHECK(m_currentTasks.back() == task); | 958 DCHECK(m_currentTasks.back() == task); |
| 953 m_currentTasks.pop_back(); | 959 m_currentTasks.pop_back(); |
| 954 | 960 |
| 961 DCHECK(m_currentStacks.size() == m_currentCreationStacks.size()); |
| 955 m_currentStacks.pop_back(); | 962 m_currentStacks.pop_back(); |
| 963 m_currentCreationStacks.pop_back(); |
| 956 if (m_recurringTasks.find(task) == m_recurringTasks.end()) { | 964 if (m_recurringTasks.find(task) == m_recurringTasks.end()) { |
| 957 asyncTaskCanceledForStack(task); | 965 asyncTaskCanceledForStack(task); |
| 958 } | 966 } |
| 959 } | 967 } |
| 960 | 968 |
| 961 void V8Debugger::asyncTaskCandidateForStepping(void* task) { | 969 void V8Debugger::asyncTaskCandidateForStepping(void* task) { |
| 962 if (!m_stepIntoAsyncCallback) return; | 970 if (!m_stepIntoAsyncCallback) return; |
| 963 DCHECK(m_targetContextGroupId); | 971 DCHECK(m_targetContextGroupId); |
| 964 if (currentContextGroupId() != m_targetContextGroupId) return; | 972 if (currentContextGroupId() != m_targetContextGroupId) return; |
| 965 m_taskWithScheduledBreak = task; | 973 m_taskWithScheduledBreak = task; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 983 | 991 |
| 984 void V8Debugger::asyncTaskCanceledForStepping(void* task) { | 992 void V8Debugger::asyncTaskCanceledForStepping(void* task) { |
| 985 if (task != m_taskWithScheduledBreak) return; | 993 if (task != m_taskWithScheduledBreak) return; |
| 986 m_taskWithScheduledBreak = nullptr; | 994 m_taskWithScheduledBreak = nullptr; |
| 987 } | 995 } |
| 988 | 996 |
| 989 void V8Debugger::allAsyncTasksCanceled() { | 997 void V8Debugger::allAsyncTasksCanceled() { |
| 990 m_asyncTaskStacks.clear(); | 998 m_asyncTaskStacks.clear(); |
| 991 m_recurringTasks.clear(); | 999 m_recurringTasks.clear(); |
| 992 m_currentStacks.clear(); | 1000 m_currentStacks.clear(); |
| 1001 m_currentCreationStacks.clear(); |
| 993 m_currentTasks.clear(); | 1002 m_currentTasks.clear(); |
| 994 m_parentTask.clear(); | 1003 m_parentTask.clear(); |
| 995 m_asyncTaskCreationStacks.clear(); | 1004 m_asyncTaskCreationStacks.clear(); |
| 996 m_idToTask.clear(); | 1005 m_idToTask.clear(); |
| 997 m_taskToId.clear(); | 1006 m_taskToId.clear(); |
| 998 m_lastTaskId = 0; | 1007 m_lastTaskId = 0; |
| 999 } | 1008 } |
| 1000 | 1009 |
| 1001 void V8Debugger::muteScriptParsedEvents() { | 1010 void V8Debugger::muteScriptParsedEvents() { |
| 1002 ++m_ignoreScriptParsedEventsCounter; | 1011 ++m_ignoreScriptParsedEventsCounter; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1022 | 1031 |
| 1023 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 1032 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 1024 } | 1033 } |
| 1025 | 1034 |
| 1026 int V8Debugger::currentContextGroupId() { | 1035 int V8Debugger::currentContextGroupId() { |
| 1027 if (!m_isolate->InContext()) return 0; | 1036 if (!m_isolate->InContext()) return 0; |
| 1028 return m_inspector->contextGroupId(m_isolate->GetCurrentContext()); | 1037 return m_inspector->contextGroupId(m_isolate->GetCurrentContext()); |
| 1029 } | 1038 } |
| 1030 | 1039 |
| 1031 } // namespace v8_inspector | 1040 } // namespace v8_inspector |
| OLD | NEW |