efl debug infra - add more event types for ability to check extended inf

This commit is contained in:
Carsten Haitzler 2015-08-17 19:37:06 +09:00
parent 956182c7c5
commit e9c5f37ab4
3 changed files with 81 additions and 53 deletions

View File

@ -247,7 +247,7 @@ static void
_begin_tick(void) _begin_tick(void)
{ {
if (ticking) return; if (ticking) return;
eina_evlog(">animator", NULL, ecore_time_get(), NULL); eina_evlog(">animator", NULL, 0.0, NULL);
ticking = 1; ticking = 1;
switch (src) switch (src)
{ {
@ -268,7 +268,7 @@ static void
_end_tick(void) _end_tick(void)
{ {
if (!ticking) return; if (!ticking) return;
eina_evlog("<animator", NULL, ecore_time_get(), NULL); eina_evlog("<animator", NULL, 0.0, NULL);
ticking = 0; ticking = 0;
_timer_tick_end(); _timer_tick_end();

View File

@ -144,6 +144,8 @@ _eina_debug_monitor(void *_data EINA_UNUSED)
// some state for debugging // some state for debugging
unsigned int poll_time = 1000; unsigned int poll_time = 1000;
Eina_Bool poll_on = EINA_FALSE; Eina_Bool poll_on = EINA_FALSE;
Eina_Bool poll_trace = EINA_FALSE;
Eina_Bool poll_cpu = EINA_FALSE;
t0 = get_time(); t0 = get_time();
// sit forever processing commands or timeouts in the debug monitor // sit forever processing commands or timeouts in the debug monitor
@ -191,12 +193,14 @@ _eina_debug_monitor(void *_data EINA_UNUSED)
{ {
if (size >= 4) memcpy(&poll_time, data, 4); if (size >= 4) memcpy(&poll_time, data, 4);
poll_on = EINA_TRUE; poll_on = EINA_TRUE;
poll_trace = EINA_TRUE;
} }
// profiling off with no payload // profiling off with no payload
else if (!strcmp(op, "PLOF")) else if (!strcmp(op, "PLOF"))
{ {
poll_time = 1000; poll_time = 1000;
poll_on = EINA_FALSE; poll_on = EINA_FALSE;
poll_trace = EINA_FALSE;
} }
// enable evlog // enable evlog
else if (!strcmp(op, "EVON")) else if (!strcmp(op, "EVON"))
@ -208,6 +212,19 @@ _eina_debug_monitor(void *_data EINA_UNUSED)
{ {
eina_evlog_stop(); 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 // fetch the evlog
else if (!strcmp(op, "EVLG")) else if (!strcmp(op, "EVLG"))
{ {
@ -240,60 +257,68 @@ _eina_debug_monitor(void *_data EINA_UNUSED)
if (poll_on) if (poll_on)
{ {
// take a lock on grabbing thread debug info like backtraces if (poll_trace)
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 *)); // take a lock on grabbing thread debug info like backtraces
if (!_bt_buf[i + 1]) goto err; eina_spinlock_take(&_eina_debug_thread_lock);
} // reset our "stack" of memory se use to dump thread info into
// get an array of ints to stor the bt len for mainloop + threads _eina_debug_chunk_tmp_reset();
_bt_buf_len = _eina_debug_chunk_tmp_push // get an array of pointers for the backtrace array for main + th
((1 + _eina_debug_thread_active_num) * sizeof(int)); _bt_buf = _eina_debug_chunk_tmp_push
// collect bt from the mainloop - always there ((1 + _eina_debug_thread_active_num) * sizeof(void *));
_eina_debug_collect_bt(_eina_debug_thread_mainloop); if (!_bt_buf) goto err;
// now collect per thread // get an array of pointers for the timespec array for mainloop + th
for (i = 0; i < _eina_debug_thread_active_num; i++) _bt_ts = _eina_debug_chunk_tmp_push
_eina_debug_collect_bt(_eina_debug_thread_active[i]); ((1 + _eina_debug_thread_active_num) * sizeof(struct timespec));
// we're done probing. now collec all the "i'm done" msgs on the if (!_bt_ts) goto err;
// semaphore for every thread + mainloop // get an array of pointers for the cpuid array for mainloop + th
for (i = 0; i < (_eina_debug_thread_active_num + 1); i++) _bt_cpu = _eina_debug_chunk_tmp_push
eina_semaphore_lock(&_eina_debug_monitor_return_sem); ((1 + _eina_debug_thread_active_num) * sizeof(int));
// we now have gotten all the data from all threadd + mainloop. if (!_bt_cpu) goto err;
// we can process it now as we see fit, so release thread lock // 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 //// 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++) // for (i = 0; i < (_eina_debug_thread_active_num + 1); i++)
// { // {
// _eina_debug_dump_fhandle_bt(stderr, _bt_buf[i], _bt_buf_len[i]); // _eina_debug_dump_fhandle_bt(stderr, _bt_buf[i], _bt_buf_len[i]);
// } // }
err: 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 //// XXX: some debug just to see how well we perform - will go
bts++; bts++;
if (bts >= 10000) 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(); // XXX: opendir /proc/sefl/task
fprintf(stderr, "%1.5f bt's per sec\n", (double)bts / (t - t0)); // eina_evlog("*cpustat", NULL, 0.0, cpustat);
t0 = t;
bts = 0;
} }
} }
} }

View File

@ -63,14 +63,17 @@ struct _Eina_Evlog_Buf
* *
* "+eventname" * "+eventname"
* "-eventname" * "-eventname"
* "!eventname"
* ">eventname" * ">eventname"
* "<eventname" * "<eventname"
* "!eventname"
* "*eventname"
* *
* etc. The "+" char means an event is beginning (and any subsequent * etc. The "+" char means an event is beginning (and any subsequent
* events logged are really children of this event). The "-" char means an * events logged are really children of this event). The "-" char means an
* event is ending and so all child events SHOULD have ended by now. A "!" * event is ending and so all child events SHOULD have ended by now. A "!"
* character means the event is a one-off with no beginning or end. A ">" * 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 * 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 * 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 * any other event, but just a state). "<" Ends the given state given by