Пример #1
0
struct bt_ctf_iter *bt_ctf_iter_create_intersect(struct bt_context *ctx,
		struct bt_iter_pos **inter_begin_pos,
		struct bt_iter_pos **inter_end_pos)
{
	int ret;
	uint64_t begin, end;

	/*
	 * The iterator's range is the union of each trace's intersection of
	 * streams. This means that we determine the "active" region of each
	 * trace (that is the region where all of its streams are active), and
	 * use the TraceCollection to merge all of these active regions.
	 *
	 * This results in a union of the traces' active regions.
	 */
	ret = ctf_find_tc_stream_packet_intersection_union(ctx, &begin, &end);
	if (ret == 1) {
		fprintf(stderr, "[error] No intersection found between trace files.\n");
		goto error;
	} else if (ret != 0) {
		goto error;
	}
	*inter_begin_pos = bt_iter_create_time_pos(NULL, begin);
	if (!(*inter_begin_pos)) {
		goto error;
	}
	*inter_end_pos = bt_iter_create_time_pos(NULL, end);
	if (!(*inter_end_pos)) {
		goto error;
	}

	ret = ctf_tc_set_stream_intersection_mode(ctx);
	if (ret) {
		goto error;
	}

	/*
	 * bt_ctf_iter does not take ownership of begin and end positions,
	 * so we return them to the caller who must still assume their ownership
	 * until the iterator is destroyed.
	 */
	return bt_ctf_iter_create(ctx, *inter_begin_pos,
			*inter_end_pos);
error:
	return NULL;
}
Пример #2
0
static
int convert_trace(struct bt_trace_descriptor *td_write,
		  struct bt_context *ctx)
{
	struct bt_ctf_iter *iter;
	struct ctf_text_stream_pos *sout;
	struct bt_iter_pos *begin_pos = NULL, *end_pos = NULL;
	struct bt_ctf_event *ctf_event;
	int ret;

	sout = container_of(td_write, struct ctf_text_stream_pos,
			trace_descriptor);

	if (!sout->parent.event_cb) {
		return 0;
	}

	if (opt_stream_intersection) {
		iter = bt_ctf_iter_create_intersect(ctx, &begin_pos, &end_pos);
	} else {
		begin_pos = bt_iter_create_time_pos(NULL, 0);
		begin_pos->type = BT_SEEK_BEGIN;
		iter = bt_ctf_iter_create(ctx, begin_pos, NULL);
	}
	if (!iter) {
		ret = -1;
		goto error_iter;
	}
	while ((ctf_event = bt_ctf_iter_read_event(iter))) {
		ret = sout->parent.event_cb(&sout->parent, ctf_event->parent->stream);
		if (ret) {
			fprintf(stderr, "[error] Writing event failed.\n");
			goto end;
		}
		ret = bt_iter_next(bt_ctf_get_iter(iter));
		if (ret < 0) {
			goto end;
		}
	}
	ret = 0;

end:
	bt_ctf_iter_destroy(iter);
error_iter:
	bt_iter_free_pos(begin_pos);
	bt_iter_free_pos(end_pos);
	return ret;
}
Пример #3
0
LttvTracesetPosition *lttv_traceset_create_time_position(LttvTraceset *traceset,
                                                                LttTime timestamp)
{
        LttvTracesetPosition *traceset_pos;

        traceset_pos = g_new(LttvTracesetPosition, 1);

        /* Check if the new passed */
        if(traceset_pos == NULL) {
                return NULL;
        }
        
        traceset_pos->iter = traceset->iter;
        traceset_pos->bt_pos = bt_iter_create_time_pos( 
                                        bt_ctf_get_iter(traceset_pos->iter),
                                        ltt_time_to_uint64(timestamp));
        traceset_pos->timestamp = G_MAXUINT64;
        traceset_pos->cpu_id = INT_MAX;
        return traceset_pos;
}