ipconfig: Add caller information to ref/unref debug prints.
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 20 Jan 2012 10:01:46 +0000 (12:01 +0200)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 24 Jan 2012 10:48:06 +0000 (11:48 +0100)
src/connman.h
src/ipconfig.c

index c5803e1..158f51f 100644 (file)
@@ -198,8 +198,17 @@ struct connman_ipconfig_ops {
 
 struct connman_ipconfig *__connman_ipconfig_create(int index,
                                        enum connman_ipconfig_type type);
-struct connman_ipconfig *__connman_ipconfig_ref(struct connman_ipconfig *ipconfig);
-void __connman_ipconfig_unref(struct connman_ipconfig *ipconfig);
+
+#define __connman_ipconfig_ref(ipconfig) \
+       __connman_ipconfig_ref_debug(ipconfig, __FILE__, __LINE__, __func__)
+#define __connman_ipconfig_unref(ipconfig) \
+       __connman_ipconfig_unref_debug(ipconfig, __FILE__, __LINE__, __func__)
+
+struct connman_ipconfig *
+__connman_ipconfig_ref_debug(struct connman_ipconfig *ipconfig,
+                       const char *file, int line, const char *caller);
+void __connman_ipconfig_unref_debug(struct connman_ipconfig *ipconfig,
+                       const char *file, int line, const char *caller);
 
 void *__connman_ipconfig_get_data(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_data(struct connman_ipconfig *ipconfig, void *data);
index 75cb56e..34a8ddc 100644 (file)
@@ -1297,9 +1297,12 @@ struct connman_ipconfig *__connman_ipconfig_create(int index,
  *
  * Increase reference counter of ipconfig
  */
-struct connman_ipconfig *__connman_ipconfig_ref(struct connman_ipconfig *ipconfig)
+struct connman_ipconfig *
+__connman_ipconfig_ref_debug(struct connman_ipconfig *ipconfig,
+                               const char *file, int line, const char *caller)
 {
-       DBG("ipconfig %p refcount %d", ipconfig, ipconfig->refcount + 1);
+       DBG("%p ref %d by %s:%d:%s()", ipconfig, ipconfig->refcount + 1,
+               file, line, caller);
 
        __sync_fetch_and_add(&ipconfig->refcount, 1);
 
@@ -1312,12 +1315,14 @@ struct connman_ipconfig *__connman_ipconfig_ref(struct connman_ipconfig *ipconfi
  *
  * Decrease reference counter of ipconfig
  */
-void __connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
+void __connman_ipconfig_unref_debug(struct connman_ipconfig *ipconfig,
+                               const char *file, int line, const char *caller)
 {
        if (ipconfig == NULL)
                return;
 
-       DBG("ipconfig %p refcount %d", ipconfig, ipconfig->refcount - 1);
+       DBG("%p ref %d by %s:%d:%s()", ipconfig, ipconfig->refcount - 1,
+               file, line, caller);
 
        if (__sync_fetch_and_sub(&ipconfig->refcount, 1) != 1)
                return;