*
* Babeltrace - CTF IR: Validation of trace, stream class, and event class
*
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016-2018 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
#define BT_LOG_TAG "VALIDATION"
#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <babeltrace/ctf-ir/validation-internal.h>
#include <babeltrace/ctf-ir/resolve-internal.h>
#include <babeltrace/ctf-ir/trace-internal.h>
#include <babeltrace/ctf-ir/stream-class-internal.h>
#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/ctf-ir/event-class-internal.h>
+#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/ref.h>
for (i = 0; i < field_count; ++i) {
struct bt_field_type *child_type =
- bt_field_type_get_field_at_index(type, i);
+ bt_field_type_borrow_field_at_index(
+ type, i);
ret = field_type_contains_sequence_or_variant_ft(
child_type);
- BT_PUT(child_type);
if (ret != 0) {
goto end;
}
struct bt_field_type *event_payload_type,
int trace_valid, int stream_class_valid, int event_class_valid,
struct bt_validation_output *output,
- enum bt_validation_flag validate_flags)
+ enum bt_validation_flag validate_flags,
+ bt_validation_flag_copy_field_type_func copy_field_type_func)
{
int ret = 0;
int contains_seq_var;
BT_LOGV_STR("Copying packet header field type because it contains at least one sequence or variant field type.");
packet_header_type_copy =
- bt_field_type_copy(packet_header_type);
+ copy_field_type_func(packet_header_type);
if (!packet_header_type_copy) {
ret = -1;
BT_LOGE_STR("Cannot copy packet header field type.");
BT_LOGV_STR("Copying packet context field type because it contains at least one sequence or variant field type.");
packet_context_type_copy =
- bt_field_type_copy(packet_context_type);
+ copy_field_type_func(packet_context_type);
if (!packet_context_type_copy) {
BT_LOGE_STR("Cannot copy packet context field type.");
goto sc_validation_error;
BT_LOGV_STR("Copying event header field type because it contains at least one sequence or variant field type.");
event_header_type_copy =
- bt_field_type_copy(event_header_type);
+ copy_field_type_func(event_header_type);
if (!event_header_type_copy) {
BT_LOGE_STR("Cannot copy event header field type.");
goto sc_validation_error;
BT_LOGV_STR("Copying stream event context field type because it contains at least one sequence or variant field type.");
stream_event_ctx_type_copy =
- bt_field_type_copy(stream_event_ctx_type);
+ copy_field_type_func(stream_event_ctx_type);
if (!stream_event_ctx_type_copy) {
BT_LOGE_STR("Cannot copy stream event context field type.");
goto sc_validation_error;
BT_LOGV_STR("Copying event context field type because it contains at least one sequence or variant field type.");
event_context_type_copy =
- bt_field_type_copy(event_context_type);
+ copy_field_type_func(event_context_type);
if (!event_context_type_copy) {
BT_LOGE_STR("Cannot copy event context field type.");
goto ec_validation_error;
BT_LOGV_STR("Copying event payload field type because it contains at least one sequence or variant field type.");
event_payload_type_copy =
- bt_field_type_copy(event_payload_type);
+ copy_field_type_func(event_payload_type);
if (!event_payload_type_copy) {
BT_LOGE_STR("Cannot copy event payload field type.");
goto ec_validation_error;
enum bt_validation_flag replace_flags)
{
if ((replace_flags & BT_VALIDATION_FLAG_TRACE) && trace) {
- bt_field_type_freeze(trace->packet_header_type);
- BT_MOVE(trace->packet_header_type, output->packet_header_type);
+ bt_field_type_freeze(trace->packet_header_field_type);
+ BT_MOVE(trace->packet_header_field_type,
+ output->packet_header_type);
}
if ((replace_flags & BT_VALIDATION_FLAG_STREAM) && stream_class) {
- bt_field_type_freeze(stream_class->packet_context_type);
- bt_field_type_freeze(stream_class->event_header_type);
- bt_field_type_freeze(stream_class->event_context_type);
- BT_MOVE(stream_class->packet_context_type,
+ bt_field_type_freeze(stream_class->packet_context_field_type);
+ bt_field_type_freeze(stream_class->event_header_field_type);
+ bt_field_type_freeze(stream_class->event_context_field_type);
+ BT_MOVE(stream_class->packet_context_field_type,
output->packet_context_type);
- BT_MOVE(stream_class->event_header_type,
+ BT_MOVE(stream_class->event_header_field_type,
output->event_header_type);
- BT_MOVE(stream_class->event_context_type,
+ BT_MOVE(stream_class->event_context_field_type,
output->stream_event_ctx_type);
}
if ((replace_flags & BT_VALIDATION_FLAG_EVENT) && event_class) {
- bt_field_type_freeze(event_class->context);
- bt_field_type_freeze(event_class->fields);
- BT_MOVE(event_class->context, output->event_context_type);
- BT_MOVE(event_class->fields, output->event_payload_type);
+ bt_field_type_freeze(event_class->context_field_type);
+ bt_field_type_freeze(event_class->payload_field_type);
+ BT_MOVE(event_class->context_field_type, output->event_context_type);
+ BT_MOVE(event_class->payload_field_type, output->event_payload_type);
}
}