From 0dd9e02df24435a13a505232be0db5a5eb07d1f4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 29 Dec 2015 19:42:05 +0900 Subject: [PATCH] Eo: Add internal function call on pointer errors Useful for GDB: break on this function when things go wrong. Similar to eina_safety. I guess we could set some Eina_Error and maybe even have error callbacks for easier application debugging. Later. --- src/lib/eo/eo_ptr_indirection.c | 6 ++++++ src/lib/eo/eo_ptr_indirection.h | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/eo/eo_ptr_indirection.c b/src/lib/eo/eo_ptr_indirection.c index ee55901..687ec8a 100644 --- a/src/lib/eo/eo_ptr_indirection.c +++ b/src/lib/eo/eo_ptr_indirection.c @@ -15,3 +15,9 @@ _Eo_Ids_Table *_empty_table = NULL; /* Next generation to use when assigning a new entry to a Eo pointer */ Generation_Counter _eo_generation_counter = 0; + +void +_eo_pointer_error(const char *msg) +{ + ERR("%s", msg); +} diff --git a/src/lib/eo/eo_ptr_indirection.h b/src/lib/eo/eo_ptr_indirection.h index e831a4a..458d2a0 100644 --- a/src/lib/eo/eo_ptr_indirection.h +++ b/src/lib/eo/eo_ptr_indirection.h @@ -10,13 +10,18 @@ #ifdef HAVE_EO_ID +void _eo_pointer_error(const char *msg); + +#define _EO_POINTER_ERR(fmt, ptr) \ + do { char buf[256]; sprintf(buf, fmt, ptr); _eo_pointer_error(buf); } while (0) + #define EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, ret) \ _Eo_Object *obj; \ do { \ if (!obj_id) return ret; \ obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ if (!obj) { \ - ERR("Obj (%p) is an invalid ref.", obj_id); \ + _EO_POINTER_ERR("Obj (%p) is an invalid ref.", obj_id); \ return ret; \ } \ } while (0) @@ -27,7 +32,7 @@ if (!obj_id) return; \ obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ if (!obj) { \ - ERR("Obj (%p) is an invalid ref.", obj_id); \ + _EO_POINTER_ERR("Obj (%p) is an invalid ref.", obj_id); \ return; \ } \ } while (0) @@ -38,7 +43,7 @@ if (!klass_id) return ret; \ klass = _eo_class_pointer_get(klass_id); \ if (!klass) { \ - ERR("Klass (%p) is an invalid ref.", klass_id); \ + _EO_POINTER_ERR("Klass (%p) is an invalid ref.", klass_id); \ return ret; \ } \ } while (0) @@ -49,7 +54,7 @@ if (!klass_id) return; \ klass = _eo_class_pointer_get(klass_id); \ if (!klass) { \ - ERR("Klass (%p) is an invalid ref.", klass_id); \ + _EO_POINTER_ERR("Klass (%p) is an invalid ref.", klass_id); \ return; \ } \ } while (0) -- 2.7.4