summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-02 14:15:21 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-02 14:50:45 -0200
commit216e6e51e4a49377d8867dfcaf0ca283c1dacfca (patch)
tree4717025e4e2f4b64e86cd83baf1f810e33132186
parentcf5aeb9804e030465f95f3eb0653a1b388983815 (diff)
downloadefl-216e6e51e4a49377d8867dfcaf0ca283c1dacfca.tar.gz
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.
-rw-r--r--src/lib/eo/eo.c18
-rw-r--r--src/lib/eo/eo_ptr_indirection.c8
-rw-r--r--src/lib/eo/eo_ptr_indirection.h6
3 files changed, 18 insertions, 14 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 6d8c701287..9719034af1 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -539,7 +539,7 @@ ok_klass:
goto ok_klass_back;
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;
}
@@ -784,8 +784,8 @@ ok_nomatch:
goto ok_nomatch_back;
err_noid:
- ERR("Object of class '%s' - Error while constructing object",
- klass->desc->name);
+ ERR("in %s:%d: Object of class '%s' - Error while constructing object",
+ file, line, klass->desc->name);
/* We have two refs at this point. */
_efl_unref(obj);
efl_del((Eo *) obj->header.id);
@@ -798,7 +798,7 @@ err_noreg:
return NULL;
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:
return NULL;
}
@@ -2145,18 +2145,18 @@ efl_domain_data_adopt(Efl_Domain_Data *data_in)
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;
}
if (data_foreign->local_domain == data->local_domain)
{
- ERR("Trying to adopt EO ID domain %i, is the same as the local %i",
- data_foreign->local_domain, data->local_domain);
+ 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, data_in, data_foreign);
return EFL_ID_DOMAIN_INVALID;
}
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;
}
data->tables[data_foreign->local_domain] =
@@ -2177,7 +2177,7 @@ efl_domain_data_return(Efl_Id_Domain 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;
}
data->tables[domain] = NULL;
diff --git a/src/lib/eo/eo_ptr_indirection.c b/src/lib/eo/eo_ptr_indirection.c
index 568b9f86f8..f8ccfe9922 100644
--- a/src/lib/eo/eo_ptr_indirection.c
+++ b/src/lib/eo/eo_ptr_indirection.c
@@ -15,9 +15,13 @@ Eo_Id_Table_Data *_eo_table_data_shared_data = NULL;
//////////////////////////////////////////////////////////////////////////
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
diff --git a/src/lib/eo/eo_ptr_indirection.h b/src/lib/eo/eo_ptr_indirection.h
index 3df4fb56ea..b10a13e06b 100644
--- a/src/lib/eo/eo_ptr_indirection.h
+++ b/src/lib/eo/eo_ptr_indirection.h
@@ -8,10 +8,10 @@
#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) \
- do { char buf[256]; sprintf(buf, fmt, ptr); _eo_pointer_error(buf); } while (0)
+#define _EO_POINTER_ERR(fmt, ...) \
+ _eo_pointer_error(__FUNCTION__, __FILE__, __LINE__, fmt, __VA_ARGS__)
#define EO_OBJ_POINTER(obj_id, obj) \
_Eo_Object *obj; \