From cf66363e66d1a9b6c18695d5d7365d9feafddff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=98=E6=9D=B0?= Date: Wed, 22 Mar 2017 17:43:46 +0800 Subject: [PATCH 1/3] fix: make it work on node7.x --- .travis.yml | 1 + src/debug.cc | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a774c4..f7a7544 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ env: - export NODE_VERSION="4" - export NODE_VERSION="5" - export NODE_VERSION="6" + - export NODE_VERSION="7" global: - node_pre_gyp_region="eu-central-1" diff --git a/src/debug.cc b/src/debug.cc index 43482e6..5afd063 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -35,15 +35,20 @@ namespace nodex { } Local fn = Local::Cast(info[0]); - v8::Debug::Call(fn); + #if (NODE_MODULE_VERSION > 48) + Local context = fn->GetIsolate()->GetCurrentContext(); + v8::Debug::Call(context, fn); + #else + v8::Debug::Call(fn); + #endif RETURN(Undefined()); }; static NAN_METHOD(SendCommand) { String::Value command(info[0]); #if (NODE_MODULE_VERSION > 11) - Isolate* debug_isolate = v8::Debug::GetDebugContext()->GetIsolate(); + Isolate* debug_isolate = v8::Debug::GetDebugContext(Isolate::GetCurrent())->GetIsolate(); v8::HandleScope debug_scope(debug_isolate); v8::Debug::SendCommand(debug_isolate, *command, command.length()); #else @@ -58,12 +63,12 @@ namespace nodex { if (expression.IsEmpty()) RETURN(Undefined()); - Local debug_context = v8::Debug::GetDebugContext(); + Local debug_context = v8::Debug::GetDebugContext(Isolate::GetCurrent()); #if (NODE_MODULE_VERSION > 45) if (debug_context.IsEmpty()) { // Force-load the debug context. v8::Debug::GetMirror(info.GetIsolate()->GetCurrentContext(), info[0]); - debug_context = v8::Debug::GetDebugContext(); + debug_context = v8::Debug::GetDebugContext(Isolate::GetCurrent()); } #endif From 96ada25da8db8ac1e21d2401fd104bcc4ecfc85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=98=E6=9D=B0?= Date: Wed, 22 Mar 2017 19:27:39 +0800 Subject: [PATCH 2/3] fix: sendCommand not work --- v8-debug.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/v8-debug.js b/v8-debug.js index 0d94df8..ce8be01 100644 --- a/v8-debug.js +++ b/v8-debug.js @@ -169,7 +169,10 @@ function sendCommand(name, attributes, userdata) { command: name, arguments: attributes || {} }; - binding.sendCommand(JSON.stringify(message)); + // don't know why yet + process.nextTick(function() { + binding.sendCommand(JSON.stringify(message)) + }); }; V8Debug.prototype.commandToEvent = function(request, response) { From 6654bfaabaad692eb74a6f8dfac7fb170650f363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=98=E6=9D=B0?= Date: Wed, 22 Mar 2017 23:29:36 +0800 Subject: [PATCH 3/3] fix: node 5.x --- src/debug.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/debug.cc b/src/debug.cc index 5afd063..e1af550 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -48,7 +48,11 @@ namespace nodex { static NAN_METHOD(SendCommand) { String::Value command(info[0]); #if (NODE_MODULE_VERSION > 11) + #if (NODE_MODULE_VERSION > 48) Isolate* debug_isolate = v8::Debug::GetDebugContext(Isolate::GetCurrent())->GetIsolate(); + #else + Isolate* debug_isolate = v8::Debug::GetDebugContext()->GetIsolate(); + #endif v8::HandleScope debug_scope(debug_isolate); v8::Debug::SendCommand(debug_isolate, *command, command.length()); #else @@ -63,12 +67,20 @@ namespace nodex { if (expression.IsEmpty()) RETURN(Undefined()); + #if (NODE_MODULE_VERSION > 48) Local debug_context = v8::Debug::GetDebugContext(Isolate::GetCurrent()); + #else + Local debug_context = v8::Debug::GetDebugContext(); + #endif #if (NODE_MODULE_VERSION > 45) if (debug_context.IsEmpty()) { // Force-load the debug context. v8::Debug::GetMirror(info.GetIsolate()->GetCurrentContext(), info[0]); + #if (NODE_MODULE_VERSION > 48) debug_context = v8::Debug::GetDebugContext(Isolate::GetCurrent()); + #else + debug_context = v8::Debug::GetDebugContext(); + #endif } #endif