X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Ftext%2FbatchAnalysis.c;h=785ff1a86c27b45a8b2819c22c5f58bd1da98d19;hb=4e4d11b3b1db254446f6cad04b3c3fa9b574851f;hp=0d8f15224ea20444544bac9e1c593811c484a018;hpb=08b1c66e3a5ad9588d08f9477af98c0cda4f070c;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/text/batchAnalysis.c b/ltt/branches/poly/lttv/modules/text/batchAnalysis.c index 0d8f1522..785ff1a8 100644 --- a/ltt/branches/poly/lttv/modules/text/batchAnalysis.c +++ b/ltt/branches/poly/lttv/modules/text/batchAnalysis.c @@ -19,15 +19,19 @@ /* This module inserts a hook in the program main loop. This hook processes all the events in the main tracefile. */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include #include #include -#include +#include #include #include +#include #include static LttvTraceset *traceset; @@ -39,8 +43,7 @@ static LttvHooks *after_trace, *before_tracefile, *after_tracefile, - *before_event, - *after_event, + *event_hook, *main_hooks; static char *a_trace; @@ -59,6 +62,10 @@ void lttv_trace_option(void *hook_data) static gboolean process_traceset(void *hook_data, void *call_data) { + LttvAttributeValue value_expression, value_filter; + + LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); + LttvTracesetStats *tscs; LttvTracesetContext *tc; @@ -76,9 +83,26 @@ static gboolean process_traceset(void *hook_data, void *call_data) lttv_state_add_event_hooks(&tscs->parent); if(a_stats) lttv_stats_add_event_hooks(tscs); - 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); + g_assert(lttv_iattribute_find_by_path(attributes, "filter/expression", + LTTV_POINTER, &value_expression)); + + g_assert(lttv_iattribute_find_by_path(attributes, "filter/lttv_filter", + LTTV_POINTER, &value_filter)); + + *(value_filter.v_pointer) = lttv_filter_new(); + g_debug("Filter string: %s",((GString*)*(value_expression.v_pointer))->str); + + g_assert(lttv_filter_append_expression(*(value_filter.v_pointer),((GString*)*(value_expression.v_pointer))->str)); + + //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_process_traceset_begin(tc, + before_traceset, + before_trace, + before_tracefile, + event_hook, + NULL); start.tv_sec = 0; start.tv_nsec = 0; @@ -88,19 +112,31 @@ static gboolean process_traceset(void *hook_data, void *call_data) g_info("BatchAnalysis process traceset"); lttv_process_traceset_seek_time(tc, start); - lttv_process_traceset(tc, end, G_MAXULONG); + lttv_process_traceset_middle(tc, + end, + G_MAXULONG, + NULL); 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_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_process_traceset_end(tc, + after_traceset, + after_trace, + after_tracefile, + event_hook, + NULL); + + lttv_filter_destroy(*(value_filter.v_pointer)); lttv_state_remove_event_hooks(&tscs->parent); if(a_stats) lttv_stats_remove_event_hooks(tscs); lttv_context_fini(tc); g_object_unref(tscs); g_info("BatchAnalysis end process traceset"); + return FALSE; } @@ -132,8 +168,9 @@ static void init() after_trace = lttv_hooks_new(); before_tracefile = lttv_hooks_new(); after_tracefile = lttv_hooks_new(); - before_event = lttv_hooks_new(); - after_event = lttv_hooks_new(); + //before_event = lttv_hooks_new(); + //after_event = lttv_hooks_new(); + event_hook = lttv_hooks_new(); g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", LTTV_POINTER, &value)); @@ -153,17 +190,20 @@ static void init() g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after", LTTV_POINTER, &value)); *(value.v_pointer) = after_tracefile; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", - LTTV_POINTER, &value)); - *(value.v_pointer) = before_event; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after", + //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", + // LTTV_POINTER, &value)); + //*(value.v_pointer) = before_event; + //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after", + // LTTV_POINTER, &value)); + //*(value.v_pointer) = after_event; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event", LTTV_POINTER, &value)); - *(value.v_pointer) = after_event; + *(value.v_pointer) = event_hook; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before", LTTV_POINTER, &value)); g_assert((main_hooks = *(value.v_pointer)) != NULL); - lttv_hooks_add(main_hooks, process_traceset, NULL); + lttv_hooks_add(main_hooks, process_traceset, NULL, LTTV_PRIO_DEFAULT); } @@ -184,15 +224,17 @@ static void destroy() lttv_hooks_destroy(after_trace); lttv_hooks_destroy(before_tracefile); lttv_hooks_destroy(after_tracefile); - lttv_hooks_destroy(before_event); - lttv_hooks_destroy(after_event); + //lttv_hooks_destroy(before_event); + //lttv_hooks_destroy(after_event); + lttv_hooks_destroy(event_hook); lttv_hooks_remove_data(main_hooks, process_traceset, NULL); nb = lttv_traceset_number(traceset); for(i = 0 ; i < nb ; i++) { trace = lttv_traceset_get(traceset, i); ltt_trace_close(lttv_trace(trace)); - lttv_trace_destroy(trace); + /* This will be done by lttv_traceset_destroy */ + //lttv_trace_destroy(trace); } lttv_traceset_destroy(traceset); @@ -201,4 +243,4 @@ static void destroy() LTTV_MODULE("batchAnalysis", "Batch processing of a trace", \ "Run through a trace calling all the registered hooks", \ - init, destroy, "state", "stats", "option") + init, destroy, "state", "stats", "option","textFilter")