Browse Source

pause command

v0.7.4-release
Fedor Indutny 13 years ago
committed by Ryan Dahl
parent
commit
b0388ccad0
  1. 21
      lib/_debugger.js
  2. 17
      src/node.cc

21
lib/_debugger.js

@ -762,7 +762,8 @@ function Interface(stdin, stdout, args) {
'out': 'o', 'out': 'o',
'backtrace': 'bt', 'backtrace': 'bt',
'setBreakpoint': 'sb', 'setBreakpoint': 'sb',
'clearBreakpoint': 'cb' 'clearBreakpoint': 'cb',
'pause_': 'pause'
}; };
function defineProperty(key, protoKey) { function defineProperty(key, protoKey) {
@ -1440,6 +1441,24 @@ Interface.prototype.breakpoints = function() {
}; };
// Pause child process
Interface.prototype.pause_ = function() {
if (!this.requireConnection()) return;
var self = this,
cmd = 'process._debugPause();';
this.pause();
this.client.reqFrameEval(cmd, NO_FRAME, function(err, res) {
if (err) {
self.error(err);
} else {
self.resume();
}
});
};
// Kill child process // Kill child process
Interface.prototype.kill = function() { Interface.prototype.kill = function() {
if (!this.child) return; if (!this.child) return;

17
src/node.cc

@ -1773,7 +1773,7 @@ void FatalException(TryCatch &try_catch) {
static void DebugMessageCallback(uv_async_t* watcher, int status) { static void DebugMessageCallback(uv_async_t* watcher, int status) {
HandleScope scope; HandleScope scope;
assert(watcher == &debug_watcher); assert(watcher == &debug_watcher);
Debug::ProcessDebugMessages(); v8::Debug::ProcessDebugMessages();
} }
static void DebugMessageDispatch(void) { static void DebugMessageDispatch(void) {
@ -1785,7 +1785,7 @@ static void DebugMessageDispatch(void) {
uv_async_send(&debug_watcher); uv_async_send(&debug_watcher);
} }
static void DebugBreakMessageHandler(const Debug::Message& message) { static void DebugBreakMessageHandler(const v8::Debug::Message& message) {
// do nothing with debug messages. // do nothing with debug messages.
// The message handler will get changed by DebuggerAgent::CreateSession in // The message handler will get changed by DebuggerAgent::CreateSession in
// debug-agent.cc of v8/src when a new session is created // debug-agent.cc of v8/src when a new session is created
@ -1982,6 +1982,7 @@ static Handle<Object> GetFeatures() {
static Handle<Value> DebugProcess(const Arguments& args); static Handle<Value> DebugProcess(const Arguments& args);
static Handle<Value> DebugPause(const Arguments& args);
Handle<Object> SetupProcessObject(int argc, char *argv[]) { Handle<Object> SetupProcessObject(int argc, char *argv[]) {
HandleScope scope; HandleScope scope;
@ -2108,6 +2109,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
NODE_SET_METHOD(process, "_kill", Kill); NODE_SET_METHOD(process, "_kill", Kill);
NODE_SET_METHOD(process, "_debugProcess", DebugProcess); NODE_SET_METHOD(process, "_debugProcess", DebugProcess);
NODE_SET_METHOD(process, "_debugPause", DebugPause);
NODE_SET_METHOD(process, "dlopen", DLOpen); NODE_SET_METHOD(process, "dlopen", DLOpen);
@ -2291,14 +2293,14 @@ static void EnableDebug(bool wait_connect) {
node_isolate->Enter(); node_isolate->Enter();
// Start the debug thread and it's associated TCP server on port 5858. // Start the debug thread and it's associated TCP server on port 5858.
bool r = Debug::EnableAgent("node " NODE_VERSION, debug_port); bool r = v8::Debug::EnableAgent("node " NODE_VERSION, debug_port);
if (wait_connect) { if (wait_connect) {
// Set up an empty handler so v8 will not continue until a debugger // Set up an empty handler so v8 will not continue until a debugger
// attaches. This is the same behavior as Debug::EnableAgent(_,_,true) // attaches. This is the same behavior as Debug::EnableAgent(_,_,true)
// except we don't break at the beginning of the script. // except we don't break at the beginning of the script.
// see Debugger::StartAgent in debug.cc of v8/src // see Debugger::StartAgent in debug.cc of v8/src
Debug::SetMessageHandler2(node::DebugBreakMessageHandler); v8::Debug::SetMessageHandler2(node::DebugBreakMessageHandler);
} }
// Crappy check that everything went well. FIXME // Crappy check that everything went well. FIXME
@ -2511,6 +2513,11 @@ static Handle<Value> DebugProcess(const Arguments& args) {
#endif // _WIN32 #endif // _WIN32
static Handle<Value> DebugPause(const Arguments& args) {
v8::Debug::DebugBreak(node_isolate);
}
char** Init(int argc, char *argv[]) { char** Init(int argc, char *argv[]) {
// Initialize prog_start_time to get relative uptime. // Initialize prog_start_time to get relative uptime.
uv_uptime(&prog_start_time); uv_uptime(&prog_start_time);
@ -2584,7 +2591,7 @@ char** Init(int argc, char *argv[]) {
// Set the callback DebugMessageDispatch which is called from the debug // Set the callback DebugMessageDispatch which is called from the debug
// thread. // thread.
Debug::SetDebugMessageDispatchHandler(node::DebugMessageDispatch); v8::Debug::SetDebugMessageDispatchHandler(node::DebugMessageDispatch);
// Initialize the async watcher. DebugMessageCallback() is called from the // Initialize the async watcher. DebugMessageCallback() is called from the
// main thread to execute a random bit of javascript - which will give V8 // main thread to execute a random bit of javascript - which will give V8

Loading…
Cancel
Save