include/babeltrace/object-internal.h: add logging
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 13 May 2017 19:08:24 +0000 (15:08 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:43 +0000 (12:57 -0400)
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 <babeltrace/logging-internal.h>, or anything that
includes this (like <babeltrace/lib-logging-internal.h>).

ctf.lttng-live is modified to respect this, as well as various
instrumented library source files.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/object-internal.h
lib/ctf-ir/attributes.c
lib/ctf-ir/clock-class.c
lib/ref.c
lib/values.c
plugins/ctf/lttng-live/lttng-live-internal.h
plugins/ctf/lttng-live/lttng-live.c
plugins/ctf/lttng-live/viewer-connection.h

index 545a20aadd21a7f9f9bd3b78971f9e64b0c5182b..2b368c5510e46f86ea26758b44e8c939a0346ae6 100644 (file)
@@ -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
index f945799663e75a107b13ff1b853010e5e59c3901..2cd3a4bf63acfc4d8c169795654dbdec4fdcf911 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "ATTRS"
+
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/values.h>
 #include <inttypes.h>
-
-#define BT_LOG_TAG "ATTRS"
 #include <babeltrace/lib-logging-internal.h>
 
 #define BT_CTF_ATTR_NAME_INDEX         0
index e3c711c0d854d0453dd268c3c80594f25fe2cf3f..4335d3b032448759df8eedc5eb75ed882c85d7d6 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "CLOCK-CLASS"
+
 #include <babeltrace/ctf-ir/clock-class-internal.h>
 #include <babeltrace/ctf-ir/utils.h>
 #include <babeltrace/ref.h>
-#include <babeltrace/object-internal.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/types.h>
 #include <inttypes.h>
-
-#define BT_LOG_TAG "CLOCK-CLASS"
 #include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/object-internal.h>
 
 static
 void bt_ctf_clock_class_destroy(struct bt_object *obj);
index d2ec688e7d3d1d3f31ebd4586bb28ffbceefaf73..bcef44f1d315b866ba7998804c8d7d8e12bc5210 100644 (file)
--- a/lib/ref.c
+++ b/lib/ref.c
  * SOFTWARE.
  */
 
-#include <babeltrace/ref-internal.h>
-#include <babeltrace/object-internal.h>
-
 #define BT_LOG_TAG "REF"
+
 #include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/ref-internal.h>
+#include <babeltrace/object-internal.h>
 
 void *bt_get(void *ptr)
 {
index abe36fd23ba477476ea36969ba86d2efc828dfa6..7497aea85b046cb01cbc874c3b3e49125d6c87c0 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "VALUES"
+
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 #include <string.h>
 #include <inttypes.h>
 #include <babeltrace/compiler-internal.h>
-#include <babeltrace/object-internal.h>
 #include <babeltrace/ref.h>
 #include <babeltrace/values.h>
 #include <babeltrace/compat/glib-internal.h>
 #include <babeltrace/types.h>
 
-#define BT_LOG_TAG "VALUES"
 #include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/object-internal.h>
 
 #define BT_VALUE_FROM_CONCRETE(_concrete) ((struct bt_value *) (_concrete))
 #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
index 10ad6607d843d8f341fff57f2bd5877a95eb0804..3d8b5fa71c07f20b503b11bd5540f92c6dd868a3 100644 (file)
@@ -28,6 +28,8 @@
  * SOFTWARE.
  */
 
+extern int bt_lttng_live_log_level;
+
 #include <stdbool.h>
 
 #include <babeltrace/babeltrace-internal.h>
@@ -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;
 
index 74d1ac3762e70477e932f8bdc6db55b7c4004cef..7c1d22a4385e284a64736c65b8d0cfdb280fb665 100644 (file)
@@ -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)
 
index e6f551f4ca12ff3080b33c5c1c1160534a73b1b4..da49e349e6d05885a56fb1588841efda08898989 100644 (file)
@@ -30,7 +30,7 @@
 
 //TODO: this should not be used by plugins. Should copy code into plugin
 //instead.
-#include "babeltrace/object-internal.h"
+#include <babeltrace/object-internal.h>
 
 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT      5344
 
This page took 0.029976 seconds and 4 git commands to generate.