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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 return Response::OK(); | 515 return Response::OK(); |
516 } | 516 } |
517 | 517 |
518 Response V8DebuggerAgentImpl::setScriptSource( | 518 Response V8DebuggerAgentImpl::setScriptSource( |
519 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, | 519 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, |
520 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 520 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
521 Maybe<bool>* stackChanged, Maybe<StackTrace>* asyncStackTrace, | 521 Maybe<bool>* stackChanged, Maybe<StackTrace>* asyncStackTrace, |
522 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) { | 522 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) { |
523 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 523 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
524 | 524 |
| 525 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 526 if (it == m_scripts.end()) { |
| 527 return Response::Error("No script with given id found"); |
| 528 } |
| 529 if (it->second->isModule()) { |
| 530 // TODO(kozyatinskiy): LiveEdit should support ES6 module |
| 531 return Response::Error("Editing module's script is not supported."); |
| 532 } |
| 533 |
525 v8::HandleScope handles(m_isolate); | 534 v8::HandleScope handles(m_isolate); |
526 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); | 535 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent); |
527 bool compileError = false; | 536 bool compileError = false; |
528 Response response = m_debugger->setScriptSource( | 537 Response response = m_debugger->setScriptSource( |
529 scriptId, newSource, dryRun.fromMaybe(false), optOutCompileError, | 538 scriptId, newSource, dryRun.fromMaybe(false), optOutCompileError, |
530 &m_pausedCallFrames, stackChanged, &compileError); | 539 &m_pausedCallFrames, stackChanged, &compileError); |
531 if (!response.isSuccess() || compileError) return response; | 540 if (!response.isSuccess() || compileError) return response; |
532 | 541 |
533 ScriptsMap::iterator it = m_scripts.find(scriptId); | 542 it->second->setSource(newSource); |
534 if (it != m_scripts.end()) it->second->setSource(newSource); | |
535 | |
536 std::unique_ptr<Array<CallFrame>> callFrames; | 543 std::unique_ptr<Array<CallFrame>> callFrames; |
537 response = currentCallFrames(&callFrames); | 544 response = currentCallFrames(&callFrames); |
538 if (!response.isSuccess()) return response; | 545 if (!response.isSuccess()) return response; |
539 *newCallFrames = std::move(callFrames); | 546 *newCallFrames = std::move(callFrames); |
540 *asyncStackTrace = currentAsyncStackTrace(); | 547 *asyncStackTrace = currentAsyncStackTrace(); |
541 return Response::OK(); | 548 return Response::OK(); |
542 } | 549 } |
543 | 550 |
544 Response V8DebuggerAgentImpl::restartFrame( | 551 Response V8DebuggerAgentImpl::restartFrame( |
545 const String16& callFrameId, | 552 const String16& callFrameId, |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 void V8DebuggerAgentImpl::reset() { | 1177 void V8DebuggerAgentImpl::reset() { |
1171 if (!enabled()) return; | 1178 if (!enabled()) return; |
1172 m_scheduledDebuggerStep = NoStep; | 1179 m_scheduledDebuggerStep = NoStep; |
1173 m_blackboxedPositions.clear(); | 1180 m_blackboxedPositions.clear(); |
1174 resetBlackboxedStateCache(); | 1181 resetBlackboxedStateCache(); |
1175 m_scripts.clear(); | 1182 m_scripts.clear(); |
1176 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1183 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1177 } | 1184 } |
1178 | 1185 |
1179 } // namespace v8_inspector | 1186 } // namespace v8_inspector |
OLD | NEW |