summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-05-08 17:18:38 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-05-08 17:18:38 +0900
commit7571020eb8d843d62fdf1580173733d773b024ac (patch)
tree52d0cfe1bfd65c4ee6c2d2a519015f1b79372eb3 /src/lib/eina
parent5b99d0f5616d345bc5890cd1260f2bd00e7d30b2 (diff)
eina debug - add comments
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_debug.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/eina/eina_debug.c b/src/lib/eina/eina_debug.c
index df6af047a4..62a050b997 100644
--- a/src/lib/eina/eina_debug.c
+++ b/src/lib/eina/eina_debug.c
@@ -3,16 +3,17 @@
3 3
4#ifdef EINA_HAVE_DEBUG 4#ifdef EINA_HAVE_DEBUG
5 5
6// access external thread data store in eina_debug_thread.c
6extern pthread_t _eina_debug_thread_mainloop; 7extern pthread_t _eina_debug_thread_mainloop;
7extern pthread_t *_eina_debug_thread_active; 8extern pthread_t *_eina_debug_thread_active;
8extern int _eina_debug_thread_active_num; 9extern int _eina_debug_thread_active_num;
9 10
10
11// yes - a global debug spinlock. i expect contention to be low for now, and 11// yes - a global debug spinlock. i expect contention to be low for now, and
12// when needed we can split this up into mroe locks to reduce contention when 12// when needed we can split this up into mroe locks to reduce contention when
13// and if that day comes 13// and if that day comes
14Eina_Spinlock _eina_debug_lock; 14Eina_Spinlock _eina_debug_lock;
15 15
16// only init once
16static Eina_Bool _inited = EINA_FALSE; 17static Eina_Bool _inited = EINA_FALSE;
17 18
18Eina_Bool 19Eina_Bool
@@ -20,12 +21,16 @@ eina_debug_init(void)
20{ 21{
21 pthread_t self; 22 pthread_t self;
22 23
24 // if already inbitted simply release our lock that we may have locked on
25 // shutdown if we are re-initted again in the same process
23 if (_inited) 26 if (_inited)
24 { 27 {
25 eina_spinlock_release(&_eina_debug_thread_lock); 28 eina_spinlock_release(&_eina_debug_thread_lock);
26 return EINA_TRUE; 29 return EINA_TRUE;
27 } 30 }
31 // mark as initted
28 _inited = EINA_TRUE; 32 _inited = EINA_TRUE;
33 // set up thread things
29 eina_spinlock_new(&_eina_debug_lock); 34 eina_spinlock_new(&_eina_debug_lock);
30 eina_spinlock_new(&_eina_debug_thread_lock); 35 eina_spinlock_new(&_eina_debug_thread_lock);
31 eina_semaphore_new(&_eina_debug_monitor_return_sem, 0); 36 eina_semaphore_new(&_eina_debug_monitor_return_sem, 0);
@@ -35,12 +40,19 @@ eina_debug_init(void)
35 // if we are setuid - don't debug! 40 // if we are setuid - don't debug!
36 if (getuid() != geteuid()) return EINA_TRUE; 41 if (getuid() != geteuid()) return EINA_TRUE;
37#endif 42#endif
43 // if someone uses the EFL_NODEBUG env var - do not do debugging. handy
44 // for when this debug code is buggy itself
38 if (getenv("EFL_NODEBUG")) return EINA_TRUE; 45 if (getenv("EFL_NODEBUG")) return EINA_TRUE;
46 // connect to our debug daemon
39 _eina_debug_monitor_service_connect(); 47 _eina_debug_monitor_service_connect();
48 // if we connected - set up the debug monitor properly
40 if (_eina_debug_monitor_service_fd >= 0) 49 if (_eina_debug_monitor_service_fd >= 0)
41 { 50 {
51 // say hello to the debug daemon
42 _eina_debug_monitor_service_greet(); 52 _eina_debug_monitor_service_greet();
53 // set up our profile signal handler
43 _eina_debug_monitor_signal_init(); 54 _eina_debug_monitor_signal_init();
55 // start the monitor thread
44 _eina_debug_monitor_thread_start(); 56 _eina_debug_monitor_thread_start();
45 } 57 }
46 return EINA_TRUE; 58 return EINA_TRUE;