Permalink
Browse files

[node] Ctrl+Break on windows starts debugger server

  • Loading branch information...
1 parent e5eb5ca commit 5d2114f36712b2650def012b8dc8ae6c635433d4 @indutny committed Sep 24, 2011
Showing with 21 additions and 0 deletions.
  1. +21 −0 src/node.cc
View
@@ -2362,6 +2362,7 @@ static void EnableDebug(bool wait_connect) {
}
+#ifdef __POSIX__
static void EnableDebugSignalHandler(int signal) {
// Break once process will return execution to v8
v8::Debug::DebugBreak();
@@ -2371,6 +2372,23 @@ static void EnableDebugSignalHandler(int signal) {
EnableDebug(false);
}
}
+#endif // __POSIX__
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+static bool EnableDebugSignalHandler(DWORD signal) {
+ if (signal != CTRL_BREAK_EVENT) return false;
+
+ // Break once process will return execution to v8
+ v8::Debug::DebugBreak();
+
+ if (!debugger_running) {
+ fprintf(stderr, "Hit Ctrl+Break - starting debugger agent.\n");
+ EnableDebug(false);
+ }
+
+ return true;
+}
+#endif
#ifdef __POSIX__
@@ -2474,6 +2492,9 @@ char** Init(int argc, char *argv[]) {
#ifdef __POSIX__
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
#endif // __POSIX__
+#if defined(__MINGW32__) || defined(_MSC_VER)
+ SetConsoleCtrlHandler((PHANDLER_ROUTINE) EnableDebugSignalHandler, TRUE);
+#endif
}
return argv;

0 comments on commit 5d2114f

Please sign in to comment.