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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 static const char skipAllPauses[] = "skipAllPauses"; | 53 static const char skipAllPauses[] = "skipAllPauses"; |
54 | 54 |
55 } // namespace DebuggerAgentState | 55 } // namespace DebuggerAgentState |
56 | 56 |
57 static const int kMaxSkipStepFrameCount = 128; | 57 static const int kMaxSkipStepFrameCount = 128; |
58 static const char kBacktraceObjectGroup[] = "backtrace"; | 58 static const char kBacktraceObjectGroup[] = "backtrace"; |
59 static const char kDebuggerNotEnabled[] = "Debugger agent is not enabled"; | 59 static const char kDebuggerNotEnabled[] = "Debugger agent is not enabled"; |
60 static const char kDebuggerNotPaused[] = | 60 static const char kDebuggerNotPaused[] = |
61 "Can only perform operation while paused."; | 61 "Can only perform operation while paused."; |
62 | 62 |
63 static String16 breakpointIdSuffix( | 63 namespace { |
64 V8DebuggerAgentImpl::BreakpointSource source) { | 64 |
| 65 void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace, |
| 66 WasmTranslation* wasmTranslation) { |
| 67 for (size_t i = 0, e = stackTrace->length(); i != e; ++i) { |
| 68 protocol::Debugger::Location* location = stackTrace->get(i)->getLocation(); |
| 69 String16 scriptId = location->getScriptId(); |
| 70 int lineNumber = location->getLineNumber(); |
| 71 int columnNumber = location->getColumnNumber(-1); |
| 72 |
| 73 if (!wasmTranslation->TranslateWasmScriptLocationToProtocolLocation( |
| 74 &scriptId, &lineNumber, &columnNumber)) { |
| 75 continue; |
| 76 } |
| 77 |
| 78 location->setScriptId(std::move(scriptId)); |
| 79 location->setLineNumber(lineNumber); |
| 80 location->setColumnNumber(columnNumber); |
| 81 } |
| 82 } |
| 83 |
| 84 ScriptBreakpoint TranslateBackWasmScriptBreakpoint( |
| 85 const ScriptBreakpoint& breakpoint, WasmTranslation* translation) { |
| 86 ScriptBreakpoint translatedBreakpoint = breakpoint; |
| 87 translation->TranslateProtocolLocationToWasmScriptLocation( |
| 88 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, |
| 89 &translatedBreakpoint.column_number); |
| 90 return translatedBreakpoint; |
| 91 } |
| 92 |
| 93 String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) { |
65 switch (source) { | 94 switch (source) { |
66 case V8DebuggerAgentImpl::UserBreakpointSource: | 95 case V8DebuggerAgentImpl::UserBreakpointSource: |
67 break; | 96 break; |
68 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: | 97 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: |
69 return ":debug"; | 98 return ":debug"; |
70 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: | 99 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: |
71 return ":monitor"; | 100 return ":monitor"; |
72 } | 101 } |
73 return String16(); | 102 return String16(); |
74 } | 103 } |
75 | 104 |
76 static String16 generateBreakpointId( | 105 String16 generateBreakpointId(const ScriptBreakpoint& breakpoint, |
77 const ScriptBreakpoint& breakpoint, | 106 V8DebuggerAgentImpl::BreakpointSource source) { |
78 V8DebuggerAgentImpl::BreakpointSource source) { | |
79 String16Builder builder; | 107 String16Builder builder; |
80 builder.append(breakpoint.script_id); | 108 builder.append(breakpoint.script_id); |
81 builder.append(':'); | 109 builder.append(':'); |
82 builder.appendNumber(breakpoint.line_number); | 110 builder.appendNumber(breakpoint.line_number); |
83 builder.append(':'); | 111 builder.append(':'); |
84 builder.appendNumber(breakpoint.column_number); | 112 builder.appendNumber(breakpoint.column_number); |
85 builder.append(breakpointIdSuffix(source)); | 113 builder.append(breakpointIdSuffix(source)); |
86 return builder.toString(); | 114 return builder.toString(); |
87 } | 115 } |
88 | 116 |
89 static bool positionComparator(const std::pair<int, int>& a, | 117 bool positionComparator(const std::pair<int, int>& a, |
90 const std::pair<int, int>& b) { | 118 const std::pair<int, int>& b) { |
91 if (a.first != b.first) return a.first < b.first; | 119 if (a.first != b.first) return a.first < b.first; |
92 return a.second < b.second; | 120 return a.second < b.second; |
93 } | 121 } |
94 | 122 |
95 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation( | 123 std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation( |
96 const String16& scriptId, int lineNumber, int columnNumber) { | 124 const String16& scriptId, int lineNumber, int columnNumber) { |
97 return protocol::Debugger::Location::create() | 125 return protocol::Debugger::Location::create() |
98 .setScriptId(scriptId) | 126 .setScriptId(scriptId) |
99 .setLineNumber(lineNumber) | 127 .setLineNumber(lineNumber) |
100 .setColumnNumber(columnNumber) | 128 .setColumnNumber(columnNumber) |
101 .build(); | 129 .build(); |
102 } | 130 } |
103 | 131 |
| 132 } // namespace |
| 133 |
104 V8DebuggerAgentImpl::V8DebuggerAgentImpl( | 134 V8DebuggerAgentImpl::V8DebuggerAgentImpl( |
105 V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, | 135 V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, |
106 protocol::DictionaryValue* state) | 136 protocol::DictionaryValue* state) |
107 : m_inspector(session->inspector()), | 137 : m_inspector(session->inspector()), |
108 m_debugger(m_inspector->debugger()), | 138 m_debugger(m_inspector->debugger()), |
109 m_session(session), | 139 m_session(session), |
110 m_enabled(false), | 140 m_enabled(false), |
111 m_state(state), | 141 m_state(state), |
112 m_frontend(frontendChannel), | 142 m_frontend(frontendChannel), |
113 m_isolate(m_inspector->isolate()), | 143 m_isolate(m_inspector->isolate()), |
114 m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other), | 144 m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other), |
115 m_scheduledDebuggerStep(NoStep), | 145 m_scheduledDebuggerStep(NoStep), |
116 m_skipNextDebuggerStepOut(false), | 146 m_skipNextDebuggerStepOut(false), |
117 m_javaScriptPauseScheduled(false), | 147 m_javaScriptPauseScheduled(false), |
118 m_steppingFromFramework(false), | 148 m_steppingFromFramework(false), |
119 m_pausingOnNativeEvent(false), | 149 m_pausingOnNativeEvent(false), |
120 m_skippedStepFrameCount(0), | 150 m_skippedStepFrameCount(0), |
121 m_recursionLevelForStepOut(0), | 151 m_recursionLevelForStepOut(0), |
122 m_recursionLevelForStepFrame(0), | 152 m_recursionLevelForStepFrame(0), |
123 m_skipAllPauses(false) { | 153 m_skipAllPauses(false), |
| 154 m_wasmTranslation(m_isolate, this) { |
124 clearBreakDetails(); | 155 clearBreakDetails(); |
125 } | 156 } |
126 | 157 |
127 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() {} | 158 V8DebuggerAgentImpl::~V8DebuggerAgentImpl() {} |
128 | 159 |
129 void V8DebuggerAgentImpl::enableImpl() { | 160 void V8DebuggerAgentImpl::enableImpl() { |
130 // m_inspector->addListener may result in reporting all parsed scripts to | 161 // m_inspector->addListener may result in reporting all parsed scripts to |
131 // the agent so it should already be in enabled state by then. | 162 // the agent so it should already be in enabled state by then. |
132 m_enabled = true; | 163 m_enabled = true; |
133 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); | 164 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 m_javaScriptPauseScheduled = false; | 211 m_javaScriptPauseScheduled = false; |
181 m_steppingFromFramework = false; | 212 m_steppingFromFramework = false; |
182 m_pausingOnNativeEvent = false; | 213 m_pausingOnNativeEvent = false; |
183 m_skippedStepFrameCount = 0; | 214 m_skippedStepFrameCount = 0; |
184 m_recursionLevelForStepFrame = 0; | 215 m_recursionLevelForStepFrame = 0; |
185 m_skipAllPauses = false; | 216 m_skipAllPauses = false; |
186 m_blackboxPattern = nullptr; | 217 m_blackboxPattern = nullptr; |
187 m_state->remove(DebuggerAgentState::blackboxPattern); | 218 m_state->remove(DebuggerAgentState::blackboxPattern); |
188 m_enabled = false; | 219 m_enabled = false; |
189 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); | 220 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); |
| 221 m_wasmTranslation.Clear(); |
190 return Response::OK(); | 222 return Response::OK(); |
191 } | 223 } |
192 | 224 |
193 void V8DebuggerAgentImpl::restore() { | 225 void V8DebuggerAgentImpl::restore() { |
194 DCHECK(!m_enabled); | 226 DCHECK(!m_enabled); |
195 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) | 227 if (!m_state->booleanProperty(DebuggerAgentState::debuggerEnabled, false)) |
196 return; | 228 return; |
197 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) | 229 if (!m_inspector->client()->canExecuteScripts(m_session->contextGroupId())) |
198 return; | 230 return; |
199 | 231 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 DCHECK(enabled()); | 528 DCHECK(enabled()); |
497 // FIXME: remove these checks once crbug.com/520702 is resolved. | 529 // FIXME: remove these checks once crbug.com/520702 is resolved. |
498 CHECK(!breakpointId.isEmpty()); | 530 CHECK(!breakpointId.isEmpty()); |
499 CHECK(!breakpoint.script_id.isEmpty()); | 531 CHECK(!breakpoint.script_id.isEmpty()); |
500 ScriptsMap::iterator scriptIterator = m_scripts.find(breakpoint.script_id); | 532 ScriptsMap::iterator scriptIterator = m_scripts.find(breakpoint.script_id); |
501 if (scriptIterator == m_scripts.end()) return nullptr; | 533 if (scriptIterator == m_scripts.end()) return nullptr; |
502 if (breakpoint.line_number < scriptIterator->second->startLine() || | 534 if (breakpoint.line_number < scriptIterator->second->startLine() || |
503 scriptIterator->second->endLine() < breakpoint.line_number) | 535 scriptIterator->second->endLine() < breakpoint.line_number) |
504 return nullptr; | 536 return nullptr; |
505 | 537 |
| 538 ScriptBreakpoint translatedBreakpoint = |
| 539 TranslateBackWasmScriptBreakpoint(breakpoint, &m_wasmTranslation); |
| 540 |
506 int actualLineNumber; | 541 int actualLineNumber; |
507 int actualColumnNumber; | 542 int actualColumnNumber; |
508 String16 debuggerBreakpointId = m_debugger->setBreakpoint( | 543 String16 debuggerBreakpointId = m_debugger->setBreakpoint( |
509 breakpoint, &actualLineNumber, &actualColumnNumber); | 544 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); |
510 if (debuggerBreakpointId.isEmpty()) return nullptr; | 545 if (debuggerBreakpointId.isEmpty()) return nullptr; |
511 | 546 |
512 m_serverBreakpoints[debuggerBreakpointId] = | 547 m_serverBreakpoints[debuggerBreakpointId] = |
513 std::make_pair(breakpointId, source); | 548 std::make_pair(breakpointId, source); |
514 CHECK(!breakpointId.isEmpty()); | 549 CHECK(!breakpointId.isEmpty()); |
515 | 550 |
516 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back( | 551 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back( |
517 debuggerBreakpointId); | 552 debuggerBreakpointId); |
518 return buildProtocolLocation(breakpoint.script_id, actualLineNumber, | 553 return buildProtocolLocation(translatedBreakpoint.script_id, actualLineNumber, |
519 actualColumnNumber); | 554 actualColumnNumber); |
520 } | 555 } |
521 | 556 |
522 Response V8DebuggerAgentImpl::searchInContent( | 557 Response V8DebuggerAgentImpl::searchInContent( |
523 const String16& scriptId, const String16& query, | 558 const String16& scriptId, const String16& query, |
524 Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex, | 559 Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex, |
525 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results) { | 560 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results) { |
526 v8::HandleScope handles(m_isolate); | 561 v8::HandleScope handles(m_isolate); |
527 ScriptsMap::iterator it = m_scripts.find(scriptId); | 562 ScriptsMap::iterator it = m_scripts.find(scriptId); |
528 if (it == m_scripts.end()) | 563 if (it == m_scripts.end()) |
529 return Response::Error("No script for id: " + scriptId); | 564 return Response::Error("No script for id: " + scriptId); |
530 | 565 |
531 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = | 566 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = |
532 searchInTextByLinesImpl(m_session, | 567 searchInTextByLinesImpl(m_session, it->second->source(m_isolate), query, |
533 toProtocolString(it->second->source(m_isolate)), | 568 optionalCaseSensitive.fromMaybe(false), |
534 query, optionalCaseSensitive.fromMaybe(false), | |
535 optionalIsRegex.fromMaybe(false)); | 569 optionalIsRegex.fromMaybe(false)); |
536 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); | 570 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); |
537 for (size_t i = 0; i < matches.size(); ++i) | 571 for (size_t i = 0; i < matches.size(); ++i) |
538 (*results)->addItem(std::move(matches[i])); | 572 (*results)->addItem(std::move(matches[i])); |
539 return Response::OK(); | 573 return Response::OK(); |
540 } | 574 } |
541 | 575 |
542 Response V8DebuggerAgentImpl::setScriptSource( | 576 Response V8DebuggerAgentImpl::setScriptSource( |
543 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, | 577 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, |
544 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 578 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 return Response::OK(); | 629 return Response::OK(); |
596 } | 630 } |
597 | 631 |
598 Response V8DebuggerAgentImpl::getScriptSource(const String16& scriptId, | 632 Response V8DebuggerAgentImpl::getScriptSource(const String16& scriptId, |
599 String16* scriptSource) { | 633 String16* scriptSource) { |
600 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 634 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
601 ScriptsMap::iterator it = m_scripts.find(scriptId); | 635 ScriptsMap::iterator it = m_scripts.find(scriptId); |
602 if (it == m_scripts.end()) | 636 if (it == m_scripts.end()) |
603 return Response::Error("No script for id: " + scriptId); | 637 return Response::Error("No script for id: " + scriptId); |
604 v8::HandleScope handles(m_isolate); | 638 v8::HandleScope handles(m_isolate); |
605 *scriptSource = toProtocolString(it->second->source(m_isolate)); | 639 *scriptSource = it->second->source(m_isolate); |
606 return Response::OK(); | 640 return Response::OK(); |
607 } | 641 } |
608 | 642 |
609 void V8DebuggerAgentImpl::schedulePauseOnNextStatement( | 643 void V8DebuggerAgentImpl::schedulePauseOnNextStatement( |
610 const String16& breakReason, | 644 const String16& breakReason, |
611 std::unique_ptr<protocol::DictionaryValue> data) { | 645 std::unique_ptr<protocol::DictionaryValue> data) { |
612 if (!enabled() || m_scheduledDebuggerStep == StepInto || | 646 if (!enabled() || m_scheduledDebuggerStep == StepInto || |
613 m_javaScriptPauseScheduled || m_debugger->isPaused() || | 647 m_javaScriptPauseScheduled || m_debugger->isPaused() || |
614 !m_debugger->breakpointsActivated()) | 648 !m_debugger->breakpointsActivated()) |
615 return; | 649 return; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 changeJavaScriptRecursionLevel(+1); | 888 changeJavaScriptRecursionLevel(+1); |
855 // Fast return. | 889 // Fast return. |
856 if (m_scheduledDebuggerStep != StepInto) return; | 890 if (m_scheduledDebuggerStep != StepInto) return; |
857 schedulePauseOnNextStatementIfSteppingInto(); | 891 schedulePauseOnNextStatementIfSteppingInto(); |
858 } | 892 } |
859 | 893 |
860 void V8DebuggerAgentImpl::didExecuteScript() { | 894 void V8DebuggerAgentImpl::didExecuteScript() { |
861 changeJavaScriptRecursionLevel(-1); | 895 changeJavaScriptRecursionLevel(-1); |
862 } | 896 } |
863 | 897 |
| 898 void V8DebuggerAgentImpl::newWasmScript(v8::Local<v8::Object> scriptWrapper) { |
| 899 m_wasmTranslation.AddScript(scriptWrapper); |
| 900 } |
| 901 |
864 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) { | 902 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) { |
865 if (m_javaScriptPauseScheduled && !m_skipAllPauses && | 903 if (m_javaScriptPauseScheduled && !m_skipAllPauses && |
866 !m_debugger->isPaused()) { | 904 !m_debugger->isPaused()) { |
867 // Do not ever loose user's pause request until we have actually paused. | 905 // Do not ever loose user's pause request until we have actually paused. |
868 m_debugger->setPauseOnNextStatement(true); | 906 m_debugger->setPauseOnNextStatement(true); |
869 } | 907 } |
870 if (m_scheduledDebuggerStep == StepOut) { | 908 if (m_scheduledDebuggerStep == StepOut) { |
871 m_recursionLevelForStepOut += step; | 909 m_recursionLevelForStepOut += step; |
872 if (!m_recursionLevelForStepOut) { | 910 if (!m_recursionLevelForStepOut) { |
873 // When StepOut crosses a task boundary (i.e. js -> c++) from where it was | 911 // When StepOut crosses a task boundary (i.e. js -> c++) from where it was |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 return Response::InternalError(); | 1035 return Response::InternalError(); |
998 } | 1036 } |
999 } | 1037 } |
1000 | 1038 |
1001 std::unique_ptr<protocol::Value> protocolValue; | 1039 std::unique_ptr<protocol::Value> protocolValue; |
1002 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); | 1040 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); |
1003 if (!response.isSuccess()) return response; | 1041 if (!response.isSuccess()) return response; |
1004 protocol::ErrorSupport errorSupport; | 1042 protocol::ErrorSupport errorSupport; |
1005 *result = Array<CallFrame>::parse(protocolValue.get(), &errorSupport); | 1043 *result = Array<CallFrame>::parse(protocolValue.get(), &errorSupport); |
1006 if (!*result) return Response::Error(errorSupport.errors()); | 1044 if (!*result) return Response::Error(errorSupport.errors()); |
| 1045 TranslateWasmStackTraceLocations(result->get(), &m_wasmTranslation); |
1007 return Response::OK(); | 1046 return Response::OK(); |
1008 } | 1047 } |
1009 | 1048 |
1010 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { | 1049 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { |
1011 if (m_pausedContext.IsEmpty()) return nullptr; | 1050 if (m_pausedContext.IsEmpty()) return nullptr; |
1012 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); | 1051 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); |
1013 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) | 1052 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) |
1014 : nullptr; | 1053 : nullptr; |
1015 } | 1054 } |
1016 | 1055 |
1017 void V8DebuggerAgentImpl::didParseSource( | 1056 void V8DebuggerAgentImpl::didParseSource( |
1018 std::unique_ptr<V8DebuggerScript> script, bool success) { | 1057 std::unique_ptr<V8DebuggerScript> script, bool success) { |
1019 v8::HandleScope handles(m_isolate); | 1058 v8::HandleScope handles(m_isolate); |
1020 String16 scriptSource = toProtocolString(script->source(m_isolate)); | 1059 String16 scriptSource = script->source(m_isolate); |
1021 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); | 1060 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); |
1022 if (!success) | 1061 if (!success) |
1023 script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); | 1062 script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); |
1024 | 1063 |
1025 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData; | 1064 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData; |
1026 if (!script->executionContextAuxData().isEmpty()) | 1065 if (!script->executionContextAuxData().isEmpty()) |
1027 executionContextAuxData = protocol::DictionaryValue::cast( | 1066 executionContextAuxData = protocol::DictionaryValue::cast( |
1028 protocol::parseJSON(script->executionContextAuxData())); | 1067 protocol::parseJSON(script->executionContextAuxData())); |
1029 bool isLiveEdit = script->isLiveEdit(); | 1068 bool isLiveEdit = script->isLiveEdit(); |
1030 bool hasSourceURL = script->hasSourceURL(); | 1069 bool hasSourceURL = script->hasSourceURL(); |
1031 String16 scriptId = script->scriptId(); | 1070 String16 scriptId = script->scriptId(); |
1032 String16 scriptURL = script->sourceURL(); | 1071 String16 scriptURL = script->sourceURL(); |
1033 | 1072 |
1034 m_scripts[scriptId] = std::move(script); | 1073 m_scripts[scriptId] = std::move(script); |
1035 | 1074 |
1036 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 1075 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
1037 DCHECK(scriptIterator != m_scripts.end()); | 1076 DCHECK(scriptIterator != m_scripts.end()); |
1038 V8DebuggerScript* scriptRef = scriptIterator->second.get(); | 1077 V8DebuggerScript* scriptRef = scriptIterator->second.get(); |
1039 | 1078 |
1040 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL(); | 1079 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL(); |
1041 Maybe<protocol::DictionaryValue> executionContextAuxDataParam( | 1080 Maybe<protocol::DictionaryValue> executionContextAuxDataParam( |
1042 std::move(executionContextAuxData)); | 1081 std::move(executionContextAuxData)); |
1043 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; | 1082 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; |
1044 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; | 1083 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; |
1045 if (success) | 1084 if (success) |
1046 m_frontend.scriptParsed( | 1085 m_frontend.scriptParsed( |
1047 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), | 1086 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
1048 scriptRef->endLine(), scriptRef->endColumn(), | 1087 scriptRef->endLine(), scriptRef->endColumn(), |
1049 scriptRef->executionContextId(), scriptRef->hash(), | 1088 scriptRef->executionContextId(), scriptRef->hash(m_isolate), |
1050 std::move(executionContextAuxDataParam), isLiveEditParam, | 1089 std::move(executionContextAuxDataParam), isLiveEditParam, |
1051 std::move(sourceMapURLParam), hasSourceURLParam); | 1090 std::move(sourceMapURLParam), hasSourceURLParam); |
1052 else | 1091 else |
1053 m_frontend.scriptFailedToParse( | 1092 m_frontend.scriptFailedToParse( |
1054 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), | 1093 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
1055 scriptRef->endLine(), scriptRef->endColumn(), | 1094 scriptRef->endLine(), scriptRef->endColumn(), |
1056 scriptRef->executionContextId(), scriptRef->hash(), | 1095 scriptRef->executionContextId(), scriptRef->hash(m_isolate), |
1057 std::move(executionContextAuxDataParam), std::move(sourceMapURLParam), | 1096 std::move(executionContextAuxDataParam), std::move(sourceMapURLParam), |
1058 hasSourceURLParam); | 1097 hasSourceURLParam); |
1059 | 1098 |
1060 if (scriptURL.isEmpty() || !success) return; | 1099 if (scriptURL.isEmpty() || !success) return; |
1061 | 1100 |
1062 protocol::DictionaryValue* breakpointsCookie = | 1101 protocol::DictionaryValue* breakpointsCookie = |
1063 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); | 1102 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); |
1064 if (!breakpointsCookie) return; | 1103 if (!breakpointsCookie) return; |
1065 | 1104 |
1066 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { | 1105 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 } | 1273 } |
1235 | 1274 |
1236 void V8DebuggerAgentImpl::reset() { | 1275 void V8DebuggerAgentImpl::reset() { |
1237 if (!enabled()) return; | 1276 if (!enabled()) return; |
1238 m_scheduledDebuggerStep = NoStep; | 1277 m_scheduledDebuggerStep = NoStep; |
1239 m_scripts.clear(); | 1278 m_scripts.clear(); |
1240 m_blackboxedPositions.clear(); | 1279 m_blackboxedPositions.clear(); |
1241 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1280 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1242 } | 1281 } |
1243 | 1282 |
| 1283 void V8DebuggerAgentImpl::translateWasmScriptLocation(String16* scriptId, |
| 1284 int* lineNumber, |
| 1285 int* columnNumber) { |
| 1286 m_wasmTranslation.TranslateProtocolLocationToWasmScriptLocation( |
| 1287 scriptId, lineNumber, columnNumber); |
| 1288 } |
| 1289 |
1244 } // namespace v8_inspector | 1290 } // namespace v8_inspector |
OLD | NEW |