OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-agent-impl.h" | 5 #include "src/inspector/v8-debugger-agent-impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/debug/debug-interface.h" | 9 #include "src/debug/debug-interface.h" |
10 #include "src/inspector/injected-script.h" | 10 #include "src/inspector/injected-script.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "include/v8-inspector.h" | 27 #include "include/v8-inspector.h" |
28 | 28 |
29 namespace v8_inspector { | 29 namespace v8_inspector { |
30 | 30 |
31 using protocol::Array; | 31 using protocol::Array; |
32 using protocol::Maybe; | 32 using protocol::Maybe; |
33 using protocol::Debugger::BreakpointId; | 33 using protocol::Debugger::BreakpointId; |
34 using protocol::Debugger::CallFrame; | 34 using protocol::Debugger::CallFrame; |
35 using protocol::Runtime::ExceptionDetails; | 35 using protocol::Runtime::ExceptionDetails; |
36 using protocol::Runtime::ScriptId; | 36 using protocol::Runtime::ScriptId; |
| 37 using protocol::Runtime::StackTrace; |
37 using protocol::Runtime::RemoteObject; | 38 using protocol::Runtime::RemoteObject; |
38 | 39 |
39 namespace DebuggerAgentState { | 40 namespace DebuggerAgentState { |
40 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; | 41 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; |
41 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; | 42 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; |
42 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; | 43 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; |
43 static const char blackboxPattern[] = "blackboxPattern"; | 44 static const char blackboxPattern[] = "blackboxPattern"; |
44 static const char debuggerEnabled[] = "debuggerEnabled"; | 45 static const char debuggerEnabled[] = "debuggerEnabled"; |
45 static const char skipAllPauses[] = "skipAllPauses"; | 46 static const char skipAllPauses[] = "skipAllPauses"; |
46 | 47 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 optionalIsRegex.fromMaybe(false)); | 591 optionalIsRegex.fromMaybe(false)); |
591 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); | 592 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); |
592 for (size_t i = 0; i < matches.size(); ++i) | 593 for (size_t i = 0; i < matches.size(); ++i) |
593 (*results)->addItem(std::move(matches[i])); | 594 (*results)->addItem(std::move(matches[i])); |
594 return Response::OK(); | 595 return Response::OK(); |
595 } | 596 } |
596 | 597 |
597 Response V8DebuggerAgentImpl::setScriptSource( | 598 Response V8DebuggerAgentImpl::setScriptSource( |
598 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, | 599 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, |
599 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 600 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
600 Maybe<bool>* stackChanged, | 601 Maybe<bool>* stackChanged, Maybe<StackTrace>* asyncStackTrace, |
601 Maybe<protocol::Runtime::StackTrace>* asyncStackTrace, | |
602 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) { | 602 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) { |
603 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 603 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
604 | 604 |
605 ScriptsMap::iterator it = m_scripts.find(scriptId); | 605 ScriptsMap::iterator it = m_scripts.find(scriptId); |
606 if (it == m_scripts.end()) { | 606 if (it == m_scripts.end()) { |
607 return Response::Error("No script with given id found"); | 607 return Response::Error("No script with given id found"); |
608 } | 608 } |
609 if (it->second->isModule()) { | 609 if (it->second->isModule()) { |
610 // TODO(kozyatinskiy): LiveEdit should support ES6 module | 610 // TODO(kozyatinskiy): LiveEdit should support ES6 module |
611 return Response::Error("Editing module's script is not supported."); | 611 return Response::Error("Editing module's script is not supported."); |
(...skipping 12 matching lines...) Expand all Loading... |
624 response = currentCallFrames(&callFrames); | 624 response = currentCallFrames(&callFrames); |
625 if (!response.isSuccess()) return response; | 625 if (!response.isSuccess()) return response; |
626 *newCallFrames = std::move(callFrames); | 626 *newCallFrames = std::move(callFrames); |
627 *asyncStackTrace = currentAsyncStackTrace(); | 627 *asyncStackTrace = currentAsyncStackTrace(); |
628 return Response::OK(); | 628 return Response::OK(); |
629 } | 629 } |
630 | 630 |
631 Response V8DebuggerAgentImpl::restartFrame( | 631 Response V8DebuggerAgentImpl::restartFrame( |
632 const String16& callFrameId, | 632 const String16& callFrameId, |
633 std::unique_ptr<Array<CallFrame>>* newCallFrames, | 633 std::unique_ptr<Array<CallFrame>>* newCallFrames, |
634 Maybe<protocol::Runtime::StackTrace>* asyncStackTrace) { | 634 Maybe<StackTrace>* asyncStackTrace) { |
635 if (!isPaused()) return Response::Error(kDebuggerNotPaused); | 635 if (!isPaused()) return Response::Error(kDebuggerNotPaused); |
636 InjectedScript::CallFrameScope scope(m_inspector, m_session->contextGroupId(), | 636 InjectedScript::CallFrameScope scope(m_inspector, m_session->contextGroupId(), |
637 callFrameId); | 637 callFrameId); |
638 Response response = scope.initialize(); | 638 Response response = scope.initialize(); |
639 if (!response.isSuccess()) return response; | 639 if (!response.isSuccess()) return response; |
640 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) | 640 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) |
641 return Response::Error("Could not find call frame with given id"); | 641 return Response::Error("Could not find call frame with given id"); |
642 | 642 |
643 v8::Local<v8::Value> resultValue; | 643 v8::Local<v8::Value> resultValue; |
644 v8::Local<v8::Boolean> result; | 644 v8::Local<v8::Boolean> result; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); | 1021 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); |
1022 if (!response.isSuccess()) return response; | 1022 if (!response.isSuccess()) return response; |
1023 protocol::ErrorSupport errorSupport; | 1023 protocol::ErrorSupport errorSupport; |
1024 *result = Array<CallFrame>::fromValue(protocolValue.get(), &errorSupport); | 1024 *result = Array<CallFrame>::fromValue(protocolValue.get(), &errorSupport); |
1025 if (!*result) return Response::Error(errorSupport.errors()); | 1025 if (!*result) return Response::Error(errorSupport.errors()); |
1026 TranslateWasmStackTraceLocations(result->get(), | 1026 TranslateWasmStackTraceLocations(result->get(), |
1027 m_debugger->wasmTranslation()); | 1027 m_debugger->wasmTranslation()); |
1028 return Response::OK(); | 1028 return Response::OK(); |
1029 } | 1029 } |
1030 | 1030 |
1031 std::unique_ptr<protocol::Runtime::StackTrace> | 1031 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { |
1032 V8DebuggerAgentImpl::currentAsyncStackTrace() { | 1032 if (!isPaused()) return nullptr; |
1033 std::shared_ptr<AsyncStackTrace> asyncParent = | 1033 return V8StackTraceImpl::buildInspectorObjectForTail(m_debugger); |
1034 m_debugger->currentAsyncParent(); | |
1035 if (!asyncParent) return nullptr; | |
1036 return asyncParent->buildInspectorObject( | |
1037 m_debugger->currentAsyncCreation().get(), | |
1038 m_debugger->maxAsyncCallChainDepth() - 1); | |
1039 } | 1034 } |
1040 | 1035 |
1041 bool V8DebuggerAgentImpl::isPaused() const { return m_debugger->isPaused(); } | 1036 bool V8DebuggerAgentImpl::isPaused() const { return m_debugger->isPaused(); } |
1042 | 1037 |
1043 void V8DebuggerAgentImpl::didParseSource( | 1038 void V8DebuggerAgentImpl::didParseSource( |
1044 std::unique_ptr<V8DebuggerScript> script, bool success) { | 1039 std::unique_ptr<V8DebuggerScript> script, bool success) { |
1045 v8::HandleScope handles(m_isolate); | 1040 v8::HandleScope handles(m_isolate); |
1046 String16 scriptSource = script->source(); | 1041 String16 scriptSource = script->source(); |
1047 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); | 1042 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); |
1048 if (!success) | 1043 if (!success) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 | 1281 |
1287 void V8DebuggerAgentImpl::reset() { | 1282 void V8DebuggerAgentImpl::reset() { |
1288 if (!enabled()) return; | 1283 if (!enabled()) return; |
1289 m_blackboxedPositions.clear(); | 1284 m_blackboxedPositions.clear(); |
1290 resetBlackboxedStateCache(); | 1285 resetBlackboxedStateCache(); |
1291 m_scripts.clear(); | 1286 m_scripts.clear(); |
1292 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1287 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1293 } | 1288 } |
1294 | 1289 |
1295 } // namespace v8_inspector | 1290 } // namespace v8_inspector |
OLD | NEW |