From 717ea0eb7487417a2bef82bf38c17ad575c7f0e6 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sat, 11 Jul 2015 22:50:09 +0200 Subject: Install simple Windows exception handlers. Will prevent Windows tests to display a pop-up message in case of a failure. Essential for Jenkins testing. --- test/core/util/test_config.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/core/util') diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index 20ab67ec15..ba62e6d4c4 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -48,7 +48,35 @@ static int seed(void) { return getpid(); } static int seed(void) { return _getpid(); } #endif +#if GPR_WINDOWS_CRASH_HANDLER +LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) { + gpr_log(GPR_DEBUG, "Exception handler called, dumping information"); + while (ex_info->ExceptionRecord) { + DWORD code = ex_info->ExceptionRecord->ExceptionCode; + DWORD flgs = ex_info->ExceptionRecord->ExceptionFlags; + PVOID addr = ex_info->ExceptionRecord->ExceptionAddress; + gpr_log("code: %x - flags: %d - address: %p", code, flgs, addr); + ex_info->ExceptionRecord = ex_info->ExceptionRecord->ExceptionRecord; + } + if (IsDebuggerPresent()) { + __debugbreak(); + } else { + _exit(1); + } + return EXCEPTION_EXECUTE_HANDLER; +} + +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); +} +#else +static void install_crash_handler() { } +#endif + void grpc_test_init(int argc, char **argv) { + install_crash_handler(); gpr_log(GPR_DEBUG, "test slowdown: machine=%f build=%f total=%f", (double)GRPC_TEST_SLOWDOWN_MACHINE_FACTOR, (double)GRPC_TEST_SLOWDOWN_BUILD_FACTOR, -- cgit v1.2.3 From e1d95d6e98fa4741d1e7092c9233dc13c1a95a78 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 14 Jul 2015 02:08:50 +0200 Subject: 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(+) (limited to 'test/core/util') diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index ba62e6d4c4..225658f5e2 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() { } -- cgit v1.2.3