From a5535464bf1eb436b612895a5ee647a670641989 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 15 Feb 2017 13:42:29 +0900 Subject: [PATCH] eo_debug: Improve one log This changes the following message when the object is referencing its own data. Also lowers from ERR to WRN and adds the class name for the referenced data. ERR<17450>:eo /home/jpeg/e/core/efl/src/lib/eo/eo_private.h:337 _efl_unref_internal() in /home/jpeg/e/core/efl/src/lib/eo/eo.c:620: func '_efl_object_call_end' Data of object 0x400000021008db58 is still referenced by object 0x400000021008db58 Note that evas and elm have a few calls to efl_data_ref(obj, NULL) which are imho quite ugly: not using the return value and not specifying the data class. I'm keeping them as-is for now. --- src/lib/eo/eo.c | 1 + src/lib/eo/eo_private.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index f13a9af..3722152 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1872,6 +1872,7 @@ _efl_data_xref_internal(const char *file, int line, _Eo_Object *obj, const _Efl_ (obj->datarefcount)++; Eo_Xref_Node *xref = calloc(1, sizeof(*xref)); xref->ref_obj = _eo_obj_id_get(ref_obj); + xref->data_klass = klass ? klass->desc->name : NULL; xref->file = file; xref->line = line; diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h index a09c2a7..7a6ed69 100644 --- a/src/lib/eo/eo_private.h +++ b/src/lib/eo/eo_private.h @@ -192,6 +192,7 @@ typedef struct { EINA_INLIST; const Eo *ref_obj; + const char *data_klass; const char *file; int line; } Eo_Xref_Node; @@ -334,7 +335,17 @@ _efl_unref_internal(_Eo_Object *obj, const char *func_name, const char *file, in { Eina_Inlist *nitr = obj->data_xrefs->next; Eo_Xref_Node *xref = EINA_INLIST_CONTAINER_GET(obj->data_xrefs, Eo_Xref_Node); - ERR("in %s:%d: func '%s' Data of object 0x%lx is still referenced by object %p", file, line, func_name, (unsigned long) _eo_obj_id_get(obj), xref->ref_obj); + Eo *obj_id = _eo_obj_id_get(obj); + if (obj_id == xref->ref_obj) + { + WRN("in %s:%d: func '%s' Object %p still has a reference to its own data (subclass: %s). Origin: %s:%d", + file, line, func_name, obj_id, xref->data_klass, xref->file, xref->line); + } + else + { + ERR("in %s:%d: func '%s' Data of object %p (subclass: %s) is still referenced by object %p. Origin: %s:%d", + file, line, func_name, obj_id, xref->data_klass, xref->ref_obj, xref->file, xref->line); + } eina_freeq_ptr_main_add(xref, free, sizeof(*xref)); obj->data_xrefs = nitr; -- 2.7.4