aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2013-03-04 11:08:21 +0900
committerCedric BAIL <cedric.bail@samsung.com>2013-03-04 11:08:21 +0900
commit1c9470e0716b26059a5eb83b9f213beba11c6cc5 (patch)
treec82d66ceaea9e11c424a6586b19e74bf87b0c379
parentddfd471c717c3d85e6227b049a1c47dfc0979562 (diff)
downloadefl-1c9470e0716b26059a5eb83b9f213beba11c6cc5.tar.gz
efl-1c9470e0716b26059a5eb83b9f213beba11c6cc5.tar.xz
efl-1c9470e0716b26059a5eb83b9f213beba11c6cc5.zip
eina: improve logging and debugging infra for Eina_Cow.
-rw-r--r--src/lib/eina/eina_cow.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/lib/eina/eina_cow.c b/src/lib/eina/eina_cow.c
index a31c36c0e..51c01d325 100644
--- a/src/lib/eina/eina_cow.c
+++ b/src/lib/eina/eina_cow.c
@@ -37,7 +37,7 @@
#define EINA_COW_MAGIC 0xDEADBEEF
-// #define MOO // Define that one if you want magic debug for Eina_Cow_Ptr
+//#define MOO // Define that one if you want magic debug for Eina_Cow_Ptr
#ifdef MOO
# define EINA_COW_PTR_MAGIC 0xBEEFE00
#endif
@@ -45,10 +45,19 @@
typedef struct _Eina_Cow_Ptr Eina_Cow_Ptr;
typedef struct _Eina_Cow_GC Eina_Cow_GC;
+#ifdef HAVE_BACKTRACE
+#define EINA_DEBUG_BT_NUM 64
+typedef void (*Eina_Bt_Func) ();
+#endif
+
struct _Eina_Cow_Ptr
{
#ifdef MOO
EINA_MAGIC;
+# ifdef HAVE_BACKTRACE
+ Eina_Bt_Func writer_bt[EINA_DEBUG_BT_NUM];
+ int writer_bt_num;
+# endif
#endif
int refcount;
@@ -374,7 +383,7 @@ eina_cow_write(Eina_Cow *cow,
ref = EINA_COW_PTR_GET(*data);
#ifndef NVALGRIND
- VALGRIND_MAKE_MEM_DEFINED(ref, sizeof (ref));
+ VALGRIND_MAKE_MEM_DEFINED(ref, sizeof (ref));
#endif
if (ref->refcount == 1)
{
@@ -383,6 +392,10 @@ eina_cow_write(Eina_Cow *cow,
if (ref->writing)
{
ERR("Request writing on an pointer that is already in a writing process %p\n", data);
+#if defined(MOO) && defined(HAVE_BACKTRACE)
+ backtrace_symbols_fd((void **) ref->writer_bt,
+ ref->writer_bt_num, 1);
+#endif
return NULL;
}
@@ -415,6 +428,10 @@ eina_cow_write(Eina_Cow *cow,
#ifndef NVALGRIND
VALGRIND_MAKE_MEM_DEFINED(ref, sizeof (ref));
#endif
+#if defined(MOO) && defined(HAVE_BACKTRACE)
+ ref->writer_bt_num = backtrace((void **)(ref->writer_bt),
+ EINA_DEBUG_BT_NUM);
+#endif
ref->writing = EINA_TRUE;
#ifndef NVALGRIND
VALGRIND_MAKE_MEM_NOACCESS(ref, sizeof (ref));