OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 "platform/v8_inspector/V8Debugger.h" | 5 #include "platform/v8_inspector/V8Debugger.h" |
6 | 6 |
7 #include "platform/v8_inspector/DebuggerScript.h" | 7 #include "platform/v8_inspector/DebuggerScript.h" |
8 #include "platform/v8_inspector/ScriptBreakpoint.h" | 8 #include "platform/v8_inspector/ScriptBreakpoint.h" |
9 #include "platform/v8_inspector/V8Compat.h" | 9 #include "platform/v8_inspector/V8Compat.h" |
10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(v8::Local<v8::Sta
ckTrace> stackTrace) | 710 std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(v8::Local<v8::Sta
ckTrace> stackTrace) |
711 { | 711 { |
712 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre
ntContext()) : 0; | 712 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre
ntContext()) : 0; |
713 return V8StackTraceImpl::create(this, contextGroupId, stackTrace, V8StackTra
ceImpl::maxCallStackSizeToCapture); | 713 return V8StackTraceImpl::create(this, contextGroupId, stackTrace, V8StackTra
ceImpl::maxCallStackSizeToCapture); |
714 } | 714 } |
715 | 715 |
716 int V8Debugger::markContext(const V8ContextInfo& info) | 716 int V8Debugger::markContext(const V8ContextInfo& info) |
717 { | 717 { |
718 DCHECK(info.context->GetIsolate() == m_isolate); | 718 DCHECK(info.context->GetIsolate() == m_isolate); |
719 int contextId = ++m_lastContextId; | 719 int contextId = ++m_lastContextId; |
720 String16 debugData = String16::fromInteger(info.contextGroupId) + "," + Stri
ng16::fromInteger(contextId) + "," + info.auxData; | 720 String16 debugData = String16::fromInteger(info.contextGroupId) + "," + Stri
ng16::fromInteger(contextId) + "," + toString16(info.auxData); |
721 v8::Context::Scope contextScope(info.context); | 721 v8::Context::Scope contextScope(info.context); |
722 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
toV8String(m_isolate, debugData)); | 722 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
toV8String(m_isolate, debugData)); |
723 return contextId; | 723 return contextId; |
724 } | 724 } |
725 | 725 |
726 void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) | 726 void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) |
727 { | 727 { |
728 if (depth <= 0) | 728 if (depth <= 0) |
729 m_maxAsyncCallStackDepthMap.erase(agent); | 729 m_maxAsyncCallStackDepthMap.erase(agent); |
730 else | 730 else |
731 m_maxAsyncCallStackDepthMap[agent] = depth; | 731 m_maxAsyncCallStackDepthMap[agent] = depth; |
732 | 732 |
733 int maxAsyncCallStackDepth = 0; | 733 int maxAsyncCallStackDepth = 0; |
734 for (const auto& pair : m_maxAsyncCallStackDepthMap) { | 734 for (const auto& pair : m_maxAsyncCallStackDepthMap) { |
735 if (pair.second > maxAsyncCallStackDepth) | 735 if (pair.second > maxAsyncCallStackDepth) |
736 maxAsyncCallStackDepth = pair.second; | 736 maxAsyncCallStackDepth = pair.second; |
737 } | 737 } |
738 | 738 |
739 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) | 739 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) |
740 return; | 740 return; |
741 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; | 741 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; |
742 if (!maxAsyncCallStackDepth) | 742 if (!maxAsyncCallStackDepth) |
743 allAsyncTasksCanceled(); | 743 allAsyncTasksCanceled(); |
744 } | 744 } |
745 | 745 |
| 746 void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task, bool
recurring) |
| 747 { |
| 748 if (!m_maxAsyncCallStackDepth) |
| 749 return; |
| 750 asyncTaskScheduled(toString16(taskName), task, recurring); |
| 751 } |
| 752 |
746 void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, bool r
ecurring) | 753 void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, bool r
ecurring) |
747 { | 754 { |
748 if (!m_maxAsyncCallStackDepth) | 755 if (!m_maxAsyncCallStackDepth) |
749 return; | 756 return; |
750 v8::HandleScope scope(m_isolate); | 757 v8::HandleScope scope(m_isolate); |
751 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre
ntContext()) : 0; | 758 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre
ntContext()) : 0; |
752 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, co
ntextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, taskName); | 759 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, co
ntextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, taskName); |
753 if (chain) { | 760 if (chain) { |
754 m_asyncTaskStacks[task] = std::move(chain); | 761 m_asyncTaskStacks[task] = std::move(chain); |
755 if (recurring) | 762 if (recurring) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 return nullptr; | 837 return nullptr; |
831 | 838 |
832 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; | 839 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; |
833 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 840 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
834 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 841 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
835 | 842 |
836 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 843 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
837 } | 844 } |
838 | 845 |
839 } // namespace v8_inspector | 846 } // namespace v8_inspector |
OLD | NEW |