aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-07-13 11:15:55 -0700
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-07-13 11:15:55 -0700
commit294d9726297c041b0e0409b0fc33300424662f20 (patch)
tree87d7dabad549b8cfe1fb644506bdab3ae32c6ec2
parentce017fe6e3e34dfb3197c4996c70df458ab2accf (diff)
parent717ea0eb7487417a2bef82bf38c17ad575c7f0e6 (diff)
Merge pull request #2399 from nicolasnoble/install-windows-exception-handler
Install simple Windows exception handlers.
-rw-r--r--include/grpc/support/port_platform.h2
-rw-r--r--test/core/util/test_config.c28
2 files changed, 30 insertions, 0 deletions
diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h
index d3cfee113d..a5d1b62702 100644
--- a/include/grpc/support/port_platform.h
+++ b/include/grpc/support/port_platform.h
@@ -82,6 +82,7 @@
#define GPR_WIN32_ATOMIC 1
#define GPR_MSVC_TLS 1
#endif
+#define GPR_WINDOWS_CRASH_HANDLER 1
#elif defined(_WIN32) || defined(WIN32)
#define GPR_ARCH_32 1
#define GPR_WIN32 1
@@ -94,6 +95,7 @@
#define GPR_WIN32_ATOMIC 1
#define GPR_MSVC_TLS 1
#endif
+#define GPR_WINDOWS_CRASH_HANDLER 1
#elif defined(ANDROID) || defined(__ANDROID__)
#define GPR_ANDROID 1
#define GPR_ARCH_32 1
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,