On Tue, 17 May 2011, Vincent Torri wrote:

>
>
> On Tue, 17 May 2011, Enlightenment SVN wrote:
>
>> Log:
>> ecore: add ecore_timer_dump.
>>
>>  Note: Will add tomorrow code needed inside e17 to dump all created timer.
>>
>>
>> Author:       cedric
>> Date:         2011-05-17 10:32:32 -0700 (Tue, 17 May 2011)
>> New Revision: 59473
>> Trac:         http://trac.enlightenment.org/e/changeset/59473
>>
>> Modified:
>>  trunk/ecore/ChangeLog trunk/ecore/configure.ac 
>> trunk/ecore/src/lib/ecore/Ecore.h trunk/ecore/src/lib/ecore/ecore_timer.c
>>
>> Modified: trunk/ecore/ChangeLog
>> ===================================================================
>> --- trunk/ecore/ChangeLog    2011-05-17 16:20:27 UTC (rev 59472)
>> +++ trunk/ecore/ChangeLog    2011-05-17 17:32:32 UTC (rev 59473)
>> @@ -182,3 +182,7 @@
>>      * Make ecore_con work on Windows (only the local connections
>>      need a port)
>>      * Make ecore_ipc compile on Windows
>> +
>> +2011-05-17  Cedric Bail
>> +
>> +    * Add ecore_timer_dump.
>>
>> Modified: trunk/ecore/configure.ac
>> ===================================================================
>> --- trunk/ecore/configure.ac 2011-05-17 16:20:27 UTC (rev 59472)
>> +++ trunk/ecore/configure.ac 2011-05-17 17:32:32 UTC (rev 59473)
>> @@ -344,7 +344,17 @@
>> fi
>> AC_SUBST(pkgconfig_requires_private)
>>
>> +### Checks for some build time option
>> +want_ecore_timer_dump="yes"
>>
>> +AC_ARG_ENABLE([ecore-timer-dump],
>> +   [AC_HELP_STRING([--disable-ecore-timer-dump], [disable tracking of timer 
>> allocation. @<:@default=enable@:>@])],
>> +   [want_ecore_timer_dump=$enableval], [])
>> +
>> +if test "x$want_ecore_timer_dump" = "xyes"; then
>> +   AC_DEFINE(WANT_ECORE_TIMER_DUMP, [1], [Want Ecore_Timer dump 
>> infrastructure])
>> +fi
>
> that's highly not sufficient. backtrace() is a GNU extension (not to
> mention that it does not work on Windows). You must check that the
> function exists

and that you have to link with -rdynamic

Vincent

>
> Vincent
>
>> +
>> ### Checks for libraries
>>
>> # Evil library for compilation on Windows
>> @@ -1469,6 +1479,7 @@
>> echo "    Always integrate GLib......: $want_glib_integration_always"
>> echo "    Use g_main_loop............: $want_g_main_loop"
>> echo "    Gathering memory statistic.: $have_mallinfo"
>> +echo "    Gathering timer allocation.: $want_ecore_timer_dump"
>> echo "  Ecore_Con....................: $have_ecore_con"
>> if test "x$have_ecore_con" = "xyes" ; then
>>   echo $ECHO_N "    OpenSSL....................: $have_openssl $ECHO_C"
>>
>> Modified: trunk/ecore/src/lib/ecore/Ecore.h
>> ===================================================================
>> --- trunk/ecore/src/lib/ecore/Ecore.h        2011-05-17 16:20:27 UTC (rev 
>> 59472)
>> +++ trunk/ecore/src/lib/ecore/Ecore.h        2011-05-17 17:32:32 UTC (rev 
>> 59473)
>> @@ -570,6 +570,7 @@
>>    EAPI double       ecore_timer_pending_get(Ecore_Timer *timer);
>>    EAPI double       ecore_timer_precision_get(void);
>>    EAPI void         ecore_timer_precision_set(double precision);
>> +   EAPI char        *ecore_timer_dump(void);
>>
>>   /**
>>    * @}
>>
>> Modified: trunk/ecore/src/lib/ecore/ecore_timer.c
>> ===================================================================
>> --- trunk/ecore/src/lib/ecore/ecore_timer.c  2011-05-17 16:20:27 UTC (rev 
>> 59472)
>> +++ trunk/ecore/src/lib/ecore/ecore_timer.c  2011-05-17 17:32:32 UTC (rev 
>> 59473)
>> @@ -8,6 +8,12 @@
>> #include "Ecore.h"
>> #include "ecore_private.h"
>>
>> +#ifdef WANT_ECORE_TIMER_DUMP
>> +# include <string.h>
>> +# include <execinfo.h>
>> +# define ECORE_TIMER_DEBUG_BT_NUM 64
>> +   typedef void (*Ecore_Timer_Bt_Func) ();
>> +#endif
>>
>> struct _Ecore_Timer
>> {
>> @@ -19,6 +25,11 @@
>>    Ecore_Task_Cb   func;
>>    void           *data;
>>
>> +#ifdef WANT_ECORE_TIMER_DUMP
>> +   Ecore_Timer_Bt_Func timer_bt[ECORE_TIMER_DEBUG_BT_NUM];
>> +   int                 timer_bt_num;
>> +#endif
>> +
>>    int             references;
>>    unsigned char   delete_me : 1;
>>    unsigned char   just_added : 1;
>> @@ -27,6 +38,7 @@
>>
>>
>> static void _ecore_timer_set(Ecore_Timer *timer, double at, double in, 
>> Ecore_Task_Cb func, void *data);
>> +static int _ecore_timer_cmp(const void *d1, const void *d2);
>>
>> static int          timers_added = 0;
>> static int          timers_delete_me = 0;
>> @@ -129,6 +141,12 @@
>>    if (!timer) return NULL;
>>    ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
>>    now = ecore_time_get();
>> +
>> +#ifdef WANT_ECORE_TIMER_DUMP
>> +   timer->timer_bt_num = backtrace((void**) (timer->timer_bt),
>> +                                   ECORE_TIMER_DEBUG_BT_NUM);
>> +#endif
>> +
>>    _ecore_timer_set(timer, now + in, in, func, (void *)data);
>>    return timer;
>> }
>> @@ -342,6 +360,51 @@
>>    _ecore_timer_set(timer, timer->pending + now, timer->in, timer->func, 
>> timer->data);
>> }
>>
>> +EAPI char *
>> +ecore_timer_dump(void)
>> +{
>> +#ifdef WANT_ECORE_TIMER_DUMP
>> +   Eina_Strbuf *result;
>> +   char *out;
>> +   Ecore_Timer *tm;
>> +   Eina_List *tmp = NULL;
>> +
>> +   result = eina_strbuf_new();
>> +
>> +   EINA_INLIST_FOREACH(timers, tm)
>> +     tmp = eina_list_sorted_insert(tmp, _ecore_timer_cmp, tm);
>> +
>> +   EINA_LIST_FREE(tmp, tm)
>> +     {
>> +        char **strings;
>> +        int nptrs;
>> +        int j;
>> +
>> +        nptrs = backtrace((void**) tm->timer_bt, ECORE_TIMER_DEBUG_BT_NUM);
>> +        strings = backtrace_symbols((void**) tm->timer_bt, nptrs);
>> +        if (strings == NULL)
>> +          continue ;
>> +
>> +        eina_strbuf_append_printf(result, "*** timer: %f ***\n", tm->in);
>> +        if (tm->frozen)
>> +          eina_strbuf_append(result, "FROZEN\n");
>> +        if (tm->delete_me)
>> +          eina_strbuf_append(result, "DELETED\n");
>> +        for (j = 0; j < nptrs; j++)
>> +          eina_strbuf_append_printf(result, "%s\n", strings[j]);
>> +
>> +        free(strings);
>> +     }
>> +
>> +   out = eina_strbuf_string_steal(result);
>> +   eina_strbuf_free(result);
>> +
>> +   return out;
>> +#else
>> +   return NULL;
>> +#endif
>> +}
>> +
>> /**
>>  * @}
>>  */
>> @@ -601,3 +664,12 @@
>>      }
>>    timers = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(timers), 
>> EINA_INLIST_GET(timer));
>> }
>> +
>> +static int
>> +_ecore_timer_cmp(const void *d1, const void *d2)
>> +{
>> +   const Ecore_Timer *t1 = d1;
>> +   const Ecore_Timer *t2 = d2;
>> +
>> +   return (int) t1->in - t2->in;
>> +}
>>
>>
>> ------------------------------------------------------------------------------
>> Achieve unprecedented app performance and reliability
>> What every C/C++ and Fortran developer should know.
>> Learn how Intel has extended the reach of its next-generation tools
>> to help boost performance applications - inlcuding clusters.
>> http://p.sf.net/sfu/intel-dev2devmay
>> _______________________________________________
>> enlightenment-svn mailing list
>> enlightenment-...@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>>
>>
>
> ------------------------------------------------------------------------------
> Achieve unprecedented app performance and reliability
> What every C/C++ and Fortran developer should know.
> Learn how Intel has extended the reach of its next-generation tools
> to help boost performance applications - inlcuding clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
>

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to