Skip to content

Commit faf5f52

Browse files
hashseedCommit bot
authored andcommitted
[debugger,api] deprecate everything in v8-debug.h
[email protected], [email protected] BUG=v8:5530 Review-Url: https://codereview.chromium.org/2727393003 Cr-Commit-Position: refs/heads/master@{#43714}
1 parent a3a244c commit faf5f52

File tree

6 files changed

+323
-353
lines changed

6 files changed

+323
-353
lines changed

include/v8-debug.h

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include "v8.h" // NOLINT(build/include)
99

1010
/**
11-
* Debugger support for the V8 JavaScript engine.
11+
* ATTENTION: The debugger API exposed by this file is deprecated and will be
12+
* removed by the end of 2017. Please use the V8 inspector declared
13+
* in include/v8-inspector.h instead.
1214
*/
1315
namespace v8 {
1416

@@ -140,21 +142,19 @@ class V8_EXPORT Debug {
140142
*/
141143
typedef void (*MessageHandler)(const Message& message);
142144

143-
/**
144-
* This is now a no-op.
145-
*/
146-
typedef void (*DebugMessageDispatchHandler)();
147-
148-
static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
149-
Local<Value> data = Local<Value>());
145+
V8_DEPRECATED("No longer supported", static bool SetDebugEventListener(
146+
Isolate* isolate, EventCallback that,
147+
Local<Value> data = Local<Value>()));
150148

151149
// Schedule a debugger break to happen when JavaScript code is run
152150
// in the given isolate.
153-
static void DebugBreak(Isolate* isolate);
151+
V8_DEPRECATED("No longer supported",
152+
static void DebugBreak(Isolate* isolate));
154153

155154
// Remove scheduled debugger break in given isolate if it has not
156155
// happened yet.
157-
static void CancelDebugBreak(Isolate* isolate);
156+
V8_DEPRECATED("No longer supported",
157+
static void CancelDebugBreak(Isolate* isolate));
158158

159159
// Check if a debugger break is scheduled in the given isolate.
160160
V8_DEPRECATED("No longer supported",
@@ -189,10 +189,10 @@ class V8_EXPORT Debug {
189189
* }
190190
* \endcode
191191
*/
192-
// TODO(dcarney): data arg should be a MaybeLocal
193-
static MaybeLocal<Value> Call(Local<Context> context,
194-
v8::Local<v8::Function> fun,
195-
Local<Value> data = Local<Value>());
192+
V8_DEPRECATED("No longer supported",
193+
static MaybeLocal<Value> Call(
194+
Local<Context> context, v8::Local<v8::Function> fun,
195+
Local<Value> data = Local<Value>()));
196196

197197
// This is now a no-op.
198198
V8_DEPRECATED("No longer supported",
@@ -221,23 +221,28 @@ class V8_EXPORT Debug {
221221
* (default Isolate if not provided). V8 will abort if LiveEdit is
222222
* unexpectedly used. LiveEdit is enabled by default.
223223
*/
224-
static void SetLiveEditEnabled(Isolate* isolate, bool enable);
224+
V8_DEPRECATED("No longer supported",
225+
static void SetLiveEditEnabled(Isolate* isolate, bool enable));
225226

226227
/**
227228
* Returns array of internal properties specific to the value type. Result has
228229
* the following format: [<name>, <value>,...,<name>, <value>]. Result array
229230
* will be allocated in the current context.
230231
*/
231-
static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
232-
Local<Value> value);
232+
V8_DEPRECATED("No longer supported",
233+
static MaybeLocal<Array> GetInternalProperties(
234+
Isolate* isolate, Local<Value> value));
233235

234236
/**
235237
* Defines if the ES2015 tail call elimination feature is enabled or not.
236238
* The change of this flag triggers deoptimization of all functions that
237239
* contain calls at tail position.
238240
*/
239-
static bool IsTailCallEliminationEnabled(Isolate* isolate);
240-
static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled);
241+
V8_DEPRECATED("No longer supported",
242+
static bool IsTailCallEliminationEnabled(Isolate* isolate));
243+
V8_DEPRECATED("No longer supported",
244+
static void SetTailCallEliminationEnabled(Isolate* isolate,
245+
bool enabled));
241246
};
242247

243248

src/api.cc

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8961,17 +8961,12 @@ bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that,
89618961
return true;
89628962
}
89638963

8964-
void Debug::DebugBreak(Isolate* isolate) {
8965-
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
8966-
}
8967-
8964+
void Debug::DebugBreak(Isolate* isolate) { debug::DebugBreak(isolate); }
89688965

89698966
void Debug::CancelDebugBreak(Isolate* isolate) {
8970-
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
8971-
internal_isolate->stack_guard()->ClearDebugBreak();
8967+
debug::CancelDebugBreak(isolate);
89728968
}
89738969

8974-
89758970
bool Debug::CheckDebugBreak(Isolate* isolate) {
89768971
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
89778972
return internal_isolate->stack_guard()->CheckDebugBreak();
@@ -8986,29 +8981,15 @@ void Debug::SendCommand(Isolate* isolate, const uint16_t* command, int length,
89868981
MaybeLocal<Value> Debug::Call(Local<Context> context,
89878982
v8::Local<v8::Function> fun,
89888983
v8::Local<v8::Value> data) {
8989-
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
8990-
i::Handle<i::Object> data_obj;
8991-
if (data.IsEmpty()) {
8992-
data_obj = isolate->factory()->undefined_value();
8993-
} else {
8994-
data_obj = Utils::OpenHandle(*data);
8995-
}
8996-
Local<Value> result;
8997-
has_pending_exception =
8998-
!ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj),
8999-
&result);
9000-
RETURN_ON_FAILED_EXECUTION(Value);
9001-
RETURN_ESCAPED(result);
8984+
return debug::Call(context, fun, data);
90028985
}
90038986

9004-
90058987
void Debug::ProcessDebugMessages(Isolate* isolate) {}
90068988

90078989
Local<Context> Debug::GetDebugContext(Isolate* isolate) {
90088990
return debug::GetDebugContext(isolate);
90098991
}
90108992

9011-
90128993
MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
90138994
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
90148995
ENTER_V8(i_isolate);
@@ -9019,8 +9000,7 @@ MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
90199000
}
90209001

90219002
void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
9022-
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
9023-
internal_isolate->debug()->set_live_edit_enabled(enable);
9003+
debug::SetLiveEditEnabled(isolate, enable);
90249004
}
90259005

90269006
bool Debug::IsTailCallEliminationEnabled(Isolate* isolate) {
@@ -9035,13 +9015,7 @@ void Debug::SetTailCallEliminationEnabled(Isolate* isolate, bool enabled) {
90359015

90369016
MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate,
90379017
Local<Value> value) {
9038-
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9039-
ENTER_V8(isolate);
9040-
i::Handle<i::Object> val = Utils::OpenHandle(*value);
9041-
i::Handle<i::JSArray> result;
9042-
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
9043-
return MaybeLocal<Array>();
9044-
return Utils::ToLocal(result);
9018+
return debug::GetInternalProperties(v8_isolate, value);
90459019
}
90469020

90479021
Local<Context> debug::GetDebugContext(Isolate* isolate) {
@@ -9053,22 +9027,43 @@ Local<Context> debug::GetDebugContext(Isolate* isolate) {
90539027
MaybeLocal<Value> debug::Call(Local<Context> context,
90549028
v8::Local<v8::Function> fun,
90559029
v8::Local<v8::Value> data) {
9056-
return Debug::Call(context, fun, data);
9030+
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
9031+
i::Handle<i::Object> data_obj;
9032+
if (data.IsEmpty()) {
9033+
data_obj = isolate->factory()->undefined_value();
9034+
} else {
9035+
data_obj = Utils::OpenHandle(*data);
9036+
}
9037+
Local<Value> result;
9038+
has_pending_exception = !ToLocal<Value>(
9039+
isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), &result);
9040+
RETURN_ON_FAILED_EXECUTION(Value);
9041+
RETURN_ESCAPED(result);
90579042
}
90589043

90599044
void debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
9060-
Debug::SetLiveEditEnabled(isolate, enable);
9045+
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
9046+
internal_isolate->debug()->set_live_edit_enabled(enable);
90619047
}
90629048

9063-
void debug::DebugBreak(Isolate* isolate) { Debug::DebugBreak(isolate); }
9049+
void debug::DebugBreak(Isolate* isolate) {
9050+
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
9051+
}
90649052

90659053
void debug::CancelDebugBreak(Isolate* isolate) {
9066-
Debug::CancelDebugBreak(isolate);
9054+
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
9055+
internal_isolate->stack_guard()->ClearDebugBreak();
90679056
}
90689057

9069-
MaybeLocal<Array> debug::GetInternalProperties(Isolate* isolate,
9058+
MaybeLocal<Array> debug::GetInternalProperties(Isolate* v8_isolate,
90709059
Local<Value> value) {
9071-
return Debug::GetInternalProperties(isolate, value);
9060+
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9061+
ENTER_V8(isolate);
9062+
i::Handle<i::Object> val = Utils::OpenHandle(*value);
9063+
i::Handle<i::JSArray> result;
9064+
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
9065+
return MaybeLocal<Array>();
9066+
return Utils::ToLocal(result);
90729067
}
90739068

90749069
void debug::ChangeBreakOnException(Isolate* isolate, ExceptionBreakState type) {

test/cctest/cctest.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <memory>
3232

3333
#include "include/libplatform/libplatform.h"
34-
#include "include/v8-debug.h"
34+
#include "src/debug/debug-interface.h"
3535
#include "src/utils.h"
3636
#include "src/v8.h"
3737
#include "src/zone/accounting-allocator.h"
@@ -547,18 +547,15 @@ static inline void CheckDoubleEquals(double expected, double actual) {
547547
CHECK_GE(expected, actual - kEpsilon);
548548
}
549549

550-
551-
static void DummyDebugEventListener(
552-
const v8::Debug::EventDetails& event_details) {}
553-
550+
static v8::debug::DebugDelegate dummy_delegate;
554551

555552
static inline void EnableDebugger(v8::Isolate* isolate) {
556-
v8::Debug::SetDebugEventListener(isolate, &DummyDebugEventListener);
553+
v8::debug::SetDebugDelegate(isolate, &dummy_delegate);
557554
}
558555

559556

560557
static inline void DisableDebugger(v8::Isolate* isolate) {
561-
v8::Debug::SetDebugEventListener(isolate, nullptr);
558+
v8::debug::SetDebugDelegate(isolate, nullptr);
562559
}
563560

564561

test/cctest/compiler/test-run-bytecode-graph-builder.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "src/compilation-info.h"
88
#include "src/compiler/pipeline.h"
9+
#include "src/debug/debug-interface.h"
910
#include "src/execution.h"
1011
#include "src/handles.h"
1112
#include "src/interpreter/bytecode-array-builder.h"
@@ -2966,16 +2967,22 @@ TEST(BytecodeGraphBuilderIllegalConstDeclaration) {
29662967
}
29672968
}
29682969

2969-
static int debug_break_count = 0;
2970-
static void DebugEventCounter(const v8::Debug::EventDetails& event_details) {
2971-
if (event_details.GetEvent() == v8::Break) debug_break_count++;
2972-
}
2970+
class CountBreakDebugDelegate : public v8::debug::DebugDelegate {
2971+
public:
2972+
void BreakProgramRequested(v8::Local<v8::Context> paused_context,
2973+
v8::Local<v8::Object> exec_state,
2974+
v8::Local<v8::Value> break_points_hit) override {
2975+
debug_break_count++;
2976+
}
2977+
int debug_break_count = 0;
2978+
};
29732979

29742980
TEST(BytecodeGraphBuilderDebuggerStatement) {
2981+
CountBreakDebugDelegate delegate;
29752982
HandleAndZoneScope scope;
29762983
Isolate* isolate = scope.main_isolate();
29772984

2978-
v8::Debug::SetDebugEventListener(CcTest::isolate(), DebugEventCounter);
2985+
v8::debug::SetDebugDelegate(CcTest::isolate(), &delegate);
29792986

29802987
ExpectedSnippet<0> snippet = {
29812988
"function f() {"
@@ -2988,9 +2995,9 @@ TEST(BytecodeGraphBuilderDebuggerStatement) {
29882995
auto callable = tester.GetCallable<>();
29892996
Handle<Object> return_value = callable().ToHandleChecked();
29902997

2991-
v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr);
2998+
v8::debug::SetDebugDelegate(CcTest::isolate(), nullptr);
29922999
CHECK(return_value.is_identical_to(snippet.return_value()));
2993-
CHECK_EQ(2, debug_break_count);
3000+
CHECK_EQ(2, delegate.debug_break_count);
29943001
}
29953002

29963003
} // namespace compiler

0 commit comments

Comments
 (0)