diff --git a/TODO b/TODO index ecb4650..e0a5356 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -* Record backtraces of object creations, so we'll be able when and why an object was created. * Make it possible to hide rects? or show only elm-widgets? or something similar? too much clutter atm. * Add filter? * Make it an elm module (or setting an env var without a module?) so I'll be able to remotely connect to elm apps. diff --git a/src/lib/libclouseau.c b/src/lib/libclouseau.c index 78f1a29..934abe4 100644 --- a/src/lib/libclouseau.c +++ b/src/lib/libclouseau.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -166,7 +167,7 @@ gl_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) Elm_Genlist_Item_Type iflag = (treeit->children) ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE; elm_genlist_item_append(gl, &itc, treeit, glit, iflag, - _gl_selected, NULL); + NULL, NULL); } } @@ -426,6 +427,51 @@ ecore_main_loop_begin(void) return; } +#define EINA_LOCK_DEBUG_BT_NUM 64 +typedef void (*Eina_Lock_Bt_Func) (); + +Evas_Object * +evas_object_new(Evas *e) +{ + Eina_Lock_Bt_Func lock_bt[EINA_LOCK_DEBUG_BT_NUM]; + int lock_bt_num; + Evas_Object *(*_evas_object_new)(Evas *e) = dlsym(RTLD_NEXT, "evas_object_new"); + Eina_Strbuf *str; + Evas_Object *r; + char **strings; + int i; + + r = _evas_object_new(e); + if (!r) return NULL; + + lock_bt_num = backtrace((void **)lock_bt, EINA_LOCK_DEBUG_BT_NUM); + strings = backtrace_symbols((void **)lock_bt, lock_bt_num); + + str = eina_strbuf_new(); + + for (i = 1; i < lock_bt_num; ++i) + eina_strbuf_append_printf(str, "%s\n", strings[i]); + + evas_object_data_set(r, ".clouseau.bt", eina_stringshare_add(eina_strbuf_string_get(str))); + + free(strings); + eina_strbuf_free(str); + + return r; +} + +void +evas_object_free(Evas_Object *obj, int clean_layer) +{ + void (*_evas_object_free)(Evas_Object *obj, int clean_layer) = dlsym(RTLD_NEXT, "evas_object_free"); + const char *tmp; + + tmp = evas_object_data_get(obj, ".clouseau.bt"); + eina_stringshare_del(tmp); + + _evas_object_free(obj, clean_layer); +} + /* HIGHLIGHT code. */ @@ -447,6 +493,7 @@ libclouseau_highlight(Evas_Object *obj) Evas *e; Evas_Object *r; int x, y, w, h; + const char *tmp; e = evas_object_evas_get(obj); if (!e) return; @@ -460,6 +507,9 @@ libclouseau_highlight(Evas_Object *obj) HIGHLIGHT_A); evas_object_show(r); ecore_timer_add(0.1, libclouseau_highlight_fade, r); + + tmp = evas_object_data_get(obj, ".clouseau.bt"); + fprintf(stderr, "Creation backtrace :\n%s*******\n", tmp); } static Eina_Bool diff --git a/src/lib/ui/obj_information.c b/src/lib/ui/obj_information.c index 0fb93a2..5a81906 100644 --- a/src/lib/ui/obj_information.c +++ b/src/lib/ui/obj_information.c @@ -124,6 +124,7 @@ static void _obj_information_free(Obj_Information *oinfo) { eina_stringshare_del(oinfo->evas_props.name); + eina_stringshare_del(oinfo->evas_props.bt); if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_ELM) { @@ -191,6 +192,7 @@ _obj_information_get(Tree_Item *treeit) oinfo->evas_props.mode = evas_object_pointer_mode_get(obj); oinfo->evas_props.is_clipper = !!evas_object_clipees_get(obj); + oinfo->evas_props.bt = eina_stringshare_ref(evas_object_data_get(obj, ".clouseau.bt")); if (!strcmp("elm_widget", evas_object_type_get(obj))) { diff --git a/src/lib/ui/obj_information.h b/src/lib/ui/obj_information.h index 28bab1b..551363b 100644 --- a/src/lib/ui/obj_information.h +++ b/src/lib/ui/obj_information.h @@ -8,6 +8,7 @@ struct _Obj_Information { struct { const char *name; + const char *bt; short layer; Evas_Coord x, y, w, h; double scale;