diff options
author | José Fonseca <[email protected]> | 2014-06-03 18:08:34 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2014-06-04 10:25:08 +0100 |
commit | 122e23249583d233e8a988abe95dcb5d76fa6b98 (patch) | |
tree | 7de365da329a1a35fad5e05fc7f1249a89f7cd4f /src | |
parent | 7e0dd80f11eae748be4c4e13916c110e4a0ff45d (diff) |
wgl: Disable CRT message boxes when Windows system error messages boxes are disabled.
At least on MSVC we statically link against the CRT, so we must disable
the CRT message boxes if we want unattended testing.
The messages are convenient when running manually, so let them be if the
system error message boxes are not disabled.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_debug.c | 32 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_debug.h | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_device.c | 2 |
3 files changed, 43 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index dc840e8566c..d79f31ea947 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -46,6 +46,12 @@ #include <limits.h> /* CHAR_BIT */ #include <ctype.h> /* isalnum */ +#ifdef _WIN32 +#include <windows.h> +#include <stdlib.h> +#endif + + void _debug_vprintf(const char *format, va_list ap) { static char buf[4096] = {'\0'}; @@ -64,6 +70,32 @@ void _debug_vprintf(const char *format, va_list ap) } +void +debug_disable_error_message_boxes(void) +{ +#ifdef _WIN32 + /* When Windows' error message boxes are disabled for this process (as is + * typically the case when running tests in an automated fashion) we disable + * CRT message boxes too. + */ + UINT uMode = SetErrorMode(0); + SetErrorMode(uMode); + if (uMode & SEM_FAILCRITICALERRORS) { + /* Disable assertion failure message box. + * http://msdn.microsoft.com/en-us/library/sas1dkb2.aspx + */ + _set_error_mode(_OUT_TO_STDERR); +#ifdef _MSC_VER + /* Disable abort message box. + * http://msdn.microsoft.com/en-us/library/e631wekh.aspx + */ + _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); +#endif + } +#endif /* _WIN32 */ +} + + #ifdef DEBUG void debug_print_blob( const char *name, const void *blob, diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 9c414211b3f..badd5e296f6 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -139,6 +139,15 @@ void debug_print_format(const char *msg, unsigned fmt ); /** + * Disable interactive error message boxes. + * + * Should be called as soon as possible for effectiveness. + */ +void +debug_disable_error_message_boxes(void); + + +/** * Hard-coded breakpoint. */ #ifdef DEBUG diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index 8f2cf9c7a1c..025dbdc8384 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -69,6 +69,8 @@ stw_init(const struct stw_winsys *stw_winsys) static struct stw_device stw_dev_storage; struct pipe_screen *screen; + debug_disable_error_message_boxes(); + debug_printf("%s\n", __FUNCTION__); assert(!stw_dev); |