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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1043 } | 1043 } |
1044 | 1044 |
1045 void V8DebuggerAgentImpl::didParseSource( | 1045 void V8DebuggerAgentImpl::didParseSource( |
1046 std::unique_ptr<V8DebuggerScript> script, bool success) { | 1046 std::unique_ptr<V8DebuggerScript> script, bool success) { |
1047 v8::HandleScope handles(m_isolate); | 1047 v8::HandleScope handles(m_isolate); |
1048 String16 scriptSource = script->source(m_isolate); | 1048 String16 scriptSource = script->source(m_isolate); |
1049 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); | 1049 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); |
1050 if (!success) | 1050 if (!success) |
1051 script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); | 1051 script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); |
1052 | 1052 |
1053 int contextId = script->executionContextId(); | |
1054 int contextGroupId = m_inspector->contextGroupId(contextId); | |
1055 InspectedContext* inspected = | |
1056 m_inspector->getContext(contextGroupId, contextId); | |
1053 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData; | 1057 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData; |
1054 if (!script->executionContextAuxData().isEmpty()) | 1058 if (inspected) { |
kozy
2016/12/09 00:24:26
Could you put comment here that script can contain
dgozman
2016/12/09 22:30:48
Done.
| |
1055 executionContextAuxData = protocol::DictionaryValue::cast( | 1059 executionContextAuxData = protocol::DictionaryValue::cast( |
1056 protocol::StringUtil::parseJSON(script->executionContextAuxData())); | 1060 protocol::StringUtil::parseJSON(inspected->auxData())); |
1061 } | |
1057 bool isLiveEdit = script->isLiveEdit(); | 1062 bool isLiveEdit = script->isLiveEdit(); |
1058 bool hasSourceURL = script->hasSourceURL(); | 1063 bool hasSourceURL = script->hasSourceURL(); |
1059 String16 scriptId = script->scriptId(); | 1064 String16 scriptId = script->scriptId(); |
1060 String16 scriptURL = script->sourceURL(); | 1065 String16 scriptURL = script->sourceURL(); |
1061 | 1066 |
1062 m_scripts[scriptId] = std::move(script); | 1067 m_scripts[scriptId] = std::move(script); |
1063 | 1068 |
1064 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 1069 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
1065 DCHECK(scriptIterator != m_scripts.end()); | 1070 DCHECK(scriptIterator != m_scripts.end()); |
1066 V8DebuggerScript* scriptRef = scriptIterator->second.get(); | 1071 V8DebuggerScript* scriptRef = scriptIterator->second.get(); |
1067 | 1072 |
1068 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL(); | 1073 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL(); |
1069 Maybe<protocol::DictionaryValue> executionContextAuxDataParam( | 1074 Maybe<protocol::DictionaryValue> executionContextAuxDataParam( |
1070 std::move(executionContextAuxData)); | 1075 std::move(executionContextAuxData)); |
1071 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; | 1076 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; |
1072 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; | 1077 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; |
1073 if (success) | 1078 if (success) |
1074 m_frontend.scriptParsed( | 1079 m_frontend.scriptParsed( |
1075 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), | 1080 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
1076 scriptRef->endLine(), scriptRef->endColumn(), | 1081 scriptRef->endLine(), scriptRef->endColumn(), contextId, |
1077 scriptRef->executionContextId(), scriptRef->hash(m_isolate), | 1082 scriptRef->hash(m_isolate), std::move(executionContextAuxDataParam), |
1078 std::move(executionContextAuxDataParam), isLiveEditParam, | 1083 isLiveEditParam, std::move(sourceMapURLParam), hasSourceURLParam); |
1079 std::move(sourceMapURLParam), hasSourceURLParam); | |
1080 else | 1084 else |
1081 m_frontend.scriptFailedToParse( | 1085 m_frontend.scriptFailedToParse( |
1082 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), | 1086 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
1083 scriptRef->endLine(), scriptRef->endColumn(), | 1087 scriptRef->endLine(), scriptRef->endColumn(), contextId, |
1084 scriptRef->executionContextId(), scriptRef->hash(m_isolate), | 1088 scriptRef->hash(m_isolate), std::move(executionContextAuxDataParam), |
1085 std::move(executionContextAuxDataParam), std::move(sourceMapURLParam), | 1089 std::move(sourceMapURLParam), hasSourceURLParam); |
1086 hasSourceURLParam); | |
1087 | 1090 |
1088 if (scriptURL.isEmpty() || !success) return; | 1091 if (scriptURL.isEmpty() || !success) return; |
1089 | 1092 |
1090 protocol::DictionaryValue* breakpointsCookie = | 1093 protocol::DictionaryValue* breakpointsCookie = |
1091 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); | 1094 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); |
1092 if (!breakpointsCookie) return; | 1095 if (!breakpointsCookie) return; |
1093 | 1096 |
1094 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { | 1097 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { |
1095 auto cookie = breakpointsCookie->at(i); | 1098 auto cookie = breakpointsCookie->at(i); |
1096 protocol::DictionaryValue* breakpointObject = | 1099 protocol::DictionaryValue* breakpointObject = |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1143 if (!topCallFrame) return RequestContinue; | 1146 if (!topCallFrame) return RequestContinue; |
1144 | 1147 |
1145 DCHECK(m_pausedContext.IsEmpty()); | 1148 DCHECK(m_pausedContext.IsEmpty()); |
1146 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); | 1149 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); |
1147 m_pausedCallFrames.swap(frames); | 1150 m_pausedCallFrames.swap(frames); |
1148 m_pausedContext.Reset(m_isolate, context); | 1151 m_pausedContext.Reset(m_isolate, context); |
1149 v8::HandleScope handles(m_isolate); | 1152 v8::HandleScope handles(m_isolate); |
1150 | 1153 |
1151 if (!exception.IsEmpty()) { | 1154 if (!exception.IsEmpty()) { |
1152 InjectedScript* injectedScript = nullptr; | 1155 InjectedScript* injectedScript = nullptr; |
1153 m_session->findInjectedScript(V8Debugger::contextId(context), | 1156 m_session->findInjectedScript(InspectedContext::contextId(context), |
1154 injectedScript); | 1157 injectedScript); |
1155 if (injectedScript) { | 1158 if (injectedScript) { |
1156 m_breakReason = | 1159 m_breakReason = |
1157 isPromiseRejection | 1160 isPromiseRejection |
1158 ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection | 1161 ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection |
1159 : protocol::Debugger::Paused::ReasonEnum::Exception; | 1162 : protocol::Debugger::Paused::ReasonEnum::Exception; |
1160 std::unique_ptr<protocol::Runtime::RemoteObject> obj; | 1163 std::unique_ptr<protocol::Runtime::RemoteObject> obj; |
1161 injectedScript->wrapObject(exception, kBacktraceObjectGroup, false, false, | 1164 injectedScript->wrapObject(exception, kBacktraceObjectGroup, false, false, |
1162 &obj); | 1165 &obj); |
1163 if (obj) { | 1166 if (obj) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1262 | 1265 |
1263 void V8DebuggerAgentImpl::reset() { | 1266 void V8DebuggerAgentImpl::reset() { |
1264 if (!enabled()) return; | 1267 if (!enabled()) return; |
1265 m_scheduledDebuggerStep = NoStep; | 1268 m_scheduledDebuggerStep = NoStep; |
1266 m_scripts.clear(); | 1269 m_scripts.clear(); |
1267 m_blackboxedPositions.clear(); | 1270 m_blackboxedPositions.clear(); |
1268 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1271 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1269 } | 1272 } |
1270 | 1273 |
1271 } // namespace v8_inspector | 1274 } // namespace v8_inspector |
OLD | NEW |