X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttv%2Flttv%2Ftracecontext.c;h=e937789c1e5ac499fd8df0f1e9817aac92f7a44a;hb=2bc1bcfb0fdff52b3350804d2824cd023f463f96;hp=1c71ac214a6644bc4eb74ae1298b911dc9f8dbd4;hpb=3667f07d4ba2bc2bae9729ca3d60451475e2a434;p=lttv.git diff --git a/lttv/lttv/tracecontext.c b/lttv/lttv/tracecontext.c index 1c71ac21..e937789c 100644 --- a/lttv/lttv/tracecontext.c +++ b/lttv/lttv/tracecontext.c @@ -28,6 +28,13 @@ #include #include #include +#include + +#include +#include + +#include +#include gint compare_tracefile(gconstpointer a, gconstpointer b) { @@ -113,6 +120,8 @@ lttv_context_new_tracefile_context(LttvTracesetContext *self) void lttv_traceset_context_compute_time_span(LttvTracesetContext *self, TimeInterval *time_span) { + //todo mdenis: adapt to babeltrace +#ifdef BABEL_CLEANUP LttvTraceset * traceset = self->ts; int numTraces = lttv_traceset_number(traceset); int i; @@ -127,6 +136,7 @@ void lttv_traceset_context_compute_time_span(LttvTracesetContext *self, for(i=0; itraces[i]; + trace = tc->t; ltt_trace_time_span_get(trace, &s, &e); @@ -147,6 +157,7 @@ void lttv_traceset_context_compute_time_span(LttvTracesetContext *self, time_span->end_time = e; } } +#endif } static void init_tracefile_context(LttTracefile *tracefile, @@ -180,12 +191,21 @@ init(LttvTracesetContext *self, LttvTraceset *ts) GData **tracefiles_groups; struct compute_tracefile_group_args args; + + struct bt_iter_pos begin_pos; nb_trace = lttv_traceset_number(ts); self->ts = ts; self->traces = g_new(LttvTraceContext *, nb_trace); self->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); self->ts_a = lttv_traceset_attribute(ts); + + begin_pos.type = BT_SEEK_BEGIN; + + self->iter = bt_ctf_iter_create(lttv_traceset_get_context(ts), + &begin_pos, + NULL); + self->event_hooks = lttv_hooks_new(); for(i = 0 ; i < nb_trace ; i++) { tc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_trace_context(self); self->traces[i] = tc; @@ -193,12 +213,15 @@ init(LttvTracesetContext *self, LttvTraceset *ts) tc->ts_context = self; tc->index = i; tc->vt = lttv_traceset_get(ts, i); +#ifdef BABEL_CLEANUP tc->t = lttv_trace(tc->vt); +#endif tc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); tc->t_a = lttv_trace_attribute(tc->vt); tc->tracefiles = g_array_sized_new(FALSE, TRUE, sizeof(LttvTracefileContext*), 10); +#ifdef BABEL_CLEANUP tracefiles_groups = ltt_trace_get_tracefiles_groups(tc->t); if(tracefiles_groups != NULL) { args.func = (ForEachTraceFileFunc)init_tracefile_context; @@ -208,33 +231,8 @@ init(LttvTracesetContext *self, LttvTraceset *ts) (GDataForeachFunc)compute_tracefile_group, &args); } +#endif -#if 0 - nb_control = ltt_trace_control_tracefile_number(tc->t); - nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t); - nb_tracefile = nb_control + nb_per_cpu; - tc->tracefiles = g_new(LttvTracefileContext *, nb_tracefile); - - for(j = 0 ; j < nb_tracefile ; j++) { - tfc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_tracefile_context(self); - tc->tracefiles[j] = tfc; - tfc->index = j; - - if(j < nb_control) { - tfc->control = TRUE; - tfc->tf = ltt_trace_control_tracefile_get(tc->t, j); - } else { - tfc->control = FALSE; - tfc->tf = ltt_trace_per_cpu_tracefile_get(tc->t, j - nb_control); - } - - tfc->t_context = tc; - tfc->e = ltt_event_new(); - tfc->event = lttv_hooks_new(); - tfc->event_by_id = lttv_hooks_by_id_new(); - tfc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); - } -#endif //0 } self->sync_position = lttv_traceset_context_position_new(self); @@ -296,6 +294,8 @@ void lttv_traceset_context_add_hooks(LttvTracesetContext *self, LttvTraceContext *tc; lttv_hooks_call(before_traceset, self); + + lttv_hooks_add_list(self->event_hooks, event); nb_trace = lttv_traceset_number(ts); @@ -682,6 +682,46 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, gulong nb_events, const LttvTracesetContextPosition *end_position) { + + unsigned count = 0; + + struct bt_ctf_event *bt_event; + + LttvEvent event; + /* TODO ybrosseau 2012-03-16: Put in really in the traceset */ + LttvTraceState state; + + while(TRUE) { + + if((count >= nb_events) && (nb_events != G_MAXULONG)) { + break; + } + + if((bt_event = bt_ctf_iter_read_event(self->iter)) != NULL) { + + count++; + + event.bt_event = bt_event; + event.state = &state; + + lttv_hooks_call(self->event_hooks, &event); + + if(bt_iter_next(bt_ctf_get_iter(self->iter)) < 0) { + printf("ERROR NEXT\n"); + break; + } + } else { + /* READ FAILED */ + + break; + + } + } + + + + return count; +#ifdef BABEL_CLEANUP GTree *pqueue = self->pqueue; LttvTracefileContext *tfc; @@ -814,6 +854,8 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, } else { return count; } + +#endif /* BABEL_CLEANUP */ } @@ -954,9 +996,25 @@ guint lttv_process_traceset_update(LttvTracesetContext *self) } void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start) -{ +{ +#ifdef WAIT_FOR_BABELTRACE_FIX_SEEK_ZERO + struct bt_iter_pos seekpos; + int ret; + seekpos.type = BT_SEEK_TIME; + seekpos.u.seek_time = ltt_time_to_uint64(start); + ret = bt_iter_set_pos(bt_ctf_get_iter(self->iter), &seekpos); + if(ret < 0) { + printf("Seek by time error: %s,\n",strerror(-ret)); + } +#else +#warning Seek time disabled because of babeltrace bugs +#endif + +#ifdef BABEL_CLEANUP guint i, nb_trace; + + LttvTraceContext *tc; //g_tree_destroy(self->pqueue); @@ -967,6 +1025,7 @@ void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start) tc = self->traces[i]; lttv_process_trace_seek_time(tc, start); } +#endif }