X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2FbatchAnalysis.c;h=98a686cd33d0be1d45255fbea3177bc303c18d66;hb=308711e5772586ce8ecc22ce04e571b175309b8e;hp=6f499ce1d394868fb2d0ae9d8d8f7e6987d1db60;hpb=c6bc9cb9f0b1432775ddc7cbbd2f2c2cfdb28474;p=lttv.git diff --git a/ltt/branches/poly/lttv/batchAnalysis.c b/ltt/branches/poly/lttv/batchAnalysis.c index 6f499ce1..98a686cd 100644 --- a/ltt/branches/poly/lttv/batchAnalysis.c +++ b/ltt/branches/poly/lttv/batchAnalysis.c @@ -9,6 +9,7 @@ #include #include #include +#include static LttvTraceset *traceset; @@ -25,6 +26,7 @@ static LttvHooks static char *a_trace; +static gboolean a_stats; void lttv_trace_option(void *hook_data) { @@ -32,37 +34,54 @@ void lttv_trace_option(void *hook_data) trace = ltt_trace_open(a_trace); if(trace == NULL) g_critical("cannot open trace %s", a_trace); - lttv_traceset_add(traceset, trace); + lttv_traceset_add(traceset, lttv_trace_new(trace)); } static gboolean process_traceset(void *hook_data, void *call_data) { - LttvTracesetState *tc; + LttvTracesetStats *tscs; + + LttvTracesetContext *tc; LttTime start, end; - tc = g_object_new(LTTV_TRACESET_STATE_TYPE, NULL); - lttv_context_init(LTTV_TRACESET_CONTEXT(tc), traceset); + g_info("BatchAnalysis begin process traceset"); + + tscs = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); + tc = &tscs->parent.parent; + + g_info("BatchAnalysis initialize context"); + + lttv_context_init(tc, traceset); + lttv_state_add_event_hooks(&tscs->parent); + if(a_stats) lttv_stats_add_event_hooks(tscs); - lttv_traceset_context_add_hooks(LTTV_TRACESET_CONTEXT(tc), + lttv_traceset_context_add_hooks(tc, before_traceset, after_traceset, NULL, before_trace, after_trace, NULL, before_tracefile, after_tracefile, NULL, before_event, after_event); - lttv_state_add_event_hooks(tc); start.tv_sec = 0; start.tv_nsec = 0; end.tv_sec = G_MAXULONG; end.tv_nsec = G_MAXULONG; - lttv_process_trace(start, end, traceset, LTTV_TRACESET_CONTEXT(tc)); - lttv_traceset_context_remove_hooks(LTTV_TRACESET_CONTEXT(tc), + g_info("BatchAnalysis process traceset"); + + lttv_process_traceset_seek_time(tc, start); + lttv_process_traceset(tc, end, G_MAXULONG); + + g_info("BatchAnalysis destroy context"); + + lttv_traceset_context_remove_hooks(tc, before_traceset, after_traceset, NULL, before_trace, after_trace, NULL, before_tracefile, after_tracefile, NULL, before_event, after_event); + lttv_state_remove_event_hooks(&tscs->parent); + if(a_stats) lttv_stats_remove_event_hooks(tscs); + lttv_context_fini(tc); + g_object_unref(tscs); - lttv_state_remove_event_hooks(tc); - lttv_context_fini(LTTV_TRACESET_CONTEXT(tc)); - g_object_unref(tc); + g_info("BatchAnalysis end process traceset"); } @@ -72,11 +91,20 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char **argv) LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); + g_info("Init batchAnalysis.c"); + lttv_option_add("trace", 't', "add a trace to the trace set to analyse", "pathname of the directory containing the trace", LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL); + a_stats = FALSE; + lttv_option_add("stats", 's', + "write the traceset and trace statistics", + "", + LTTV_OPT_NONE, &a_stats, NULL, NULL); + + traceset = lttv_traceset_new(); before_traceset = lttv_hooks_new(); @@ -124,9 +152,12 @@ G_MODULE_EXPORT void destroy() { guint i, nb; - lttv_hooks_remove_data(main_hooks, process_traceset, NULL); + LttvTrace *trace; + + g_info("Destroy batchAnalysis.c"); lttv_option_remove("trace"); + lttv_option_remove("stats"); lttv_hooks_destroy(before_traceset); lttv_hooks_destroy(after_traceset); @@ -136,10 +167,13 @@ G_MODULE_EXPORT void destroy() lttv_hooks_destroy(after_tracefile); lttv_hooks_destroy(before_event); lttv_hooks_destroy(after_event); + lttv_hooks_remove_data(main_hooks, process_traceset, NULL); nb = lttv_traceset_number(traceset); for(i = 0 ; i < nb ; i++) { - ltt_trace_close(lttv_traceset_get(traceset, i)); + trace = lttv_traceset_get(traceset, i); + ltt_trace_close(lttv_trace(trace)); + lttv_trace_destroy(trace); } lttv_traceset_destroy(traceset);