From 69d166fcef67fc9497abcc233a08e07fd6c31beb Mon Sep 17 00:00:00 2001 From: Alexey Kozyatinskiy Date: Thu, 21 Jun 2018 07:24:46 -0700 Subject: [PATCH] [debug] migrate all liveedit tests to use LiveEdit::PatchScript After this CL all liveedit tests call the same LiveEdit::PatchScript method. This method will be updated later. As well some new liveedit cctests added, unfortunately part of them do not work with current implementation. R=dgozman@chromium.org,yangguo@chromium.org Bug: v8:7862 Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;luci.chromium.try:linux_chromium_rel_ng;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I3521af12b0f95b39d13aaafb1d1cf60f3f642a97 Reviewed-on: https://chromium-review.googlesource.com/1108382 Commit-Queue: Aleksey Kozyatinskiy Reviewed-by: Yang Guo Reviewed-by: Dmitry Gozman Cr-Commit-Position: refs/heads/master@{#53936} --- src/api.cc | 6 +- src/debug/debug-interface.h | 21 +- src/debug/debug.cc | 53 +++- src/debug/debug.h | 4 +- src/debug/liveedit.cc | 5 + src/debug/liveedit.h | 5 + src/inspector/v8-debugger-agent-impl.cc | 85 +---- src/inspector/v8-debugger-script.cc | 12 +- src/inspector/v8-debugger-script.h | 2 +- src/runtime/runtime-debug.cc | 38 +++ src/runtime/runtime.h | 3 +- test/cctest/test-liveedit.cc | 296 ++++++++++++++++++ test/debugger/debug/debug-liveedit-1.js | 9 +- test/debugger/debug/debug-liveedit-2.js | 14 +- test/debugger/debug/debug-liveedit-3.js | 13 +- test/debugger/debug/debug-liveedit-4.js | 9 +- .../debug/debug-liveedit-check-stack.js | 34 +- .../debug/debug-liveedit-compile-error.js | 18 +- .../debug/debug-liveedit-double-call.js | 3 +- .../debug/debug-liveedit-exceptions.js | 7 +- test/debugger/debug/debug-liveedit-inline.js | 14 +- .../debugger/debug/debug-liveedit-literals.js | 12 +- .../debug/debug-liveedit-newsource.js | 10 +- .../debug-liveedit-patch-positions-replace.js | 19 +- .../debug/debug-liveedit-replace-code.js | 10 +- .../debug/debug-liveedit-stack-padding.js | 20 +- test/debugger/debug/debug-liveedit-stepin.js | 13 +- .../debug/es6/debug-liveedit-new-target-1.js | 13 +- .../debug/es6/debug-liveedit-new-target-2.js | 13 +- .../debug/es6/debug-liveedit-new-target-3.js | 9 +- .../debug/es6/generators-debug-liveedit.js | 28 +- .../debug/es8/debug-async-liveedit.js | 37 ++- test/debugger/test-api.js | 5 - .../inspector/debugger/set-script-source-2.js | 2 + .../set-script-source-exception-expected.txt | 12 +- .../debugger/set-script-source-expected.txt | 4 +- 36 files changed, 557 insertions(+), 301 deletions(-) diff --git a/src/api.cc b/src/api.cc index ea7c126aa5..65043dbdf6 100644 --- a/src/api.cc +++ b/src/api.cc @@ -33,6 +33,7 @@ #include "src/debug/debug-evaluate.h" #include "src/debug/debug-type-profile.h" #include "src/debug/debug.h" +#include "src/debug/liveedit.h" #include "src/deoptimizer.h" #include "src/detachable-vector.h" #include "src/execution.h" @@ -9404,11 +9405,12 @@ v8::debug::Location debug::Script::GetSourceLocation(int offset) const { } bool debug::Script::SetScriptSource(v8::Local newSource, - bool preview, bool* stack_changed) const { + bool preview, + debug::LiveEditResult* result) const { i::Handle script = Utils::OpenHandle(this); i::Isolate* isolate = script->GetIsolate(); return isolate->debug()->SetScriptSource( - script, Utils::OpenHandle(*newSource), preview, stack_changed); + script, Utils::OpenHandle(*newSource), preview, result); } bool debug::Script::SetBreakpoint(v8::Local condition, diff --git a/src/debug/debug-interface.h b/src/debug/debug-interface.h index c075d0b492..01f45871cc 100644 --- a/src/debug/debug-interface.h +++ b/src/debug/debug-interface.h @@ -86,6 +86,25 @@ void BreakRightNow(Isolate* isolate); bool AllFramesOnStackAreBlackboxed(Isolate* isolate); +struct LiveEditResult { + enum Status { + OK, + COMPILE_ERROR, + BLOCKED_BY_RUNNING_GENERATOR, + BLOCKED_BY_FUNCTION_ABOVE_BREAK_FRAME, + BLOCKED_BY_FUNCTION_BELOW_NON_DROPPABLE_FRAME, + BLOCKED_BY_ACTIVE_FUNCTION, + BLOCKED_BY_NEW_TARGET_IN_RESTART_FRAME, + FRAME_RESTART_IS_NOT_SUPPORTED + }; + Status status = OK; + bool stack_changed = false; + // Fields below are available only for COMPILE_ERROR. + v8::Local message; + int line_number = -1; + int column_number = -1; +}; + /** * Native wrapper around v8::internal::Script object. */ @@ -114,7 +133,7 @@ class V8_EXPORT_PRIVATE Script { 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; + LiveEditResult* result) const; bool SetBreakpoint(v8::Local condition, debug::Location* location, BreakpointId* id) const; }; diff --git a/src/debug/debug.cc b/src/debug/debug.cc index 6b8937839b..ff398c65a0 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -601,7 +601,7 @@ bool Debug::IsMutedAtCurrentLocation(JavaScriptFrame* frame) { MaybeHandle Debug::CallFunction(const char* name, int argc, Handle args[], - bool catch_exceptions) { + MaybeHandle* maybe_exception) { AllowJavascriptExecutionDebugOnly allow_script(isolate_); PostponeInterruptsScope no_interrupts(isolate_); AssertDebugContext(); @@ -610,17 +610,11 @@ MaybeHandle Debug::CallFunction(const char* name, int argc, Handle fun = Handle::cast( JSReceiver::GetProperty(isolate_, holder, name).ToHandleChecked()); Handle undefined = isolate_->factory()->undefined_value(); - if (catch_exceptions) { - MaybeHandle maybe_exception; - return Execution::TryCall(isolate_, fun, undefined, argc, args, - Execution::MessageHandling::kReport, - &maybe_exception); - } else { - return Execution::Call(isolate_, fun, undefined, argc, args); - } + return Execution::TryCall(isolate_, fun, undefined, argc, args, + Execution::MessageHandling::kReport, + maybe_exception); } - // Check whether a single break point object is triggered. bool Debug::CheckBreakPoint(Handle break_point, bool is_break_at_entry) { @@ -1907,22 +1901,52 @@ bool Debug::CanBreakAtEntry(Handle shared) { } bool Debug::SetScriptSource(Handle