| 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/InjectedScript.h" | 9 #include "platform/v8_inspector/InjectedScript.h" |
| 10 #include "platform/v8_inspector/InspectedContext.h" | 10 #include "platform/v8_inspector/InspectedContext.h" |
| 11 #include "platform/v8_inspector/JavaScriptCallFrame.h" | 11 #include "platform/v8_inspector/JavaScriptCallFrame.h" |
| 12 #include "platform/v8_inspector/RemoteObjectId.h" | 12 #include "platform/v8_inspector/RemoteObjectId.h" |
| 13 #include "platform/v8_inspector/ScriptBreakpoint.h" | 13 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 14 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 14 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| 15 #include "platform/v8_inspector/V8Regex.h" | 15 #include "platform/v8_inspector/V8Regex.h" |
| 16 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 16 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
| 17 #include "platform/v8_inspector/V8StackTraceImpl.h" | 17 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 18 #include "platform/v8_inspector/V8StringUtil.h" | 18 #include "platform/v8_inspector/V8StringUtil.h" |
| 19 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" | 19 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" |
| 20 #include "platform/v8_inspector/public/V8Debugger.h" | 20 #include "platform/v8_inspector/public/V8Debugger.h" |
| 21 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 21 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
| 22 #include "platform/v8_inspector/public/V8ToProtocolValue.h" | 22 #include "platform/v8_inspector/public/V8ToProtocolValue.h" |
| 23 | 23 |
| 24 using blink::protocol::Array; | 24 using blink::protocol::Array; |
| 25 using blink::protocol::Maybe; | 25 using blink::protocol::Maybe; |
| 26 using blink::protocol::Debugger::BreakpointId; | 26 using blink::protocol::Debugger::BreakpointId; |
| 27 using blink::protocol::Debugger::CallFrame; | 27 using blink::protocol::Debugger::CallFrame; |
| 28 using blink::protocol::Runtime::ExceptionDetails; | 28 using blink::protocol::Runtime::ExceptionDetails; |
| 29 using blink::protocol::Debugger::FunctionDetails; | |
| 30 using blink::protocol::Runtime::ScriptId; | 29 using blink::protocol::Runtime::ScriptId; |
| 31 using blink::protocol::Runtime::StackTrace; | 30 using blink::protocol::Runtime::StackTrace; |
| 32 using blink::protocol::Runtime::RemoteObject; | 31 using blink::protocol::Runtime::RemoteObject; |
| 33 | 32 |
| 34 namespace blink { | 33 namespace blink { |
| 35 | 34 |
| 36 namespace DebuggerAgentState { | 35 namespace DebuggerAgentState { |
| 37 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; | 36 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; |
| 38 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; | 37 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; |
| 39 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; | 38 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 return; | 587 return; |
| 589 ScriptsMap::iterator it = m_scripts.find(scriptId); | 588 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 590 if (it == m_scripts.end()) { | 589 if (it == m_scripts.end()) { |
| 591 *error = "No script for id: " + scriptId; | 590 *error = "No script for id: " + scriptId; |
| 592 return; | 591 return; |
| 593 } | 592 } |
| 594 v8::HandleScope handles(m_isolate); | 593 v8::HandleScope handles(m_isolate); |
| 595 *scriptSource = toProtocolString(it->second->source(m_isolate)); | 594 *scriptSource = toProtocolString(it->second->source(m_isolate)); |
| 596 } | 595 } |
| 597 | 596 |
| 598 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
ing16& functionId, std::unique_ptr<FunctionDetails>* details) | |
| 599 { | |
| 600 if (!checkEnabled(errorString)) | |
| 601 return; | |
| 602 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex
tGroupId(), functionId); | |
| 603 if (!scope.initialize()) | |
| 604 return; | |
| 605 if (!scope.object()->IsFunction()) { | |
| 606 *errorString = "Value with given id is not a function"; | |
| 607 return; | |
| 608 } | |
| 609 v8::Local<v8::Function> function = scope.object().As<v8::Function>(); | |
| 610 | |
| 611 v8::Local<v8::Value> scopesValue; | |
| 612 v8::Local<v8::Array> scopes; | |
| 613 if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValu
e->IsArray()) { | |
| 614 scopes = scopesValue.As<v8::Array>(); | |
| 615 if (!scope.injectedScript()->wrapPropertyInArray(errorString, scopes, to
V8StringInternalized(m_isolate, "object"), scope.objectGroupName())) | |
| 616 return; | |
| 617 } | |
| 618 | |
| 619 std::unique_ptr<FunctionDetails> functionDetails = FunctionDetails::create() | |
| 620 .setLocation(buildProtocolLocation(String16::number(function->ScriptId()
), function->GetScriptLineNumber(), function->GetScriptColumnNumber())) | |
| 621 .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName())
) | |
| 622 .setIsGenerator(function->IsGeneratorFunction()).build(); | |
| 623 | |
| 624 if (!scopes.IsEmpty()) { | |
| 625 protocol::ErrorSupport errorSupport; | |
| 626 std::unique_ptr<protocol::Array<protocol::Debugger::Scope>> scopeChain =
protocol::Array<protocol::Debugger::Scope>::parse(toProtocolValue(scope.context
(), scopes).get(), &errorSupport); | |
| 627 if (hasInternalError(errorString, errorSupport.hasErrors())) | |
| 628 return; | |
| 629 functionDetails->setScopeChain(std::move(scopeChain)); | |
| 630 } | |
| 631 | |
| 632 *details = std::move(functionDetails); | |
| 633 } | |
| 634 | |
| 635 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas
on, std::unique_ptr<protocol::DictionaryValue> data) | 597 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas
on, std::unique_ptr<protocol::DictionaryValue> data) |
| 636 { | 598 { |
| 637 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc
heduled || debugger().isPaused() || !debugger().breakpointsActivated()) | 599 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc
heduled || debugger().isPaused() || !debugger().breakpointsActivated()) |
| 638 return; | 600 return; |
| 639 m_breakReason = breakReason; | 601 m_breakReason = breakReason; |
| 640 m_breakAuxData = std::move(data); | 602 m_breakAuxData = std::move(data); |
| 641 m_pausingOnNativeEvent = true; | 603 m_pausingOnNativeEvent = true; |
| 642 m_skipNextDebuggerStepOut = false; | 604 m_skipNextDebuggerStepOut = false; |
| 643 debugger().setPauseOnNextStatement(true); | 605 debugger().setPauseOnNextStatement(true); |
| 644 } | 606 } |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 { | 1175 { |
| 1214 if (!enabled()) | 1176 if (!enabled()) |
| 1215 return; | 1177 return; |
| 1216 m_scheduledDebuggerStep = NoStep; | 1178 m_scheduledDebuggerStep = NoStep; |
| 1217 m_scripts.clear(); | 1179 m_scripts.clear(); |
| 1218 m_blackboxedPositions.clear(); | 1180 m_blackboxedPositions.clear(); |
| 1219 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1181 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1220 } | 1182 } |
| 1221 | 1183 |
| 1222 } // namespace blink | 1184 } // namespace blink |
| OLD | NEW |