X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Ftext%2Fpretty%2Fprint.c;h=cdbbc1b66084804ed5c8411ab56a6e2b8aa5522f;hb=605e1019783967f33d86967e7c98dd52cbd69a4c;hp=a4ace53420145cfe112b253178a32e53e0c7fac5;hpb=44c440bc5fe8219cc17d1b786d91fd83c4c9860a;p=babeltrace.git diff --git a/plugins/text/pretty/print.c b/plugins/text/pretty/print.c index a4ace534..cdbbc1b6 100644 --- a/plugins/text/pretty/print.c +++ b/plugins/text/pretty/print.c @@ -1,8 +1,4 @@ /* - * print.c - * - * Babeltrace CTF Text Output Plugin Event Printing - * * Copyright 2016 Jérémie Galarneau * Copyright 2016 Mathieu Desnoyers * @@ -50,12 +46,12 @@ struct timestamp { int64_t real_timestamp; /* Relative to UNIX epoch. */ - uint64_t clock_value; /* In cycles. */ + uint64_t clock_snapshot; /* In cycles. */ }; static -enum bt_component_status print_field(struct pretty_component *pretty, - struct bt_field *field, bool print_names, +int print_field(struct pretty_component *pretty, + const bt_field *field, bool print_names, GQuark *filters_fields, int filter_array_len); static @@ -82,19 +78,19 @@ void print_field_name_equal(struct pretty_component *pretty, const char *name) static void print_timestamp_cycles(struct pretty_component *pretty, - struct bt_event *event) + const bt_event *event) { - struct bt_clock_value *clock_value; + const bt_clock_snapshot *clock_snapshot; uint64_t cycles; - enum bt_clock_value_status cv_status; + enum bt_clock_snapshot_status cv_status; - cv_status = bt_event_borrow_default_clock_value(event, &clock_value); - if (cv_status != BT_CLOCK_VALUE_STATUS_KNOWN || !clock_value) { + cv_status = bt_event_borrow_default_clock_snapshot_const(event, &clock_snapshot); + if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN || !clock_snapshot) { g_string_append(pretty->string, "????????????????????"); return; } - cycles = bt_clock_value_get_value(clock_value); + cycles = bt_clock_snapshot_get_value(clock_snapshot); g_string_append_printf(pretty->string, "%020" PRIu64, cycles); if (pretty->last_cycles_timestamp != -1ULL) { @@ -105,7 +101,7 @@ void print_timestamp_cycles(struct pretty_component *pretty, static void print_timestamp_wall(struct pretty_component *pretty, - struct bt_clock_value *clock_value) + const bt_clock_snapshot *clock_snapshot) { int ret; int64_t ts_nsec = 0; /* add configurable offset */ @@ -113,12 +109,12 @@ void print_timestamp_wall(struct pretty_component *pretty, uint64_t ts_sec_abs, ts_nsec_abs; bool is_negative; - if (!clock_value) { + if (!clock_snapshot) { g_string_append(pretty->string, "??:??:??.?????????"); return; } - ret = bt_clock_value_get_ns_from_origin(clock_value, &ts_nsec); + ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, &ts_nsec); if (ret) { // TODO: log, this is unexpected g_string_append(pretty->string, "Error"); @@ -219,36 +215,31 @@ end: } static -enum bt_component_status print_event_timestamp(struct pretty_component *pretty, - struct bt_event *event, bool *start_line) +int print_event_timestamp(struct pretty_component *pretty, + const bt_event *event, bool *start_line) { bool print_names = pretty->options.print_header_field_names; - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_stream *stream = NULL; - struct bt_stream_class *stream_class = NULL; - struct bt_trace *trace = NULL; - struct bt_clock_value *clock_value = NULL; - enum bt_clock_value_status cv_status; - - stream = bt_event_borrow_stream(event); + int ret = 0; + const bt_stream *stream = NULL; + const bt_stream_class *stream_class = NULL; + const bt_clock_snapshot *clock_snapshot = NULL; + enum bt_clock_snapshot_status cv_status; + + stream = bt_event_borrow_stream_const(event); if (!stream) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } - stream_class = bt_stream_borrow_class(stream); + stream_class = bt_stream_borrow_class_const(stream); if (!stream_class) { - ret = BT_COMPONENT_STATUS_ERROR; - goto end; - } - trace = bt_stream_class_borrow_trace(stream_class); - if (!trace) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } - cv_status = bt_event_borrow_default_clock_value(event, &clock_value); - if (cv_status != BT_CLOCK_VALUE_STATUS_KNOWN || !clock_value) { + cv_status = bt_event_borrow_default_clock_snapshot_const(event, + &clock_snapshot); + if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN || !clock_snapshot) { /* No default clock value: skip the timestamp without an error */ goto end; } @@ -264,10 +255,10 @@ enum bt_component_status print_event_timestamp(struct pretty_component *pretty, if (pretty->options.print_timestamp_cycles) { print_timestamp_cycles(pretty, event); } else { - clock_value = NULL; - cv_status = bt_event_borrow_default_clock_value(event, - &clock_value); - print_timestamp_wall(pretty, clock_value); + clock_snapshot = NULL; + cv_status = bt_event_borrow_default_clock_snapshot_const(event, + &clock_snapshot); + print_timestamp_wall(pretty, clock_snapshot); } if (pretty->use_colors) { g_string_append(pretty->string, COLOR_RST); @@ -316,40 +307,34 @@ end: } static -enum bt_component_status print_event_header(struct pretty_component *pretty, - struct bt_event *event) +int print_event_header(struct pretty_component *pretty, + const bt_event *event) { bool print_names = pretty->options.print_header_field_names; - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_event_class *event_class = NULL; - struct bt_stream_class *stream_class = NULL; - struct bt_trace *trace_class = NULL; + int ret = 0; + const bt_event_class *event_class = NULL; + const bt_stream_class *stream_class = NULL; + const bt_trace_class *trace_class = NULL; + const bt_packet *packet = NULL; + const bt_stream *stream = NULL; + const bt_trace *trace = NULL; int dom_print = 0; enum bt_property_availability prop_avail; - event_class = bt_event_borrow_class(event); - if (!event_class) { - ret = BT_COMPONENT_STATUS_ERROR; - goto end; - } - stream_class = bt_event_class_borrow_stream_class(event_class); - if (!stream_class) { - ret = BT_COMPONENT_STATUS_ERROR; - goto end; - } - trace_class = bt_stream_class_borrow_trace(stream_class); - if (!trace_class) { - ret = BT_COMPONENT_STATUS_ERROR; - goto end; - } + event_class = bt_event_borrow_class_const(event); + stream_class = bt_event_class_borrow_stream_class_const(event_class); + trace_class = bt_stream_class_borrow_trace_class_const(stream_class); + packet = bt_event_borrow_packet_const(event); + stream = bt_packet_borrow_stream_const(packet); + trace = bt_stream_borrow_trace_const(stream); ret = print_event_timestamp(pretty, event, &pretty->start_line); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret) { goto end; } if (pretty->options.print_trace_field) { const char *name; - name = bt_trace_get_name(trace_class); + name = bt_trace_get_name(trace); if (name) { if (!pretty->start_line) { g_string_append(pretty->string, ", "); @@ -366,9 +351,9 @@ enum bt_component_status print_event_header(struct pretty_component *pretty, } } if (pretty->options.print_trace_hostname_field) { - struct bt_value *hostname_str; + const bt_value *hostname_str; - hostname_str = bt_trace_borrow_environment_entry_value_by_name( + hostname_str = bt_trace_class_borrow_environment_entry_value_by_name_const( trace_class, "hostname"); if (hostname_str) { const char *str; @@ -379,17 +364,15 @@ enum bt_component_status print_event_header(struct pretty_component *pretty, if (print_names) { print_name_equal(pretty, "trace:hostname"); } - if (bt_value_string_get(hostname_str, &str) - == BT_VALUE_STATUS_OK) { - g_string_append(pretty->string, str); - } + str = bt_value_string_get(hostname_str); + g_string_append(pretty->string, str); dom_print = 1; } } if (pretty->options.print_trace_domain_field) { - struct bt_value *domain_str; + const bt_value *domain_str; - domain_str = bt_trace_borrow_environment_entry_value_by_name( + domain_str = bt_trace_class_borrow_environment_entry_value_by_name_const( trace_class, "domain"); if (domain_str) { const char *str; @@ -402,17 +385,15 @@ enum bt_component_status print_event_header(struct pretty_component *pretty, } else if (dom_print) { g_string_append(pretty->string, ":"); } - if (bt_value_string_get(domain_str, &str) - == BT_VALUE_STATUS_OK) { - g_string_append(pretty->string, str); - } + str = bt_value_string_get(domain_str); + g_string_append(pretty->string, str); dom_print = 1; } } if (pretty->options.print_trace_procname_field) { - struct bt_value *procname_str; + const bt_value *procname_str; - procname_str = bt_trace_borrow_environment_entry_value_by_name( + procname_str = bt_trace_class_borrow_environment_entry_value_by_name_const( trace_class, "procname"); if (procname_str) { const char *str; @@ -425,18 +406,15 @@ enum bt_component_status print_event_header(struct pretty_component *pretty, } else if (dom_print) { g_string_append(pretty->string, ":"); } - if (bt_value_string_get(procname_str, &str) - == BT_VALUE_STATUS_OK) { - g_string_append(pretty->string, str); - } - + str = bt_value_string_get(procname_str); + g_string_append(pretty->string, str); dom_print = 1; } } if (pretty->options.print_trace_vpid_field) { - struct bt_value *vpid_value; + const bt_value *vpid_value; - vpid_value = bt_trace_borrow_environment_entry_value_by_name( + vpid_value = bt_trace_class_borrow_environment_entry_value_by_name_const( trace_class, "vpid"); if (vpid_value) { int64_t value; @@ -449,11 +427,9 @@ enum bt_component_status print_event_header(struct pretty_component *pretty, } else if (dom_print) { g_string_append(pretty->string, ":"); } - if (bt_value_integer_get(vpid_value, &value) - == BT_VALUE_STATUS_OK) { - g_string_append_printf(pretty->string, "(%" PRId64 ")", value); - } - + value = bt_value_integer_get(vpid_value); + g_string_append_printf(pretty->string, + "(%" PRId64 ")", value); dom_print = 1; } } @@ -545,24 +521,24 @@ end: } static -enum bt_component_status print_integer(struct pretty_component *pretty, - struct bt_field *field) +int print_integer(struct pretty_component *pretty, + const bt_field *field) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - enum bt_field_type_integer_preferred_display_base base; - struct bt_field_type *int_ft; + int ret = 0; + enum bt_field_class_integer_preferred_display_base base; + const bt_field_class *int_fc; union { uint64_t u; int64_t s; } v; bool rst_color = false; - enum bt_field_type_id ft_id; + enum bt_field_class_type ft_type; - int_ft = bt_field_borrow_type(field); - BT_ASSERT(int_ft); - ft_id = bt_field_get_type_id(field); - if (ft_id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER || - ft_id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION) { + int_fc = bt_field_borrow_class_const(field); + BT_ASSERT(int_fc); + ft_type = bt_field_get_class_type(field); + if (ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || + ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) { v.u = bt_field_unsigned_integer_get_value(field); } else { v.s = bt_field_signed_integer_get_value(field); @@ -573,13 +549,13 @@ enum bt_component_status print_integer(struct pretty_component *pretty, rst_color = true; } - base = bt_field_type_integer_get_preferred_display_base(int_ft); + base = bt_field_class_integer_get_preferred_display_base(int_fc); switch (base) { - case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY: + case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY: { int bitnr, len; - len = bt_field_type_integer_get_field_value_range(int_ft); + len = bt_field_class_integer_get_field_value_range(int_fc); g_string_append(pretty->string, "0b"); v.u = _bt_piecewise_lshift(v.u, 64 - len); for (bitnr = 0; bitnr < len; bitnr++) { @@ -588,14 +564,14 @@ enum bt_component_status print_integer(struct pretty_component *pretty, } break; } - case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL: + case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL: { - if (ft_id == BT_FIELD_TYPE_ID_SIGNED_INTEGER || - ft_id == BT_FIELD_TYPE_ID_SIGNED_ENUMERATION) { + if (ft_type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || + ft_type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { int len; - len = bt_field_type_integer_get_field_value_range( - int_ft); + len = bt_field_class_integer_get_field_value_range( + int_fc); if (len < 64) { size_t rounded_len; @@ -609,19 +585,19 @@ enum bt_component_status print_integer(struct pretty_component *pretty, g_string_append_printf(pretty->string, "0%" PRIo64, v.u); break; } - case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL: - if (ft_id == BT_FIELD_TYPE_ID_UNSIGNED_INTEGER || - ft_id == BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION) { + case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL: + if (ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || + ft_type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) { g_string_append_printf(pretty->string, "%" PRIu64, v.u); } else { g_string_append_printf(pretty->string, "%" PRId64, v.s); } break; - case BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL: + case BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL: { int len; - len = bt_field_type_integer_get_field_value_range(int_ft); + len = bt_field_class_integer_get_field_value_range(int_fc); if (len < 64) { /* Round length to the nearest nibble */ uint8_t rounded_len = ((len + 3) & ~0x3); @@ -633,7 +609,7 @@ enum bt_component_status print_integer(struct pretty_component *pretty, break; } default: - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } end: @@ -712,27 +688,27 @@ void print_escape_string(struct pretty_component *pretty, const char *str) } static -enum bt_component_status print_enum(struct pretty_component *pretty, - struct bt_field *field) +int print_enum(struct pretty_component *pretty, + const bt_field *field) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field_type *enumeration_field_type = NULL; - bt_field_type_enumeration_mapping_label_array label_array; + int ret = 0; + const bt_field_class *enumeration_field_class = NULL; + bt_field_class_enumeration_mapping_label_array label_array; uint64_t label_count; uint64_t i; - enumeration_field_type = bt_field_borrow_type(field); - if (!enumeration_field_type) { - ret = BT_COMPONENT_STATUS_ERROR; + enumeration_field_class = bt_field_borrow_class_const(field); + if (!enumeration_field_class) { + ret = -1; goto end; } - switch (bt_field_get_type_id(field)) { - case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION: + switch (bt_field_get_class_type(field)) { + case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: ret = bt_field_unsigned_enumeration_get_mapping_labels(field, &label_array, &label_count); break; - case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION: + case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: ret = bt_field_signed_enumeration_get_mapping_labels(field, &label_array, &label_count); break; @@ -741,7 +717,7 @@ enum bt_component_status print_enum(struct pretty_component *pretty, } if (ret) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } @@ -773,7 +749,7 @@ enum bt_component_status print_enum(struct pretty_component *pretty, skip_loop: g_string_append(pretty->string, " : container = "); ret = print_integer(pretty, field); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } g_string_append(pretty->string, " )"); @@ -801,29 +777,29 @@ int filter_field_name(struct pretty_component *pretty, const char *field_name, } static -enum bt_component_status print_struct_field(struct pretty_component *pretty, - struct bt_field *_struct, - struct bt_field_type *struct_type, +int print_struct_field(struct pretty_component *pretty, + const bt_field *_struct, + const bt_field_class *struct_class, uint64_t i, bool print_names, uint64_t *nr_printed_fields, GQuark *filter_fields, int filter_array_len) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + int ret = 0; const char *field_name; - struct bt_field *field = NULL; - struct bt_field_type *field_type = NULL;; + const bt_field *field = NULL; + const bt_field_class *field_class = NULL;; - field = bt_field_structure_borrow_member_field_by_index(_struct, i); + field = bt_field_structure_borrow_member_field_by_index_const(_struct, i); if (!field) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } - bt_field_type_structure_borrow_member_by_index(struct_type, i, - &field_name, &field_type); + bt_field_class_structure_borrow_member_by_index_const(struct_class, i, + &field_name, &field_class); if (filter_fields && !filter_field_name(pretty, field_name, filter_fields, filter_array_len)) { - ret = BT_COMPONENT_STATUS_OK; + ret = 0; goto end; } @@ -843,32 +819,32 @@ end: } static -enum bt_component_status print_struct(struct pretty_component *pretty, - struct bt_field *_struct, bool print_names, +int print_struct(struct pretty_component *pretty, + const bt_field *_struct, bool print_names, GQuark *filter_fields, int filter_array_len) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field_type *struct_type = NULL; + int ret = 0; + const bt_field_class *struct_class = NULL; uint64_t nr_fields, i, nr_printed_fields; - struct_type = bt_field_borrow_type(_struct); - if (!struct_type) { - ret = BT_COMPONENT_STATUS_ERROR; + struct_class = bt_field_borrow_class_const(_struct); + if (!struct_class) { + ret = -1; goto end; } - nr_fields = bt_field_type_structure_get_member_count(struct_type); + nr_fields = bt_field_class_structure_get_member_count(struct_class); if (nr_fields < 0) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } g_string_append(pretty->string, "{"); pretty->depth++; nr_printed_fields = 0; for (i = 0; i < nr_fields; i++) { - ret = print_struct_field(pretty, _struct, struct_type, i, + ret = print_struct_field(pretty, _struct, struct_class, i, print_names, &nr_printed_fields, filter_fields, filter_array_len); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } } @@ -880,10 +856,10 @@ end: } static -enum bt_component_status print_array_field(struct pretty_component *pretty, - struct bt_field *array, uint64_t i, bool print_names) +int print_array_field(struct pretty_component *pretty, + const bt_field *array, uint64_t i, bool print_names) { - struct bt_field *field = NULL; + const bt_field *field = NULL; if (i != 0) { g_string_append(pretty->string, ", "); @@ -894,23 +870,23 @@ enum bt_component_status print_array_field(struct pretty_component *pretty, g_string_append_printf(pretty->string, "[%" PRIu64 "] = ", i); } - field = bt_field_array_borrow_element_field_by_index(array, i); + field = bt_field_array_borrow_element_field_by_index_const(array, i); BT_ASSERT(field); return print_field(pretty, field, print_names, NULL, 0); } static -enum bt_component_status print_array(struct pretty_component *pretty, - struct bt_field *array, bool print_names) +int print_array(struct pretty_component *pretty, + const bt_field *array, bool print_names) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field_type *array_type = NULL; + int ret = 0; + const bt_field_class *array_class = NULL; uint64_t len; uint64_t i; - array_type = bt_field_borrow_type(array); - if (!array_type) { - ret = BT_COMPONENT_STATUS_ERROR; + array_class = bt_field_borrow_class_const(array); + if (!array_class) { + ret = -1; goto end; } len = bt_field_array_get_length(array); @@ -918,7 +894,7 @@ enum bt_component_status print_array(struct pretty_component *pretty, pretty->depth++; for (i = 0; i < len; i++) { ret = print_array_field(pretty, array, i, print_names); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } } @@ -930,10 +906,10 @@ end: } static -enum bt_component_status print_sequence_field(struct pretty_component *pretty, - struct bt_field *seq, uint64_t i, bool print_names) +int print_sequence_field(struct pretty_component *pretty, + const bt_field *seq, uint64_t i, bool print_names) { - struct bt_field *field = NULL; + const bt_field *field = NULL; if (i != 0) { g_string_append(pretty->string, ", "); @@ -944,22 +920,22 @@ enum bt_component_status print_sequence_field(struct pretty_component *pretty, g_string_append_printf(pretty->string, "[%" PRIu64 "] = ", i); } - field = bt_field_array_borrow_element_field_by_index(seq, i); + field = bt_field_array_borrow_element_field_by_index_const(seq, i); BT_ASSERT(field); return print_field(pretty, field, print_names, NULL, 0); } static -enum bt_component_status print_sequence(struct pretty_component *pretty, - struct bt_field *seq, bool print_names) +int print_sequence(struct pretty_component *pretty, + const bt_field *seq, bool print_names) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + int ret = 0; uint64_t len; uint64_t i; len = bt_field_array_get_length(seq); if (len < 0) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } @@ -968,7 +944,7 @@ enum bt_component_status print_sequence(struct pretty_component *pretty, pretty->depth++; for (i = 0; i < len; i++) { ret = print_sequence_field(pretty, seq, i, print_names); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } } @@ -980,13 +956,13 @@ end: } static -enum bt_component_status print_variant(struct pretty_component *pretty, - struct bt_field *variant, bool print_names) +int print_variant(struct pretty_component *pretty, + const bt_field *variant, bool print_names) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field *field = NULL; + int ret = 0; + const bt_field *field = NULL; - field = bt_field_variant_borrow_selected_option_field(variant); + field = bt_field_variant_borrow_selected_option_field_const(variant); BT_ASSERT(field); g_string_append(pretty->string, "{ "); pretty->depth++; @@ -995,7 +971,7 @@ enum bt_component_status print_variant(struct pretty_component *pretty, // print_field_name_equal(pretty, tag_choice); } ret = print_field(pretty, field, print_names, NULL, 0); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } pretty->depth--; @@ -1006,18 +982,18 @@ end: } static -enum bt_component_status print_field(struct pretty_component *pretty, - struct bt_field *field, bool print_names, +int print_field(struct pretty_component *pretty, + const bt_field *field, bool print_names, GQuark *filter_fields, int filter_array_len) { - enum bt_field_type_id type_id; + enum bt_field_class_type class_id; - type_id = bt_field_get_type_id(field); - switch (type_id) { - case BT_FIELD_TYPE_ID_UNSIGNED_INTEGER: - case BT_FIELD_TYPE_ID_SIGNED_INTEGER: + class_id = bt_field_get_class_type(field); + switch (class_id) { + case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: + case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: return print_integer(pretty, field); - case BT_FIELD_TYPE_ID_REAL: + case BT_FIELD_CLASS_TYPE_REAL: { double v; @@ -1029,18 +1005,18 @@ enum bt_component_status print_field(struct pretty_component *pretty, if (pretty->use_colors) { g_string_append(pretty->string, COLOR_RST); } - return BT_COMPONENT_STATUS_OK; + return 0; } - case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION: - case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION: + case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: + case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: return print_enum(pretty, field); - case BT_FIELD_TYPE_ID_STRING: + case BT_FIELD_CLASS_TYPE_STRING: { const char *str; str = bt_field_string_get_value(field); if (!str) { - return BT_COMPONENT_STATUS_ERROR; + return -1; } if (pretty->use_colors) { @@ -1050,38 +1026,38 @@ enum bt_component_status print_field(struct pretty_component *pretty, if (pretty->use_colors) { g_string_append(pretty->string, COLOR_RST); } - return BT_COMPONENT_STATUS_OK; + return 0; } - case BT_FIELD_TYPE_ID_STRUCTURE: + case BT_FIELD_CLASS_TYPE_STRUCTURE: return print_struct(pretty, field, print_names, filter_fields, filter_array_len); - case BT_FIELD_TYPE_ID_VARIANT: + case BT_FIELD_CLASS_TYPE_VARIANT: return print_variant(pretty, field, print_names); - case BT_FIELD_TYPE_ID_STATIC_ARRAY: + case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: return print_array(pretty, field, print_names); - case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY: + case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: return print_sequence(pretty, field, print_names); default: // TODO: log instead - fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) type_id); - return BT_COMPONENT_STATUS_ERROR; + fprintf(pretty->err, "[error] Unknown type id: %d\n", (int) class_id); + return -1; } } static -enum bt_component_status print_stream_packet_context(struct pretty_component *pretty, - struct bt_event *event) +int print_stream_packet_context(struct pretty_component *pretty, + const bt_event *event) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_packet *packet = NULL; - struct bt_field *main_field = NULL; + int ret = 0; + const bt_packet *packet = NULL; + const bt_field *main_field = NULL; - packet = bt_event_borrow_packet(event); + packet = bt_event_borrow_packet_const(event); if (!packet) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } - main_field = bt_packet_borrow_context_field(packet); + main_field = bt_packet_borrow_context_field_const(packet); if (!main_field) { goto end; } @@ -1102,13 +1078,13 @@ end: } static -enum bt_component_status print_event_header_raw(struct pretty_component *pretty, - struct bt_event *event) +int print_event_header_raw(struct pretty_component *pretty, + const bt_event *event) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field *main_field = NULL; + int ret = 0; + const bt_field *main_field = NULL; - main_field = bt_event_borrow_header_field(event); + main_field = bt_event_borrow_header_field_const(event); if (!main_field) { goto end; } @@ -1127,13 +1103,13 @@ end: } static -enum bt_component_status print_stream_event_context(struct pretty_component *pretty, - struct bt_event *event) +int print_stream_event_context(struct pretty_component *pretty, + const bt_event *event) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field *main_field = NULL; + int ret = 0; + const bt_field *main_field = NULL; - main_field = bt_event_borrow_common_context_field(event); + main_field = bt_event_borrow_common_context_field_const(event); if (!main_field) { goto end; } @@ -1152,13 +1128,13 @@ end: } static -enum bt_component_status print_event_context(struct pretty_component *pretty, - struct bt_event *event) +int print_event_context(struct pretty_component *pretty, + const bt_event *event) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field *main_field = NULL; + int ret = 0; + const bt_field *main_field = NULL; - main_field = bt_event_borrow_specific_context_field(event); + main_field = bt_event_borrow_specific_context_field_const(event); if (!main_field) { goto end; } @@ -1177,13 +1153,13 @@ end: } static -enum bt_component_status print_event_payload(struct pretty_component *pretty, - struct bt_event *event) +int print_event_payload(struct pretty_component *pretty, + const bt_event *event) { - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_field *main_field = NULL; + int ret = 0; + const bt_field *main_field = NULL; - main_field = bt_event_borrow_payload_field(event); + main_field = bt_event_borrow_payload_field_const(event); if (!main_field) { goto end; } @@ -1219,51 +1195,51 @@ end: } BT_HIDDEN -enum bt_component_status pretty_print_event(struct pretty_component *pretty, - struct bt_notification *event_notif) +int pretty_print_event(struct pretty_component *pretty, + const bt_message *event_msg) { - enum bt_component_status ret; - struct bt_event *event = - bt_notification_event_borrow_event(event_notif); + int ret; + const bt_event *event = + bt_message_event_borrow_event_const(event_msg); BT_ASSERT(event); pretty->start_line = true; g_string_assign(pretty->string, ""); ret = print_event_header(pretty, event); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } ret = print_stream_packet_context(pretty, event); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } if (pretty->options.verbose) { ret = print_event_header_raw(pretty, event); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } } ret = print_stream_event_context(pretty, event); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } ret = print_event_context(pretty, event); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } ret = print_event_payload(pretty, event); - if (ret != BT_COMPONENT_STATUS_OK) { + if (ret != 0) { goto end; } g_string_append_c(pretty->string, '\n'); if (flush_buf(pretty->out, pretty)) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; goto end; } @@ -1272,31 +1248,31 @@ end: } static -enum bt_component_status print_discarded_elements_msg( - struct pretty_component *pretty, struct bt_packet *packet, +int print_discarded_elements_msg( + struct pretty_component *pretty, const bt_packet *packet, uint64_t count, const char *elem_type) { #if 0 - enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - struct bt_stream *stream = NULL; - struct bt_stream_class *stream_class = NULL; - struct bt_trace *trace = NULL; + int ret = 0; + const bt_stream *stream = NULL; + const bt_stream_class *stream_class = NULL; + const bt_trace *trace = NULL; const char *stream_name; const char *trace_name; const unsigned char *trace_uuid; int64_t stream_class_id; int64_t stream_id; - struct bt_clock_value *begin_clock_value = NULL; - struct bt_clock_value *end_clock_value = NULL; + bt_clock_snapshot *begin_clock_snapshot = NULL; + bt_clock_snapshot *end_clock_snapshot = NULL; /* Stream name */ BT_ASSERT(packet); - stream = bt_packet_borrow_stream(packet); + stream = bt_packet_borrow_stream_const(packet); BT_ASSERT(stream); stream_name = bt_stream_get_name(stream); /* Stream class ID */ - stream_class = bt_stream_borrow_class(stream); + stream_class = bt_stream_borrow_class_const(stream); BT_ASSERT(stream_class); stream_class_id = bt_stream_class_get_id(stream_class); @@ -1304,7 +1280,7 @@ enum bt_component_status print_discarded_elements_msg( stream_id = bt_stream_get_id(stream); /* Trace name */ - trace = bt_stream_class_borrow_trace(stream_class); + trace = bt_stream_class_borrow_trace_const(stream_class); BT_ASSERT(trace); trace_name = bt_trace_get_name(trace); if (!trace_name) { @@ -1315,10 +1291,10 @@ enum bt_component_status print_discarded_elements_msg( trace_uuid = bt_trace_get_uuid(trace); /* Beginning and end times */ - (void) bt_packet_borrow_previous_packet_default_end_clock_value( - packet, &begin_clock_value); - (void) bt_packet_borrow_default_end_clock_value(packet, - &end_clock_value); + (void) bt_packet_borrow_previous_packet_default_end_clock_snapshot_const( + packet, &begin_clock_snapshot); + (void) bt_packet_borrow_default_end_clock_snapshot_const(packet, + &end_clock_snapshot); /* Format message */ g_string_assign(pretty->string, ""); @@ -1330,11 +1306,11 @@ enum bt_component_status print_discarded_elements_msg( bt_common_color_fg_yellow(), count, elem_type, count == 1 ? "" : "s"); - if (begin_clock_value && end_clock_value) { + if (begin_clock_snapshot && end_clock_snapshot) { g_string_append(pretty->string, "between ["); - print_timestamp_wall(pretty, begin_clock_value); + print_timestamp_wall(pretty, begin_clock_snapshot); g_string_append(pretty->string, "] and ["); - print_timestamp_wall(pretty, end_clock_value); + print_timestamp_wall(pretty, end_clock_snapshot); g_string_append(pretty->string, "]"); } else { g_string_append(pretty->string, "(unknown time range)"); @@ -1384,7 +1360,7 @@ enum bt_component_status print_discarded_elements_msg( * with Babeltrace 1. */ if (flush_buf(stderr, pretty)) { - ret = BT_COMPONENT_STATUS_ERROR; + ret = -1; } return ret; @@ -1393,21 +1369,21 @@ enum bt_component_status print_discarded_elements_msg( } BT_HIDDEN -enum bt_component_status pretty_print_packet(struct pretty_component *pretty, - struct bt_notification *packet_beginning_notif) +int pretty_print_packet(struct pretty_component *pretty, + const bt_message *packet_beginning_msg) { #if 0 - struct bt_packet *packet = bt_notification_packet_begin_borrow_packet( - packet_beginning_notif); + const bt_packet *packet = bt_message_packet_beginning_borrow_packet_const( + packet_beginning_msg); uint64_t count; - enum bt_component_status status = BT_COMPONENT_STATUS_OK; + int status = 0; if (bt_packet_get_discarded_event_count(packet, &count) == BT_PACKET_PROPERTY_AVAILABILITY_AVAILABLE && count > 0) { status = print_discarded_elements_msg(pretty, packet, count, "event"); - if (status != BT_COMPONENT_STATUS_OK) { + if (status != 0) { goto end; } } @@ -1417,7 +1393,7 @@ enum bt_component_status pretty_print_packet(struct pretty_component *pretty, count > 0) { status = print_discarded_elements_msg(pretty, packet, count, "packet"); - if (status != BT_COMPONENT_STATUS_OK) { + if (status != 0) { goto end; } }