static int append_trace_metadata(struct bt_ctf_trace *trace, struct metadata_context *context) { unsigned char *uuid = trace->uuid; int ret; g_string_append(context->string, "trace {\n"); g_string_append(context->string, "\tmajor = 1;\n"); g_string_append(context->string, "\tminor = 8;\n"); g_string_append_printf(context->string, "\tuuid = \"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\";\n", uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]); g_string_append_printf(context->string, "\tbyte_order = %s;\n", get_byte_order_string(trace->byte_order)); g_string_append(context->string, "\tpacket.header := "); context->current_indentation_level++; g_string_assign(context->field_name, ""); ret = bt_ctf_field_type_serialize(trace->packet_header_type, context); if (ret) { goto end; } context->current_indentation_level--; g_string_append(context->string, ";\n};\n\n"); end: return ret; }
int bt_ctf_writer_add_clock(struct bt_ctf_writer *writer, struct bt_ctf_clock *clock) { int ret = 0; struct search_query query = { .value = clock, .found = 0 }; if (!writer || !clock) { ret = -1; goto end; } /* Check for duplicate clocks */ g_ptr_array_foreach(writer->clocks, value_exists, &query); if (query.found) { ret = -1; goto end; } bt_ctf_clock_get(clock); g_ptr_array_add(writer->clocks, clock); end: return ret; } BT_HIDDEN const char *get_byte_order_string(int byte_order) { const char *string; switch (byte_order) { case LITTLE_ENDIAN: string = "le"; break; case BIG_ENDIAN: string = "be"; break; default: string = "unknown"; break; } return string; } static int append_trace_metadata(struct bt_ctf_writer *writer, struct metadata_context *context) { unsigned char *uuid = writer->uuid; int ret; g_string_append(context->string, "trace {\n"); g_string_append(context->string, "\tmajor = 1;\n"); g_string_append(context->string, "\tminor = 8;\n"); g_string_append_printf(context->string, "\tuuid = \"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\";\n", uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]); g_string_append_printf(context->string, "\tbyte_order = %s;\n", get_byte_order_string(writer->byte_order)); g_string_append(context->string, "\tpacket.header := "); context->current_indentation_level++; g_string_assign(context->field_name, ""); ret = bt_ctf_field_type_serialize(writer->trace_packet_header_type, context); if (ret) { goto end; } context->current_indentation_level--; g_string_append(context->string, ";\n};\n\n"); end: return ret; }