Commit faf5f526 authored by yangguo's avatar yangguo Committed by Commit bot

[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}
parent a3a244cb
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include "v8.h" // NOLINT(build/include) #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 { namespace v8 {
...@@ -140,21 +142,19 @@ class V8_EXPORT Debug { ...@@ -140,21 +142,19 @@ class V8_EXPORT Debug {
*/ */
typedef void (*MessageHandler)(const Message& message); typedef void (*MessageHandler)(const Message& message);
/** V8_DEPRECATED("No longer supported", static bool SetDebugEventListener(
* This is now a no-op. Isolate* isolate, EventCallback that,
*/ Local<Value> data = Local<Value>()));
typedef void (*DebugMessageDispatchHandler)();
static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
Local<Value> data = Local<Value>());
// Schedule a debugger break to happen when JavaScript code is run // Schedule a debugger break to happen when JavaScript code is run
// in the given isolate. // 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 // Remove scheduled debugger break in given isolate if it has not
// happened yet. // 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. // Check if a debugger break is scheduled in the given isolate.
V8_DEPRECATED("No longer supported", V8_DEPRECATED("No longer supported",
...@@ -189,10 +189,10 @@ class V8_EXPORT Debug { ...@@ -189,10 +189,10 @@ class V8_EXPORT Debug {
* } * }
* \endcode * \endcode
*/ */
// TODO(dcarney): data arg should be a MaybeLocal V8_DEPRECATED("No longer supported",
static MaybeLocal<Value> Call(Local<Context> context, static MaybeLocal<Value> Call(
v8::Local<v8::Function> fun, Local<Context> context, v8::Local<v8::Function> fun,
Local<Value> data = Local<Value>()); Local<Value> data = Local<Value>()));
// This is now a no-op. // This is now a no-op.
V8_DEPRECATED("No longer supported", V8_DEPRECATED("No longer supported",
...@@ -221,23 +221,28 @@ class V8_EXPORT Debug { ...@@ -221,23 +221,28 @@ class V8_EXPORT Debug {
* (default Isolate if not provided). V8 will abort if LiveEdit is * (default Isolate if not provided). V8 will abort if LiveEdit is
* unexpectedly used. LiveEdit is enabled by default. * 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 * Returns array of internal properties specific to the value type. Result has
* the following format: [<name>, <value>,...,<name>, <value>]. Result array * the following format: [<name>, <value>,...,<name>, <value>]. Result array
* will be allocated in the current context. * will be allocated in the current context.
*/ */
static MaybeLocal<Array> GetInternalProperties(Isolate* isolate, V8_DEPRECATED("No longer supported",
Local<Value> value); static MaybeLocal<Array> GetInternalProperties(
Isolate* isolate, Local<Value> value));
/** /**
* Defines if the ES2015 tail call elimination feature is enabled or not. * Defines if the ES2015 tail call elimination feature is enabled or not.
* The change of this flag triggers deoptimization of all functions that * The change of this flag triggers deoptimization of all functions that
* contain calls at tail position. * contain calls at tail position.
*/ */
static bool IsTailCallEliminationEnabled(Isolate* isolate); V8_DEPRECATED("No longer supported",
static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled); static bool IsTailCallEliminationEnabled(Isolate* isolate));
V8_DEPRECATED("No longer supported",
static void SetTailCallEliminationEnabled(Isolate* isolate,
bool enabled));
}; };
......
...@@ -8961,17 +8961,12 @@ bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that, ...@@ -8961,17 +8961,12 @@ bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that,
return true; return true;
} }
void Debug::DebugBreak(Isolate* isolate) { void Debug::DebugBreak(Isolate* isolate) { debug::DebugBreak(isolate); }
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
}
void Debug::CancelDebugBreak(Isolate* isolate) { void Debug::CancelDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); debug::CancelDebugBreak(isolate);
internal_isolate->stack_guard()->ClearDebugBreak();
} }
bool Debug::CheckDebugBreak(Isolate* isolate) { bool Debug::CheckDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
return internal_isolate->stack_guard()->CheckDebugBreak(); return internal_isolate->stack_guard()->CheckDebugBreak();
...@@ -8986,29 +8981,15 @@ void Debug::SendCommand(Isolate* isolate, const uint16_t* command, int length, ...@@ -8986,29 +8981,15 @@ void Debug::SendCommand(Isolate* isolate, const uint16_t* command, int length,
MaybeLocal<Value> Debug::Call(Local<Context> context, MaybeLocal<Value> Debug::Call(Local<Context> context,
v8::Local<v8::Function> fun, v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) { v8::Local<v8::Value> data) {
PREPARE_FOR_EXECUTION(context, Debug, Call, Value); return debug::Call(context, fun, data);
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::ProcessDebugMessages(Isolate* isolate) {} void Debug::ProcessDebugMessages(Isolate* isolate) {}
Local<Context> Debug::GetDebugContext(Isolate* isolate) { Local<Context> Debug::GetDebugContext(Isolate* isolate) {
return debug::GetDebugContext(isolate); return debug::GetDebugContext(isolate);
} }
MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) { MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
ENTER_V8(i_isolate); ENTER_V8(i_isolate);
...@@ -9019,8 +9000,7 @@ MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) { ...@@ -9019,8 +9000,7 @@ MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
} }
void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) { void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); debug::SetLiveEditEnabled(isolate, enable);
internal_isolate->debug()->set_live_edit_enabled(enable);
} }
bool Debug::IsTailCallEliminationEnabled(Isolate* isolate) { bool Debug::IsTailCallEliminationEnabled(Isolate* isolate) {
...@@ -9035,13 +9015,7 @@ void Debug::SetTailCallEliminationEnabled(Isolate* isolate, bool enabled) { ...@@ -9035,13 +9015,7 @@ void Debug::SetTailCallEliminationEnabled(Isolate* isolate, bool enabled) {
MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate, MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate,
Local<Value> value) { Local<Value> value) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); return debug::GetInternalProperties(v8_isolate, value);
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);
} }
Local<Context> debug::GetDebugContext(Isolate* isolate) { Local<Context> debug::GetDebugContext(Isolate* isolate) {
...@@ -9053,22 +9027,43 @@ Local<Context> debug::GetDebugContext(Isolate* isolate) { ...@@ -9053,22 +9027,43 @@ Local<Context> debug::GetDebugContext(Isolate* isolate) {
MaybeLocal<Value> debug::Call(Local<Context> context, MaybeLocal<Value> debug::Call(Local<Context> context,
v8::Local<v8::Function> fun, v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) { 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) { 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) { 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) { 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) { void debug::ChangeBreakOnException(Isolate* isolate, ExceptionBreakState type) {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <memory> #include <memory>
#include "include/libplatform/libplatform.h" #include "include/libplatform/libplatform.h"
#include "include/v8-debug.h" #include "src/debug/debug-interface.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/v8.h" #include "src/v8.h"
#include "src/zone/accounting-allocator.h" #include "src/zone/accounting-allocator.h"
...@@ -547,18 +547,15 @@ static inline void CheckDoubleEquals(double expected, double actual) { ...@@ -547,18 +547,15 @@ static inline void CheckDoubleEquals(double expected, double actual) {
CHECK_GE(expected, actual - kEpsilon); CHECK_GE(expected, actual - kEpsilon);
} }
static v8::debug::DebugDelegate dummy_delegate;
static void DummyDebugEventListener(
const v8::Debug::EventDetails& event_details) {}
static inline void EnableDebugger(v8::Isolate* isolate) { 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) { static inline void DisableDebugger(v8::Isolate* isolate) {
v8::Debug::SetDebugEventListener(isolate, nullptr); v8::debug::SetDebugDelegate(isolate, nullptr);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "src/compilation-info.h" #include "src/compilation-info.h"
#include "src/compiler/pipeline.h" #include "src/compiler/pipeline.h"
#include "src/debug/debug-interface.h"
#include "src/execution.h" #include "src/execution.h"
#include "src/handles.h" #include "src/handles.h"
#include "src/interpreter/bytecode-array-builder.h" #include "src/interpreter/bytecode-array-builder.h"
...@@ -2966,16 +2967,22 @@ TEST(BytecodeGraphBuilderIllegalConstDeclaration) { ...@@ -2966,16 +2967,22 @@ TEST(BytecodeGraphBuilderIllegalConstDeclaration) {
} }
} }
static int debug_break_count = 0; class CountBreakDebugDelegate : public v8::debug::DebugDelegate {
static void DebugEventCounter(const v8::Debug::EventDetails& event_details) { public:
if (event_details.GetEvent() == v8::Break) debug_break_count++; 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) { TEST(BytecodeGraphBuilderDebuggerStatement) {
CountBreakDebugDelegate delegate;
HandleAndZoneScope scope; HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate(); Isolate* isolate = scope.main_isolate();
v8::Debug::SetDebugEventListener(CcTest::isolate(), DebugEventCounter); v8::debug::SetDebugDelegate(CcTest::isolate(), &delegate);
ExpectedSnippet<0> snippet = { ExpectedSnippet<0> snippet = {
"function f() {" "function f() {"
...@@ -2988,9 +2995,9 @@ TEST(BytecodeGraphBuilderDebuggerStatement) { ...@@ -2988,9 +2995,9 @@ TEST(BytecodeGraphBuilderDebuggerStatement) {
auto callable = tester.GetCallable<>(); auto callable = tester.GetCallable<>();
Handle<Object> return_value = callable().ToHandleChecked(); 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(return_value.is_identical_to(snippet.return_value()));
CHECK_EQ(2, debug_break_count); CHECK_EQ(2, delegate.debug_break_count);
} }
} // namespace compiler } // namespace compiler
......
This diff is collapsed.
...@@ -54,7 +54,7 @@ void CheckLocationsFail(WasmCompiledModule *compiled_module, ...@@ -54,7 +54,7 @@ void CheckLocationsFail(WasmCompiledModule *compiled_module,
CHECK(!success); CHECK(!success);
} }
class BreakHandler { class BreakHandler : public debug::DebugDelegate {
public: public:
enum Action { enum Action {
Continue = StepAction::LastStepAction + 1, Continue = StepAction::LastStepAction + 1,
...@@ -72,18 +72,13 @@ class BreakHandler { ...@@ -72,18 +72,13 @@ class BreakHandler {
explicit BreakHandler(Isolate* isolate, explicit BreakHandler(Isolate* isolate,
std::initializer_list<BreakPoint> expected_breaks) std::initializer_list<BreakPoint> expected_breaks)
: isolate_(isolate), expected_breaks_(expected_breaks) { : isolate_(isolate), expected_breaks_(expected_breaks) {
current_handler = this; v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_), this);
v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate),
DebugEventListener);
} }
~BreakHandler() { ~BreakHandler() {
// Check that all expected breakpoints have been hit. // Check that all expected breakpoints have been hit.
CHECK_EQ(count_, expected_breaks_.size()); CHECK_EQ(count_, expected_breaks_.size());
// BreakHandlers must be correctly stacked. v8::debug::SetDebugDelegate(reinterpret_cast<v8::Isolate*>(isolate_),
CHECK_EQ(this, current_handler); nullptr);
current_handler = nullptr;
v8::Debug::SetDebugEventListener(reinterpret_cast<v8::Isolate*>(isolate_),
nullptr);
} }
int count() const { return count_; } int count() const { return count_; }
...@@ -93,9 +88,9 @@ class BreakHandler { ...@@ -93,9 +88,9 @@ class BreakHandler {
int count_ = 0; int count_ = 0;
std::vector<BreakPoint> expected_breaks_; std::vector<BreakPoint> expected_breaks_;
static BreakHandler* current_handler; void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state,
void HandleBreak() { v8::Local<v8::Value> break_points_hit) override {
printf("Break #%d\n", count_); printf("Break #%d\n", count_);
CHECK_GT(expected_breaks_.size(), count_); CHECK_GT(expected_breaks_.size(), count_);
...@@ -118,18 +113,8 @@ class BreakHandler { ...@@ -118,18 +113,8 @@ class BreakHandler {
} }
++count_; ++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> MakeFakeBreakpoint(Isolate* isolate, int position) {
Handle<JSObject> obj = Handle<JSObject> obj =
isolate->factory()->NewJSObject(isolate->object_function()); isolate->factory()->NewJSObject(isolate->object_function());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment