* SOFTWARE.
*/
+#define BT_LOG_TAG "WRITER"
+#include <babeltrace/lib-logging-internal.h>
+
#include <babeltrace/ctf-writer/clock-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/endian-internal.h>
#include <babeltrace/compiler-internal.h>
+#include <babeltrace/compat/uuid-internal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
static
void bt_ctf_writer_destroy(struct bt_object *obj);
+static
+int init_trace_packet_header(struct bt_ctf_trace *trace)
+{
+ int ret = 0;
+ struct bt_ctf_field *magic = NULL, *uuid_array = NULL;
+ struct bt_ctf_field_type *_uint32_t =
+ get_field_type(FIELD_TYPE_ALIAS_UINT32_T);
+ struct bt_ctf_field_type *_uint8_t =
+ get_field_type(FIELD_TYPE_ALIAS_UINT8_T);
+ struct bt_ctf_field_type *trace_packet_header_type =
+ bt_ctf_field_type_structure_create();
+ struct bt_ctf_field_type *uuid_array_type =
+ bt_ctf_field_type_array_create(_uint8_t, 16);
+
+ if (!trace_packet_header_type || !uuid_array_type) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_field_type_structure_add_field(trace_packet_header_type,
+ _uint32_t, "magic");
+ if (ret) {
+ goto end;
+ }
+
+ ret = bt_ctf_field_type_structure_add_field(trace_packet_header_type,
+ uuid_array_type, "uuid");
+ if (ret) {
+ goto end;
+ }
+
+ ret = bt_ctf_field_type_structure_add_field(trace_packet_header_type,
+ _uint32_t, "stream_id");
+ if (ret) {
+ goto end;
+ }
+
+ ret = bt_ctf_trace_set_packet_header_type(trace,
+ trace_packet_header_type);
+ if (ret) {
+ goto end;
+ }
+end:
+ bt_put(uuid_array_type);
+ bt_put(_uint32_t);
+ bt_put(_uint8_t);
+ bt_put(magic);
+ bt_put(uuid_array);
+ bt_put(trace_packet_header_type);
+ return ret;
+}
+
struct bt_ctf_writer *bt_ctf_writer_create(const char *path)
{
int ret;
struct bt_ctf_writer *writer = NULL;
+ unsigned char uuid[16];
if (!path) {
goto error;
goto error_destroy;
}
+ ret = init_trace_packet_header(writer->trace);
+ if (ret) {
+ goto error_destroy;
+ }
+
+ /* Generate a UUID for this writer's trace */
+ ret = bt_uuid_generate(uuid);
+ if (ret) {
+ BT_LOGE_STR("Cannot generate UUID for CTF writer's trace.");
+ goto error_destroy;
+ }
+
+ ret = bt_ctf_trace_set_uuid(writer->trace, uuid);
+ if (ret) {
+ goto error_destroy;
+ }
+
writer->trace->is_created_by_writer = 1;
bt_object_set_parent(writer->trace, writer);
bt_put(writer->trace);
{
struct bt_ctf_stream *stream = NULL;
int stream_class_count;
- bool stream_class_found = false;
+ bt_bool stream_class_found = BT_FALSE;
int i;
if (!writer || !stream_class) {
for (i = 0; i < stream_class_count; i++) {
struct bt_ctf_stream_class *existing_stream_class =
- bt_ctf_trace_get_stream_class(writer->trace, i);
+ bt_ctf_trace_get_stream_class_by_index(
+ writer->trace, i);
if (existing_stream_class == stream_class) {
- stream_class_found = true;
+ stream_class_found = BT_TRUE;
}
BT_PUT(existing_stream_class);
}
int bt_ctf_writer_add_environment_field_int64(struct bt_ctf_writer *writer,
- const char *name,
- int64_t value)
+ const char *name, int64_t value)
{
int ret = -1;