diff --git a/include/v8-debug.h b/include/v8-debug.h index 0b64fb3882..e802a5235d 100644 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -155,8 +155,12 @@ class V8_EXPORT Debug { */ typedef void (*DebugMessageDispatchHandler)(); - static bool SetDebugEventListener(EventCallback that, + static bool SetDebugEventListener(Isolate* isolate, EventCallback that, Local data = Local()); + V8_DEPRECATE_SOON( + "Use version with an Isolate", + static bool SetDebugEventListener(EventCallback that, + Local data = Local())); // Schedule a debugger break to happen when JavaScript code is run // in the given isolate. @@ -170,7 +174,9 @@ class V8_EXPORT Debug { static bool CheckDebugBreak(Isolate* isolate); // Message based interface. The message protocol is JSON. - static void SetMessageHandler(MessageHandler handler); + static void SetMessageHandler(Isolate* isolate, MessageHandler handler); + V8_DEPRECATE_SOON("Use version with an Isolate", + static void SetMessageHandler(MessageHandler handler)); static void SendCommand(Isolate* isolate, const uint16_t* command, int length, @@ -242,7 +248,9 @@ class V8_EXPORT Debug { * "Evaluate" debug command behavior currently is not specified in scope * of this method. */ - static void ProcessDebugMessages(); + static void ProcessDebugMessages(Isolate* isolate); + V8_DEPRECATE_SOON("Use version with an Isolate", + static void ProcessDebugMessages()); /** * Debugger is running in its own context which is entered while debugger @@ -251,7 +259,9 @@ class V8_EXPORT Debug { * to change. The Context exists only when the debugger is active, i.e. at * least one DebugEventListener or MessageHandler is set. */ - static Local GetDebugContext(); + static Local GetDebugContext(Isolate* isolate); + V8_DEPRECATE_SOON("Use version with an Isolate", + static Local GetDebugContext()); /** diff --git a/src/api.cc b/src/api.cc index 9025b296fd..20b27e67ad 100644 --- a/src/api.cc +++ b/src/api.cc @@ -7727,20 +7727,26 @@ Local Exception::GetStackTrace(Local exception) { // --- D e b u g S u p p o r t --- -bool Debug::SetDebugEventListener(EventCallback that, Local data) { - i::Isolate* isolate = i::Isolate::Current(); - ENTER_V8(isolate); - i::HandleScope scope(isolate); - i::Handle foreign = isolate->factory()->undefined_value(); +bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that, + Local data) { + i::Isolate* i_isolate = reinterpret_cast(isolate); + ENTER_V8(i_isolate); + i::HandleScope scope(i_isolate); + i::Handle foreign = i_isolate->factory()->undefined_value(); if (that != NULL) { - foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that)); + foreign = i_isolate->factory()->NewForeign(FUNCTION_ADDR(that)); } - isolate->debug()->SetEventListener(foreign, - Utils::OpenHandle(*data, true)); + i_isolate->debug()->SetEventListener(foreign, Utils::OpenHandle(*data, true)); return true; } +bool Debug::SetDebugEventListener(EventCallback that, Local data) { + return SetDebugEventListener( + reinterpret_cast(i::Isolate::Current()), that, data); +} + + void Debug::DebugBreak(Isolate* isolate) { reinterpret_cast(isolate)->stack_guard()->RequestDebugBreak(); } @@ -7758,10 +7764,16 @@ bool Debug::CheckDebugBreak(Isolate* isolate) { } +void Debug::SetMessageHandler(Isolate* isolate, + v8::Debug::MessageHandler handler) { + i::Isolate* i_isolate = reinterpret_cast(isolate); + ENTER_V8(i_isolate); + i_isolate->debug()->SetMessageHandler(handler); +} + + void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) { - i::Isolate* isolate = i::Isolate::Current(); - ENTER_V8(isolate); - isolate->debug()->SetMessageHandler(handler); + SetMessageHandler(reinterpret_cast(i::Isolate::Current()), handler); } @@ -7827,15 +7839,25 @@ Local Debug::GetMirror(v8::Local obj) { } +void Debug::ProcessDebugMessages(Isolate* isolate) { + reinterpret_cast(isolate)->debug()->ProcessDebugMessages(true); +} + + void Debug::ProcessDebugMessages() { - i::Isolate::Current()->debug()->ProcessDebugMessages(true); + ProcessDebugMessages(reinterpret_cast(i::Isolate::Current())); +} + + +Local Debug::GetDebugContext(Isolate* isolate) { + i::Isolate* i_isolate = reinterpret_cast(isolate); + ENTER_V8(i_isolate); + return Utils::ToLocal(i_isolate->debug()->GetDebugContext()); } Local Debug::GetDebugContext() { - i::Isolate* isolate = i::Isolate::Current(); - ENTER_V8(isolate); - return Utils::ToLocal(isolate->debug()->GetDebugContext()); + return GetDebugContext(reinterpret_cast(i::Isolate::Current())); } diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h index c20e573e57..6806ca6e66 100644 --- a/test/cctest/cctest.h +++ b/test/cctest/cctest.h @@ -679,12 +679,14 @@ static void DummyDebugEventListener( const v8::Debug::EventDetails& event_details) {} -static inline void EnableDebugger() { - v8::Debug::SetDebugEventListener(&DummyDebugEventListener); +static inline void EnableDebugger(v8::Isolate* isolate) { + v8::Debug::SetDebugEventListener(isolate, &DummyDebugEventListener); } -static inline void DisableDebugger() { v8::Debug::SetDebugEventListener(NULL); } +static inline void DisableDebugger(v8::Isolate* isolate) { + v8::Debug::SetDebugEventListener(isolate, nullptr); +} static inline void EmptyMessageQueues(v8::Isolate* isolate) { diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 096d0afccb..9bce7fce20 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -20145,7 +20145,7 @@ TEST(Regress385349) { HandleScope handle_scope(isolate); isolate->SetAutorunMicrotasks(false); Local context = Context::New(isolate); - v8::Debug::SetDebugEventListener(DebugEventInObserver); + v8::Debug::SetDebugEventListener(isolate, DebugEventInObserver); { Context::Scope context_scope(context); CompileRun("var obj = {};" @@ -20154,7 +20154,7 @@ TEST(Regress385349) { } isolate->RunMicrotasks(); isolate->SetAutorunMicrotasks(true); - v8::Debug::SetDebugEventListener(NULL); + v8::Debug::SetDebugEventListener(isolate, nullptr); } @@ -22690,7 +22690,7 @@ TEST(StreamingWithDebuggingEnabledLate) { v8::ScriptOrigin origin(v8_str("http://foo.com")); char* full_source = TestSourceStream::FullSourceString(chunks); - EnableDebugger(); + EnableDebugger(isolate); v8::Local