eo: better error reporting, always provide caller/source when available.

_eo_pointer_error() was kinda a bitch to debug as it provided a nice
breakpoint location, but did not provide a good output since the file,
line and function were always the same.

Change that to be a thin wrapper on top of eina_log_vprint(), then we
keep the breakpoint location yet provide useful information.

In that sense, change other error messages so they carry as much
information as possible.
This commit is contained in:
Gustavo Sverzut Barbieri 2016-12-02 14:15:21 -02:00
parent cf5aeb9804
commit 216e6e51e4
3 changed files with 18 additions and 14 deletions

View File

@ -539,7 +539,7 @@ ok_klass:
goto ok_klass_back; goto ok_klass_back;
err_klass: err_klass:
_EO_POINTER_ERR("Class (%p) is an invalid ref.", eo_id); _EO_POINTER_ERR("in %s:%d: func '%s': obj_id=%p is an invalid ref.", file, line, func_name, eo_id);
return EINA_FALSE; return EINA_FALSE;
} }
@ -784,8 +784,8 @@ ok_nomatch:
goto ok_nomatch_back; goto ok_nomatch_back;
err_noid: err_noid:
ERR("Object of class '%s' - Error while constructing object", ERR("in %s:%d: Object of class '%s' - Error while constructing object",
klass->desc->name); file, line, klass->desc->name);
/* We have two refs at this point. */ /* We have two refs at this point. */
_efl_unref(obj); _efl_unref(obj);
efl_del((Eo *) obj->header.id); efl_del((Eo *) obj->header.id);
@ -798,7 +798,7 @@ err_noreg:
return NULL; return NULL;
err_klass: err_klass:
_EO_POINTER_ERR("Class (%p) is an invalid ref.", klass_id); _EO_POINTER_ERR("in %s:%d: Class (%p) is an invalid ref.", file, line, klass_id);
err_parent: err_parent:
return NULL; return NULL;
} }
@ -2145,18 +2145,18 @@ efl_domain_data_adopt(Efl_Domain_Data *data_in)
if (!data_foreign) if (!data_foreign)
{ {
ERR("Trying to adopt NULL domain data"); ERR("Trying to adopt NULL domain data [data=%p in=%p]", data, data_in);
return EFL_ID_DOMAIN_INVALID; return EFL_ID_DOMAIN_INVALID;
} }
if (data_foreign->local_domain == data->local_domain) if (data_foreign->local_domain == data->local_domain)
{ {
ERR("Trying to adopt EO ID domain %i, is the same as the local %i", ERR("Trying to adopt EO ID domain %i, is the same as the local %i [data=%p in=%p foreign=%p]",
data_foreign->local_domain, data->local_domain); data_foreign->local_domain, data->local_domain, data, data_in, data_foreign);
return EFL_ID_DOMAIN_INVALID; return EFL_ID_DOMAIN_INVALID;
} }
if (data->tables[data_foreign->local_domain]) if (data->tables[data_foreign->local_domain])
{ {
ERR("Trying to adopt an already adopted domain"); ERR("Trying to adopt an already adopted domain [data=%p in=%p foreign=%p]", data, data_in, data_foreign);
return EFL_ID_DOMAIN_INVALID; return EFL_ID_DOMAIN_INVALID;
} }
data->tables[data_foreign->local_domain] = data->tables[data_foreign->local_domain] =
@ -2177,7 +2177,7 @@ efl_domain_data_return(Efl_Id_Domain domain)
} }
if (domain == data->local_domain) if (domain == data->local_domain)
{ {
ERR("Cannot return the local domain back to its owner"); ERR("Cannot return the local domain %i back to its owner [data=%p]", domain, data);
return EINA_FALSE; return EINA_FALSE;
} }
data->tables[domain] = NULL; data->tables[domain] = NULL;

View File

@ -15,9 +15,13 @@ Eo_Id_Table_Data *_eo_table_data_shared_data = NULL;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void void
_eo_pointer_error(const char *msg) _eo_pointer_error(const char *func_name, const char *file, int line, const char *fmt, ...)
{ {
ERR("%s", msg); /* NOTE: this function exists to allow easy breakpoint on pointer errors */
va_list args;
va_start(args, fmt);
eina_log_vprint(_eo_log_dom, EINA_LOG_LEVEL_ERR, file, func_name, line, fmt, args);
va_end(args);
} }
#ifdef HAVE_EO_ID #ifdef HAVE_EO_ID

View File

@ -8,10 +8,10 @@
#ifdef HAVE_EO_ID #ifdef HAVE_EO_ID
void _eo_pointer_error(const char *msg); void _eo_pointer_error(const char *func_name, const char *file, int line, const char *fmt, ...);
#define _EO_POINTER_ERR(fmt, ptr) \ #define _EO_POINTER_ERR(fmt, ...) \
do { char buf[256]; sprintf(buf, fmt, ptr); _eo_pointer_error(buf); } while (0) _eo_pointer_error(__FUNCTION__, __FILE__, __LINE__, fmt, __VA_ARGS__)
#define EO_OBJ_POINTER(obj_id, obj) \ #define EO_OBJ_POINTER(obj_id, obj) \
_Eo_Object *obj; \ _Eo_Object *obj; \