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

Commit

Permalink
Ctrl+Break on windows starts debugger server
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny authored and ry committed Sep 25, 2011
1 parent 26aab0d commit 82d0ac7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/node.cc
Expand Up @@ -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();
Expand All @@ -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__
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 82d0ac7

Please sign in to comment.