From 02c77847cb7c492a969716af339eb18c219a9584 Mon Sep 17 00:00:00 2001 From: mehrdadn Date: Sun, 10 Jul 2016 23:39:54 +0300 Subject: [PATCH] RAY_BREAK_IF_DEBUGGING (#247) --- include/ray/logging.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/ray/logging.h b/include/ray/logging.h index cb650cdd4..09e971fdb 100644 --- a/include/ray/logging.h +++ b/include/ray/logging.h @@ -16,6 +16,13 @@ extern RayConfig global_ray_config; #define RAY_REFCOUNT RAY_VERBOSE #define RAY_ALIAS RAY_VERBOSE +#ifdef _MSC_VER +extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); +#define RAY_BREAK_IF_DEBUGGING() IsDebuggerPresent() && (__debugbreak(), 1) +#else +#define RAY_BREAK_IF_DEBUGGING() +#endif + #define RAY_LOG(LEVEL, MESSAGE) \ if (LEVEL == RAY_VERBOSE) { \ \ @@ -24,6 +31,7 @@ extern RayConfig global_ray_config; if (global_ray_config.log_to_file) { \ global_ray_config.logfile << "fatal error occured: " << MESSAGE << std::endl; \ } \ + RAY_BREAK_IF_DEBUGGING(); \ std::exit(1); \ } else if (LEVEL == RAY_DEBUG) { \ \