From e1d95d6e98fa4741d1e7092c9233dc13c1a95a78 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 14 Jul 2015 02:08:50 +0200 Subject: [PATCH] Adding a handler for abort(). We want to have a chance to debug a call to abort() in case we have a debugger attached. --- test/core/util/test_config.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index ba62e6d4c4c..225658f5e2a 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -66,10 +66,20 @@ LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) { 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() { SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) crash_handler); _set_abort_behavior(0, _WRITE_ABORT_MSG); _set_abort_behavior(0, _CALL_REPORTFAULT); + signal(SIGABRT, abort_handler); } #else static void install_crash_handler() { }