Skip to content

Commit a6a5de9

Browse files
committed
Added method setPauseOnNextStatement
1 parent 46b133f commit a6a5de9

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
@@ -109,6 +109,8 @@ inherits(V8Debug, EventEmitter);
109109
function V8Debug() {
110110
if (!(this instanceof V8Debug)) return new V8Debug();
111111

112+
this._Debug = this.get('Debug');
113+
112114
this._webkitProtocolEnabled = false;
113115

114116
// NOTE: Call `_setDebugEventListener` before all other changes in Debug Context.
@@ -129,15 +131,13 @@ function V8Debug() {
129131
}
130132

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

138139
V8Debug.prototype._unsetDebugEventListener = function() {
139-
var Debug = this.get('Debug');
140-
Debug.setListener(null);
140+
this._Debug.setListener(null);
141141
};
142142

143143
V8Debug.prototype._shareSecurityToken = function() {
@@ -160,8 +160,8 @@ V8Debug.prototype._wrapDebugCommandProcessor = function() {
160160
proto.extendedProcessDebugJSONRequestHandles_['disconnect'] = function(request, response) {
161161
this.emit('close');
162162
proto._DebugCommandProcessor;
163-
proto.processDebugJSONRequest(request, response);
164-
return true;
163+
//proto.processDebugJSONRequest(request, response);
164+
//return true;
165165
}.bind(this);
166166
};
167167

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

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

0 commit comments

Comments
 (0)