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

index 8e9f859..8b4d199 100644 (file)
@@ -59,8 +59,17 @@ enum connman_provider_error {
 struct connman_provider;
 struct connman_ipaddress;
 
-struct connman_provider *connman_provider_ref(struct connman_provider *provider);
-void connman_provider_unref(struct connman_provider *provider);
+#define connman_provider_ref(provider) \
+       connman_provider_ref_debug(provider, __FILE__, __LINE__, __func__)
+
+#define connman_provider_unref(provider) \
+       connman_provider_unref_debug(provider, __FILE__, __LINE__, __func__)
+
+struct connman_provider *
+connman_provider_ref_debug(struct connman_provider *provider,
+                       const char *file, int line, const char *caller);
+void connman_provider_unref_debug(struct connman_provider *provider,
+                       const char *file, int line, const char *caller);
 
 int connman_provider_set_string(struct connman_provider *provider,
                                        const char *key, const char *value);
index f0a91e8..ce3382d 100644 (file)
@@ -209,9 +209,12 @@ static void provider_unregister(struct connman_provider *provider)
        provider_remove(provider);
 }
 
-struct connman_provider *connman_provider_ref(struct connman_provider *provider)
+struct connman_provider *
+connman_provider_ref_debug(struct connman_provider *provider,
+                       const char *file, int line, const char *caller)
 {
-       DBG("provider %p refcount %d", provider, provider->refcount + 1);
+       DBG("%p ref %d by %s:%d:%s()", provider, provider->refcount + 1,
+               file, line, caller);
 
        __sync_fetch_and_add(&provider->refcount, 1);
 
@@ -231,9 +234,11 @@ static void provider_destruct(struct connman_provider *provider)
        g_hash_table_destroy(provider->setting_strings);
 }
 
-void connman_provider_unref(struct connman_provider *provider)
+void connman_provider_unref_debug(struct connman_provider *provider,
+                               const char *file, int line, const char *caller)
 {
-       DBG("provider %p refcount %d", provider, provider->refcount - 1);
+       DBG("%p ref %d by %s:%d:%s()", provider, provider->refcount - 1,
+               file, line, caller);
 
        if (__sync_fetch_and_sub(&provider->refcount, 1) != 1)
                return;