diff --git a/src/debug.cc b/src/debug.cc index 61c5091..64521d6 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -10,6 +10,7 @@ using v8::Isolate; using v8::Local; using v8::Value; +using v8::Boolean; using v8::String; using v8::Object; using v8::Context; @@ -114,6 +115,16 @@ namespace nodex { #endif debug_context->UseDefaultSecurityToken(); } + + static NAN_METHOD(SetPauseOnNextStatement) { + Local _pause = CHK(To(info[0])); + bool pause = _pause->Value(); + if (pause) + v8::Debug::DebugBreak(info.GetIsolate()); + else + v8::Debug::CancelDebugBreak(info.GetIsolate()); + } + private: Debug() {} ~Debug() {} @@ -131,6 +142,7 @@ namespace nodex { SetMethod(target, "allowNatives", Debug::AllowNatives); SetMethod(target, "shareSecurityToken", Debug::ShareSecurityToken); SetMethod(target, "unshareSecurityToken", Debug::UnshareSecurityToken); + SetMethod(target, "setPauseOnNextStatement", Debug::SetPauseOnNextStatement); } NODE_MODULE(debug, Initialize) diff --git a/v8-debug.js b/v8-debug.js index bf65fad..36f3c68 100644 --- a/v8-debug.js +++ b/v8-debug.js @@ -109,6 +109,8 @@ inherits(V8Debug, EventEmitter); function V8Debug() { if (!(this instanceof V8Debug)) return new V8Debug(); + this._Debug = this.get('Debug'); + this._webkitProtocolEnabled = false; // NOTE: Call `_setDebugEventListener` before all other changes in Debug Context. @@ -129,15 +131,13 @@ function V8Debug() { } V8Debug.prototype._setDebugEventListener = function() { - var Debug = this.get('Debug'); - Debug.setListener(function(_, execState, event) { + this._Debug.setListener(function(_, execState, event) { // TODO(3y3): Handle events here }); }; V8Debug.prototype._unsetDebugEventListener = function() { - var Debug = this.get('Debug'); - Debug.setListener(null); + this._Debug.setListener(null); }; V8Debug.prototype._shareSecurityToken = function() { @@ -160,8 +160,8 @@ V8Debug.prototype._wrapDebugCommandProcessor = function() { proto.extendedProcessDebugJSONRequestHandles_['disconnect'] = function(request, response) { this.emit('close'); proto._DebugCommandProcessor; - proto.processDebugJSONRequest(request, response); - return true; + //proto.processDebugJSONRequest(request, response); + //return true; }.bind(this); }; @@ -173,6 +173,14 @@ V8Debug.prototype._unwrapDebugCommandProcessor = function() { proto.extendedProcessDebugJSONRequestAsyncHandles_ = {}; }; +V8Debug.prototype.setPauseOnNextStatement = function(pause) { + binding.setPauseOnNextStatement(pause === true); +}; + +V8Debug.prototype.scripts = function() { + return this._Debug.scripts(); +}; + V8Debug.prototype.register = V8Debug.prototype.registerCommand = function(name, func) { var proto = this._DebugCommandProcessor;