* SOFTWARE.
*/
+#define BT_COMP_LOG_SELF_COMP (ctx->self_comp)
+#define BT_LOG_OUTPUT_LEVEL (ctx->log_level)
#define BT_LOG_TAG "PLUGIN/SINK.CTF.FS/TRANSLATE-TRACE-IR-TO-CTF-IR"
-#include "logging.h"
+#include "plugins/comp-logging.h"
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
#include <string.h>
#include <glib.h>
+#include "fs-sink.h"
#include "fs-sink-ctf-meta.h"
struct field_path_elem {
};
struct ctx {
+ bt_logging_level log_level;
+ bt_self_component *self_comp;
+
/* Weak */
struct fs_sink_ctf_stream_class *cur_sc;
is_reserved_member_name(ir_name, "timestamp_end") ||
is_reserved_member_name(ir_name, "events_discarded") ||
is_reserved_member_name(ir_name, "packet_seq_num")) {
- BT_LOGE("Unsupported reserved TSDL structure field class member "
+ BT_COMP_LOGE("Unsupported reserved TSDL structure field class member "
"or variant field class option name: name=\"%s\"",
ir_name);
ret = -1;
ret = fs_sink_ctf_protect_name(field_path_elem->name);
if (ret) {
- BT_LOGE("Unsupported non-TSDL structure field class member "
+ BT_COMP_LOGE("Unsupported non-TSDL structure field class member "
"or variant field class option name: name=\"%s\"",
ir_name);
goto end;
ret = cur_path_stack_push(ctx, i, name, memb_ir_fc,
(void *) struct_fc);
if (ret) {
- BT_LOGE("Cannot translate structure field class member: "
+ BT_COMP_LOGE("Cannot translate structure field class member: "
"name=\"%s\"", name);
goto end;
}
ret = translate_field_class(ctx);
if (ret) {
- BT_LOGE("Cannot translate structure field class member: "
+ BT_COMP_LOGE("Cannot translate structure field class member: "
"name=\"%s\"", name);
goto end;
}
opt);
ret = cur_path_stack_push(ctx, i, name, opt_ir_fc, (void *) fc);
if (ret) {
- BT_LOGE("Cannot translate variant field class option: "
+ BT_COMP_LOGE("Cannot translate variant field class option: "
"name=\"%s\"", name);
goto end;
}
ret = translate_field_class(ctx);
if (ret) {
- BT_LOGE("Cannot translate variant field class option: "
+ BT_COMP_LOGE("Cannot translate variant field class option: "
"name=\"%s\"", name);
goto end;
}
ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, elem_ir_fc,
(void *) fc);
if (ret) {
- BT_LOGE_STR("Cannot translate static array field class element.");
+ BT_COMP_LOGE_STR("Cannot translate static array field class element.");
goto end;
}
ret = translate_field_class(ctx);
if (ret) {
- BT_LOGE_STR("Cannot translate static array field class element.");
+ BT_COMP_LOGE_STR("Cannot translate static array field class element.");
goto end;
}
ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, elem_ir_fc,
(void *) fc);
if (ret) {
- BT_LOGE_STR("Cannot translate dynamic array field class element.");
+ BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
goto end;
}
ret = translate_field_class(ctx);
if (ret) {
- BT_LOGE_STR("Cannot translate dynamic array field class element.");
+ BT_COMP_LOGE_STR("Cannot translate dynamic array field class element.");
goto end;
}
BT_ASSERT(ctx->cur_path->len == 0);
ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, ir_fc, NULL);
if (ret) {
- BT_LOGE("Cannot translate scope structure field class: "
+ BT_COMP_LOGE("Cannot translate scope structure field class: "
"scope=%d", scope);
goto end;
}
ret = translate_structure_field_class_members(ctx, (void *) *fc, ir_fc);
if (ret) {
- BT_LOGE("Cannot translate scope structure field class: "
+ BT_COMP_LOGE("Cannot translate scope structure field class: "
"scope=%d", scope);
goto end;
}
}
static inline
-void ctx_init(struct ctx *ctx)
+void ctx_init(struct ctx *ctx, struct fs_sink_comp *fs_sink)
{
memset(ctx, 0, sizeof(struct ctx));
ctx->cur_path = g_array_new(FALSE, TRUE,
sizeof(struct field_path_elem));
BT_ASSERT(ctx->cur_path);
+ ctx->log_level = fs_sink->log_level;
+ ctx->self_comp = fs_sink->self_comp;
}
static inline
}
static
-int translate_event_class(struct fs_sink_ctf_stream_class *sc,
+int translate_event_class(struct fs_sink_comp *fs_sink,
+ struct fs_sink_ctf_stream_class *sc,
const bt_event_class *ir_ec,
struct fs_sink_ctf_event_class **out_ec)
{
BT_ASSERT(sc);
BT_ASSERT(ir_ec);
- ctx_init(&ctx);
+ ctx_init(&ctx, fs_sink);
ec = fs_sink_ctf_event_class_create(sc, ir_ec);
BT_ASSERT(ec);
ctx.cur_sc = sc;
BT_HIDDEN
int try_translate_event_class_trace_ir_to_ctf_ir(
+ struct fs_sink_comp *fs_sink,
struct fs_sink_ctf_stream_class *sc,
const bt_event_class *ir_ec,
struct fs_sink_ctf_event_class **out_ec)
goto end;
}
- ret = translate_event_class(sc, ir_ec, out_ec);
+ ret = translate_event_class(fs_sink, sc, ir_ec, out_ec);
end:
return ret;
}
-bool default_clock_class_name_exists(struct fs_sink_ctf_trace_class *tc,
+bool default_clock_class_name_exists(struct fs_sink_ctf_trace *trace,
const char *name)
{
bool exists = false;
uint64_t i;
- for (i = 0; i < tc->stream_classes->len; i++) {
+ for (i = 0; i < trace->stream_classes->len; i++) {
struct fs_sink_ctf_stream_class *sc =
- tc->stream_classes->pdata[i];
+ trace->stream_classes->pdata[i];
if (sc->default_clock_class_name->len == 0) {
/* No default clock class */
g_string_assign(sc->default_clock_class_name, "");
sprintf(buf, "default");
- while (default_clock_class_name_exists(sc->tc, buf)) {
+ while (default_clock_class_name_exists(sc->trace, buf)) {
sprintf(buf, "default%u", suffix);
suffix++;
}
}
static
-int translate_stream_class(struct fs_sink_ctf_trace_class *tc,
+int translate_stream_class(struct fs_sink_comp *fs_sink,
+ struct fs_sink_ctf_trace *trace,
const bt_stream_class *ir_sc,
struct fs_sink_ctf_stream_class **out_sc)
{
int ret = 0;
struct ctx ctx;
- BT_ASSERT(tc);
+ BT_ASSERT(trace);
BT_ASSERT(ir_sc);
- ctx_init(&ctx);
- *out_sc = fs_sink_ctf_stream_class_create(tc, ir_sc);
+ ctx_init(&ctx, fs_sink);
+ *out_sc = fs_sink_ctf_stream_class_create(trace, ir_sc);
BT_ASSERT(*out_sc);
/* Set default clock class's protected name, if any */
BT_HIDDEN
int try_translate_stream_class_trace_ir_to_ctf_ir(
- struct fs_sink_ctf_trace_class *tc,
+ struct fs_sink_comp *fs_sink,
+ struct fs_sink_ctf_trace *trace,
const bt_stream_class *ir_sc,
struct fs_sink_ctf_stream_class **out_sc)
{
int ret = 0;
uint64_t i;
- BT_ASSERT(tc);
+ BT_ASSERT(trace);
BT_ASSERT(ir_sc);
- for (i = 0; i < tc->stream_classes->len; i++) {
- *out_sc = tc->stream_classes->pdata[i];
+ for (i = 0; i < trace->stream_classes->len; i++) {
+ *out_sc = trace->stream_classes->pdata[i];
if ((*out_sc)->ir_sc == ir_sc) {
goto end;
}
}
- ret = translate_stream_class(tc, ir_sc, out_sc);
+ ret = translate_stream_class(fs_sink, trace, ir_sc, out_sc);
end:
return ret;
}
BT_HIDDEN
-struct fs_sink_ctf_trace_class *translate_trace_class_trace_ir_to_ctf_ir(
- const bt_trace_class *ir_tc)
+struct fs_sink_ctf_trace *translate_trace_trace_ir_to_ctf_ir(
+ struct fs_sink_comp *fs_sink, const bt_trace *ir_trace)
{
uint64_t count;
uint64_t i;
- struct fs_sink_ctf_trace_class *tc = NULL;
+ struct fs_sink_ctf_trace *trace = NULL;
- /* Check that trace class's environment is TSDL-compatible */
- count = bt_trace_class_get_environment_entry_count(ir_tc);
+ /* Check that trace's environment is TSDL-compatible */
+ count = bt_trace_get_environment_entry_count(ir_trace);
for (i = 0; i < count; i++) {
const char *name;
const bt_value *val;
- bt_trace_class_borrow_environment_entry_by_index_const(
- ir_tc, i, &name, &val);
+ bt_trace_borrow_environment_entry_by_index_const(
+ ir_trace, i, &name, &val);
if (!fs_sink_ctf_ist_valid_identifier(name)) {
- BT_LOGE("Unsupported trace class's environment entry name: "
+ BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, fs_sink->log_level,
+ fs_sink->self_comp,
+ "Unsupported trace class's environment entry name: "
"name=\"%s\"", name);
goto end;
}
case BT_VALUE_TYPE_STRING:
break;
default:
- BT_LOGE("Unsupported trace class's environment entry value type: "
+ BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, fs_sink->log_level,
+ fs_sink->self_comp,
+ "Unsupported trace class's environment entry value type: "
"type=%s",
bt_common_value_type_string(
bt_value_get_type(val)));
}
}
- tc = fs_sink_ctf_trace_class_create(ir_tc);
- BT_ASSERT(tc);
+ trace = fs_sink_ctf_trace_create(ir_trace);
+ BT_ASSERT(trace);
end:
- return tc;
+ return trace;
}