| 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" |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 } | 681 } |
| 682 DCHECK(value->IsObject()); | 682 DCHECK(value->IsObject()); |
| 683 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); | 683 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); |
| 684 } | 684 } |
| 685 | 685 |
| 686 v8::Local<v8::Context> V8Debugger::debuggerContext() const { | 686 v8::Local<v8::Context> V8Debugger::debuggerContext() const { |
| 687 DCHECK(!m_debuggerContext.IsEmpty()); | 687 DCHECK(!m_debuggerContext.IsEmpty()); |
| 688 return m_debuggerContext.Get(m_isolate); | 688 return m_debuggerContext.Get(m_isolate); |
| 689 } | 689 } |
| 690 | 690 |
| 691 v8::MaybeLocal<v8::Value> V8Debugger::functionScopes( | 691 v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes( |
| 692 v8::Local<v8::Context> context, v8::Local<v8::Function> function) { | 692 v8::Local<v8::Context> context, v8::Local<v8::Value> value, |
| 693 ScopeTargetKind kind) { |
| 693 if (!enabled()) { | 694 if (!enabled()) { |
| 694 UNREACHABLE(); | 695 UNREACHABLE(); |
| 695 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); | 696 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); |
| 696 } | 697 } |
| 697 v8::Local<v8::Value> argv[] = {function}; | 698 v8::Local<v8::Value> argv[] = {value}; |
| 698 v8::Local<v8::Value> scopesValue; | 699 v8::Local<v8::Value> scopesValue; |
| 699 if (!callDebuggerMethod("getFunctionScopes", 1, argv).ToLocal(&scopesValue)) | 700 |
| 701 const char* debuggerMethod = nullptr; |
| 702 switch (kind) { |
| 703 case FUNCTION: |
| 704 debuggerMethod = "getFunctionScopes"; |
| 705 break; |
| 706 case GENERATOR: |
| 707 debuggerMethod = "getGeneratorScopes"; |
| 708 break; |
| 709 } |
| 710 |
| 711 if (!callDebuggerMethod(debuggerMethod, 1, argv).ToLocal(&scopesValue)) |
| 700 return v8::MaybeLocal<v8::Value>(); | 712 return v8::MaybeLocal<v8::Value>(); |
| 701 v8::Local<v8::Value> copied; | 713 v8::Local<v8::Value> copied; |
| 702 if (!copyValueFromDebuggerContext(m_isolate, debuggerContext(), context, | 714 if (!copyValueFromDebuggerContext(m_isolate, debuggerContext(), context, |
| 703 scopesValue) | 715 scopesValue) |
| 704 .ToLocal(&copied) || | 716 .ToLocal(&copied) || |
| 705 !copied->IsArray()) | 717 !copied->IsArray()) |
| 706 return v8::MaybeLocal<v8::Value>(); | 718 return v8::MaybeLocal<v8::Value>(); |
| 707 if (!markAsInternal(context, v8::Local<v8::Array>::Cast(copied), | 719 if (!markAsInternal(context, v8::Local<v8::Array>::Cast(copied), |
| 708 V8InternalValueType::kScopeList)) | 720 V8InternalValueType::kScopeList)) |
| 709 return v8::MaybeLocal<v8::Value>(); | 721 return v8::MaybeLocal<v8::Value>(); |
| 710 if (!markArrayEntriesAsInternal(context, v8::Local<v8::Array>::Cast(copied), | 722 if (!markArrayEntriesAsInternal(context, v8::Local<v8::Array>::Cast(copied), |
| 711 V8InternalValueType::kScope)) | 723 V8InternalValueType::kScope)) |
| 712 return v8::MaybeLocal<v8::Value>(); | 724 return v8::MaybeLocal<v8::Value>(); |
| 713 return copied; | 725 return copied; |
| 714 } | 726 } |
| 715 | 727 |
| 728 v8::MaybeLocal<v8::Value> V8Debugger::functionScopes( |
| 729 v8::Local<v8::Context> context, v8::Local<v8::Function> function) { |
| 730 return getTargetScopes(context, function, FUNCTION); |
| 731 } |
| 732 |
| 733 v8::MaybeLocal<v8::Value> V8Debugger::generatorScopes( |
| 734 v8::Local<v8::Context> context, v8::Local<v8::Value> generator) { |
| 735 return getTargetScopes(context, generator, GENERATOR); |
| 736 } |
| 737 |
| 716 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties( | 738 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties( |
| 717 v8::Local<v8::Context> context, v8::Local<v8::Value> value) { | 739 v8::Local<v8::Context> context, v8::Local<v8::Value> value) { |
| 718 v8::Local<v8::Array> properties; | 740 v8::Local<v8::Array> properties; |
| 719 if (!v8::DebugInterface::GetInternalProperties(m_isolate, value) | 741 if (!v8::DebugInterface::GetInternalProperties(m_isolate, value) |
| 720 .ToLocal(&properties)) | 742 .ToLocal(&properties)) |
| 721 return v8::MaybeLocal<v8::Array>(); | 743 return v8::MaybeLocal<v8::Array>(); |
| 722 if (value->IsFunction()) { | 744 if (value->IsFunction()) { |
| 723 v8::Local<v8::Function> function = value.As<v8::Function>(); | 745 v8::Local<v8::Function> function = value.As<v8::Function>(); |
| 724 v8::Local<v8::Value> location = functionLocation(context, function); | 746 v8::Local<v8::Value> location = functionLocation(context, function); |
| 725 if (location->IsObject()) { | 747 if (location->IsObject()) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 748 } | 770 } |
| 749 if (value->IsGeneratorObject()) { | 771 if (value->IsGeneratorObject()) { |
| 750 v8::Local<v8::Value> location = | 772 v8::Local<v8::Value> location = |
| 751 generatorObjectLocation(context, v8::Local<v8::Object>::Cast(value)); | 773 generatorObjectLocation(context, v8::Local<v8::Object>::Cast(value)); |
| 752 if (location->IsObject()) { | 774 if (location->IsObject()) { |
| 753 createDataProperty( | 775 createDataProperty( |
| 754 context, properties, properties->Length(), | 776 context, properties, properties->Length(), |
| 755 toV8StringInternalized(m_isolate, "[[GeneratorLocation]]")); | 777 toV8StringInternalized(m_isolate, "[[GeneratorLocation]]")); |
| 756 createDataProperty(context, properties, properties->Length(), location); | 778 createDataProperty(context, properties, properties->Length(), location); |
| 757 } | 779 } |
| 780 v8::Local<v8::Value> scopes; |
| 781 if (generatorScopes(context, value).ToLocal(&scopes)) { |
| 782 createDataProperty(context, properties, properties->Length(), |
| 783 toV8StringInternalized(m_isolate, "[[Scopes]]")); |
| 784 createDataProperty(context, properties, properties->Length(), scopes); |
| 785 } |
| 758 } | 786 } |
| 759 if (value->IsFunction()) { | 787 if (value->IsFunction()) { |
| 760 v8::Local<v8::Function> function = value.As<v8::Function>(); | 788 v8::Local<v8::Function> function = value.As<v8::Function>(); |
| 761 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); | 789 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); |
| 762 v8::Local<v8::Value> scopes; | 790 v8::Local<v8::Value> scopes; |
| 763 if (boundFunction->IsUndefined() && | 791 if (boundFunction->IsUndefined() && |
| 764 functionScopes(context, function).ToLocal(&scopes)) { | 792 functionScopes(context, function).ToLocal(&scopes)) { |
| 765 createDataProperty(context, properties, properties->Length(), | 793 createDataProperty(context, properties, properties->Length(), |
| 766 toV8StringInternalized(m_isolate, "[[Scopes]]")); | 794 toV8StringInternalized(m_isolate, "[[Scopes]]")); |
| 767 createDataProperty(context, properties, properties->Length(), scopes); | 795 createDataProperty(context, properties, properties->Length(), scopes); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 | 1009 |
| 982 size_t stackSize = | 1010 size_t stackSize = |
| 983 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 1011 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
| 984 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 1012 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 985 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 1013 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 986 | 1014 |
| 987 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 1015 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 988 } | 1016 } |
| 989 | 1017 |
| 990 } // namespace v8_inspector | 1018 } // namespace v8_inspector |
| OLD | NEW |