예제 #1
0
파일: metadata.c 프로젝트: eepp/babeltrace
int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace,
		struct ctf_fs_metadata_config *config)
{
	int ret = 0;
	struct ctf_fs_file *file = NULL;
	struct ctf_metadata_decoder *metadata_decoder = NULL;
	struct ctf_metadata_decoder_config decoder_config = {
		.clock_class_offset_s = config ? config->clock_class_offset_s : 0,
		.clock_class_offset_ns = config ? config->clock_class_offset_ns : 0,
	};

	file = get_file(ctf_fs_trace->path->str);
	if (!file) {
		BT_LOGE("Cannot create metadata file object");
		ret = -1;
		goto end;
	}

	metadata_decoder = ctf_metadata_decoder_create(
		config ? &decoder_config : NULL,
		ctf_fs_trace->name->str);
	if (!metadata_decoder) {
		BT_LOGE("Cannot create metadata decoder object");
		ret = -1;
		goto end;
	}

	ret = ctf_metadata_decoder_decode(metadata_decoder, file->fp);
	if (ret) {
		BT_LOGE("Cannot decode metadata file");
		goto end;
	}

	ctf_fs_trace->metadata->trace = ctf_metadata_decoder_get_trace(
		metadata_decoder);
	assert(ctf_fs_trace->metadata->trace);

end:
	ctf_fs_file_destroy(file);
	ctf_metadata_decoder_destroy(metadata_decoder);
	return ret;
}

int ctf_fs_metadata_init(struct ctf_fs_metadata *metadata)
{
	/* Nothing to initialize for the moment. */
	return 0;
}

void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata)
{
	if (metadata->text) {
		free(metadata->text);
	}

	if (metadata->trace) {
		BT_PUT(metadata->trace);
	}
}
예제 #2
0
BT_HIDDEN
int lttng_live_metadata_create_stream(struct lttng_live_session *session,
		uint64_t ctf_trace_id,
		uint64_t stream_id,
		const char *trace_name)
{
	struct lttng_live_component *lttng_live =
		session->lttng_live_msg_iter->lttng_live_comp;
	struct lttng_live_metadata *metadata = NULL;
	struct lttng_live_trace *trace;
	const char *match;

	metadata = g_new0(struct lttng_live_metadata, 1);
	if (!metadata) {
		return -1;
	}
	metadata->stream_id = stream_id;

	match = strstr(trace_name, session->session_name->str);
	if (!match) {
		goto error;
	}

	metadata->decoder = ctf_metadata_decoder_create(
				lttng_live->self_comp, NULL);
	if (!metadata->decoder) {
		goto error;
	}
	trace = lttng_live_borrow_trace(session, ctf_trace_id);
	if (!trace) {
		goto error;
	}
	metadata->trace = trace;
	trace->metadata = metadata;
	return 0;

error:
	ctf_metadata_decoder_destroy(metadata->decoder);
	g_free(metadata);
	return -1;
}