/*
+ * SPDX-License-Identifier: MIT
+ *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
* Copyright 2017-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
- * 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.
- *
- * 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.
*/
#define BT_LOG_TAG "CTF-WRITER/TRACE"
#include "logging.h"
#include <inttypes.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <babeltrace2/ctf-writer/event.h>
-#include <babeltrace2/ctf-writer/object.h>
-#include <babeltrace2/ctf-writer/utils.h>
+#include <babeltrace2-ctf-writer/event.h>
+#include <babeltrace2-ctf-writer/object.h>
+#include <babeltrace2-ctf-writer/utils.h>
#include <babeltrace2/types.h>
#include "common/assert.h"
#define DEFAULT_IDENTIFIER_SIZE 128
#define DEFAULT_METADATA_STRING_SIZE 4096
-BT_HIDDEN
int bt_ctf_trace_common_initialize(struct bt_ctf_trace_common *trace,
bt_ctf_object_release_func release_func)
{
return ret;
}
-BT_HIDDEN
void bt_ctf_trace_common_finalize(struct bt_ctf_trace_common *trace)
{
BT_LOGD("Finalizing common trace object: addr=%p, name=\"%s\"",
bt_ctf_object_put_ref(trace->packet_header_field_type);
}
-BT_HIDDEN
int bt_ctf_trace_common_set_name(struct bt_ctf_trace_common *trace, const char *name)
{
int ret = 0;
return ret;
}
-BT_HIDDEN
int bt_ctf_trace_common_set_uuid(struct bt_ctf_trace_common *trace,
const uint8_t *uuid)
{
}
bt_uuid_copy(trace->uuid, uuid);
- trace->uuid_set = BT_TRUE;
+ trace->uuid_set = BT_CTF_TRUE;
BT_LOGT("Set trace's UUID: addr=%p, name=\"%s\", "
"uuid=\"" BT_UUID_FMT "\"",
trace, bt_ctf_trace_common_get_name(trace),
return ret;
}
-BT_HIDDEN
int bt_ctf_trace_common_set_environment_field(struct bt_ctf_trace_common *trace,
const char *name, struct bt_ctf_private_value *value)
{
return ret;
}
-BT_HIDDEN
int bt_ctf_trace_common_set_environment_field_string(struct bt_ctf_trace_common *trace,
const char *name, const char *value)
{
return ret;
}
-BT_HIDDEN
int bt_ctf_trace_common_set_environment_field_integer(
struct bt_ctf_trace_common *trace, const char *name, int64_t value)
{
return ret;
}
-BT_HIDDEN
int bt_ctf_trace_common_add_clock_class(struct bt_ctf_trace_common *trace,
struct bt_ctf_clock_class *clock_class)
{
ret = bt_ctf_field_type_common_structure_borrow_field_by_index(
packet_header_type, &field_name, NULL, 0);
- BT_ASSERT(ret == 0);
+ BT_ASSERT_DBG(ret == 0);
if (strcmp(field_name, "magic") != 0) {
BT_LOGW("Invalid packet header field type: `magic` field must be the first field: "
}
elem_ft = bt_ctf_field_type_common_array_borrow_element_field_type(field_type);
- BT_ASSERT(elem_ft);
+ BT_ASSERT_DBG(elem_ft);
if (elem_ft->id != BT_CTF_FIELD_TYPE_ID_INTEGER) {
BT_LOGW("Invalid packet header field type: `uuid` field's element field type must be an integer field type: "
goto invalid;
}
- BT_ASSERT(int_ft);
+ BT_ASSERT_DBG(int_ft);
if (bt_ctf_field_type_common_integer_is_signed(int_ft)) {
BT_LOGW("Invalid event header field type: `id` field must be an unsigned integer or enumeration field type: "
"id-ft-addr=%p", int_ft);
return ret;
}
-BT_HIDDEN
int bt_ctf_trace_common_add_stream_class(struct bt_ctf_trace_common *trace,
struct bt_ctf_stream_class_common *stream_class,
bt_ctf_validation_flag_copy_field_type_func copy_field_type_func,
struct bt_ctf_field_type_common *packet_context_type = NULL;
struct bt_ctf_field_type_common *event_header_type = NULL;
struct bt_ctf_field_type_common *stream_event_ctx_type = NULL;
- int64_t event_class_count;
+ int64_t event_class_count = 0;
struct bt_ctf_trace_common *current_parent_trace = NULL;
struct bt_ctf_clock_class *expected_clock_class =
bt_ctf_object_get_ref(init_expected_clock_class);
- BT_ASSERT(copy_field_type_func);
+ BT_ASSERT_DBG(copy_field_type_func);
if (!trace) {
BT_LOGW_STR("Invalid parameter: trace is NULL.");
event_class_count =
bt_ctf_stream_class_common_get_event_class_count(stream_class);
- BT_ASSERT(event_class_count >= 0);
+ BT_ASSERT_DBG(event_class_count >= 0);
if (!stream_class->frozen) {
/*
end:
if (ret) {
- bt_ctf_object_set_parent(&stream_class->base, NULL);
+ if (stream_class) {
+ bt_ctf_object_set_parent(&stream_class->base, NULL);
+ }
if (ec_validation_outputs) {
for (i = 0; i < event_class_count; i++) {
return ret;
}
-BT_HIDDEN
-bt_bool bt_ctf_trace_common_has_clock_class(struct bt_ctf_trace_common *trace,
+bt_ctf_bool bt_ctf_trace_common_has_clock_class(struct bt_ctf_trace_common *trace,
struct bt_ctf_clock_class *clock_class)
{
struct bt_ctf_search_query query = { .value = clock_class, .found = 0 };
- BT_ASSERT(trace);
- BT_ASSERT(clock_class);
+ BT_ASSERT_DBG(trace);
+ BT_ASSERT_DBG(clock_class);
g_ptr_array_foreach(trace->clock_classes, value_exists, &query);
return query.found;
}
-BT_HIDDEN
int bt_ctf_trace_common_set_native_byte_order(struct bt_ctf_trace_common *trace,
enum bt_ctf_byte_order byte_order, bool allow_unspecified)
{
return ret;
}
-BT_HIDDEN
int bt_ctf_trace_common_set_packet_header_field_type(struct bt_ctf_trace_common *trace,
struct bt_ctf_field_type_common *packet_header_type)
{
g_free(trace);
}
-BT_HIDDEN
struct bt_ctf_trace *bt_ctf_trace_create(void)
{
struct bt_ctf_trace *trace = NULL;
return trace;
}
+BT_EXPORT
const uint8_t *bt_ctf_trace_get_uuid(struct bt_ctf_trace *trace)
{
return bt_ctf_trace_common_get_uuid(BT_CTF_TO_COMMON(trace));
}
+BT_EXPORT
int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace,
const uint8_t *uuid)
{
return bt_ctf_trace_common_set_uuid(BT_CTF_TO_COMMON(trace), uuid);
}
+BT_EXPORT
int bt_ctf_trace_set_environment_field_string(struct bt_ctf_trace *trace,
const char *name, const char *value)
{
name, value);
}
+BT_EXPORT
int bt_ctf_trace_set_environment_field_integer(
struct bt_ctf_trace *trace, const char *name, int64_t value)
{
BT_CTF_TO_COMMON(trace), name));
}
-BT_HIDDEN
int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace,
struct bt_ctf_clock_class *clock_class)
{
(void *) clock_class);
}
-BT_HIDDEN
int64_t bt_ctf_trace_get_clock_class_count(struct bt_ctf_trace *trace)
{
return bt_ctf_trace_common_get_clock_class_count(BT_CTF_TO_COMMON(trace));
}
-BT_HIDDEN
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
return ret;
}
+BT_EXPORT
int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace,
struct bt_ctf_stream_class *stream_class)
{
return ret;
}
+BT_EXPORT
int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace)
{
return bt_ctf_trace_common_get_stream_count(BT_CTF_TO_COMMON(trace));
}
+BT_EXPORT
struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
BT_CTF_TO_COMMON(trace), index));
}
+BT_EXPORT
int64_t bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace)
{
return bt_ctf_trace_common_get_stream_class_count(BT_CTF_TO_COMMON(trace));
}
+BT_EXPORT
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
BT_CTF_TO_COMMON(trace), index));
}
+BT_EXPORT
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
struct bt_ctf_trace *trace, uint64_t id)
{
BT_CTF_TO_COMMON(trace), id));
}
-BT_HIDDEN
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name(
struct bt_ctf_trace *trace, const char *name)
{
g_string_append(context->string, "trace {\n");
g_string_append(context->string, "\tmajor = 1;\n");
g_string_append(context->string, "\tminor = 8;\n");
- BT_ASSERT(trace->common.native_byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ||
+ BT_ASSERT_DBG(trace->common.native_byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ||
trace->common.native_byte_order == BT_CTF_BYTE_ORDER_BIG_ENDIAN ||
trace->common.native_byte_order == BT_CTF_BYTE_ORDER_NETWORK);
env_field_value_obj = bt_ctf_attributes_borrow_field_value(
trace->common.environment, i);
- BT_ASSERT(entry_name);
- BT_ASSERT(env_field_value_obj);
+ BT_ASSERT_DBG(entry_name);
+ BT_ASSERT_DBG(env_field_value_obj);
switch (bt_ctf_value_get_type(
bt_ctf_private_value_as_value(env_field_value_obj))) {
return metadata;
}
+BT_EXPORT
enum bt_ctf_byte_order bt_ctf_trace_get_native_byte_order(
struct bt_ctf_trace *trace)
{
return (int) bt_ctf_trace_common_get_native_byte_order(BT_CTF_TO_COMMON(trace));
}
+BT_EXPORT
int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace,
enum bt_ctf_byte_order byte_order)
{
(int) byte_order, false);
}
+BT_EXPORT
struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_field_type(
struct bt_ctf_trace *trace)
{
BT_CTF_TO_COMMON(trace)));
}
+BT_EXPORT
int bt_ctf_trace_set_packet_header_field_type(struct bt_ctf_trace *trace,
struct bt_ctf_field_type *packet_header_type)
{
(void *) packet_header_type);
}
+BT_EXPORT
const char *bt_ctf_trace_get_name(struct bt_ctf_trace *trace)
{
return bt_ctf_trace_common_get_name(BT_CTF_TO_COMMON(trace));