From 6b0bf1659e734d2e1c67cc874bd08c60a2b24cf4 Mon Sep 17 00:00:00 2001 From: Alexey Kozyatinskiy Date: Fri, 28 Jul 2017 11:48:22 -0700 Subject: [PATCH] [inspector] move SetScriptSource call to native To avoid using debugging context and debugger-script.js on inspector side we can move SetScriptSource call to v8::internal::Debug. Theoretically we can move live edit implementation to native completely but since it will be reimplemented it looks redundant. R=yangguo@chromium.org,jgruber@chromium.org Bug: chromium:652939 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Id09492c2d2a93efbde429c9cc1bc181d5fdda19b Reviewed-on: https://chromium-review.googlesource.com/590736 Commit-Queue: Aleksey Kozyatinskiy Reviewed-by: Jakob Gruber Cr-Commit-Position: refs/heads/master@{#46985} --- src/api.cc | 8 ++ src/debug/debug-interface.h | 4 +- src/debug/debug.cc | 42 ++++++- src/debug/debug.h | 12 +- src/debug/liveedit.js | 5 + src/inspector/debugger-script.js | 39 ------- src/inspector/debugger_script_externs.js | 25 ----- src/inspector/v8-debugger-agent-impl.cc | 94 ++++++++++++++-- src/inspector/v8-debugger-script.cc | 15 +++ src/inspector/v8-debugger-script.h | 6 +- src/inspector/v8-debugger.cc | 104 +----------------- src/inspector/v8-debugger.h | 7 +- .../debugger/set-script-source-2-expected.txt | 73 ++++++++++++ .../inspector/debugger/set-script-source-2.js | 97 ++++++++++++++++ test/inspector/protocol-test.js | 4 +- 15 files changed, 340 insertions(+), 195 deletions(-) create mode 100644 test/inspector/debugger/set-script-source-2-expected.txt create mode 100644 test/inspector/debugger/set-script-source-2.js diff --git a/src/api.cc b/src/api.cc index 838c72853c..a2abb582a3 100644 --- a/src/api.cc +++ b/src/api.cc @@ -9666,6 +9666,14 @@ v8::debug::Location debug::Script::GetSourceLocation(int offset) const { return debug::Location(info.line, info.column); } +bool debug::Script::SetScriptSource(v8::Local newSource, + bool preview, bool* stack_changed) const { + i::Handle script = Utils::OpenHandle(this); + i::Isolate* isolate = script->GetIsolate(); + return isolate->debug()->SetScriptSource( + script, Utils::OpenHandle(*newSource), preview, stack_changed); +} + debug::WasmScript* debug::WasmScript::Cast(debug::Script* script) { CHECK(script->IsWasm()); return static_cast(script); diff --git a/src/debug/debug-interface.h b/src/debug/debug-interface.h index 532c19f41a..4cd2c97863 100644 --- a/src/debug/debug-interface.h +++ b/src/debug/debug-interface.h @@ -146,6 +146,8 @@ class V8_EXPORT_PRIVATE Script { std::vector* locations) const; int GetSourceOffset(const debug::Location& location) const; v8::debug::Location GetSourceLocation(int offset) const; + bool SetScriptSource(v8::Local newSource, bool preview, + bool* stack_changed) const; }; // Specialization for wasm Scripts. @@ -171,7 +173,7 @@ class DebugDelegate { virtual ~DebugDelegate() {} virtual void PromiseEventOccurred(debug::PromiseDebugActionType type, int id, int parent_id, bool created_by_user) {} - virtual void ScriptCompiled(v8::Local