Skip to content
Snippets Groups Projects
Commit e1d95d6e authored by Nicolas "Pixel" Noble's avatar Nicolas "Pixel" Noble
Browse files

Adding a handler for abort().

We want to have a chance to debug a call to abort() in case we have a debugger attached.
parent 294d9726
No related branches found
No related tags found
No related merge requests found
...@@ -66,10 +66,20 @@ LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) { ...@@ -66,10 +66,20 @@ LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) {
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;
} }
void abort_handler(int sig) {
gpr_log(GPR_DEBUG, "Abort handler called.");
if (IsDebuggerPresent()) {
__debugbreak();
} else {
_exit(1);
}
}
static void install_crash_handler() { static void install_crash_handler() {
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) crash_handler); SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) crash_handler);
_set_abort_behavior(0, _WRITE_ABORT_MSG); _set_abort_behavior(0, _WRITE_ABORT_MSG);
_set_abort_behavior(0, _CALL_REPORTFAULT); _set_abort_behavior(0, _CALL_REPORTFAULT);
signal(SIGABRT, abort_handler);
} }
#else #else
static void install_crash_handler() { } static void install_crash_handler() { }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment