Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
EnableDebug immediatly on SIGUSR1
Browse files Browse the repository at this point in the history
Don't wait for script to break somewhere, because that may not happen if
execution is inside event-loop, not in v8.

Add '\n' to the end of 'debugger listening...' message
  • Loading branch information
indutny authored and ry committed Sep 25, 2011
1 parent 9b6acc2 commit 26aab0d
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/node.cc
Expand Up @@ -2356,32 +2356,23 @@ static void EnableDebug(bool wait_connect) {
assert(r);

// Print out some information.
fprintf(stderr, "debugger listening on port %d", debug_port);
fprintf(stderr, "debugger listening on port %d\n", debug_port);

debugger_running = true;
}


static volatile bool hit_signal;

static void EnableDebugSignalHandler(int signal) {
// Break once process will return execution to v8
v8::Debug::DebugBreak();

static void DebugSignalCB(const Debug::EventDetails& details) {
if (!debugger_running && hit_signal && details.GetEvent() == v8::Break) {
hit_signal = false;
if (!debugger_running) {
fprintf(stderr, "Hit SIGUSR1 - starting debugger agent.\n");
EnableDebug(false);
}
}


static void EnableDebugSignalHandler(int signal) {
// This is signal safe.
hit_signal = true;
v8::Debug::SetDebugEventListener2(DebugSignalCB);
v8::Debug::DebugBreak();
}


#ifdef __POSIX__

static int RegisterSignalHandler(int signal, void (*handler)(int)) {
Expand Down

0 comments on commit 26aab0d

Please sign in to comment.