gallium: Use debug_get_bool_option for controlling assert failure behaviour.

Add
  GALLIUM_ABORT_ON_ASSERT=no
to C:\gallium.cfg instead.
This commit is contained in:
José Fonseca
2008-04-16 22:32:10 +09:00
parent 3be453bf7f
commit 3a765bbe00

View File

@@ -200,6 +200,8 @@ debug_get_bool_option(const char *name, boolean dfault)
if(str == NULL) if(str == NULL)
result = dfault; result = dfault;
else if(!strcmp(str, "n"))
result = FALSE;
else if(!strcmp(str, "no")) else if(!strcmp(str, "no"))
result = FALSE; result = FALSE;
else if(!strcmp(str, "0")) else if(!strcmp(str, "0"))
@@ -251,57 +253,16 @@ debug_get_flags_option(const char *name,
} }
#if defined(WIN32)
ULONG_PTR debug_config_file = 0;
void *mapped_config_file = 0;
enum {
eAssertAbortEn = 0x1,
};
/* Check for aborts enabled. */
static unsigned abort_en(void)
{
if (!mapped_config_file)
{
/* Open an 8 byte file for configuration data. */
mapped_config_file = EngMapFile(L"\\??\\c:\\gaDebug.cfg", 8, &debug_config_file);
}
/* A value of "0" (ascii) in the configuration file will clear the
* first 8 bits in the test byte.
*
* A value of "1" (ascii) in the configuration file will set the
* first bit in the test byte.
*
* A value of "2" (ascii) in the configuration file will set the
* second bit in the test byte.
*
* Currently the only interesting values are 0 and 1, which clear
* and set abort-on-assert behaviour respectively.
*/
return ((((char *)mapped_config_file)[0]) - 0x30) & eAssertAbortEn;
}
#else /* WIN32 */
static unsigned abort_en(void)
{
return !GETENV("GALLIUM_ABORT_ON_ASSERT");
}
#endif
void _debug_assert_fail(const char *expr, void _debug_assert_fail(const char *expr,
const char *file, const char *file,
unsigned line, unsigned line,
const char *function) const char *function)
{ {
_debug_printf("%s:%u:%s: Assertion `%s' failed.\n", file, line, function, expr); _debug_printf("%s:%u:%s: Assertion `%s' failed.\n", file, line, function, expr);
if (abort_en()) if (debug_get_bool_option("GALLIUM_ABORT_ON_ASSERT", TRUE))
{
debug_break(); debug_break();
} else else
{
_debug_printf("continuing...\n"); _debug_printf("continuing...\n");
}
} }