| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/V8DebuggerAgentImpl.h" | 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/String16.h" | 7 #include "platform/inspector_protocol/String16.h" |
| 8 #include "platform/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
| 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" | 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" |
| 10 #include "platform/v8_inspector/InjectedScript.h" | 10 #include "platform/v8_inspector/InjectedScript.h" |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
ing16& functionId, OwnPtr<FunctionDetails>* details) | 680 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
ing16& functionId, OwnPtr<FunctionDetails>* details) |
| 681 { | 681 { |
| 682 if (!checkEnabled(errorString)) | 682 if (!checkEnabled(errorString)) |
| 683 return; | 683 return; |
| 684 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, functio
nId); | 684 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, functio
nId); |
| 685 if (!remoteId) | 685 if (!remoteId) |
| 686 return; | 686 return; |
| 687 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); | 687 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); |
| 688 if (!injectedScript) | 688 if (!injectedScript) |
| 689 return; | 689 return; |
| 690 injectedScript->getFunctionDetails(errorString, functionId, details); | 690 |
| 691 v8::HandleScope scope(m_isolate); |
| 692 v8::Local<v8::Context> context = injectedScript->context(); |
| 693 v8::Context::Scope contextScope(context); |
| 694 |
| 695 v8::Local<v8::Value> value; |
| 696 if (!injectedScript->findObject(errorString, *remoteId, &value)) |
| 697 return; |
| 698 if (!value->IsFunction()) { |
| 699 *errorString = "Value with given id is not a function"; |
| 700 return; |
| 701 } |
| 702 v8::Local<v8::Function> function = value.As<v8::Function>(); |
| 703 |
| 704 v8::Local<v8::Value> scopesValue; |
| 705 v8::Local<v8::Array> scopes; |
| 706 String16 objectGroupName = injectedScript->objectGroupName(*remoteId); |
| 707 if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValu
e->IsArray()) { |
| 708 scopes = scopesValue.As<v8::Array>(); |
| 709 for (size_t i = 0; i < scopes->Length(); ++i) { |
| 710 v8::Local<v8::Value> scope; |
| 711 if (!scopes->Get(injectedScript->context(), i).ToLocal(&scope) || !s
cope->IsObject()) { |
| 712 *errorString = "Internal error"; |
| 713 return; |
| 714 } |
| 715 if (!injectedScript->wrapObjectProperty(errorString, scope.As<v8::Ob
ject>(), toV8String(injectedScript->isolate(), "object"), objectGroupName)) |
| 716 return; |
| 717 } |
| 718 } |
| 719 |
| 720 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location
::create() |
| 721 .setScriptId(String16::number(function->ScriptId())) |
| 722 .setLineNumber(function->GetScriptLineNumber()) |
| 723 .setColumnNumber(function->GetScriptColumnNumber()).build(); |
| 724 |
| 725 OwnPtr<FunctionDetails> functionDetails = FunctionDetails::create() |
| 726 .setLocation(location.release()) |
| 727 .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName())
) |
| 728 .setIsGenerator(function->IsGeneratorFunction()).build(); |
| 729 |
| 730 if (!scopes.IsEmpty()) { |
| 731 protocol::ErrorSupport errorSupport; |
| 732 OwnPtr<protocol::Array<protocol::Debugger::Scope>> scopeChain = protocol
::Array<protocol::Debugger::Scope>::parse(toProtocolValue(injectedScript->contex
t(), scopes).get(), &errorSupport); |
| 733 if (errorSupport.hasErrors()) { |
| 734 *errorString = "Internal error"; |
| 735 return; |
| 736 } |
| 737 functionDetails->setScopeChain(scopeChain.release()); |
| 738 } |
| 739 |
| 740 *details = functionDetails.release(); |
| 691 } | 741 } |
| 692 | 742 |
| 693 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co
nst String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails) | 743 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co
nst String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails) |
| 694 { | 744 { |
| 695 if (!checkEnabled(errorString)) | 745 if (!checkEnabled(errorString)) |
| 696 return; | 746 return; |
| 697 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI
d); | 747 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI
d); |
| 698 if (!remoteId) | 748 if (!remoteId) |
| 699 return; | 749 return; |
| 700 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); | 750 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(errorString, remoteId.get()); |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 m_scripts.clear(); | 1624 m_scripts.clear(); |
| 1575 m_blackboxedPositions.clear(); | 1625 m_blackboxedPositions.clear(); |
| 1576 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1626 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1577 resetAsyncCallTracker(); | 1627 resetAsyncCallTracker(); |
| 1578 m_promiseTracker->clear(); | 1628 m_promiseTracker->clear(); |
| 1579 if (m_frontend) | 1629 if (m_frontend) |
| 1580 m_frontend->globalObjectCleared(); | 1630 m_frontend->globalObjectCleared(); |
| 1581 } | 1631 } |
| 1582 | 1632 |
| 1583 } // namespace blink | 1633 } // namespace blink |
| OLD | NEW |