| 1 | /* This file is part of the Linux Trace Toolkit viewer |
| 2 | * Copyright (C) 2003-2004 Michel Dagenais |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License Version 2 as |
| 6 | * published by the Free Software Foundation; |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 16 | * MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | /* This module inserts a hook in the program main loop. This hook processes |
| 20 | all the events in the main tracefile while testing the speed and |
| 21 | functionality of the state and stats computations. */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include <config.h> |
| 25 | #endif |
| 26 | |
| 27 | #include <string.h> |
| 28 | #include <lttv/lttv.h> |
| 29 | #include <lttv/attribute.h> |
| 30 | #include <lttv/hook.h> |
| 31 | #include <lttv/option.h> |
| 32 | #include <lttv/module.h> |
| 33 | #include <lttv/tracecontext.h> |
| 34 | #include <lttv/state.h> |
| 35 | #include <lttv/stats.h> |
| 36 | #include <ltt/trace.h> |
| 37 | #include <ltt/event.h> |
| 38 | |
| 39 | #define __UNUSED__ __attribute__((__unused__)) |
| 40 | |
| 41 | static LttvTraceset *traceset; |
| 42 | |
| 43 | static LttvHooks |
| 44 | *before_traceset, |
| 45 | *after_traceset, |
| 46 | *before_trace, |
| 47 | *after_trace, |
| 48 | *before_tracefile, |
| 49 | *after_tracefile, |
| 50 | //*before_event, |
| 51 | //*after_event, |
| 52 | *event_hook, |
| 53 | *main_hooks; |
| 54 | |
| 55 | static char *a_trace; |
| 56 | |
| 57 | static char *a_dump_tracefiles; |
| 58 | |
| 59 | static char *a_save_sample; |
| 60 | |
| 61 | static int |
| 62 | a_sample_interval, |
| 63 | a_sample_number, |
| 64 | a_seek_number, |
| 65 | a_save_interval; |
| 66 | |
| 67 | static gboolean |
| 68 | a_trace_event, |
| 69 | a_save_state_copy, |
| 70 | a_test1, |
| 71 | a_test2, |
| 72 | a_test3, |
| 73 | a_test4, |
| 74 | a_test5, |
| 75 | a_test6, |
| 76 | a_test7, |
| 77 | a_test8, |
| 78 | a_test9, |
| 79 | a_test10, |
| 80 | a_test_all; |
| 81 | |
| 82 | static GQuark QUARK_BLOCK_START, |
| 83 | QUARK_BLOCK_END; |
| 84 | |
| 85 | LttEventPosition *a_event_position; |
| 86 | |
| 87 | typedef struct _save_state { |
| 88 | guint count; |
| 89 | FILE *fp; |
| 90 | guint interval; |
| 91 | guint position; |
| 92 | guint size; |
| 93 | LttTime *write_time; |
| 94 | guint version; |
| 95 | } SaveState; |
| 96 | |
| 97 | |
| 98 | static void lttv_trace_option(void __UNUSED__ *hook_data) |
| 99 | { |
| 100 | LttTrace *trace; |
| 101 | |
| 102 | trace = ltt_trace_open(a_trace); |
| 103 | if(trace == NULL) { |
| 104 | g_critical("cannot open trace %s", a_trace); |
| 105 | } else { |
| 106 | lttv_traceset_add(traceset, lttv_trace_new(trace)); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | static double get_time() |
| 111 | { |
| 112 | GTimeVal gt; |
| 113 | |
| 114 | g_get_current_time(>); |
| 115 | return gt.tv_sec + (double)gt.tv_usec / (double)1000000.0; |
| 116 | } |
| 117 | |
| 118 | static double run_one_test(LttvTracesetState *ts, LttTime start, LttTime end) |
| 119 | { |
| 120 | double t0, t1; |
| 121 | |
| 122 | unsigned int i; |
| 123 | |
| 124 | //lttv_traceset_context_add_hooks(&ts->parent, |
| 125 | //before_traceset, after_traceset, NULL, before_trace, after_trace, |
| 126 | //NULL, before_tracefile, after_tracefile, NULL, before_event, after_event); |
| 127 | lttv_process_traceset_begin(&ts->parent, |
| 128 | before_traceset, |
| 129 | before_trace, |
| 130 | before_tracefile, |
| 131 | event_hook, |
| 132 | NULL); |
| 133 | |
| 134 | for(i = 0 ; i < lttv_traceset_number(traceset) ; i++) { |
| 135 | ((LttvTraceState *)(ts->parent.traces[i]))->save_interval =a_save_interval; |
| 136 | } |
| 137 | |
| 138 | t0 = get_time(); |
| 139 | lttv_state_traceset_seek_time_closest(ts, start); |
| 140 | //lttv_process_traceset(&ts->parent, end, G_MAXULONG); |
| 141 | lttv_process_traceset_middle(&ts->parent, |
| 142 | end, |
| 143 | G_MAXULONG, |
| 144 | NULL); |
| 145 | t1 = get_time(); |
| 146 | |
| 147 | //lttv_traceset_context_remove_hooks(&ts->parent, |
| 148 | //before_traceset, after_traceset, NULL, before_trace, after_trace, |
| 149 | //NULL, before_tracefile, after_tracefile, NULL, before_event, after_event); |
| 150 | lttv_process_traceset_end(&ts->parent, |
| 151 | after_traceset, |
| 152 | after_trace, |
| 153 | after_tracefile, |
| 154 | event_hook, |
| 155 | NULL); |
| 156 | |
| 157 | return t1 - t0; |
| 158 | } |
| 159 | |
| 160 | |
| 161 | gboolean trace_event(void __UNUSED__ *hook_data, void *call_data) |
| 162 | { |
| 163 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
| 164 | |
| 165 | guint nb_block, offset; |
| 166 | |
| 167 | guint64 tsc; |
| 168 | |
| 169 | LttTracefile *tf; |
| 170 | LttEvent *e = ltt_tracefile_get_event(tfs->parent.tf); |
| 171 | ltt_event_position(e, a_event_position); |
| 172 | ltt_event_position_get(a_event_position, &tf, &nb_block, &offset, &tsc); |
| 173 | fprintf(stderr,"Event %s %lu.%09lu [%u 0x%x tsc %llu]\n", |
| 174 | g_quark_to_string(marker_get_info_from_id(ltt_tracefile_get_trace(tf), |
| 175 | ltt_event_id(e))->name), |
| 176 | tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec, |
| 177 | nb_block, offset, tsc); |
| 178 | return FALSE; |
| 179 | } |
| 180 | |
| 181 | static LttTime count_previous_time = { 0, 0 }; |
| 182 | |
| 183 | gboolean count_event(void *hook_data, void __UNUSED__ *call_data) |
| 184 | { |
| 185 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
| 186 | LttTracefile *tracefile = tfs->parent.tf; |
| 187 | guint nb_block, offset; |
| 188 | LttTracefile *tf_pos; |
| 189 | guint64 tsc; |
| 190 | LttEvent * event = ltt_tracefile_get_event(tracefile); |
| 191 | LttTime time; |
| 192 | guint *pcount = (guint *)hook_data; |
| 193 | |
| 194 | (*pcount)++; |
| 195 | |
| 196 | time = ltt_event_time(event); |
| 197 | ltt_event_position(event, a_event_position); |
| 198 | ltt_event_position_get(a_event_position, &tf_pos, &nb_block, &offset, &tsc); |
| 199 | |
| 200 | if(ltt_time_compare(time, count_previous_time) < 0) { |
| 201 | g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/0x%x", |
| 202 | g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile))), |
| 203 | g_quark_to_string(ltt_tracefile_name(tracefile)), |
| 204 | tfs->cpu, nb_block, offset); |
| 205 | g_warning("last time %lu.%lu vs current %lu.%lu", |
| 206 | count_previous_time.tv_sec, count_previous_time.tv_nsec, |
| 207 | time.tv_sec, time.tv_nsec); |
| 208 | } |
| 209 | count_previous_time = time; |
| 210 | |
| 211 | |
| 212 | |
| 213 | return FALSE; |
| 214 | } |
| 215 | |
| 216 | |
| 217 | gboolean save_state_copy_event(void *hook_data, void *call_data) |
| 218 | { |
| 219 | SaveState __UNUSED__ *save_state = (SaveState *)hook_data; |
| 220 | |
| 221 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
| 222 | |
| 223 | LttvTraceState *ts = (LttvTraceState *)tfs->parent.t_context; |
| 224 | |
| 225 | LttEvent *e = ltt_tracefile_get_event(tfs->parent.tf); |
| 226 | |
| 227 | GString *filename; |
| 228 | |
| 229 | FILE *fp; |
| 230 | |
| 231 | LttTrace *trace = ((LttvTracefileContext *)tfs)->t_context->t; |
| 232 | |
| 233 | if(ts->nb_event == 0 && |
| 234 | marker_get_info_from_id(trace, e->event_id)->name |
| 235 | == QUARK_BLOCK_START) { |
| 236 | if(a_save_sample != NULL) { |
| 237 | filename = g_string_new(""); |
| 238 | g_string_printf(filename, "%s.copy.%lu.%09lu.xml", a_save_sample, |
| 239 | tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec); |
| 240 | fp = fopen(filename->str, "w"); |
| 241 | if(fp == NULL) g_error("Cannot open %s", filename->str); |
| 242 | g_string_free(filename, TRUE); |
| 243 | lttv_state_write(ts, tfs->parent.timestamp, fp); |
| 244 | fclose(fp); |
| 245 | } //else lttv_state_write(ts, tfs->parent.timestamp, save_state->fp); |
| 246 | } |
| 247 | return FALSE; |
| 248 | } |
| 249 | |
| 250 | |
| 251 | gboolean save_state_event(void *hook_data, void *call_data) |
| 252 | { |
| 253 | SaveState *save_state = (SaveState *)hook_data; |
| 254 | |
| 255 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
| 256 | |
| 257 | LttvTraceState *ts = (LttvTraceState *)tfs->parent.t_context; |
| 258 | |
| 259 | GString *filename; |
| 260 | |
| 261 | FILE *fp; |
| 262 | |
| 263 | (save_state->count)++; |
| 264 | if(save_state->count % save_state->interval == 0 && |
| 265 | save_state->position < save_state->size) { |
| 266 | if(a_save_sample != NULL) { |
| 267 | filename = g_string_new(""); |
| 268 | g_string_printf(filename, "%s.%u.xml.%u", a_save_sample, |
| 269 | save_state->position, save_state->version); |
| 270 | fp = fopen(filename->str, "w"); |
| 271 | if(fp == NULL) g_error("Cannot open %s", filename->str); |
| 272 | g_string_free(filename, TRUE); |
| 273 | lttv_state_write(ts, tfs->parent.timestamp, fp); |
| 274 | fclose(fp); |
| 275 | } //else lttv_state_write(ts, tfs->parent.timestamp, save_state->fp); |
| 276 | |
| 277 | save_state->write_time[save_state->position] = tfs->parent.timestamp; |
| 278 | save_state->position++; |
| 279 | } |
| 280 | return FALSE; |
| 281 | } |
| 282 | |
| 283 | |
| 284 | static void sanitize_name(gchar *name) |
| 285 | { |
| 286 | while(*name != '\0') { |
| 287 | if(*name == '/') *name = '_'; |
| 288 | name++; |
| 289 | } |
| 290 | |
| 291 | } |
| 292 | |
| 293 | |
| 294 | static void compute_tracefile(LttTracefile *tracefile, void *hook_data) |
| 295 | { |
| 296 | GString *filename; |
| 297 | guint nb_equal, nb_block, offset; |
| 298 | guint64 tsc; |
| 299 | FILE *fp; |
| 300 | LttTime time, previous_time; |
| 301 | LttEvent *event = ltt_tracefile_get_event(tracefile); |
| 302 | //LttEventType *event_type; |
| 303 | struct marker_info *minfo; |
| 304 | int err; |
| 305 | gchar mod_name[PATH_MAX]; |
| 306 | |
| 307 | /* start_count is always initialized in this function _if_ there is always |
| 308 | * a block_start before a block_end. |
| 309 | */ |
| 310 | //long long unsigned cycle_count, start_count=0, delta_cycle; |
| 311 | |
| 312 | |
| 313 | filename = g_string_new(""); |
| 314 | strcpy(mod_name, g_quark_to_string(ltt_tracefile_name(tracefile))); |
| 315 | |
| 316 | sanitize_name(mod_name); |
| 317 | |
| 318 | g_warning("test %s test", g_quark_to_string(ltt_tracefile_name(tracefile))); |
| 319 | g_string_printf(filename, "%s.%s.%u.trace", a_dump_tracefiles, |
| 320 | mod_name, ltt_tracefile_cpu(tracefile)); |
| 321 | fp = fopen(filename->str, "w"); |
| 322 | if(fp == NULL) g_error("Cannot open %s", filename->str); |
| 323 | g_string_free(filename, TRUE); |
| 324 | err = ltt_tracefile_seek_time(tracefile, ltt_time_zero); |
| 325 | if(err) goto close; |
| 326 | |
| 327 | previous_time = ltt_time_zero; |
| 328 | nb_equal = 0; |
| 329 | |
| 330 | do { |
| 331 | LttTracefile *tf_pos; |
| 332 | //event_type = ltt_event_eventtype(event); |
| 333 | minfo = marker_get_info_from_id(ltt_tracefile_get_trace(tracefile), |
| 334 | ltt_event_id(event)); |
| 335 | time = ltt_event_time(event); |
| 336 | ltt_event_position(event, a_event_position); |
| 337 | ltt_event_position_get(a_event_position, &tf_pos, &nb_block, &offset, &tsc); |
| 338 | //fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", |
| 339 | fprintf(fp, "%s: %llu %lu.%09lu position %u/%u, tracefile %s\n", |
| 340 | g_quark_to_string(minfo->name), |
| 341 | tsc, (unsigned long)time.tv_sec, |
| 342 | (unsigned long)time.tv_nsec, |
| 343 | nb_block, offset, |
| 344 | g_quark_to_string(ltt_tracefile_name(tracefile))); |
| 345 | |
| 346 | if(ltt_time_compare(time, previous_time) < 0) { |
| 347 | g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/0x%x", |
| 348 | g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile))), |
| 349 | g_quark_to_string(ltt_tracefile_name(tracefile)), |
| 350 | ltt_tracefile_cpu(tracefile), nb_block, offset); |
| 351 | g_warning("last time %lu.%lu vs current %lu.%lu", |
| 352 | previous_time.tv_sec, previous_time.tv_nsec, |
| 353 | time.tv_sec, time.tv_nsec); |
| 354 | } |
| 355 | |
| 356 | #if 0 //FIXME |
| 357 | if(ltt_eventtype_name(event_type) == QUARK_BLOCK_START) { |
| 358 | start_count = cycle_count; |
| 359 | start_time = time; |
| 360 | } |
| 361 | else if(ltt_eventtype_name(event_type) == QUARK_BLOCK_END) { |
| 362 | delta_cycle = cycle_count - start_count; |
| 363 | end_nsec_sec = (long long unsigned)time.tv_sec * (long long unsigned)1000000000; |
| 364 | end_nsec_nsec = time.tv_nsec; |
| 365 | end_nsec = end_nsec_sec + end_nsec_nsec; |
| 366 | start_nsec = (long long unsigned)start_time.tv_sec * (long long unsigned)1000000000 + (long long unsigned)start_time.tv_nsec; |
| 367 | delta_nsec = end_nsec - start_nsec; |
| 368 | cycle_per_nsec = (double)delta_cycle / (double)delta_nsec; |
| 369 | nsec_per_cycle = (double)delta_nsec / (double)delta_cycle; |
| 370 | added_nsec = (double)delta_cycle * nsec_per_cycle; |
| 371 | interpolated_nsec = start_nsec + added_nsec; |
| 372 | added_nsec2 = (double)delta_cycle / cycle_per_nsec; |
| 373 | interpolated_nsec2 = start_nsec + added_nsec2; |
| 374 | |
| 375 | fprintf(fp,"Time: start_count %llu, end_count %llu, delta_cycle %llu, start_nsec %llu, end_nsec_sec %llu, end_nsec_nsec %llu, end_nsec %llu, delta_nsec %llu, cycle_per_nsec %.25f, nsec_per_cycle %.25f, added_nsec %llu, added_nsec2 %llu, interpolated_nsec %llu, interpolated_nsec2 %llu\n", start_count, cycle_count, delta_cycle, start_nsec, end_nsec_sec, end_nsec_nsec, end_nsec, delta_nsec, cycle_per_nsec, nsec_per_cycle, added_nsec, added_nsec2, interpolated_nsec, interpolated_nsec2); |
| 376 | } |
| 377 | else { |
| 378 | #endif //0 |
| 379 | if(ltt_time_compare(time, previous_time) == 0) |
| 380 | nb_equal++; |
| 381 | else if(nb_equal > 0) { |
| 382 | g_warning("Consecutive %d events with time %lu.%09lu", |
| 383 | nb_equal + 1, previous_time.tv_sec, previous_time.tv_nsec); |
| 384 | nb_equal = 0; |
| 385 | } |
| 386 | previous_time = time; |
| 387 | //} |
| 388 | } while((!ltt_tracefile_read(tracefile))); |
| 389 | |
| 390 | close: |
| 391 | fclose(fp); |
| 392 | } |
| 393 | |
| 394 | static gboolean process_traceset(void __UNUSED__ *hook_data, |
| 395 | void __UNUSED__ *call_data) |
| 396 | { |
| 397 | GString *filename; |
| 398 | LttvTracesetStats *tscs; |
| 399 | |
| 400 | LttvTracesetState *ts; |
| 401 | |
| 402 | LttvTracesetContext *tc; |
| 403 | |
| 404 | FILE *fp; |
| 405 | |
| 406 | double t; |
| 407 | |
| 408 | //guint count, nb_control, nb_tracefile, nb_block, nb_event; |
| 409 | //guint i, j, count, nb_control, nb_tracefile, nb_block, nb_event, nb_equal; |
| 410 | guint i, j, count; |
| 411 | |
| 412 | LttTrace *trace; |
| 413 | |
| 414 | LttTime max_time = { G_MAXULONG, G_MAXULONG }; |
| 415 | |
| 416 | a_event_position = ltt_event_position_new(); |
| 417 | |
| 418 | GData **tracefiles_groups; |
| 419 | |
| 420 | struct compute_tracefile_group_args args; |
| 421 | |
| 422 | args.func = compute_tracefile; |
| 423 | args.func_args = NULL; |
| 424 | |
| 425 | if(a_dump_tracefiles != NULL) { |
| 426 | for(i = 0 ; i < lttv_traceset_number(traceset) ; i++) { |
| 427 | trace = lttv_trace(lttv_traceset_get(traceset, i)); |
| 428 | tracefiles_groups = ltt_trace_get_tracefiles_groups(trace); |
| 429 | |
| 430 | g_datalist_foreach(tracefiles_groups, |
| 431 | (GDataForeachFunc)compute_tracefile_group, |
| 432 | &args); |
| 433 | |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | tscs = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); |
| 438 | ts = &tscs->parent; |
| 439 | tc = &tscs->parent.parent; |
| 440 | |
| 441 | lttv_context_init(tc, traceset); |
| 442 | |
| 443 | /* For each case compute and print the elapsed time. |
| 444 | The first case is simply to run through all events with a |
| 445 | simple counter. */ |
| 446 | |
| 447 | if(a_test1 || a_test_all) { |
| 448 | count = 0; |
| 449 | lttv_hooks_add(event_hook, count_event, &count, LTTV_PRIO_DEFAULT); |
| 450 | t = run_one_test(ts, ltt_time_zero, max_time); |
| 451 | lttv_hooks_remove_data(event_hook, count_event, &count); |
| 452 | g_message( |
| 453 | "Processing trace while counting events (%u events in %g seconds)", |
| 454 | count, t); |
| 455 | } |
| 456 | |
| 457 | /* Run through all events computing the state. */ |
| 458 | |
| 459 | if(a_test2 || a_test_all) { |
| 460 | lttv_state_add_event_hooks(ts); |
| 461 | t = run_one_test(ts, ltt_time_zero, max_time); |
| 462 | lttv_state_remove_event_hooks(ts); |
| 463 | g_message("Processing trace while updating state (%g seconds)", t); |
| 464 | } |
| 465 | |
| 466 | /* Run through all events computing the state and writing it out |
| 467 | periodically. */ |
| 468 | |
| 469 | SaveState save_state; |
| 470 | |
| 471 | save_state.interval = a_sample_interval; |
| 472 | save_state.size = a_sample_number; |
| 473 | save_state.fp = stderr; |
| 474 | save_state.write_time = g_new(LttTime, a_sample_number); |
| 475 | |
| 476 | |
| 477 | if(a_test3 || a_test_all) { |
| 478 | for(i = 0 ; i < 2 ; i++) { |
| 479 | save_state.count = 0; |
| 480 | save_state.position = 0; |
| 481 | save_state.version = i; |
| 482 | lttv_state_add_event_hooks(ts); |
| 483 | lttv_hooks_add(event_hook, save_state_event, &save_state, |
| 484 | LTTV_PRIO_DEFAULT); |
| 485 | t = run_one_test(ts, ltt_time_zero, max_time); |
| 486 | lttv_state_remove_event_hooks(ts); |
| 487 | lttv_hooks_remove_data(event_hook, save_state_event, &save_state); |
| 488 | g_warning("Processing while updating/writing state (%g seconds)", t); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | /* Run through all events computing the stats. */ |
| 493 | |
| 494 | if(a_test4 || a_test_all) { |
| 495 | if(lttv_profile_memory) { |
| 496 | g_message("Memory summary before computing stats"); |
| 497 | g_mem_profile(); |
| 498 | } |
| 499 | |
| 500 | lttv_stats_add_event_hooks(tscs); |
| 501 | t = run_one_test(ts, ltt_time_zero, max_time); |
| 502 | lttv_stats_remove_event_hooks(tscs); |
| 503 | g_message("Processing trace while counting stats (%g seconds)", t); |
| 504 | |
| 505 | if(lttv_profile_memory) { |
| 506 | g_message("Memory summary after computing stats"); |
| 507 | g_mem_profile(); |
| 508 | } |
| 509 | |
| 510 | lttv_stats_sum_traceset(tscs, ltt_time_infinite); |
| 511 | |
| 512 | if(lttv_profile_memory) { |
| 513 | g_message("Memory summary after summing stats"); |
| 514 | g_mem_profile(); |
| 515 | } |
| 516 | |
| 517 | lttv_context_fini(tc); |
| 518 | lttv_context_init(tc, traceset); |
| 519 | |
| 520 | if(lttv_profile_memory) { |
| 521 | g_message("Memory summary after cleaning up the stats"); |
| 522 | g_mem_profile(); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | /* Run through all events computing the state and stats. */ |
| 527 | |
| 528 | if(a_test5 || a_test_all) { |
| 529 | if(lttv_profile_memory) { |
| 530 | g_message("Memory summary before computing state and stats"); |
| 531 | g_mem_profile(); |
| 532 | } |
| 533 | |
| 534 | lttv_state_add_event_hooks(ts); |
| 535 | lttv_stats_add_event_hooks(tscs); |
| 536 | t = run_one_test(ts, ltt_time_zero, max_time); |
| 537 | lttv_state_remove_event_hooks(ts); |
| 538 | lttv_stats_remove_event_hooks(tscs); |
| 539 | g_message( |
| 540 | "Processing trace while counting state and stats (%g seconds)", t); |
| 541 | |
| 542 | if(lttv_profile_memory) { |
| 543 | g_message("Memory summary after computing and state and stats"); |
| 544 | g_mem_profile(); |
| 545 | } |
| 546 | |
| 547 | lttv_context_fini(tc); |
| 548 | lttv_context_init(tc, traceset); |
| 549 | |
| 550 | if(lttv_profile_memory) { |
| 551 | g_message("Memory summary after cleaning up the stats"); |
| 552 | g_mem_profile(); |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | /* Run through all events computing and saving the state. */ |
| 557 | |
| 558 | if(a_trace_event) lttv_hooks_add(event_hook, trace_event, NULL, |
| 559 | LTTV_PRIO_DEFAULT); |
| 560 | |
| 561 | if(a_test6 || a_test_all) { |
| 562 | if(lttv_profile_memory) { |
| 563 | g_message("Memory summary before computing and saving state"); |
| 564 | g_mem_profile(); |
| 565 | } |
| 566 | |
| 567 | lttv_state_add_event_hooks(ts); |
| 568 | lttv_state_save_add_event_hooks(ts); |
| 569 | if(a_save_state_copy) |
| 570 | lttv_hooks_add(event_hook, save_state_copy_event, &save_state, |
| 571 | LTTV_PRIO_DEFAULT); |
| 572 | t = run_one_test(ts, ltt_time_zero, max_time); |
| 573 | lttv_state_remove_event_hooks(ts); |
| 574 | lttv_state_save_remove_event_hooks(ts); |
| 575 | if(a_save_state_copy) |
| 576 | lttv_hooks_remove_data(event_hook,save_state_copy_event, &save_state); |
| 577 | |
| 578 | g_message("Processing trace while updating/saving state (%g seconds)", t); |
| 579 | |
| 580 | if(lttv_profile_memory) { |
| 581 | g_message("Memory summary after computing/saving state"); |
| 582 | g_mem_profile(); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | /* Seek a few times to each saved position */ |
| 587 | |
| 588 | if((a_test7 && a_test3) || a_test_all) { |
| 589 | g_assert(a_seek_number >= 0); |
| 590 | for(i = 0 ; i < (guint)a_seek_number ; i++) { |
| 591 | gint reverse_j; /* just to make sure j is unsigned */ |
| 592 | for(reverse_j = save_state.position - 1 ; reverse_j >= 0 ; reverse_j--) { |
| 593 | j = (guint)reverse_j; |
| 594 | lttv_state_add_event_hooks(ts); |
| 595 | t = run_one_test(ts, save_state.write_time[j], |
| 596 | save_state.write_time[j]); |
| 597 | lttv_state_remove_event_hooks(ts); |
| 598 | g_message("Seeking to %lu.%lu (%g seconds)", |
| 599 | save_state.write_time[j].tv_sec, save_state.write_time[j].tv_nsec, |
| 600 | t); |
| 601 | |
| 602 | if(a_save_sample != NULL) { |
| 603 | filename = g_string_new(""); |
| 604 | g_string_printf(filename, "%s.%d.xml.bak%d", a_save_sample, j, i); |
| 605 | fp = fopen(filename->str, "w"); |
| 606 | if(fp == NULL) g_error("Cannot open %s", filename->str); |
| 607 | g_string_free(filename, TRUE); |
| 608 | lttv_state_write((LttvTraceState *)tc->traces[0], |
| 609 | save_state.write_time[j], fp); |
| 610 | fclose(fp); |
| 611 | } |
| 612 | //else lttv_state_write((LttvTraceState *)tc->traces[0], |
| 613 | // save_state.write_time[j], save_state.fp); |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | /* Seek at specified interval, using states computed in 6, making |
| 619 | * sure that there is no more than the number of events between |
| 620 | * state save interval to read before getting there. |
| 621 | */ |
| 622 | |
| 623 | if((a_test8 && a_test6) || a_test_all) { |
| 624 | g_message("Running test 8 : check save interval"); |
| 625 | LttTime time = tc->time_span.start_time; |
| 626 | LttTime interval; |
| 627 | interval.tv_sec = 0; |
| 628 | interval.tv_nsec = 175674987; |
| 629 | guint count; |
| 630 | |
| 631 | while(ltt_time_compare(time, tc->time_span.end_time) < 0) { |
| 632 | //g_message("Seeking at time %u.%u", time.tv_sec, time.tv_nsec); |
| 633 | lttv_process_traceset_seek_time(&ts->parent, ltt_time_zero); |
| 634 | lttv_state_traceset_seek_time_closest(ts, time); |
| 635 | /* We add no hook to the traceset, not necessary */ |
| 636 | count = lttv_process_traceset_middle(&ts->parent, |
| 637 | time, G_MAXUINT, NULL); |
| 638 | g_info("Number of events to jump over : %u", count); |
| 639 | |
| 640 | if(count > LTTV_STATE_SAVE_INTERVAL) |
| 641 | 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.", |
| 642 | LTTV_STATE_SAVE_INTERVAL, count, time.tv_sec, time.tv_nsec); |
| 643 | time = ltt_time_add(time, interval); |
| 644 | } |
| 645 | |
| 646 | } |
| 647 | |
| 648 | if(a_test9 || a_test_all) { |
| 649 | double t0, t1; |
| 650 | /* Run seek_forward and seek_backward test */ |
| 651 | guint count; |
| 652 | LttvTracesetContext *tsc = &ts->parent; |
| 653 | LttvTracesetContextPosition *saved_pos = |
| 654 | lttv_traceset_context_position_new(tsc); |
| 655 | g_message("Running test 9 : seek_forward and seek_backward"); |
| 656 | lttv_process_traceset_seek_time(tsc, ltt_time_zero); |
| 657 | |
| 658 | count = lttv_process_traceset_seek_n_forward(tsc, 500, NULL, NULL, NULL, NULL, NULL, NULL); |
| 659 | g_assert(count == 500); |
| 660 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 661 | t0 = get_time(); |
| 662 | count = lttv_process_traceset_seek_n_forward(tsc, 150000, NULL, NULL, NULL, NULL, NULL, NULL); |
| 663 | t1 = get_time(); |
| 664 | g_message("Seek forward 150000 events in %g seconds", t1 - t0); |
| 665 | g_assert(count == 150000); |
| 666 | t0 = get_time(); |
| 667 | count = lttv_process_traceset_seek_n_backward(tsc, 150000, |
| 668 | seek_back_default_offset, lttv_process_traceset_seek_time, NULL, |
| 669 | NULL, NULL, NULL, NULL, NULL); |
| 670 | t1 = get_time(); |
| 671 | g_message("Seek backward 150000 events in %g seconds", t1 - t0); |
| 672 | g_assert(count == 150000); |
| 673 | if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) { |
| 674 | g_warning("Problem with seek_n ! Positions differ. (1)"); |
| 675 | } |
| 676 | |
| 677 | lttv_process_traceset_seek_n_forward(tsc, 500, NULL, NULL, NULL, NULL, NULL, NULL); |
| 678 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 679 | lttv_process_traceset_seek_n_forward(tsc, 15000, NULL, NULL, NULL, NULL, NULL, NULL); |
| 680 | lttv_process_traceset_seek_n_backward(tsc, 15005, |
| 681 | seek_back_default_offset, lttv_process_traceset_seek_time, NULL, |
| 682 | NULL, NULL, NULL, NULL, NULL); |
| 683 | lttv_process_traceset_seek_n_forward(tsc, 5, NULL, NULL, NULL, NULL, NULL, NULL); |
| 684 | if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) { |
| 685 | g_warning("Problem with seek_n ! Positions differ. (2)"); |
| 686 | } |
| 687 | |
| 688 | lttv_process_traceset_seek_time(tsc, ltt_time_infinite); |
| 689 | |
| 690 | count = lttv_process_traceset_seek_n_forward(tsc, 15000, NULL, NULL, NULL, NULL, NULL, NULL); |
| 691 | if(count > 0) |
| 692 | g_warning("Problem with seek_n ! Forward at end of traceset."); |
| 693 | |
| 694 | lttv_process_traceset_seek_time(tsc, ltt_time_infinite); |
| 695 | |
| 696 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 697 | t0 = get_time(); |
| 698 | lttv_process_traceset_seek_n_backward(tsc, 300, |
| 699 | seek_back_default_offset, lttv_process_traceset_seek_time, NULL, |
| 700 | NULL, NULL, NULL, NULL, NULL); |
| 701 | t1 = get_time(); |
| 702 | g_message("Seek backward 300 events in %g seconds", t1 - t0); |
| 703 | count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL, NULL, NULL, NULL, NULL, NULL); |
| 704 | count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL, NULL, NULL, NULL, NULL, NULL); |
| 705 | |
| 706 | if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) { |
| 707 | g_warning("Problem with seek_n ! Positions differ. (4)"); |
| 708 | } |
| 709 | |
| 710 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 711 | t0 = get_time(); |
| 712 | lttv_process_traceset_seek_n_backward(tsc, 10, |
| 713 | seek_back_default_offset, lttv_process_traceset_seek_time, NULL, |
| 714 | NULL, NULL, NULL, NULL, NULL); |
| 715 | t1 = get_time(); |
| 716 | g_message("Seek backward 10 events in %g seconds", t1 - t0); |
| 717 | t0 = get_time(); |
| 718 | count = lttv_process_traceset_seek_n_forward(tsc, 10, NULL, NULL, NULL, NULL, NULL, NULL); |
| 719 | t1 = get_time(); |
| 720 | g_message("Seek forward 10 events in %g seconds", t1 - t0); |
| 721 | |
| 722 | |
| 723 | /* try a volountary error */ |
| 724 | lttv_process_traceset_seek_time(tsc, ltt_time_infinite); |
| 725 | |
| 726 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 727 | lttv_process_traceset_seek_n_backward(tsc, 301, |
| 728 | seek_back_default_offset, lttv_process_traceset_seek_time, NULL, |
| 729 | NULL, NULL, NULL, NULL, NULL); |
| 730 | count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL, NULL, NULL, NULL, NULL, NULL); |
| 731 | count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL, NULL, NULL, NULL, NULL, NULL); |
| 732 | |
| 733 | if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) == 0) { |
| 734 | g_warning("Problem with seek_n ! Positions _should_ differ. (5)"); |
| 735 | } |
| 736 | |
| 737 | /* Try a seek by closest time : Hint : try this one with and without states |
| 738 | * computed. */ |
| 739 | lttv_process_traceset_seek_time(tsc, ltt_time_zero); |
| 740 | count = lttv_process_traceset_seek_n_forward(tsc, 200000, NULL, NULL, NULL, NULL, NULL, NULL); |
| 741 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 742 | t0 = get_time(); |
| 743 | lttv_process_traceset_seek_n_backward(tsc, 100301, |
| 744 | seek_back_default_offset, |
| 745 | (seek_time_fct)lttv_state_traceset_seek_time_closest, NULL, |
| 746 | NULL, NULL, NULL, NULL, NULL); |
| 747 | t1 = get_time(); |
| 748 | g_message("Seek backward 100301 events (with seek closest) in %g seconds", |
| 749 | t1 - t0); |
| 750 | count = lttv_process_traceset_seek_n_forward(tsc, 100301, NULL, NULL, NULL, NULL, NULL, NULL); |
| 751 | |
| 752 | if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) { |
| 753 | g_warning("Problem with seek_n with state seek time! Positions differ. (6)"); |
| 754 | } |
| 755 | |
| 756 | lttv_traceset_context_position_destroy(saved_pos); |
| 757 | } |
| 758 | |
| 759 | if(a_test10 || a_test_all) { |
| 760 | g_message("Running test 10 : check seek traceset context position"); |
| 761 | LttvTracesetContext *tsc = &ts->parent; |
| 762 | LttvTracesetContextPosition *saved_pos = |
| 763 | lttv_traceset_context_position_new(tsc); |
| 764 | |
| 765 | lttv_process_traceset_seek_time(tsc, ltt_time_zero); |
| 766 | lttv_process_traceset_seek_n_forward(tsc, 200000, NULL, NULL, NULL, NULL, NULL, NULL); |
| 767 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 768 | if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) != 0) |
| 769 | g_critical("Error in seek position. (1)"); |
| 770 | |
| 771 | lttv_process_traceset_seek_time(tsc, ltt_time_infinite); |
| 772 | lttv_process_traceset_seek_n_backward(tsc, 500, |
| 773 | seek_back_default_offset, lttv_process_traceset_seek_time, NULL, |
| 774 | NULL, NULL, NULL, NULL, NULL); |
| 775 | lttv_traceset_context_position_save(tsc, saved_pos); |
| 776 | |
| 777 | if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) != 0) |
| 778 | g_critical("Error in seek position. (2)"); |
| 779 | |
| 780 | lttv_traceset_context_position_destroy(saved_pos); |
| 781 | } |
| 782 | |
| 783 | if(a_trace_event) lttv_hooks_remove_data(event_hook, trace_event, NULL); |
| 784 | |
| 785 | g_free(save_state.write_time); |
| 786 | g_free(a_event_position); |
| 787 | lttv_context_fini(tc); |
| 788 | g_object_unref(tscs); |
| 789 | |
| 790 | if(lttv_profile_memory) { |
| 791 | g_message("Memory summary at the end of batchtest"); |
| 792 | g_mem_profile(); |
| 793 | } |
| 794 | |
| 795 | g_info("BatchTest end process traceset"); |
| 796 | return 0; |
| 797 | } |
| 798 | |
| 799 | |
| 800 | static void init() |
| 801 | { |
| 802 | LttvAttributeValue value; |
| 803 | |
| 804 | LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 805 | |
| 806 | g_info("Init batchtest.c"); |
| 807 | |
| 808 | /* Init GQuarks */ |
| 809 | QUARK_BLOCK_START = g_quark_from_string("block_start"); |
| 810 | QUARK_BLOCK_END = g_quark_from_string("block_end"); |
| 811 | |
| 812 | |
| 813 | lttv_option_add("trace", 't', |
| 814 | "add a trace to the trace set to analyse", |
| 815 | "pathname of the directory containing the trace", |
| 816 | LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL); |
| 817 | |
| 818 | a_trace_event = FALSE; |
| 819 | |
| 820 | a_dump_tracefiles = NULL; |
| 821 | lttv_option_add("dump-tracefiles", 'D', |
| 822 | "Write event by event the content of tracefiles", |
| 823 | "basename for the files where to dump events", |
| 824 | LTTV_OPT_STRING, &a_dump_tracefiles, NULL, NULL); |
| 825 | |
| 826 | a_save_sample = NULL; |
| 827 | lttv_option_add("save-sample", 's', |
| 828 | "Save state samples to multiple files", |
| 829 | "basename for the files containing the state samples", |
| 830 | LTTV_OPT_STRING, &a_save_sample, NULL, NULL); |
| 831 | |
| 832 | a_save_state_copy = FALSE; |
| 833 | lttv_option_add("save-state-copy", 'S', "Write the state saved for seeking", |
| 834 | "", LTTV_OPT_NONE, &a_save_state_copy, NULL, NULL); |
| 835 | |
| 836 | a_save_interval = 100000; |
| 837 | lttv_option_add("save-interval", 'i', |
| 838 | "Interval between saving state", |
| 839 | "number of events before a block start triggers saving state", |
| 840 | LTTV_OPT_INT, &a_save_interval, NULL, NULL); |
| 841 | |
| 842 | a_sample_interval = 100000; |
| 843 | lttv_option_add("sample-interval", 'S', |
| 844 | "Interval between sampling state", |
| 845 | "number of events before sampling and writing state", |
| 846 | LTTV_OPT_INT, &a_sample_interval, NULL, NULL); |
| 847 | |
| 848 | a_sample_number = 20; |
| 849 | lttv_option_add("sample-number", 'N', |
| 850 | "Number of state samples", |
| 851 | "maximum number", |
| 852 | LTTV_OPT_INT, &a_sample_number, NULL, NULL); |
| 853 | |
| 854 | a_seek_number = 200; |
| 855 | lttv_option_add("seek-number", 'K', |
| 856 | "Number of seek", |
| 857 | "number", |
| 858 | LTTV_OPT_INT, &a_seek_number, NULL, NULL); |
| 859 | |
| 860 | a_test1 = FALSE; |
| 861 | lttv_option_add("test1", '1', "Test just counting events", "", |
| 862 | LTTV_OPT_NONE, &a_test1, NULL, NULL); |
| 863 | |
| 864 | a_test2 = FALSE; |
| 865 | lttv_option_add("test2", '2', "Test computing the state", "", |
| 866 | LTTV_OPT_NONE, &a_test2, NULL, NULL); |
| 867 | |
| 868 | a_test3 = FALSE; |
| 869 | lttv_option_add("test3", '3', "Test computing the state, writing out a few", |
| 870 | "", LTTV_OPT_NONE, &a_test3, NULL, NULL); |
| 871 | |
| 872 | a_test4 = FALSE; |
| 873 | lttv_option_add("test4", '4', "Test computing the stats", "", |
| 874 | LTTV_OPT_NONE, &a_test4, NULL, NULL); |
| 875 | |
| 876 | a_test5 = FALSE; |
| 877 | lttv_option_add("test5", '5', "Test computing the state and stats", "", |
| 878 | LTTV_OPT_NONE, &a_test5, NULL, NULL); |
| 879 | |
| 880 | a_test6 = FALSE; |
| 881 | lttv_option_add("test6", '6', "Test computing and saving the state", "", |
| 882 | LTTV_OPT_NONE, &a_test6, NULL, NULL); |
| 883 | |
| 884 | a_test7 = FALSE; |
| 885 | lttv_option_add("test7", '7', "Test seeking to positions written out in 3", |
| 886 | "", LTTV_OPT_NONE, &a_test7, NULL, NULL); |
| 887 | |
| 888 | a_test8 = FALSE; |
| 889 | lttv_option_add("test8", '8', "Test seeking to positions using saved states computed at 6 : check if number of events fits", |
| 890 | "", LTTV_OPT_NONE, &a_test8, NULL, NULL); |
| 891 | |
| 892 | a_test9 = FALSE; |
| 893 | lttv_option_add("test9", '9', "Test seeking backward/forward positions", |
| 894 | "", LTTV_OPT_NONE, &a_test9, NULL, NULL); |
| 895 | |
| 896 | a_test10 = FALSE; |
| 897 | lttv_option_add("test10", ' ', "Test seeking traceset by position", |
| 898 | "", LTTV_OPT_NONE, &a_test10, NULL, NULL); |
| 899 | |
| 900 | |
| 901 | |
| 902 | a_test_all = FALSE; |
| 903 | lttv_option_add("testall", 'a', "Run all tests ", "", |
| 904 | LTTV_OPT_NONE, &a_test_all, NULL, NULL); |
| 905 | |
| 906 | traceset = lttv_traceset_new(); |
| 907 | |
| 908 | before_traceset = lttv_hooks_new(); |
| 909 | after_traceset = lttv_hooks_new(); |
| 910 | before_trace = lttv_hooks_new(); |
| 911 | after_trace = lttv_hooks_new(); |
| 912 | before_tracefile = lttv_hooks_new(); |
| 913 | after_tracefile = lttv_hooks_new(); |
| 914 | //before_event = lttv_hooks_new(); |
| 915 | //after_event = lttv_hooks_new(); |
| 916 | event_hook = lttv_hooks_new(); |
| 917 | |
| 918 | |
| 919 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", |
| 920 | LTTV_POINTER, &value)); |
| 921 | *(value.v_pointer) = before_traceset; |
| 922 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", |
| 923 | LTTV_POINTER, &value)); |
| 924 | *(value.v_pointer) = after_traceset; |
| 925 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before", |
| 926 | LTTV_POINTER, &value)); |
| 927 | *(value.v_pointer) = before_trace; |
| 928 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after", |
| 929 | LTTV_POINTER, &value)); |
| 930 | *(value.v_pointer) = after_trace; |
| 931 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before", |
| 932 | LTTV_POINTER, &value)); |
| 933 | *(value.v_pointer) = before_tracefile; |
| 934 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after", |
| 935 | LTTV_POINTER, &value)); |
| 936 | *(value.v_pointer) = after_tracefile; |
| 937 | //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", |
| 938 | // LTTV_POINTER, &value)); |
| 939 | //*(value.v_pointer) = before_event; |
| 940 | //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after", |
| 941 | // LTTV_POINTER, &value)); |
| 942 | //*(value.v_pointer) = after_event; |
| 943 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event", |
| 944 | LTTV_POINTER, &value)); |
| 945 | *(value.v_pointer) = event_hook; |
| 946 | g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before", |
| 947 | LTTV_POINTER, &value)); |
| 948 | g_assert((main_hooks = *(value.v_pointer)) != NULL); |
| 949 | lttv_hooks_add(main_hooks, process_traceset, NULL, LTTV_PRIO_DEFAULT); |
| 950 | } |
| 951 | |
| 952 | |
| 953 | static void destroy() |
| 954 | { |
| 955 | guint i, nb; |
| 956 | |
| 957 | LttvTrace *trace; |
| 958 | |
| 959 | g_info("Destroy batchAnalysis.c"); |
| 960 | |
| 961 | lttv_option_remove("trace"); |
| 962 | lttv_option_remove("dump-tracefiles"); |
| 963 | lttv_option_remove("save-sample"); |
| 964 | lttv_option_remove("save-state-copy"); |
| 965 | lttv_option_remove("sample-interval"); |
| 966 | lttv_option_remove("sample-number"); |
| 967 | lttv_option_remove("seek-number"); |
| 968 | lttv_option_remove("save-interval"); |
| 969 | lttv_option_remove("test1"); |
| 970 | lttv_option_remove("test2"); |
| 971 | lttv_option_remove("test3"); |
| 972 | lttv_option_remove("test4"); |
| 973 | lttv_option_remove("test5"); |
| 974 | lttv_option_remove("test6"); |
| 975 | lttv_option_remove("test7"); |
| 976 | lttv_option_remove("test8"); |
| 977 | lttv_option_remove("test9"); |
| 978 | lttv_option_remove("test10"); |
| 979 | lttv_option_remove("testall"); |
| 980 | |
| 981 | lttv_hooks_destroy(before_traceset); |
| 982 | lttv_hooks_destroy(after_traceset); |
| 983 | lttv_hooks_destroy(before_trace); |
| 984 | lttv_hooks_destroy(after_trace); |
| 985 | lttv_hooks_destroy(before_tracefile); |
| 986 | lttv_hooks_destroy(after_tracefile); |
| 987 | //lttv_hooks_destroy(before_event); |
| 988 | //lttv_hooks_destroy(after_event); |
| 989 | lttv_hooks_destroy(event_hook); |
| 990 | lttv_hooks_remove_data(main_hooks, process_traceset, NULL); |
| 991 | |
| 992 | nb = lttv_traceset_number(traceset); |
| 993 | for(i = 0 ; i < nb ; i++) { |
| 994 | trace = lttv_traceset_get(traceset, i); |
| 995 | lttv_traceset_remove(traceset,i); |
| 996 | ltt_trace_close(lttv_trace(trace)); |
| 997 | lttv_trace_destroy(trace); |
| 998 | } |
| 999 | |
| 1000 | lttv_traceset_destroy(traceset); |
| 1001 | } |
| 1002 | |
| 1003 | |
| 1004 | LTTV_MODULE("batchtest", "Batch processing of a trace for tests", \ |
| 1005 | "Run through a trace calling all the registered hooks for tests", \ |
| 1006 | init, destroy, "state", "stats", "option" ) |