[debugger,api] deprecate everything in v8-debug.h

R=clemensh@chromium.org, jgruber@chromium.org
BUG=v8:5530

Review-Url: https://codereview.chromium.org/2727393003
Cr-Commit-Position: refs/heads/master@{#43714}
This commit is contained in:
yangguo 2017-03-09 23:06:25 -08:00 committed by Commit bot
parent a3a244cb87
commit faf5f52627
6 changed files with 323 additions and 353 deletions

View File

@ -8,7 +8,9 @@
#include "v8.h" // NOLINT(build/include)
/**
* Debugger support for the V8 JavaScript engine.
* ATTENTION: The debugger API exposed by this file is deprecated and will be
* removed by the end of 2017. Please use the V8 inspector declared
* in include/v8-inspector.h instead.
*/
namespace v8 {
@ -140,21 +142,19 @@ class V8_EXPORT Debug {
*/
typedef void (*MessageHandler)(const Message& message);
/**
* This is now a no-op.
*/
typedef void (*DebugMessageDispatchHandler)();
static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
Local<Value> data = Local<Value>());
V8_DEPRECATED("No longer supported", static bool SetDebugEventListener(
Isolate* isolate, EventCallback that,
Local<Value> data = Local<Value>()));
// Schedule a debugger break to happen when JavaScript code is run
// in the given isolate.
static void DebugBreak(Isolate* isolate);
V8_DEPRECATED("No longer supported",
static void DebugBreak(Isolate* isolate));
// Remove scheduled debugger break in given isolate if it has not
// happened yet.
static void CancelDebugBreak(Isolate* isolate);
V8_DEPRECATED("No longer supported",
static void CancelDebugBreak(Isolate* isolate));
// Check if a debugger break is scheduled in the given isolate.
V8_DEPRECATED("No longer supported",
@ -189,10 +189,10 @@ class V8_EXPORT Debug {
* }
* \endcode
*/
// TODO(dcarney): data arg should be a MaybeLocal
static MaybeLocal<Value> Call(Local<Context> context,
v8::Local<v8::Function> fun,
Local<Value> data = Local<Value>());
V8_DEPRECATED("No longer supported",
static MaybeLocal<Value> Call(
Local<Context> context, v8::Local<v8::Function> fun,
Local<Value> data = Local<Value>()));
// This is now a no-op.
V8_DEPRECATED("No longer supported",
@ -221,23 +221,28 @@ class V8_EXPORT Debug {
* (default Isolate if not provided). V8 will abort if LiveEdit is
* unexpectedly used. LiveEdit is enabled by default.
*/
static void SetLiveEditEnabled(Isolate* isolate, bool enable);
V8_DEPRECATED("No longer supported",
static void SetLiveEditEnabled(Isolate* isolate, bool enable));
/**
* Returns array of internal properties specific to the value type. Result has
* the following format: [<name>, <value>,...,<name>, <value>]. Result array
* will be allocated in the current context.
*/
static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
Local<Value> value);
V8_DEPRECATED("No longer supported",
static MaybeLocal<Array> GetInternalProperties(
Isolate* isolate, Local<Value> value));
/**
* Defines if the ES2015 tail call elimination feature is enabled or not.
* The change of this flag triggers deoptimization of all functions that
* contain calls at tail position.
*/
static bool IsTailCallEliminationEnabled(Isolate* isolate);
static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled);
V8_DEPRECATED("No longer supported",
static bool IsTailCallEliminationEnabled(Isolate* isolate));
V8_DEPRECATED("No longer supported",
static void SetTailCallEliminationEnabled(Isolate* isolate,
bool enabled));
};

View File

@ -8961,17 +8961,12 @@ bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that,
return true;
}
void Debug::DebugBreak(Isolate* isolate) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
}
void Debug::DebugBreak(Isolate* isolate) { debug::DebugBreak(isolate); }
void Debug::CancelDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->ClearDebugBreak();
debug::CancelDebugBreak(isolate);
}
bool Debug::CheckDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
return internal_isolate->stack_guard()->CheckDebugBreak();
@ -8986,29 +8981,15 @@ void Debug::SendCommand(Isolate* isolate, const uint16_t* command, int length,
MaybeLocal<Value> Debug::Call(Local<Context> context,
v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) {
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
i::Handle<i::Object> data_obj;
if (data.IsEmpty()) {
data_obj = isolate->factory()->undefined_value();
} else {
data_obj = Utils::OpenHandle(*data);
}
Local<Value> result;
has_pending_exception =
!ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj),
&result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
return debug::Call(context, fun, data);
}
void Debug::ProcessDebugMessages(Isolate* isolate) {}
Local<Context> Debug::GetDebugContext(Isolate* isolate) {
return debug::GetDebugContext(isolate);
}
MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
ENTER_V8(i_isolate);
@ -9019,8 +9000,7 @@ MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
}
void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->set_live_edit_enabled(enable);
debug::SetLiveEditEnabled(isolate, enable);
}
bool Debug::IsTailCallEliminationEnabled(Isolate* isolate) {
@ -9035,13 +9015,7 @@ void Debug::SetTailCallEliminationEnabled(Isolate* isolate, bool enabled) {
MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate,
Local<Value> value) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
i::Handle<i::Object> val = Utils::OpenHandle(*value);
i::Handle<i::JSArray> result;
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
return MaybeLocal<Array>();
return Utils::ToLocal(result);
return debug::GetInternalProperties(v8_isolate, value);
}
Local<Context> debug::GetDebugContext(Isolate* isolate) {
@ -9053,22 +9027,43 @@ Local<Context> debug::GetDebugContext(Isolate* isolate) {
MaybeLocal<Value> debug::Call(Local<Context> context,
v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) {
return Debug::Call(context, fun, data);
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
i::Handle<i::Object> data_obj;
if (data.IsEmpty()) {
data_obj = isolate->factory()->undefined_value();
} else {
data_obj = Utils::OpenHandle(*data);
}
Local<Value> result;
has_pending_exception = !ToLocal<Value>(
isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
}
void debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
Debug::SetLiveEditEnabled(isolate, enable);
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->set_live_edit_enabled(enable);
}
void debug::DebugBreak(Isolate* isolate) { Debug::DebugBreak(isolate); }
void debug::DebugBreak(Isolate* isolate) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
}
void debug::CancelDebugBreak(Isolate* isolate) {
Debug::CancelDebugBreak(isolate);
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->ClearDebugBreak();
}
MaybeLocal<Array> debug::GetInternalProperties(Isolate* isolate,
MaybeLocal<Array> debug::GetInternalProperties(Isolate* v8_isolate,
Local<Value> value) {
return Debug::GetInternalProperties(isolate, value);
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
i::Handle<i::Object> val = Utils::OpenHandle(*value);
i::Handle<i::JSArray> result;
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
return MaybeLocal<Array>();
return Utils::ToLocal(result);
}
void debug::ChangeBreakOnException(Isolate* isolate, ExceptionBreakState type) {

View File

@ -31,7 +31,7 @@
#include <memory>
#include "include/libplatform/libplatform.h"
#include "include/v8-debug.h"
#include "src/debug/debug-interface.h"
#include "src/utils.h"
#include "src/v8.h"
#include "src/zone/accounting-allocator.h"
@ -547,18 +547,15 @@ static inline void CheckDoubleEquals(double expected, double actual) {
CHECK_GE(expected, actual - kEpsilon);
}
static void DummyDebugEventListener(
const v8::Debug::EventDetails& event_details) {}
static v8::debug::DebugDelegate dummy_delegate;
static inline void EnableDebugger(v8::Isolate* isolate) {
v8::Debug::SetDebugEventListener(isolate, &DummyDebugEventListener);
v8::debug::SetDebugDelegate(isolate, &dummy_delegate);
}
static inline void DisableDebugger(v8::Isolate* isolate) {
v8::Debug::SetDebugEventListener(isolate, nullptr);
v8::debug::SetDebugDelegate(isolate, nullptr);
}

View File

@ -6,6 +6,7 @@
#include "src/compilation-info.h"
#include "src/compiler/pipeline.h"
#include "src/debug/debug-interface.h"
#include "src/execution.h"
#include "src/handles.h"
#include "src/interpreter/bytecode-array-builder.h"
@ -2966,16 +2967,22 @@ TEST(BytecodeGraphBuilderIllegalConstDeclaration) {
}
}
static int debug_break_count = 0;
static void DebugEventCounter(const v8::Debug::EventDetails& event_details) {
if (event_details.GetEvent() == v8::Break) debug_break_count++;
}
class CountBreakDebugDelegate : public v8::debug::DebugDelegate {
public:
void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit) override {
debug_break_count++;
}
int debug_break_count = 0;
};
TEST(BytecodeGraphBuilderDebuggerStatement) {
CountBreakDebugDelegate delegate;
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
v8::Debug::SetDebugEventListener(CcTest::isolate(), DebugEventCounter);
v8::debug::SetDebugDelegate(CcTest::isolate(), &delegate);
ExpectedSnippet<0> snippet = {
"function f() {"
@ -2988,9 +2995,9 @@ TEST(BytecodeGraphBuilderDebuggerStatement) {
auto callable = tester.GetCallable<>();
Handle<Object> return_value = callable().ToHandleChecked();
v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr);
v8::debug::SetDebugDelegate(CcTest::isolate(), nullptr);
CHECK(return_value.is_identical_to(snippet.return_value()));
CHECK_EQ(2, debug_break_count);
CHECK_EQ(2, delegate.debug_break_count);
}
} // namespace compiler

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@ void CheckLocationsFail(WasmCompiledModule *compiled_module,
CHECK(!success);
}
class BreakHandler {
class BreakHandler : public debug::DebugDelegate {
public:
enum Action {
Continue = StepAction::LastStepAction + 1,
@ -72,18 +72,13 @@ class BreakHandler {
explicit BreakHandler(Isolate* isolate,
std::initializer_list<BreakPoint> expected_breaks)
: isolate_(isolate), expected_breaks_(expected_breaks) {
current_handler = this;
v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate),
DebugEventListener);
v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), this);
}
~BreakHandler() {
// Check that all expected breakpoints have been hit.
CHECK_EQ(count_, expected_breaks_.size());
// BreakHandlers must be correctly stacked.
CHECK_EQ(this, current_handler);
current_handler = nullptr;
v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate_),
nullptr);
v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_),
nullptr);
}
int count() const { return count_; }
@ -93,9 +88,9 @@ class BreakHandler {
int count_ = 0;
std::vector<BreakPoint> expected_breaks_;
static BreakHandler* current_handler;
void HandleBreak() {
void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit) override {
printf("Break #%d\n", count_);
CHECK_GT(expected_breaks_.size(), count_);
@ -118,18 +113,8 @@ class BreakHandler {
}
++count_;
}
static void DebugEventListener(const v8::Debug::EventDetails& event_details) {
if (event_details.GetEvent() != v8::DebugEvent::Break) return;
CHECK_NOT_NULL(current_handler);
current_handler->HandleBreak();
}
};
// static
BreakHandler* BreakHandler::current_handler = nullptr;
Handle<JSObject> MakeFakeBreakpoint(Isolate* isolate, int position) {
Handle<JSObject> obj =
isolate->factory()->NewJSObject(isolate->object_function());