From: tasn Date: Sun, 10 Jun 2012 08:43:49 +0000 (+0000) Subject: Evas magic checks: Print magic errors by default. X-Git-Tag: 2.0_alpha~50^2~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2307da1db6b157101c13f6c0c98f5ef3943e4fb7;p=framework%2Fuifw%2Fevas.git Evas magic checks: Print magic errors by default. We still don't print on NULL because there are two many such errors in evas, but at least we print on magic errors which are even worse. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@71894 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/main.c b/src/lib/main.c index f999889..0431977 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -6,7 +6,11 @@ EAPI Evas_Version *evas_version = &_version; int _evas_alloc_error = 0; static int _evas_debug_init = 0; -static int _evas_debug_show = 0; +static enum { + _EVAS_DEBUG_DEFAULT, + _EVAS_DEBUG_HIDE, + _EVAS_DEBUG_SHOW +} _evas_debug_show = _EVAS_DEBUG_DEFAULT; static int _evas_debug_abort = 0; EAPI Evas_Alloc_Error @@ -45,16 +49,27 @@ evas_mem_calloc(int size) return NULL; } +static void +_evas_debug_init_from_env() +{ + const char *tmp = getenv("EVAS_DEBUG_SHOW"); + if (tmp) + { + int dbgshow = atoi(tmp); + _evas_debug_show = (dbgshow) ? _EVAS_DEBUG_SHOW : _EVAS_DEBUG_HIDE; + } + if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; + _evas_debug_init = 1; +} + void evas_debug_error(void) { if (!_evas_debug_init) { - if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; - if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; - _evas_debug_init = 1; + _evas_debug_init_from_env(); } - if (_evas_debug_show) + if (_evas_debug_show == _EVAS_DEBUG_SHOW) CRIT("Evas Magic Check Failed!!!"); } @@ -63,11 +78,9 @@ evas_debug_input_null(void) { if (!_evas_debug_init) { - if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; - if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; - _evas_debug_init = 1; + _evas_debug_init_from_env(); } - if (_evas_debug_show) + if (_evas_debug_show == _EVAS_DEBUG_SHOW) CRIT("Input object pointer is NULL!"); if (_evas_debug_abort) abort(); } @@ -77,11 +90,10 @@ evas_debug_magic_null(void) { if (!_evas_debug_init) { - if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; - if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; - _evas_debug_init = 1; + _evas_debug_init_from_env(); } - if (_evas_debug_show) + if ((_evas_debug_show == _EVAS_DEBUG_SHOW) || + (_evas_debug_show == _EVAS_DEBUG_DEFAULT)) CRIT("Input object is zero'ed out (maybe a freed object or zero-filled RAM)!"); if (_evas_debug_abort) abort(); } @@ -91,11 +103,10 @@ evas_debug_magic_wrong(DATA32 expected, DATA32 supplied) { if (!_evas_debug_init) { - if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; - if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; - _evas_debug_init = 1; + _evas_debug_init_from_env(); } - if (_evas_debug_show) + if ((_evas_debug_show == _EVAS_DEBUG_SHOW) || + (_evas_debug_show == _EVAS_DEBUG_DEFAULT)) CRIT("Input object is wrong type\n" " Expected: %08x - %s\n" " Supplied: %08x - %s", @@ -109,11 +120,10 @@ evas_debug_generic(const char *str) { if (!_evas_debug_init) { - if (getenv("EVAS_DEBUG_SHOW")) _evas_debug_show = 1; - if (getenv("EVAS_DEBUG_ABORT")) _evas_debug_abort = 1; - _evas_debug_init = 1; + _evas_debug_init_from_env(); } - if (_evas_debug_show) + if ((_evas_debug_show == _EVAS_DEBUG_SHOW) || + (_evas_debug_show == _EVAS_DEBUG_DEFAULT)) CRIT("%s", str); if (_evas_debug_abort) abort(); }