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