static bool need_tick_cb;
static Persistent<String> tick_callback_sym;
-static ev_async enable_debug;
static ev_async eio_want_poll_notifier;
static ev_async eio_done_poll_notifier;
static ev_idle eio_poller;
// debug-agent.cc of v8/src when a new session is created
}
+
Persistent<Object> binding_cache;
static Handle<Value> Binding(const Arguments& args) {
}
-static void EnableDebugSignalHandler(int signal) {
- // can't do much here, marshal this back into the main thread where we'll
- // enable the debugger.
- ev_async_send(EV_DEFAULT_UC_ &enable_debug);
-}
-
-
static void EnableDebug(bool wait_connect) {
// Start the debug thread and it's associated TCP server on port 5858.
bool r = Debug::EnableAgent("node " NODE_VERSION, debug_port);
}
-static void EnableDebug2(EV_P_ ev_async *watcher, int revents) {
- assert(watcher == &enable_debug);
- assert(revents == EV_ASYNC);
- EnableDebug(false);
+static volatile bool hit_signal;
+
+
+static void EnableDebugSignalHandler(int signal) {
+ // This is signal safe.
+ hit_signal = true;
+ v8::Debug::DebugBreak();
+}
+
+
+static void DebugSignalCB(const Debug::EventDetails& details) {
+ if (hit_signal && details.GetEvent() == v8::Break) {
+ hit_signal = false;
+ fprintf(stderr, "Hit SIGUSR1 - starting debugger agent.\n");
+ EnableDebug(false);
+ }
}
} else {
#ifdef __POSIX__
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
- ev_async_init(&enable_debug, EnableDebug2);
- ev_async_start(EV_DEFAULT_UC_ &enable_debug);
- ev_unref(EV_DEFAULT_UC);
+ Debug::SetDebugEventListener2(DebugSignalCB);
#endif // __POSIX__
}