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/protocol/Protocol.h" | 8 #include "src/inspector/protocol/Protocol.h" |
9 #include "src/inspector/script-breakpoint.h" | 9 #include "src/inspector/script-breakpoint.h" |
10 #include "src/inspector/string-util.h" | 10 #include "src/inspector/string-util.h" |
11 #include "src/inspector/v8-debugger-agent-impl.h" | 11 #include "src/inspector/v8-debugger-agent-impl.h" |
12 #include "src/inspector/v8-inspector-impl.h" | 12 #include "src/inspector/v8-inspector-impl.h" |
13 #include "src/inspector/v8-internal-value-type.h" | 13 #include "src/inspector/v8-internal-value-type.h" |
14 #include "src/inspector/v8-stack-trace-impl.h" | 14 #include "src/inspector/v8-stack-trace-impl.h" |
15 #include "src/inspector/v8-value-copier.h" | 15 #include "src/inspector/v8-value-copier.h" |
16 | 16 |
17 namespace v8_inspector { | 17 namespace v8_inspector { |
18 | 18 |
19 namespace { | 19 namespace { |
20 const char stepIntoV8MethodName[] = "stepIntoStatement"; | 20 const char stepIntoV8MethodName[] = "stepIntoStatement"; |
21 const char stepOutV8MethodName[] = "stepOutOfFunction"; | 21 const char stepOutV8MethodName[] = "stepOutOfFunction"; |
22 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; | 22 static const char v8AsyncTaskEventEnqueue[] = "enqueue"; |
| 23 static const char v8AsyncTaskEventEnqueueRecurring[] = "enqueueRecurring"; |
23 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; | 24 static const char v8AsyncTaskEventWillHandle[] = "willHandle"; |
24 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; | 25 static const char v8AsyncTaskEventDidHandle[] = "didHandle"; |
| 26 static const char v8AsyncTaskEventCancel[] = "cancel"; |
25 | 27 |
26 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) { | 28 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) { |
27 return value ? v8::True(isolate) : v8::False(isolate); | 29 return value ? v8::True(isolate) : v8::False(isolate); |
28 } | 30 } |
29 | 31 |
30 } // namespace | 32 } // namespace |
31 | 33 |
32 static bool inLiveEditScope = false; | 34 static bool inLiveEditScope = false; |
33 | 35 |
34 v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod( | 36 v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod( |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 int id = static_cast<int>(callInternalGetterFunction(eventData, "id") | 648 int id = static_cast<int>(callInternalGetterFunction(eventData, "id") |
647 ->ToInteger(context) | 649 ->ToInteger(context) |
648 .ToLocalChecked() | 650 .ToLocalChecked() |
649 ->Value()); | 651 ->Value()); |
650 // Async task events from Promises are given misaligned pointers to prevent | 652 // Async task events from Promises are given misaligned pointers to prevent |
651 // from overlapping with other Blink task identifiers. There is a single | 653 // from overlapping with other Blink task identifiers. There is a single |
652 // namespace of such ids, managed by src/js/promise.js. | 654 // namespace of such ids, managed by src/js/promise.js. |
653 void* ptr = reinterpret_cast<void*>(id * 2 + 1); | 655 void* ptr = reinterpret_cast<void*>(id * 2 + 1); |
654 if (type == v8AsyncTaskEventEnqueue) | 656 if (type == v8AsyncTaskEventEnqueue) |
655 asyncTaskScheduled(name, ptr, false); | 657 asyncTaskScheduled(name, ptr, false); |
| 658 else if (type == v8AsyncTaskEventEnqueueRecurring) |
| 659 asyncTaskScheduled(name, ptr, true, 1); |
656 else if (type == v8AsyncTaskEventWillHandle) | 660 else if (type == v8AsyncTaskEventWillHandle) |
657 asyncTaskStarted(ptr); | 661 asyncTaskStarted(ptr); |
658 else if (type == v8AsyncTaskEventDidHandle) | 662 else if (type == v8AsyncTaskEventDidHandle) |
659 asyncTaskFinished(ptr); | 663 asyncTaskFinished(ptr); |
| 664 else if (type == v8AsyncTaskEventCancel) |
| 665 asyncTaskCanceled(ptr); |
660 else | 666 else |
661 UNREACHABLE(); | 667 UNREACHABLE(); |
662 } | 668 } |
663 | 669 |
664 V8StackTraceImpl* V8Debugger::currentAsyncCallChain() { | 670 V8StackTraceImpl* V8Debugger::currentAsyncCallChain() { |
665 if (!m_currentStacks.size()) return nullptr; | 671 if (!m_currentStacks.size()) return nullptr; |
666 return m_currentStacks.back().get(); | 672 return m_currentStacks.back().get(); |
667 } | 673 } |
668 | 674 |
669 void V8Debugger::compileDebuggerScript() { | 675 void V8Debugger::compileDebuggerScript() { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 if (pair.second > maxAsyncCallStackDepth) | 890 if (pair.second > maxAsyncCallStackDepth) |
885 maxAsyncCallStackDepth = pair.second; | 891 maxAsyncCallStackDepth = pair.second; |
886 } | 892 } |
887 | 893 |
888 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) return; | 894 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) return; |
889 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; | 895 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; |
890 if (!maxAsyncCallStackDepth) allAsyncTasksCanceled(); | 896 if (!maxAsyncCallStackDepth) allAsyncTasksCanceled(); |
891 } | 897 } |
892 | 898 |
893 void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task, | 899 void V8Debugger::asyncTaskScheduled(const StringView& taskName, void* task, |
894 bool recurring) { | 900 bool recurring, int skipInitialFrames) { |
895 if (!m_maxAsyncCallStackDepth) return; | 901 if (!m_maxAsyncCallStackDepth) return; |
896 asyncTaskScheduled(toString16(taskName), task, recurring); | 902 asyncTaskScheduled(toString16(taskName), task, recurring); |
897 } | 903 } |
898 | 904 |
899 void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, | 905 void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, |
900 bool recurring) { | 906 bool recurring, int skipInitialFrames) { |
901 if (!m_maxAsyncCallStackDepth) return; | 907 if (!m_maxAsyncCallStackDepth) return; |
902 v8::HandleScope scope(m_isolate); | 908 v8::HandleScope scope(m_isolate); |
903 int contextGroupId = | 909 int contextGroupId = |
904 m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; | 910 m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; |
905 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture( | 911 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture( |
906 this, contextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, | 912 this, contextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, |
907 taskName); | 913 taskName, skipInitialFrames); |
908 if (chain) { | 914 if (chain) { |
909 m_asyncTaskStacks[task] = std::move(chain); | 915 m_asyncTaskStacks[task] = std::move(chain); |
910 if (recurring) m_recurringTasks.insert(task); | 916 if (recurring) m_recurringTasks.insert(task); |
911 } | 917 } |
912 } | 918 } |
913 | 919 |
914 void V8Debugger::asyncTaskCanceled(void* task) { | 920 void V8Debugger::asyncTaskCanceled(void* task) { |
915 if (!m_maxAsyncCallStackDepth) return; | 921 if (!m_maxAsyncCallStackDepth) return; |
916 m_asyncTaskStacks.erase(task); | 922 m_asyncTaskStacks.erase(task); |
917 m_recurringTasks.erase(task); | 923 m_recurringTasks.erase(task); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 979 |
974 size_t stackSize = | 980 size_t stackSize = |
975 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 981 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
976 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 982 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
977 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 983 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
978 | 984 |
979 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 985 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
980 } | 986 } |
981 | 987 |
982 } // namespace v8_inspector | 988 } // namespace v8_inspector |
OLD | NEW |