clouseau: track object creation and destruction.

SVN revision: 69260
This commit is contained in:
Cedric BAIL 2012-03-12 16:36:15 +00:00
parent e4fdc44b1f
commit b4d57ef6ff
4 changed files with 54 additions and 2 deletions

1
TODO
View File

@ -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.

View File

@ -5,6 +5,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <execinfo.h>
#include <Eina.h>
#include <Ecore.h>
@ -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

View File

@ -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)))
{

View File

@ -8,6 +8,7 @@ struct _Obj_Information
{
struct {
const char *name;
const char *bt;
short layer;
Evas_Coord x, y, w, h;
double scale;