diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2015-05-05 11:35:16 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2015-05-08 14:13:17 +0900 |
commit | 664708b817ab0cdc7177df3743b5d9c9ab7dd2b0 (patch) | |
tree | 04becb4abc16c79b2383629df16c661b20a36407 /src/lib/eina/eina_debug.c | |
parent | 38faeacee1a1aa10eabebb52edfaf91e2a2c158b (diff) | |
download | efl-664708b817ab0cdc7177df3743b5d9c9ab7dd2b0.tar.gz |
eina - start a much improved eina dbug infra and have eina_log use it
this makes eina_log give bt's for all error logs. this is very useful
in finding just where a problem happens. the problem int he past is
that these have not been too useful due to backtrace_symbols() being
"useless". thus use the eina_btlog tool i added too.
also started infra for a debug monitor that can use the backtrace
infra to collect runtime stats ANY TIME for a process (don't need to
run under a debugger).
@feat
Diffstat (limited to 'src/lib/eina/eina_debug.c')
-rw-r--r-- | src/lib/eina/eina_debug.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/lib/eina/eina_debug.c b/src/lib/eina/eina_debug.c new file mode 100644 index 0000000000..766ec7ac3c --- /dev/null +++ b/src/lib/eina/eina_debug.c @@ -0,0 +1,69 @@ +#include "eina_debug.h" + +#ifdef EINA_HAVE_DEBUG + +extern pthread_t _eina_debug_thread_mainloop; +extern pthread_t *_eina_debug_thread_active; +extern int _eina_debug_thread_active_num; + + +// yes - a global debug spinlock. i expect contention to be low for now, and +// when needed we can split this up into mroe locks to reduce contention when +// and if that day comes +Eina_Spinlock _eina_debug_lock; + +static Eina_Bool _inited = EINA_FALSE; + +Eina_Bool +eina_debug_init(void) +{ + pthread_t self; + + if (_inited) + { + eina_spinlock_release(&_eina_debug_thread_lock); + return EINA_TRUE; + } + _inited = EINA_TRUE; + eina_spinlock_new(&_eina_debug_lock); + eina_spinlock_new(&_eina_debug_thread_lock); + eina_semaphore_new(&_eina_debug_monitor_return_sem, 0); + self = pthread_self(); + _eina_debug_thread_mainloop_set(&self); +#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) + // if we are setuid - don't debug! + if (getuid() != geteuid()) return EINA_TRUE; +#endif + if (getenv("EFL_NODEBUG")) return EINA_TRUE; + _eina_debug_monitor_service_connect(); + if (_eina_debug_monitor_service_fd >= 0) + { + _eina_debug_monitor_service_greet(); + _eina_debug_monitor_signal_init(); + _eina_debug_monitor_thread_start(); + } + return EINA_TRUE; +} + +Eina_Bool +eina_debug_shutdown(void) +{ + eina_spinlock_take(&_eina_debug_thread_lock); + // yes - we never free on shutdown - this is because the monitor thread + // never exits. this is not a leak - we intend to never free up any + // resources here because they are allocated once only ever. + return EINA_TRUE; +} +#else +Eina_Bool +eina_debug_init(void) +{ + return EINA_TRUE; +} + +Eina_Bool +eina_debug_shutdown(void) +{ + return EINA_TRUE; +} +#endif |