EnableDebug immediatly on SIGUSR1
authorFedor Indutny <fedor.indutny@gmail.com>
Sat, 24 Sep 2011 07:28:27 +0000 (14:28 +0700)
committerRyan Dahl <ry@tinyclouds.org>
Sun, 25 Sep 2011 18:58:22 +0000 (11:58 -0700)
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

src/node.cc

index 9de3fb9..f7fa133 100644 (file)
@@ -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)) {