| 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/v8_inspector/InjectedScript.h" | 7 #include "platform/v8_inspector/InjectedScript.h" |
| 8 #include "platform/v8_inspector/InspectedContext.h" | 8 #include "platform/v8_inspector/InspectedContext.h" |
| 9 #include "platform/v8_inspector/JavaScriptCallFrame.h" | 9 #include "platform/v8_inspector/JavaScriptCallFrame.h" |
| 10 #include "platform/v8_inspector/RemoteObjectId.h" | 10 #include "platform/v8_inspector/RemoteObjectId.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) | 228 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) |
| 229 { | 229 { |
| 230 if (!checkEnabled(errorString)) | 230 if (!checkEnabled(errorString)) |
| 231 return; | 231 return; |
| 232 m_debugger->setBreakpointsActivated(active); | 232 m_debugger->setBreakpointsActivated(active); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skip) | 235 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) |
| 236 { | 236 { |
| 237 m_skipAllPauses = skip; | 237 m_skipAllPauses = skipped; |
| 238 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); | 238 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); |
| 239 } | 239 } |
| 240 | 240 |
| 241 static std::unique_ptr<protocol::DictionaryValue> buildObjectForBreakpointCookie
(const String16& url, int lineNumber, int columnNumber, const String16& conditio
n, bool isRegex) | 241 static std::unique_ptr<protocol::DictionaryValue> buildObjectForBreakpointCookie
(const String16& url, int lineNumber, int columnNumber, const String16& conditio
n, bool isRegex) |
| 242 { | 242 { |
| 243 std::unique_ptr<protocol::DictionaryValue> breakpointObject = protocol::Dict
ionaryValue::create(); | 243 std::unique_ptr<protocol::DictionaryValue> breakpointObject = protocol::Dict
ionaryValue::create(); |
| 244 breakpointObject->setString(DebuggerAgentState::url, url); | 244 breakpointObject->setString(DebuggerAgentState::url, url); |
| 245 breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); | 245 breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); |
| 246 breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber)
; | 246 breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber)
; |
| 247 breakpointObject->setString(DebuggerAgentState::condition, condition); | 247 breakpointObject->setString(DebuggerAgentState::condition, condition); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 510 |
| 511 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = sear
chInTextByLinesImpl(m_session, toProtocolString(it->second->source(m_isolate)),
query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false))
; | 511 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = sear
chInTextByLinesImpl(m_session, toProtocolString(it->second->source(m_isolate)),
query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false))
; |
| 512 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); | 512 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); |
| 513 for (size_t i = 0; i < matches.size(); ++i) | 513 for (size_t i = 0; i < matches.size(); ++i) |
| 514 (*results)->addItem(std::move(matches[i])); | 514 (*results)->addItem(std::move(matches[i])); |
| 515 } | 515 } |
| 516 | 516 |
| 517 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, | 517 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, |
| 518 const String16& scriptId, | 518 const String16& scriptId, |
| 519 const String16& newContent, | 519 const String16& newContent, |
| 520 const Maybe<bool>& dryRun, | 520 const Maybe<bool>& preview, |
| 521 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 521 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
| 522 Maybe<bool>* stackChanged, | 522 Maybe<bool>* stackChanged, |
| 523 Maybe<StackTrace>* asyncStackTrace, | 523 Maybe<StackTrace>* asyncStackTrace, |
| 524 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) | 524 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) |
| 525 { | 525 { |
| 526 if (!checkEnabled(errorString)) | 526 if (!checkEnabled(errorString)) |
| 527 return; | 527 return; |
| 528 | 528 |
| 529 v8::HandleScope handles(m_isolate); | 529 v8::HandleScope handles(m_isolate); |
| 530 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); | 530 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); |
| 531 if (!m_debugger->setScriptSource(scriptId, newSource, dryRun.fromMaybe(false
), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) | 531 if (!m_debugger->setScriptSource(scriptId, newSource, preview.fromMaybe(fals
e), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) |
| 532 return; | 532 return; |
| 533 | 533 |
| 534 ScriptsMap::iterator it = m_scripts.find(scriptId); | 534 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 535 if (it != m_scripts.end()) | 535 if (it != m_scripts.end()) |
| 536 it->second->setSource(m_isolate, newSource); | 536 it->second->setSource(m_isolate, newSource); |
| 537 | 537 |
| 538 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString
); | 538 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString
); |
| 539 if (!callFrames) | 539 if (!callFrames) |
| 540 return; | 540 return; |
| 541 *newCallFrames = std::move(callFrames); | 541 *newCallFrames = std::move(callFrames); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 *errorString = "Internal error. Could not change pause on exceptions sta
te"; | 704 *errorString = "Internal error. Could not change pause on exceptions sta
te"; |
| 705 else | 705 else |
| 706 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseSta
te); | 706 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseSta
te); |
| 707 } | 707 } |
| 708 | 708 |
| 709 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, | 709 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, |
| 710 const String16& callFrameId, | 710 const String16& callFrameId, |
| 711 const String16& expression, | 711 const String16& expression, |
| 712 const Maybe<String16>& objectGroup, | 712 const Maybe<String16>& objectGroup, |
| 713 const Maybe<bool>& includeCommandLineAPI, | 713 const Maybe<bool>& includeCommandLineAPI, |
| 714 const Maybe<bool>& silent, | 714 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, |
| 715 const Maybe<bool>& returnByValue, | 715 const Maybe<bool>& returnByValue, |
| 716 const Maybe<bool>& generatePreview, | 716 const Maybe<bool>& generatePreview, |
| 717 std::unique_ptr<RemoteObject>* result, | 717 std::unique_ptr<RemoteObject>* result, |
| 718 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) | 718 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
| 719 { | 719 { |
| 720 if (!assertPaused(errorString)) | 720 if (!assertPaused(errorString)) |
| 721 return; | 721 return; |
| 722 InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->co
ntextGroupId(), callFrameId); | 722 InjectedScript::CallFrameScope scope(errorString, m_inspector, m_session->co
ntextGroupId(), callFrameId); |
| 723 if (!scope.initialize()) | 723 if (!scope.initialize()) |
| 724 return; | 724 return; |
| 725 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { | 725 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { |
| 726 *errorString = "Could not find call frame with given id"; | 726 *errorString = "Could not find call frame with given id"; |
| 727 return; | 727 return; |
| 728 } | 728 } |
| 729 | 729 |
| 730 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI()
) | 730 if (includeCommandLineAPI.fromMaybe(false) && !scope.installCommandLineAPI()
) |
| 731 return; | 731 return; |
| 732 if (silent.fromMaybe(false)) | 732 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) |
| 733 scope.ignoreExceptionsAndMuteConsole(); | 733 scope.ignoreExceptionsAndMuteConsole(); |
| 734 | 734 |
| 735 v8::MaybeLocal<v8::Value> maybeResultValue = m_pausedCallFrames[scope.frameO
rdinal()]->evaluate(toV8String(m_isolate, expression)); | 735 v8::MaybeLocal<v8::Value> maybeResultValue = m_pausedCallFrames[scope.frameO
rdinal()]->evaluate(toV8String(m_isolate, expression)); |
| 736 | 736 |
| 737 // Re-initialize after running client's code, as it could have destroyed con
text or session. | 737 // Re-initialize after running client's code, as it could have destroyed con
text or session. |
| 738 if (!scope.initialize()) | 738 if (!scope.initialize()) |
| 739 return; | 739 return; |
| 740 scope.injectedScript()->wrapEvaluateResult(errorString, | 740 scope.injectedScript()->wrapEvaluateResult(errorString, |
| 741 maybeResultValue, | 741 maybeResultValue, |
| 742 scope.tryCatch(), | 742 scope.tryCatch(), |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 { | 1158 { |
| 1159 if (!enabled()) | 1159 if (!enabled()) |
| 1160 return; | 1160 return; |
| 1161 m_scheduledDebuggerStep = NoStep; | 1161 m_scheduledDebuggerStep = NoStep; |
| 1162 m_scripts.clear(); | 1162 m_scripts.clear(); |
| 1163 m_blackboxedPositions.clear(); | 1163 m_blackboxedPositions.clear(); |
| 1164 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1164 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1165 } | 1165 } |
| 1166 | 1166 |
| 1167 } // namespace blink | 1167 } // namespace blink |
| OLD | NEW |