Skip to content

Commit 50f33cd

Browse files
committed
Added method setPauseOnNextStatement
1 parent 11158f4 commit 50f33cd

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/debug.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using v8::Isolate;
1111
using v8::Local;
1212
using v8::Value;
13+
using v8::Boolean;
1314
using v8::String;
1415
using v8::Object;
1516
using v8::Context;
@@ -114,6 +115,16 @@ namespace nodex {
114115
#endif
115116
debug_context->UseDefaultSecurityToken();
116117
}
118+
119+
static NAN_METHOD(SetPauseOnNextStatement) {
120+
Local<Boolean> _pause = CHK(To<Boolean>(info[0]));
121+
bool pause = _pause->Value();
122+
if (pause)
123+
v8::Debug::DebugBreak(info.GetIsolate());
124+
else
125+
v8::Debug::CancelDebugBreak(info.GetIsolate());
126+
}
127+
117128
private:
118129
Debug() {}
119130
~Debug() {}
@@ -131,6 +142,7 @@ namespace nodex {
131142
SetMethod(target, "allowNatives", Debug::AllowNatives);
132143
SetMethod(target, "shareSecurityToken", Debug::ShareSecurityToken);
133144
SetMethod(target, "unshareSecurityToken", Debug::UnshareSecurityToken);
145+
SetMethod(target, "setPauseOnNextStatement", Debug::SetPauseOnNextStatement);
134146
}
135147

136148
NODE_MODULE(debug, Initialize)

v8-debug.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ inherits(V8Debug, EventEmitter);
108108
function V8Debug() {
109109
if (!(this instanceof V8Debug)) return new V8Debug();
110110

111+
this._Debug = this.get('Debug');
112+
111113
this._webkitProtocolEnabled = false;
112114

113115
// NOTE: Call `_setDebugEventListener` before all other changes in Debug Context.
@@ -128,15 +130,13 @@ function V8Debug() {
128130
}
129131

130132
V8Debug.prototype._setDebugEventListener = function() {
131-
var Debug = this.get('Debug');
132-
Debug.setListener(function(_, execState, event) {
133+
this._Debug.setListener(function(_, execState, event) {
133134
// TODO(3y3): Handle events here
134135
});
135136
};
136137

137138
V8Debug.prototype._unsetDebugEventListener = function() {
138-
var Debug = this.get('Debug');
139-
Debug.setListener(null);
139+
this._Debug.setListener(null);
140140
};
141141

142142
V8Debug.prototype._shareSecurityToken = function() {
@@ -159,8 +159,8 @@ V8Debug.prototype._wrapDebugCommandProcessor = function() {
159159
proto.extendedProcessDebugJSONRequestHandles_['disconnect'] = function(request, response) {
160160
this.emit('close');
161161
proto._DebugCommandProcessor;
162-
proto.processDebugJSONRequest(request, response);
163-
return true;
162+
//proto.processDebugJSONRequest(request, response);
163+
//return true;
164164
}.bind(this);
165165
};
166166

@@ -172,6 +172,14 @@ V8Debug.prototype._unwrapDebugCommandProcessor = function() {
172172
proto.extendedProcessDebugJSONRequestAsyncHandles_ = {};
173173
};
174174

175+
V8Debug.prototype.setPauseOnNextStatement = function(pause) {
176+
binding.setPauseOnNextStatement(pause === true);
177+
};
178+
179+
V8Debug.prototype.scripts = function() {
180+
return this._Debug.scripts();
181+
};
182+
175183
V8Debug.prototype.register =
176184
V8Debug.prototype.registerCommand = function(name, func) {
177185
var proto = this._DebugCommandProcessor;

0 commit comments

Comments
 (0)