Chromium Code Reviews| 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, true); | |
|
kozy
2016/09/23 21:49:45
Based on offline discussion on DevTools side:
Let'
Dan Ehrenberg
2016/09/23 21:51:25
If you look at patchset 12, you will find skipping
| |
| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { |
| 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) { |
| 907 asyncTaskScheduled(taskName, task, recurring, false); | |
| 908 } | |
| 909 | |
| 910 void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, | |
| 911 bool recurring, bool skipInitialFrame) { | |
| 901 if (!m_maxAsyncCallStackDepth) return; | 912 if (!m_maxAsyncCallStackDepth) return; |
| 902 v8::HandleScope scope(m_isolate); | 913 v8::HandleScope scope(m_isolate); |
| 903 int contextGroupId = | 914 int contextGroupId = |
| 904 m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; | 915 m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; |
| 905 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture( | 916 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture( |
| 906 this, contextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, | 917 this, contextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, |
| 907 taskName); | 918 taskName, skipInitialFrame); |
| 908 if (chain) { | 919 if (chain) { |
| 909 m_asyncTaskStacks[task] = std::move(chain); | 920 m_asyncTaskStacks[task] = std::move(chain); |
| 910 if (recurring) m_recurringTasks.insert(task); | 921 if (recurring) m_recurringTasks.insert(task); |
| 911 } | 922 } |
| 912 } | 923 } |
| 913 | 924 |
| 914 void V8Debugger::asyncTaskCanceled(void* task) { | 925 void V8Debugger::asyncTaskCanceled(void* task) { |
| 915 if (!m_maxAsyncCallStackDepth) return; | 926 if (!m_maxAsyncCallStackDepth) return; |
| 916 m_asyncTaskStacks.erase(task); | 927 m_asyncTaskStacks.erase(task); |
| 917 m_recurringTasks.erase(task); | 928 m_recurringTasks.erase(task); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 973 | 984 |
| 974 size_t stackSize = | 985 size_t stackSize = |
| 975 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 986 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
| 976 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 987 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 977 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 988 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 978 | 989 |
| 979 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 990 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 980 } | 991 } |
| 981 | 992 |
| 982 } // namespace v8_inspector | 993 } // namespace v8_inspector |
| OLD | NEW |