/*
- * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * SPDX-License-Identifier: MIT
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
*/
#include <babeltrace2/babeltrace.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
static inline
void incr_indent_by(struct details_write_ctx *ctx, unsigned int value)
{
- BT_ASSERT(ctx);
+ BT_ASSERT_DBG(ctx);
ctx->indent_level += value;
}
static inline
void decr_indent_by(struct details_write_ctx *ctx, unsigned int value)
{
- BT_ASSERT(ctx);
- BT_ASSERT(ctx->indent_level >= value);
+ BT_ASSERT_DBG(ctx);
+ BT_ASSERT_DBG(ctx->indent_level >= value);
ctx->indent_level -= value;
}
break;
default:
- abort();
+ bt_common_abort();
}
sprintf(buf_start, spec, value);
break;
default:
- abort();
+ bt_common_abort();
}
sprintf(buf_start, spec, abs_value);
static inline
void write_nl(struct details_write_ctx *ctx)
{
- BT_ASSERT(ctx);
+ BT_ASSERT_DBG(ctx);
g_string_append_c(ctx->str, '\n');
}
static inline
void write_sp(struct details_write_ctx *ctx)
{
- BT_ASSERT(ctx);
+ BT_ASSERT_DBG(ctx);
g_string_append_c(ctx->str, ' ');
}
{
uint64_t i;
- BT_ASSERT(ctx);
+ BT_ASSERT_DBG(ctx);
for (i = 0; i < ctx->indent_level; i++) {
write_sp(ctx);
void write_obj_type_name(struct details_write_ctx *ctx, const char *name)
{
g_string_append_printf(ctx->str, "%s%s%s%s",
- color_fg_yellow(ctx), color_bold(ctx), name, color_reset(ctx));
+ color_bold(ctx), color_fg_bright_yellow(ctx), name,
+ color_reset(ctx));
}
static inline
void write_none_prop_value(struct details_write_ctx *ctx, const char *value)
{
g_string_append_printf(ctx->str, "%s%s%s%s",
- color_bold(ctx), color_fg_magenta(ctx),
+ color_bold(ctx), color_fg_bright_magenta(ctx),
value, color_reset(ctx));
}
void write_str_prop_line(struct details_write_ctx *ctx, const char *prop_name,
const char *prop_value)
{
- BT_ASSERT(prop_value);
+ BT_ASSERT_DBG(prop_value);
write_indent(ctx);
write_prop_name(ctx, prop_name);
g_string_append(ctx->str, ": ");
g_string_append(ctx->str, color_bold(ctx));
if (prop_value) {
- g_string_append(ctx->str, color_fg_green(ctx));
+ g_string_append(ctx->str, color_fg_bright_green(ctx));
str = "Yes";
} else {
- g_string_append(ctx->str, color_fg_red(ctx));
+ g_string_append(ctx->str, color_fg_bright_red(ctx));
str = "No";
}
void write_uuid_prop_line(struct details_write_ctx *ctx, const char *prop_name,
bt_uuid uuid)
{
- BT_ASSERT(uuid);
+ BT_ASSERT_DBG(uuid);
write_indent(ctx);
write_prop_name(ctx, prop_name);
g_string_append_printf(ctx->str,
}
static
-bt_bool map_value_foreach_add_key_to_array(const char *key,
- const bt_value *object, void *data)
+bt_value_map_foreach_entry_const_func_status map_value_foreach_add_key_to_array(
+ const char *key, const bt_value *object, void *data)
{
GPtrArray *keys = data;
- BT_ASSERT(keys);
+ BT_ASSERT_DBG(keys);
g_ptr_array_add(keys, (void *) key);
- return BT_TRUE;
+ return BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_OK;
}
static
GPtrArray *keys = g_ptr_array_new();
char buf[64];
- BT_ASSERT(keys);
+ BT_ASSERT_DBG(keys);
/* Write field's name */
if (name) {
bt_value_map_foreach_entry_const(value,
map_value_foreach_add_key_to_array, keys);
- BT_ASSERT(foreach_status ==
+ BT_ASSERT_DBG(foreach_status ==
BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_OK);
g_ptr_array_sort(keys, (GCompareFunc) compare_strings);
break;
}
default:
- abort();
+ bt_common_abort();
}
g_ptr_array_free(keys, TRUE);
void write_user_attributes(struct details_write_ctx *ctx,
const bt_value *user_attrs, bool write_newline, bool *written)
{
- BT_ASSERT(user_attrs);
+ BT_ASSERT_DBG(user_attrs);
if (!bt_value_map_is_empty(user_attrs)) {
write_value(ctx, user_attrs, "User attributes");
write_uint_prop_value(ctx, 16);
break;
default:
- abort();
+ bt_common_abort();
}
if (close) {
mappings = g_ptr_array_new_with_free_func(
(GDestroyNotify) destroy_enum_field_class_mapping);
- BT_ASSERT(mappings);
+ BT_ASSERT_DBG(mappings);
/*
* Copy field class's mappings to our own arrays and structures
struct enum_field_class_mapping *mapping = g_new0(
struct enum_field_class_mapping, 1);
- BT_ASSERT(mapping);
+ BT_ASSERT_DBG(mapping);
if (is_signed) {
fc_mapping = bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
fc_mapping));
mapping->ranges = range_set_to_int_ranges(fc_range_set,
is_signed);
- BT_ASSERT(mapping->ranges);
+ BT_ASSERT_DBG(mapping->ranges);
g_ptr_array_add(mappings, mapping);
}
write_str_prop_value(ctx, "Event payload");
break;
default:
- abort();
+ bt_common_abort();
}
g_string_append(ctx->str, ": ");
write_str_prop_value(ctx, "<current>");
break;
default:
- abort();
+ bt_common_abort();
}
}
uint64_t i;
int_ranges = range_set_to_int_ranges(orig_ranges, is_signed);
- BT_ASSERT(int_ranges);
+ BT_ASSERT_DBG(int_ranges);
for (i = 0; i < int_ranges->len; i++) {
struct int_range *range = int_range_at(int_ranges, i);
type = "Variant (signed integer selector)";
break;
default:
- abort();
+ bt_common_abort();
}
g_string_append_printf(ctx->str, "%s%s%s",
sel_field_path =
bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
fc);
- BT_ASSERT(sel_field_path);
+ BT_ASSERT_DBG(sel_field_path);
}
g_string_append(ctx->str, " (");
const bt_field_class_structure_member *member =
bt_field_class_structure_borrow_member_by_index_const(
fc, i);
- const bt_value *user_attrs;
+ const bt_value *member_user_attrs;
const bt_field_class *member_fc =
bt_field_class_structure_member_borrow_field_class_const(member);
write_nl(ctx);
write_compound_member_name(ctx,
bt_field_class_structure_member_get_name(member));
- user_attrs = bt_field_class_structure_member_borrow_user_attributes_const(
+ member_user_attrs = bt_field_class_structure_member_borrow_user_attributes_const(
member);
- if (bt_value_map_is_empty(user_attrs)) {
+ if (bt_value_map_is_empty(member_user_attrs)) {
write_sp(ctx);
write_field_class(ctx, member_fc);
} else {
write_nl(ctx);
/* User attributes */
- write_user_attributes(ctx, user_attrs,
+ write_user_attributes(ctx, member_user_attrs,
false, NULL);
decr_indent(ctx);
if (ranges) {
GArray *sorted_ranges = range_set_to_int_ranges(
ranges, selector_is_signed);
- uint64_t i;
- BT_ASSERT(sorted_ranges);
- BT_ASSERT(sorted_ranges->len > 0);
+ BT_ASSERT_DBG(sorted_ranges);
+ BT_ASSERT_DBG(sorted_ranges->len > 0);
write_prop_name_line(ctx, "Selector ranges");
for (i = 0; i < sorted_ranges->len; i++) {
void write_root_field_class(struct details_write_ctx *ctx, const char *name,
const bt_field_class *fc)
{
- BT_ASSERT(name);
- BT_ASSERT(fc);
+ BT_ASSERT_DBG(name);
+ BT_ASSERT_DBG(fc);
write_indent(ctx);
write_prop_name(ctx, name);
g_string_append(ctx->str, ": ");
ll_str = "Debug";
break;
default:
- abort();
+ bt_common_abort();
}
write_str_prop_line(ctx, "Log level", ll_str);
{
int ret = 0;
- BT_ASSERT(tc);
+ BT_ASSERT_DBG(tc);
if (details_need_to_write_trace_class(ctx, tc)) {
uint64_t sc_i;
if (sc && details_need_to_write_meta_object(ctx, tc, sc)) {
uint64_t ec_i;
- BT_ASSERT(tc);
+ BT_ASSERT_DBG(tc);
if (ctx->details_comp->cfg.compact &&
ctx->details_comp->printed_something) {
}
if (ec && details_need_to_write_meta_object(ctx, tc, ec)) {
- BT_ASSERT(sc);
+ BT_ASSERT_DBG(sc);
if (ctx->details_comp->cfg.compact &&
ctx->details_comp->printed_something) {
}
g_string_append_printf(ctx->str, "[%s%s%s%s]",
- color_bold(ctx), color_fg_blue(ctx), str, color_reset(ctx));
+ color_bold(ctx), color_fg_bright_blue(ctx), str,
+ color_reset(ctx));
if (ctx->details_comp->cfg.compact) {
write_sp(ctx);
format_uint(buf, bt_clock_snapshot_get_value(cs), 10);
g_string_append_printf(ctx->str, "[%s%s%s%s%s",
- color_bold(ctx), color_fg_blue(ctx), buf,
+ color_bold(ctx), color_fg_bright_blue(ctx), buf,
color_reset(ctx),
ctx->details_comp->cfg.compact ? "" : " cycles");
cs_status = bt_clock_snapshot_get_ns_from_origin(cs, &ns_from_origin);
format_int(buf, ns_from_origin, 10);
g_string_append_printf(ctx->str, "%s %s%s%s%s%s",
ctx->details_comp->cfg.compact ? "" : ",",
- color_bold(ctx), color_fg_blue(ctx), buf,
+ color_bold(ctx), color_fg_bright_blue(ctx), buf,
color_reset(ctx),
ctx->details_comp->cfg.compact ? "" : " ns from origin");
}
if (ctx->details_comp->cfg.compact) {
g_string_append_printf(ctx->str,
- "%s{%s%" PRIu64 " %" PRIu64 " %" PRIu64 "%s%s}%s ",
+ "%s{%s%s%" PRIu64 " %" PRIu64 " %" PRIu64 "%s%s}%s ",
color_fg_cyan(ctx), color_bold(ctx),
+ color_fg_bright_cyan(ctx),
unique_trace_id, bt_stream_class_get_id(sc),
bt_stream_get_id(stream),
color_reset(ctx), color_fg_cyan(ctx), color_reset(ctx));
} else {
g_string_append_printf(ctx->str,
- "%s{Trace %s%" PRIu64 "%s%s, Stream class ID %s%" PRIu64 "%s%s, Stream ID %s%" PRIu64 "%s%s}%s\n",
+ "%s{Trace %s%s%" PRIu64 "%s%s, Stream class ID %s%s%" PRIu64 "%s%s, Stream ID %s%s%" PRIu64 "%s%s}%s\n",
+ color_fg_cyan(ctx),
+ color_bold(ctx), color_fg_bright_cyan(ctx),
+ unique_trace_id, color_reset(ctx),
color_fg_cyan(ctx),
- color_bold(ctx), unique_trace_id,
- color_reset(ctx), color_fg_cyan(ctx),
- color_bold(ctx), bt_stream_class_get_id(sc),
- color_reset(ctx), color_fg_cyan(ctx),
- color_bold(ctx), bt_stream_get_id(stream),
- color_reset(ctx), color_fg_cyan(ctx),
- color_reset(ctx));
+ color_bold(ctx), color_fg_bright_cyan(ctx),
+ bt_stream_class_get_id(sc), color_reset(ctx),
+ color_fg_cyan(ctx),
+ color_bold(ctx), color_fg_bright_cyan(ctx),
+ bt_stream_get_id(stream), color_reset(ctx),
+ color_fg_cyan(ctx), color_reset(ctx));
}
end:
fmt_base = 16;
break;
default:
- abort();
+ bt_common_abort();
}
if (bt_field_class_type_is(fc_type,
bt_field_variant_borrow_selected_option_field_const(
field), NULL);
} else {
- abort();
+ bt_common_abort();
}
}
void write_root_field(struct details_write_ctx *ctx, const char *name,
const bt_field *field)
{
- BT_ASSERT(name);
- BT_ASSERT(field);
+ BT_ASSERT_DBG(name);
+ BT_ASSERT_DBG(field);
write_indent(ctx);
write_prop_name(ctx, name);
g_string_append(ctx->str, ":");
static
void write_trace(struct details_write_ctx *ctx, const bt_trace *trace)
{
- const char *name;
GPtrArray *streams = g_ptr_array_new();
uint64_t i;
bool printed_prop = false;
/* Write name */
if (ctx->details_comp->cfg.with_trace_name) {
- name = bt_trace_get_name(trace);
+ const char *name = bt_trace_get_name(trace);
if (name) {
g_string_append(ctx->str, " `");
write_str_prop_value(ctx, name);
bt_trace_borrow_environment_entry_value_by_name_const(
trace, name);
- BT_ASSERT(value);
+ BT_ASSERT_DBG(value);
write_compound_member_name(ctx, name);
write_sp(ctx);
write_str_prop_value(ctx,
bt_value_string_get(value));
} else {
- abort();
+ bt_common_abort();
}
write_nl(ctx);
/* Write times */
if (beginning_cs) {
write_time(ctx, beginning_cs);
- BT_ASSERT(end_cs);
+ BT_ASSERT_DBG(end_cs);
write_time(ctx, end_cs);
}
{
int ret = 0;
const bt_clock_snapshot *cs =
- bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
+ bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
msg);
/* Write time */
ret = write_discarded_packets_message(&ctx, msg);
break;
default:
- abort();
+ bt_common_abort();
}
/*