From f6b2f71d17beefe25e09e2d3b297009456603249 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 11 May 2017 02:17:38 -0400 Subject: [PATCH] lib/ref.c: add logging MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- lib/ref.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/ref.c b/lib/ref.c index 4e245adf5..d2ec688e7 100644 --- a/lib/ref.c +++ b/lib/ref.c @@ -27,6 +27,9 @@ #include #include +#define BT_LOG_TAG "REF" +#include + void *bt_get(void *ptr) { struct bt_object *obj = ptr; @@ -36,9 +39,14 @@ void *bt_get(void *ptr) } if (unlikely(obj->parent && bt_object_get_ref_count(obj) == 0)) { + BT_LOGV("Incrementing object's parent's reference count: " + "addr=%p, parent-addr=%p", ptr, obj->parent); bt_get(obj->parent); } bt_ref_get(&obj->ref_count); + BT_LOGV("Incremented object's reference count: %lu -> %lu: " + "addr=%p, new-count=%lu", obj->ref_count.count - 1, + obj->ref_count.count, ptr, obj->ref_count.count); end: return obj; } @@ -51,5 +59,8 @@ void bt_put(void *ptr) return; } + BT_LOGV("Decrementing object's reference count: %lu -> %lu: " + "addr=%p, cur-count=%lu", obj->ref_count.count, + obj->ref_count.count - 1, ptr, obj->ref_count.count); bt_ref_put(&obj->ref_count); } -- 2.34.1