| 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 | 604 |
| 605 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties(v8::Local<v8::Context>
context, v8::Local<v8::Value> value) | 605 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties(v8::Local<v8::Context>
context, v8::Local<v8::Value> value) |
| 606 { | 606 { |
| 607 v8::Local<v8::Array> properties; | 607 v8::Local<v8::Array> properties; |
| 608 if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)
) | 608 if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)
) |
| 609 return v8::MaybeLocal<v8::Array>(); | 609 return v8::MaybeLocal<v8::Array>(); |
| 610 if (value->IsFunction()) { | 610 if (value->IsFunction()) { |
| 611 v8::Local<v8::Function> function = value.As<v8::Function>(); | 611 v8::Local<v8::Function> function = value.As<v8::Function>(); |
| 612 v8::Local<v8::Value> location = functionLocation(context, function); | 612 v8::Local<v8::Value> location = functionLocation(context, function); |
| 613 if (location->IsObject()) { | 613 if (location->IsObject()) { |
| 614 properties->Set(properties->Length(), toV8StringInternalized(m_isola
te, "[[FunctionLocation]]")); | 614 safeCreateDataProperty(context, properties, properties->Length(), to
V8StringInternalized(m_isolate, "[[FunctionLocation]]")); |
| 615 properties->Set(properties->Length(), location); | 615 safeCreateDataProperty(context, properties, properties->Length(), lo
cation); |
| 616 } | 616 } |
| 617 if (function->IsGeneratorFunction()) { | 617 if (function->IsGeneratorFunction()) { |
| 618 properties->Set(properties->Length(), toV8StringInternalized(m_isola
te, "[[IsGenerator]]")); | 618 safeCreateDataProperty(context, properties, properties->Length(), to
V8StringInternalized(m_isolate, "[[IsGenerator]]")); |
| 619 properties->Set(properties->Length(), v8::True(m_isolate)); | 619 safeCreateDataProperty(context, properties, properties->Length(), v8
::True(m_isolate)); |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 if (!enabled()) | 622 if (!enabled()) |
| 623 return properties; | 623 return properties; |
| 624 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS
et() || value->IsSetIterator() || value->IsMapIterator()) { | 624 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS
et() || value->IsSetIterator() || value->IsMapIterator()) { |
| 625 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8::
Object>::Cast(value)); | 625 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8::
Object>::Cast(value)); |
| 626 if (entries->IsArray()) { | 626 if (entries->IsArray()) { |
| 627 properties->Set(properties->Length(), toV8StringInternalized(m_isola
te, "[[Entries]]")); | 627 safeCreateDataProperty(context, properties, properties->Length(), to
V8StringInternalized(m_isolate, "[[Entries]]")); |
| 628 properties->Set(properties->Length(), entries); | 628 safeCreateDataProperty(context, properties, properties->Length(), en
tries); |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 if (value->IsGeneratorObject()) { | 631 if (value->IsGeneratorObject()) { |
| 632 v8::Local<v8::Value> location = generatorObjectLocation(context, v8::Loc
al<v8::Object>::Cast(value)); | 632 v8::Local<v8::Value> location = generatorObjectLocation(context, v8::Loc
al<v8::Object>::Cast(value)); |
| 633 if (location->IsObject()) { | 633 if (location->IsObject()) { |
| 634 properties->Set(properties->Length(), toV8StringInternalized(m_isola
te, "[[GeneratorLocation]]")); | 634 safeCreateDataProperty(context, properties, properties->Length(), to
V8StringInternalized(m_isolate, "[[GeneratorLocation]]")); |
| 635 properties->Set(properties->Length(), location); | 635 safeCreateDataProperty(context, properties, properties->Length(), lo
cation); |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 if (value->IsFunction()) { | 638 if (value->IsFunction()) { |
| 639 v8::Local<v8::Function> function = value.As<v8::Function>(); | 639 v8::Local<v8::Function> function = value.As<v8::Function>(); |
| 640 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); | 640 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); |
| 641 v8::Local<v8::Value> scopes; | 641 v8::Local<v8::Value> scopes; |
| 642 if (boundFunction->IsUndefined() && functionScopes(context, function).To
Local(&scopes)) { | 642 if (boundFunction->IsUndefined() && functionScopes(context, function).To
Local(&scopes)) { |
| 643 properties->Set(properties->Length(), toV8StringInternalized(m_isola
te, "[[Scopes]]")); | 643 safeCreateDataProperty(context, properties, properties->Length(), to
V8StringInternalized(m_isolate, "[[Scopes]]")); |
| 644 properties->Set(properties->Length(), scopes); | 644 safeCreateDataProperty(context, properties, properties->Length(), sc
opes); |
| 645 } | 645 } |
| 646 } | 646 } |
| 647 return properties; | 647 return properties; |
| 648 } | 648 } |
| 649 | 649 |
| 650 v8::Local<v8::Value> V8Debugger::collectionEntries(v8::Local<v8::Context> contex
t, v8::Local<v8::Object> object) | 650 v8::Local<v8::Value> V8Debugger::collectionEntries(v8::Local<v8::Context> contex
t, v8::Local<v8::Object> object) |
| 651 { | 651 { |
| 652 if (!enabled()) { | 652 if (!enabled()) { |
| 653 NOTREACHED(); | 653 NOTREACHED(); |
| 654 return v8::Undefined(m_isolate); | 654 return v8::Undefined(m_isolate); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 684 int scriptId = function->ScriptId(); | 684 int scriptId = function->ScriptId(); |
| 685 if (scriptId == v8::UnboundScript::kNoScriptId) | 685 if (scriptId == v8::UnboundScript::kNoScriptId) |
| 686 return v8::Null(m_isolate); | 686 return v8::Null(m_isolate); |
| 687 int lineNumber = function->GetScriptLineNumber(); | 687 int lineNumber = function->GetScriptLineNumber(); |
| 688 int columnNumber = function->GetScriptColumnNumber(); | 688 int columnNumber = function->GetScriptColumnNumber(); |
| 689 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F
unction::kLineOffsetNotFound) | 689 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F
unction::kLineOffsetNotFound) |
| 690 return v8::Null(m_isolate); | 690 return v8::Null(m_isolate); |
| 691 v8::Local<v8::Object> location = v8::Object::New(m_isolate); | 691 v8::Local<v8::Object> location = v8::Object::New(m_isolate); |
| 692 if (!location->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) | 692 if (!location->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) |
| 693 return v8::Null(m_isolate); | 693 return v8::Null(m_isolate); |
| 694 if (!location->Set(context, toV8StringInternalized(m_isolate, "scriptId"), t
oV8String(m_isolate, String16::fromInteger(scriptId))).FromMaybe(false)) | 694 if (!safeCreateDataProperty(context, location, toV8StringInternalized(m_isol
ate, "scriptId"), toV8String(m_isolate, String16::fromInteger(scriptId))).FromMa
ybe(false)) |
| 695 return v8::Null(m_isolate); | 695 return v8::Null(m_isolate); |
| 696 if (!location->Set(context, toV8StringInternalized(m_isolate, "lineNumber"),
v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false)) | 696 if (!safeCreateDataProperty(context, location, toV8StringInternalized(m_isol
ate, "lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false)) |
| 697 return v8::Null(m_isolate); | 697 return v8::Null(m_isolate); |
| 698 if (!location->Set(context, toV8StringInternalized(m_isolate, "columnNumber"
), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false)) | 698 if (!safeCreateDataProperty(context, location, toV8StringInternalized(m_isol
ate, "columnNumber"), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false
)) |
| 699 return v8::Null(m_isolate); | 699 return v8::Null(m_isolate); |
| 700 if (!markAsInternal(context, location, V8InternalValueType::kLocation)) | 700 if (!markAsInternal(context, location, V8InternalValueType::kLocation)) |
| 701 return v8::Null(m_isolate); | 701 return v8::Null(m_isolate); |
| 702 return location; | 702 return location; |
| 703 } | 703 } |
| 704 | 704 |
| 705 bool V8Debugger::isPaused() | 705 bool V8Debugger::isPaused() |
| 706 { | 706 { |
| 707 return !m_pausedContext.IsEmpty(); | 707 return !m_pausedContext.IsEmpty(); |
| 708 } | 708 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 return nullptr; | 830 return nullptr; |
| 831 | 831 |
| 832 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; | 832 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; |
| 833 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 833 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 834 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 834 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 835 | 835 |
| 836 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 836 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 837 } | 837 } |
| 838 | 838 |
| 839 } // namespace v8_inspector | 839 } // namespace v8_inspector |
| OLD | NEW |