From e9c5f37ab4acfe891600291033689ded03a8ee4a Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Mon, 17 Aug 2015 19:37:06 +0900 Subject: [PATCH] efl debug infra - add more event types for ability to check extended inf --- src/lib/ecore/ecore_anim.c | 4 +- src/lib/eina/eina_debug_monitor.c | 123 +++++++++++++++++++++++--------------- src/lib/eina/eina_evlog.h | 7 ++- 3 files changed, 81 insertions(+), 53 deletions(-) diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c index 8c61047..908da64 100644 --- a/src/lib/ecore/ecore_anim.c +++ b/src/lib/ecore/ecore_anim.c @@ -247,7 +247,7 @@ static void _begin_tick(void) { if (ticking) return; - eina_evlog(">animator", NULL, ecore_time_get(), NULL); + eina_evlog(">animator", NULL, 0.0, NULL); ticking = 1; switch (src) { @@ -268,7 +268,7 @@ static void _end_tick(void) { if (!ticking) return; - eina_evlog("= 4) memcpy(&poll_time, data, 4); poll_on = EINA_TRUE; + poll_trace = EINA_TRUE; } // profiling off with no payload else if (!strcmp(op, "PLOF")) { poll_time = 1000; poll_on = EINA_FALSE; + poll_trace = EINA_FALSE; } // enable evlog else if (!strcmp(op, "EVON")) @@ -208,6 +212,19 @@ _eina_debug_monitor(void *_data EINA_UNUSED) { eina_evlog_stop(); } + // enable evlog + else if (!strcmp(op, "CPON")) + { + if (size >= 4) memcpy(&poll_time, data, 4); + poll_on = EINA_TRUE; + poll_cpu = EINA_TRUE; + } + // stop evlog + else if (!strcmp(op, "CPOF")) + { + poll_on = EINA_FALSE; + poll_cpu = EINA_FALSE; + } // fetch the evlog else if (!strcmp(op, "EVLG")) { @@ -240,60 +257,68 @@ _eina_debug_monitor(void *_data EINA_UNUSED) if (poll_on) { - // take a lock on grabbing thread debug info like backtraces - eina_spinlock_take(&_eina_debug_thread_lock); - // reset our "stack" of memory se use to dump thread info into - _eina_debug_chunk_tmp_reset(); - // get an array of pointers for the backtrace array for main + th - _bt_buf = _eina_debug_chunk_tmp_push - ((1 + _eina_debug_thread_active_num) * sizeof(void *)); - if (!_bt_buf) goto err; - // get an array of pointers for the timespec array for mainloop + th - _bt_ts = _eina_debug_chunk_tmp_push - ((1 + _eina_debug_thread_active_num) * sizeof(struct timespec)); - if (!_bt_ts) goto err; - // get an array of pointers for the cpuid array for mainloop + th - _bt_cpu = _eina_debug_chunk_tmp_push - ((1 + _eina_debug_thread_active_num) * sizeof(int)); - if (!_bt_cpu) goto err; - // now get an array of void pts for mainloop bt - _bt_buf[0] = _eina_debug_chunk_tmp_push(EINA_MAX_BT * sizeof(void *)); - if (!_bt_buf[0]) goto err; - // get an array of void ptrs for each thread we know about for bt - for (i = 0; i < _eina_debug_thread_active_num; i++) + if (poll_trace) { - _bt_buf[i + 1] = _eina_debug_chunk_tmp_push(EINA_MAX_BT * sizeof(void *)); - if (!_bt_buf[i + 1]) goto err; - } - // get an array of ints to stor the bt len for mainloop + threads - _bt_buf_len = _eina_debug_chunk_tmp_push - ((1 + _eina_debug_thread_active_num) * sizeof(int)); - // collect bt from the mainloop - always there - _eina_debug_collect_bt(_eina_debug_thread_mainloop); - // now collect per thread - for (i = 0; i < _eina_debug_thread_active_num; i++) - _eina_debug_collect_bt(_eina_debug_thread_active[i]); - // we're done probing. now collec all the "i'm done" msgs on the - // semaphore for every thread + mainloop - for (i = 0; i < (_eina_debug_thread_active_num + 1); i++) - eina_semaphore_lock(&_eina_debug_monitor_return_sem); - // we now have gotten all the data from all threadd + mainloop. - // we can process it now as we see fit, so release thread lock + // take a lock on grabbing thread debug info like backtraces + eina_spinlock_take(&_eina_debug_thread_lock); + // reset our "stack" of memory se use to dump thread info into + _eina_debug_chunk_tmp_reset(); + // get an array of pointers for the backtrace array for main + th + _bt_buf = _eina_debug_chunk_tmp_push + ((1 + _eina_debug_thread_active_num) * sizeof(void *)); + if (!_bt_buf) goto err; + // get an array of pointers for the timespec array for mainloop + th + _bt_ts = _eina_debug_chunk_tmp_push + ((1 + _eina_debug_thread_active_num) * sizeof(struct timespec)); + if (!_bt_ts) goto err; + // get an array of pointers for the cpuid array for mainloop + th + _bt_cpu = _eina_debug_chunk_tmp_push + ((1 + _eina_debug_thread_active_num) * sizeof(int)); + if (!_bt_cpu) goto err; + // now get an array of void pts for mainloop bt + _bt_buf[0] = _eina_debug_chunk_tmp_push(EINA_MAX_BT * sizeof(void *)); + if (!_bt_buf[0]) goto err; + // get an array of void ptrs for each thread we know about for bt + for (i = 0; i < _eina_debug_thread_active_num; i++) + { + _bt_buf[i + 1] = _eina_debug_chunk_tmp_push(EINA_MAX_BT * sizeof(void *)); + if (!_bt_buf[i + 1]) goto err; + } + // get an array of ints to stor the bt len for mainloop + threads + _bt_buf_len = _eina_debug_chunk_tmp_push + ((1 + _eina_debug_thread_active_num) * sizeof(int)); + // collect bt from the mainloop - always there + _eina_debug_collect_bt(_eina_debug_thread_mainloop); + // now collect per thread + for (i = 0; i < _eina_debug_thread_active_num; i++) + _eina_debug_collect_bt(_eina_debug_thread_active[i]); + // we're done probing. now collec all the "i'm done" msgs on the + // semaphore for every thread + mainloop + for (i = 0; i < (_eina_debug_thread_active_num + 1); i++) + eina_semaphore_lock(&_eina_debug_monitor_return_sem); + // we now have gotten all the data from all threadd + mainloop. + // we can process it now as we see fit, so release thread lock //// XXX: some debug so we can see the bt's we collect - will go -// for (i = 0; i < (_eina_debug_thread_active_num + 1); i++) -// { -// _eina_debug_dump_fhandle_bt(stderr, _bt_buf[i], _bt_buf_len[i]); -// } +// for (i = 0; i < (_eina_debug_thread_active_num + 1); i++) +// { +// _eina_debug_dump_fhandle_bt(stderr, _bt_buf[i], _bt_buf_len[i]); +// } err: - eina_spinlock_release(&_eina_debug_thread_lock); + eina_spinlock_release(&_eina_debug_thread_lock); //// XXX: some debug just to see how well we perform - will go - bts++; - if (bts >= 10000) + bts++; + if (bts >= 10000) + { + t = get_time(); + fprintf(stderr, "%1.5f bt's per sec\n", (double)bts / (t - t0)); + t0 = t; + bts = 0; + } + } + if (poll_cpu) { - t = get_time(); - fprintf(stderr, "%1.5f bt's per sec\n", (double)bts / (t - t0)); - t0 = t; - bts = 0; + // XXX: opendir /proc/sefl/task +// eina_evlog("*cpustat", NULL, 0.0, cpustat); } } } diff --git a/src/lib/eina/eina_evlog.h b/src/lib/eina/eina_evlog.h index f8be828..9727863 100644 --- a/src/lib/eina/eina_evlog.h +++ b/src/lib/eina/eina_evlog.h @@ -63,14 +63,17 @@ struct _Eina_Evlog_Buf * * "+eventname" * "-eventname" - * "!eventname" * ">eventname" * "" + * character means the event is a one-off with no beginning or end. A"*" + * Means this is special metadata and the defail field may need special + * parsing based on the eventname, so ignroe unless known. A ">" * character means we begin this "state" of the process (these are separate * to "+" and "-" events and don't nest - arenot related to a thread or * any other event, but just a state). "<" Ends the given state given by -- 2.7.4