From 0f5e83e54ee2a84640a7924bb4ae6d48557eefed Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 13 May 2017 15:08:24 -0400 Subject: [PATCH] include/babeltrace/object-internal.h: add logging MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Because the static inline functions are instrumented in the header itself, it cannot have its own tag. So this header MUST be included AFTER including , or anything that includes this (like ). ctf.lttng-live is modified to respect this, as well as various instrumented library source files. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- include/babeltrace/object-internal.h | 19 ++++++++++++++++++- lib/ctf-ir/attributes.c | 4 ++-- lib/ctf-ir/clock-class.c | 6 +++--- lib/ref.c | 6 +++--- lib/values.c | 5 +++-- plugins/ctf/lttng-live/lttng-live-internal.h | 4 ++-- plugins/ctf/lttng-live/lttng-live.c | 2 +- plugins/ctf/lttng-live/viewer-connection.h | 2 +- 8 files changed, 33 insertions(+), 15 deletions(-) diff --git a/include/babeltrace/object-internal.h b/include/babeltrace/object-internal.h index 545a20aa..2b368c55 100644 --- a/include/babeltrace/object-internal.h +++ b/include/babeltrace/object-internal.h @@ -59,6 +59,11 @@ void bt_object_release(void *ptr) { struct bt_object *obj = ptr; +#ifdef BT_LOGV + BT_LOGV("Releasing object: addr=%p, ref-count=%lu", ptr, + obj->ref_count.count); +#endif + if (obj && obj->release && !bt_object_get_ref_count(obj)) { obj->release(obj); } @@ -68,7 +73,14 @@ static inline void generic_release(struct bt_object *obj) { if (obj->parent) { - void *parent = obj->parent; + struct bt_object *parent = obj->parent; + +#ifdef BT_LOGV + BT_LOGV("Releasing parented object: addr=%p, ref-count=%lu, " + "parent-addr=%p, parent-ref-count=%lu", + obj, obj->ref_count.count, + parent, parent->ref_count.count); +#endif if (obj->parent_is_owner_listener) { /* @@ -110,6 +122,11 @@ void bt_object_set_parent(void *child_ptr, void *parent) return; } +#ifdef BT_LOGV + BT_LOGV("Setting object's parent: addr=%p, parent-addr=%p", + child_ptr, parent); +#endif + /* * It is assumed that a "child" being "parented" is publicly reachable. * Therefore, a reference to its parent must be taken. The reference diff --git a/lib/ctf-ir/attributes.c b/lib/ctf-ir/attributes.c index f9457996..2cd3a4bf 100644 --- a/lib/ctf-ir/attributes.c +++ b/lib/ctf-ir/attributes.c @@ -25,11 +25,11 @@ * SOFTWARE. */ +#define BT_LOG_TAG "ATTRS" + #include #include #include - -#define BT_LOG_TAG "ATTRS" #include #define BT_CTF_ATTR_NAME_INDEX 0 diff --git a/lib/ctf-ir/clock-class.c b/lib/ctf-ir/clock-class.c index e3c711c0..4335d3b0 100644 --- a/lib/ctf-ir/clock-class.c +++ b/lib/ctf-ir/clock-class.c @@ -26,16 +26,16 @@ * SOFTWARE. */ +#define BT_LOG_TAG "CLOCK-CLASS" + #include #include #include -#include #include #include #include - -#define BT_LOG_TAG "CLOCK-CLASS" #include +#include static void bt_ctf_clock_class_destroy(struct bt_object *obj); diff --git a/lib/ref.c b/lib/ref.c index d2ec688e..bcef44f1 100644 --- a/lib/ref.c +++ b/lib/ref.c @@ -24,11 +24,11 @@ * SOFTWARE. */ -#include -#include - #define BT_LOG_TAG "REF" + #include +#include +#include void *bt_get(void *ptr) { diff --git a/lib/values.c b/lib/values.c index abe36fd2..7497aea8 100644 --- a/lib/values.c +++ b/lib/values.c @@ -25,20 +25,21 @@ * SOFTWARE. */ +#define BT_LOG_TAG "VALUES" + #include #include #include #include #include #include -#include #include #include #include #include -#define BT_LOG_TAG "VALUES" #include +#include #define BT_VALUE_FROM_CONCRETE(_concrete) ((struct bt_value *) (_concrete)) #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base)) diff --git a/plugins/ctf/lttng-live/lttng-live-internal.h b/plugins/ctf/lttng-live/lttng-live-internal.h index 10ad6607..3d8b5fa7 100644 --- a/plugins/ctf/lttng-live/lttng-live-internal.h +++ b/plugins/ctf/lttng-live/lttng-live-internal.h @@ -28,6 +28,8 @@ * SOFTWARE. */ +extern int bt_lttng_live_log_level; + #include #include @@ -51,8 +53,6 @@ #define U64_STR_MAX_LEN 20 #define STREAM_NAME_MAX_LEN (sizeof(STREAM_NAME_PREFIX) + U64_STR_MAX_LEN) -extern int bt_lttng_live_log_level; - struct lttng_live_component; struct lttng_live_session; diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index 74d1ac37..7c1d22a4 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -49,9 +49,9 @@ #define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE" -#include "lttng-live-internal.h" #include "data-stream.h" #include "metadata.h" +#include "lttng-live-internal.h" #define MAX_QUERY_SIZE (256*1024) diff --git a/plugins/ctf/lttng-live/viewer-connection.h b/plugins/ctf/lttng-live/viewer-connection.h index e6f551f4..da49e349 100644 --- a/plugins/ctf/lttng-live/viewer-connection.h +++ b/plugins/ctf/lttng-live/viewer-connection.h @@ -30,7 +30,7 @@ //TODO: this should not be used by plugins. Should copy code into plugin //instead. -#include "babeltrace/object-internal.h" +#include #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344 -- 2.34.1