lib: add option field classes with integer selectors
[babeltrace.git] / src / lib / lib-logging.c
index fe72253d7f8eaa9edd42165081454e7e4c078327..dc0c97c5dcd573fcb7080122af4f40a4e9456b69 100644 (file)
 #include "assert-pre.h"
 #include "assert-post.h"
 #include "value.h"
+#include "integer-range-set.h"
 #include "object-pool.h"
+#include "graph/interrupter.h"
 #include "graph/component-class.h"
-#include "graph/component-class-sink-colander.h"
 #include "graph/component-filter.h"
 #include "graph/component.h"
 #include "graph/component-sink.h"
@@ -192,18 +193,18 @@ static inline void format_field_class(char **buf_ch, bool extended,
        }
 
        switch (field_class->type) {
-       case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
-       case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
+       case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
        {
-               format_integer_field_class(buf_ch, extended, prefix, field_class);
+               const struct bt_field_class_bit_array *ba_fc =
+                       (const void *) field_class;
+
+               BUF_APPEND(", %slength=%" PRIu64, PRFIELD(ba_fc->length));
                break;
        }
-       case BT_FIELD_CLASS_TYPE_REAL:
+       case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
+       case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
        {
-               const struct bt_field_class_real *real_fc = (void *) field_class;
-
-               BUF_APPEND(", %sis-single-precision=%d",
-                       PRFIELD(real_fc->is_single_precision));
+               format_integer_field_class(buf_ch, extended, prefix, field_class);
                break;
        }
        case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
@@ -231,7 +232,7 @@ static inline void format_field_class(char **buf_ch, bool extended,
        }
        case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
        {
-               const struct bt_field_class_static_array *array_fc =
+               const struct bt_field_class_array_static *array_fc =
                        (const void *) field_class;
 
                format_array_field_class(buf_ch, extended, prefix, field_class);
@@ -240,7 +241,7 @@ static inline void format_field_class(char **buf_ch, bool extended,
        }
        case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
        {
-               const struct bt_field_class_dynamic_array *array_fc =
+               const struct bt_field_class_array_dynamic *array_fc =
                        (const void *) field_class;
 
                format_array_field_class(buf_ch, extended, prefix, field_class);
@@ -259,6 +260,38 @@ static inline void format_field_class(char **buf_ch, bool extended,
 
                break;
        }
+       case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
+       {
+               const struct bt_field_class_option *opt_fc =
+                       (const void *) field_class;
+
+               BUF_APPEND(", %scontent-fc-addr=%p, %scontent-fc-type=%s",
+                       PRFIELD(opt_fc->content_fc),
+                       PRFIELD(bt_common_field_class_type_string(opt_fc->content_fc->type)));
+
+               if (field_class->type !=
+                               BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR) {
+                       const struct bt_field_class_option_with_selector *opt_with_sel_fc =
+                               (const void *) field_class;
+
+                       if (opt_with_sel_fc->selector_fc) {
+                               SET_TMP_PREFIX("selector-fc-");
+                               format_field_class(buf_ch, extended, tmp_prefix,
+                                       opt_with_sel_fc->selector_fc);
+                       }
+
+                       if (opt_with_sel_fc->selector_field_path) {
+                               SET_TMP_PREFIX("selector-field-path-");
+                               format_field_path(buf_ch, extended, tmp_prefix,
+                                       opt_with_sel_fc->selector_field_path);
+                       }
+               }
+
+               break;
+       }
        case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
@@ -351,6 +384,21 @@ static inline void format_field(char **buf_ch, bool extended,
        }
 
        switch (field->class->type) {
+       case BT_FIELD_CLASS_TYPE_BOOL:
+       {
+               const struct bt_field_bool *bool_field = (const void *) field;
+
+               BUF_APPEND(", %svalue=%d", PRFIELD(bool_field->value));
+               break;
+       }
+       case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
+       {
+               const struct bt_field_bit_array *ba_field = (const void *) field;
+
+               BUF_APPEND(", %svalue-as-int=%" PRIx64,
+                       PRFIELD(ba_field->value_as_int));
+               break;
+       }
        case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
        case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
        case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
@@ -359,7 +407,8 @@ static inline void format_field(char **buf_ch, bool extended,
                format_field_integer_extended(buf_ch, prefix, field);
                break;
        }
-       case BT_FIELD_CLASS_TYPE_REAL:
+       case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL:
+       case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL:
        {
                const struct bt_field_real *real_field = (const void *) field;
 
@@ -806,6 +855,12 @@ static inline void format_clock_snapshot(char **buf_ch, bool extended,
        }
 }
 
+static inline void format_interrupter(char **buf_ch, bool extended,
+               const char *prefix, const struct bt_interrupter *intr)
+{
+       BUF_APPEND(", %sis-set=%d", PRFIELD(intr->is_set));
+}
+
 static inline void format_value(char **buf_ch, bool extended,
                const char *prefix, const struct bt_value *value)
 {
@@ -827,13 +882,13 @@ static inline void format_value(char **buf_ch, bool extended,
        case BT_VALUE_TYPE_UNSIGNED_INTEGER:
        {
                BUF_APPEND(", %svalue=%" PRIu64,
-                       PRFIELD(bt_value_unsigned_integer_get(value)));
+                       PRFIELD(bt_value_integer_unsigned_get(value)));
                break;
        }
        case BT_VALUE_TYPE_SIGNED_INTEGER:
        {
                BUF_APPEND(", %svalue=%" PRId64,
-                       PRFIELD(bt_value_signed_integer_get(value)));
+                       PRFIELD(bt_value_integer_signed_get(value)));
                break;
        }
        case BT_VALUE_TYPE_REAL:
@@ -852,7 +907,7 @@ static inline void format_value(char **buf_ch, bool extended,
        }
        case BT_VALUE_TYPE_ARRAY:
        {
-               int64_t count = bt_value_array_get_size(value);
+               int64_t count = bt_value_array_get_length(value);
 
                BT_ASSERT(count >= 0);
                BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count));
@@ -871,6 +926,19 @@ static inline void format_value(char **buf_ch, bool extended,
        }
 }
 
+static inline void format_integer_range_set(char **buf_ch, bool extended,
+               const char *prefix,
+               const struct bt_integer_range_set *range_set)
+{
+       BUF_APPEND(", %srange-count=%u", PRFIELD(range_set->ranges->len));
+
+       if (!extended) {
+               return;
+       }
+
+       BUF_APPEND(", %sis-frozen=%d", PRFIELD(range_set->frozen));
+}
+
 static inline void format_message(char **buf_ch, bool extended,
                const char *prefix, const struct bt_message *msg)
 {
@@ -1099,9 +1167,7 @@ static inline void format_graph(char **buf_ch, bool extended,
 {
        char tmp_prefix[TMP_PREFIX_LEN];
 
-       BUF_APPEND(", %sis-canceled=%d, %scan-consume=%d, "
-               "%sconfig-state=%s",
-               PRFIELD(graph->canceled),
+       BUF_APPEND(", %scan-consume=%d, %sconfig-state=%s",
                PRFIELD(graph->can_consume),
                PRFIELD(bt_graph_configuration_state_string(graph->config_state)));
 
@@ -1134,66 +1200,34 @@ static inline void format_message_iterator(char **buf_ch,
                bool extended, const char *prefix,
                const struct bt_message_iterator *iterator)
 {
-       const char *type;
        char tmp_prefix[TMP_PREFIX_LEN];
+       const struct bt_self_component_port_input_message_iterator *
+               port_in_iter = (const void *) iterator;
 
-       if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT) {
-               type = "BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT";
-       } else if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT) {
-               type = "BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT";
-       } else {
-               type = "(unknown)";
+       if (port_in_iter->upstream_component) {
+               SET_TMP_PREFIX("upstream-comp-");
+               format_component(buf_ch, false, tmp_prefix,
+                       port_in_iter->upstream_component);
        }
 
-       BUF_APPEND(", %stype=%s", PRFIELD(type));
-
-       switch (iterator->type) {
-       case BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT:
-       {
-               const struct bt_self_component_port_input_message_iterator *
-                       port_in_iter = (const void *) iterator;
-
-               if (port_in_iter->upstream_component) {
-                       SET_TMP_PREFIX("upstream-comp-");
-                       format_component(buf_ch, false, tmp_prefix,
-                               port_in_iter->upstream_component);
-               }
-
-               if (port_in_iter->upstream_port) {
-                       SET_TMP_PREFIX("upstream-port-");
-                       format_port(buf_ch, false, tmp_prefix,
-                               port_in_iter->upstream_port);
-               }
-
-               if (port_in_iter->connection) {
-                       SET_TMP_PREFIX("upstream-conn-");
-                       format_connection(buf_ch, false, tmp_prefix,
-                               port_in_iter->connection);
-               }
-               break;
+       if (!extended) {
+               goto end;
        }
-       case BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT:
-       {
-               const struct bt_port_output_message_iterator *port_out_iter =
-                       (const void *) iterator;
 
-               if (port_out_iter->graph) {
-                       SET_TMP_PREFIX("graph-");
-                       format_graph(buf_ch, false, tmp_prefix,
-                               port_out_iter->graph);
-               }
-
-               if (port_out_iter->colander) {
-                       SET_TMP_PREFIX("colander-comp-");
-                       format_component(buf_ch, false, tmp_prefix,
-                               (void *) port_out_iter->colander);
-               }
-
-               break;
+       if (port_in_iter->upstream_port) {
+               SET_TMP_PREFIX("upstream-port-");
+               format_port(buf_ch, false, tmp_prefix,
+                       port_in_iter->upstream_port);
        }
-       default:
-               break;
+
+       if (port_in_iter->connection) {
+               SET_TMP_PREFIX("upstream-conn-");
+               format_connection(buf_ch, false, tmp_prefix,
+                       port_in_iter->connection);
        }
+
+end:
+       return;
 }
 
 static inline void format_plugin(char **buf_ch, bool extended,
@@ -1405,6 +1439,9 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
        case 'v':
                format_value(buf_ch, extended, prefix, obj);
                break;
+       case 'R':
+               format_integer_range_set(buf_ch, extended, prefix, obj);
+               break;
        case 'n':
                format_message(buf_ch, extended, prefix, obj);
                break;
@@ -1429,6 +1466,9 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
        case 'g':
                format_graph(buf_ch, extended, prefix, obj);
                break;
+       case 'z':
+               format_interrupter(buf_ch, extended, prefix, obj);
+               break;
        case 'o':
                format_object_pool(buf_ch, extended, prefix, obj);
                break;
This page took 0.027789 seconds and 4 git commands to generate.