Beispiel #1
0
static
void merge_ctf_fs_traces(struct ctf_fs_trace **traces, unsigned int num_traces)
{
	unsigned int winner_count;
	struct ctf_fs_trace *winner;
	guint i;
	char uuid_str[BABELTRACE_UUID_STR_LEN];

	BT_ASSERT(num_traces >= 2);

	winner_count = metadata_count_stream_and_event_classes(traces[0]);
	winner = traces[0];

	/* Find the trace with the largest metadata. */
	for (i = 1; i < num_traces; i++) {
		struct ctf_fs_trace *candidate;
		unsigned int candidate_count;

		candidate = traces[i];

		/* A bit of sanity check. */
		BT_ASSERT(bt_uuid_compare(winner->metadata->tc->uuid, candidate->metadata->tc->uuid) == 0);

		candidate_count = metadata_count_stream_and_event_classes(candidate);

		if (candidate_count > winner_count) {
			winner_count = candidate_count;
			winner = candidate;
		}
	}

	/* Merge all the other traces in the winning trace. */
	for (i = 0; i < num_traces; i++) {
		struct ctf_fs_trace *trace = traces[i];

		/* Don't merge the winner into itself. */
		if (trace == winner) {
			continue;
		}

		/* Merge trace's data stream file groups into winner's. */
		merge_matching_ctf_fs_ds_file_groups(winner, trace);

		/* Free the trace that got merged into winner, clear the slot in the array. */
		ctf_fs_trace_destroy(trace);
		traces[i] = NULL;
	}

	/* Use the string representation of the UUID as the trace name. */
	bt_uuid_unparse(winner->metadata->tc->uuid, uuid_str);
	g_string_printf(winner->name, "%s", uuid_str);
}
static
void print_metadata(FILE *fp)
{
	char uuid_str[BABELTRACE_UUID_STR_LEN];
	unsigned int major = 0, minor = 0;
	int ret;

	ret = sscanf(VERSION, "%u.%u", &major, &minor);
	if (ret != 2)
		fprintf(stderr, "[warning] Incorrect babeltrace version format\n.");
	bt_uuid_unparse(s_uuid, uuid_str);
	fprintf(fp, metadata_fmt,
		major,
		minor,
		uuid_str,
		BYTE_ORDER == LITTLE_ENDIAN ? "le" : "be",
		s_timestamp ? metadata_stream_event_header_timestamp : "");
}