Skip to content

Commit

Permalink
Added method setPauseOnNextStatement
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Jan 25, 2016
1 parent 11158f4 commit 50f33cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -114,6 +115,16 @@ namespace nodex {
#endif
debug_context->UseDefaultSecurityToken();
}

static NAN_METHOD(SetPauseOnNextStatement) {
Local<Boolean> _pause = CHK(To<Boolean>(info[0]));
bool pause = _pause->Value();
if (pause)
v8::Debug::DebugBreak(info.GetIsolate());
else
v8::Debug::CancelDebugBreak(info.GetIsolate());
}

private:
Debug() {}
~Debug() {}
Expand All @@ -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)
Expand Down
20 changes: 14 additions & 6 deletions v8-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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.
Expand All @@ -128,15 +130,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() {
Expand All @@ -159,8 +159,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);
};

Expand All @@ -172,6 +172,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;
Expand Down

0 comments on commit 50f33cd

Please sign in to comment.