X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fbatchtest.c;h=8d4be06ea2b0c07afee533ee265af86bc99a605c;hb=f4b88a7dd49bfb6b88ea579410d7e4b59faaf73c;hp=101cef506e0cc51002bb5d976c86e7d3c8f67176;hpb=3865ea0940b718a7832b813a790f287140233efc;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/batchtest.c b/ltt/branches/poly/lttv/lttv/batchtest.c index 101cef50..8d4be06e 100644 --- a/ltt/branches/poly/lttv/lttv/batchtest.c +++ b/ltt/branches/poly/lttv/lttv/batchtest.c @@ -76,6 +76,7 @@ static gboolean a_test5, a_test6, a_test7, + a_test8, a_test_all; static GQuark QUARK_BLOCK_START, @@ -99,8 +100,11 @@ static void lttv_trace_option(void __UNUSED__ *hook_data) LttTrace *trace; trace = ltt_trace_open(a_trace); - if(trace == NULL) g_critical("cannot open trace %s", a_trace); - lttv_traceset_add(traceset, lttv_trace_new(trace)); + if(trace == NULL) { + g_critical("cannot open trace %s", a_trace); + } else { + lttv_traceset_add(traceset, lttv_trace_new(trace)); + } } static double get_time() @@ -166,19 +170,45 @@ gboolean trace_event(void __UNUSED__ *hook_data, void *call_data) LttEvent *e = ltt_tracefile_get_event(tfs->parent.tf); ltt_event_position(e, a_event_position); ltt_event_position_get(a_event_position, &tf, &nb_block, &offset, &tsc); - fprintf(stderr,"Event %s %lu.%09lu [%u %u tsc %llu]\n", + fprintf(stderr,"Event %s %lu.%09lu [%u 0x%x tsc %llu]\n", g_quark_to_string(ltt_eventtype_name(ltt_event_eventtype(e))), tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec, nb_block, offset, tsc); return FALSE; } +static LttTime count_previous_time = { 0, 0 }; gboolean count_event(void *hook_data, void __UNUSED__ *call_data) { + LttvTracefileState *tfs = (LttvTracefileState *)call_data; + LttTracefile *tracefile = tfs->parent.tf; + guint nb_block, offset; + LttTracefile *tf_pos; + guint64 tsc; + LttEvent * event = ltt_tracefile_get_event(tracefile); + LttTime time; guint *pcount = (guint *)hook_data; (*pcount)++; + + time = ltt_event_time(event); + ltt_event_position(event, a_event_position); + ltt_event_position_get(a_event_position, &tf_pos, &nb_block, &offset, &tsc); + + if(ltt_time_compare(time, count_previous_time) < 0) { + g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/0x%x", + g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile))), + g_quark_to_string(ltt_tracefile_name(tracefile)), + ltt_tracefile_num(tracefile), nb_block, offset); + g_warning("last time %lu.%lu vs current %lu.%lu", + count_previous_time.tv_sec, count_previous_time.tv_nsec, + time.tv_sec, time.tv_nsec); + } + count_previous_time = time; + + + return FALSE; } @@ -248,18 +278,28 @@ gboolean save_state_event(void *hook_data, void *call_data) } +static void sanitize_name(gchar *name) +{ + while(*name != '\0') { + if(*name == '/') *name = '_'; + name++; + } + +} + -static void compute_tracefile(LttTracefile *tracefile) +static void compute_tracefile(LttTracefile *tracefile, void *hook_data) { GString *filename; - guint i, j, nb_equal, nb_block, offset; + guint nb_equal, nb_block, offset; guint64 tsc; FILE *fp; LttTime time, previous_time; - LttEvent *event = ltt_event_new(); + LttEvent *event = ltt_tracefile_get_event(tracefile); LttFacility *facility; LttEventType *event_type; int err; + gchar mod_name[PATH_MAX]; /* start_count is always initialized in this function _if_ there is always * a block_start before a block_end. @@ -268,7 +308,13 @@ static void compute_tracefile(LttTracefile *tracefile) filename = g_string_new(""); - g_string_printf(filename, "%s.%u.%u.trace", a_dump_tracefiles, i, j); + strcpy(mod_name, g_quark_to_string(ltt_tracefile_name(tracefile))); + + sanitize_name(mod_name); + + g_warning("test %s test", g_quark_to_string(ltt_tracefile_name(tracefile))); + g_string_printf(filename, "%s.%s.%u.trace", a_dump_tracefiles, + mod_name, ltt_tracefile_num(tracefile)); fp = fopen(filename->str, "w"); if(fp == NULL) g_error("Cannot open %s", filename->str); g_string_free(filename, TRUE); @@ -285,15 +331,23 @@ static void compute_tracefile(LttTracefile *tracefile) time = ltt_event_time(event); ltt_event_position(event, a_event_position); ltt_event_position_get(a_event_position, &tf_pos, &nb_block, &offset, &tsc); - fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", - ltt_facility_name(facility), ltt_eventtype_name(event_type), + //fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", + fprintf(fp, "%s.%s: %llu %lu.%09lu position %u/%u, tracefile %s\n", + g_quark_to_string(ltt_facility_name(facility)), + g_quark_to_string(ltt_eventtype_name(event_type)), tsc, (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec, - nb_block, offset); + nb_block, offset, + g_quark_to_string(ltt_tracefile_name(tracefile))); if(ltt_time_compare(time, previous_time) < 0) { - g_warning("Time decreasing trace %d tracefile %d position %u/%u", - i, j, nb_block, offset); + g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/0x%x", + g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile))), + g_quark_to_string(ltt_tracefile_name(tracefile)), + ltt_tracefile_num(tracefile), nb_block, offset); + g_warning("last time %lu.%lu vs current %lu.%lu", + previous_time.tv_sec, previous_time.tv_nsec, + time.tv_sec, time.tv_nsec); } #if 0 //FIXME @@ -331,7 +385,6 @@ static void compute_tracefile(LttTracefile *tracefile) close: fclose(fp); - ltt_event_destroy(event); } static gboolean process_traceset(void __UNUSED__ *hook_data, @@ -368,6 +421,11 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, GData **tracefiles_groups; + struct compute_tracefile_group_args args; + + args.func = compute_tracefile; + args.func_args = NULL; + if(a_dump_tracefiles != NULL) { for(i = 0 ; i < lttv_traceset_number(traceset) ; i++) { trace = lttv_trace(lttv_traceset_get(traceset, i)); @@ -375,7 +433,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, g_datalist_foreach(tracefiles_groups, (GDataForeachFunc)compute_tracefile_group, - compute_tracefile); + &args); } } @@ -395,7 +453,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, lttv_hooks_add(event_hook, count_event, &count, LTTV_PRIO_DEFAULT); t = run_one_test(ts, ltt_time_zero, max_time); lttv_hooks_remove_data(event_hook, count_event, &count); - g_warning( + g_message( "Processing trace while counting events (%u events in %g seconds)", count, t); } @@ -406,7 +464,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, lttv_state_add_event_hooks(ts); t = run_one_test(ts, ltt_time_zero, max_time); lttv_state_remove_event_hooks(ts); - g_warning("Processing trace while updating state (%g seconds)", t); + g_message("Processing trace while updating state (%g seconds)", t); } /* Run through all events computing the state and writing it out @@ -446,7 +504,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, lttv_stats_add_event_hooks(tscs); t = run_one_test(ts, ltt_time_zero, max_time); lttv_stats_remove_event_hooks(tscs); - g_warning("Processing trace while counting stats (%g seconds)", t); + g_message("Processing trace while counting stats (%g seconds)", t); if(lttv_profile_memory) { g_message("Memory summary after computing stats"); @@ -482,7 +540,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, t = run_one_test(ts, ltt_time_zero, max_time); lttv_state_remove_event_hooks(ts); lttv_stats_remove_event_hooks(tscs); - g_warning( + g_message( "Processing trace while counting state and stats (%g seconds)", t); if(lttv_profile_memory) { @@ -521,7 +579,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, if(a_save_state_copy) lttv_hooks_remove_data(event_hook,save_state_copy_event, &save_state); - g_warning("Processing trace while updating/saving state (%g seconds)", t); + g_message("Processing trace while updating/saving state (%g seconds)", t); if(lttv_profile_memory) { g_message("Memory summary after computing/saving state"); @@ -541,7 +599,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, t = run_one_test(ts, save_state.write_time[j], save_state.write_time[j]); lttv_state_remove_event_hooks(ts); - g_warning("Seeking to %lu.%lu (%g seconds)", + g_message("Seeking to %lu.%lu (%g seconds)", save_state.write_time[j].tv_sec, save_state.write_time[j].tv_nsec, t); @@ -561,6 +619,36 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, } } + /* Seek at specified interval, using states computed in 6, making + * sure that there is no more than the number of events between + * state save interval to read before getting there. + */ + + if((a_test8 && a_test6) || a_test_all) { + g_message("Running test 8 : check save interval"); + LttTime time = tc->time_span.start_time; + LttTime interval; + interval.tv_sec = 0; + interval.tv_nsec = 175674987; + guint count; + + while(ltt_time_compare(time, tc->time_span.end_time) < 0) { + //g_message("Seeking at time %u.%u", time.tv_sec, time.tv_nsec); + lttv_process_traceset_seek_time(&ts->parent, ltt_time_zero); + lttv_state_traceset_seek_time_closest(ts, time); + /* We add no hook to the traceset, not necessary */ + count = lttv_process_traceset_middle(&ts->parent, + time, G_MAXUINT, NULL); + g_info("Number of events to jump over : %u", count); + + if(count > LTTV_STATE_SAVE_INTERVAL) + g_warning("Oops! Save interval is %u and it took %u events to seek to a time %lu.%lu supposed to be closer from the last saved state.", + LTTV_STATE_SAVE_INTERVAL, count, time.tv_sec, time.tv_nsec); + time = ltt_time_add(time, interval); + } + + } + if(a_trace_event) lttv_hooks_remove_data(event_hook, trace_event, NULL); g_free(save_state.write_time); @@ -666,6 +754,10 @@ static void init() lttv_option_add("test7", '7', "Test seeking to positions written out in 3", "", LTTV_OPT_NONE, &a_test7, NULL, NULL); + a_test8 = FALSE; + lttv_option_add("test8", '8', "Test seeking to positions using saved states computed at 6 : check if number of events fits", + "", LTTV_OPT_NONE, &a_test8, NULL, NULL); + a_test_all = FALSE; lttv_option_add("testall", 'a', "Run all tests ", "", LTTV_OPT_NONE, &a_test_all, NULL, NULL); @@ -740,6 +832,7 @@ static void destroy() lttv_option_remove("test5"); lttv_option_remove("test6"); lttv_option_remove("test7"); + lttv_option_remove("test8"); lttv_option_remove("testall"); lttv_hooks_destroy(before_traceset);