From 26aab0dc5d324bad1fdd6204b6b29e5eafa168a5 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 24 Sep 2011 14:28:27 +0700 Subject: [PATCH] EnableDebug immediatly on SIGUSR1 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 | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/node.cc b/src/node.cc index 9de3fb9..f7fa133 100644 --- a/src/node.cc +++ b/src/node.cc @@ -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)) { -- 2.7.4