uninitialized variables checked, plus O2 optimisations checked : strict aliasing...
[lttv.git] / ltt / branches / poly / lttv / lttv / batchtest.c
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 #include <string.h>
23
24 #include <lttv/lttv.h>
25 #include <lttv/attribute.h>
26 #include <lttv/hook.h>
27 #include <lttv/option.h>
28 #include <lttv/module.h>
29 #include <lttv/tracecontext.h>
30 #include <lttv/state.h>
31 #include <lttv/stats.h>
32 #include <ltt/trace.h>
33 #include <ltt/event.h>
34 #include <ltt/type.h>
35 #include <ltt/facility.h>
36
37 #define __UNUSED__ __attribute__((__unused__))
38
39 static LttvTraceset *traceset;
40
41 static LttvHooks
42 *before_traceset,
43 *after_traceset,
44 *before_trace,
45 *after_trace,
46 *before_tracefile,
47 *after_tracefile,
48 //*before_event,
49 //*after_event,
50 *event_hook,
51 *main_hooks;
52
53 static char *a_trace;
54
55 static char *a_dump_tracefiles;
56
57 static char *a_save_sample;
58
59 static int
60 a_sample_interval,
61 a_sample_number,
62 a_seek_number,
63 a_save_interval;
64
65 static gboolean
66 a_trace_event,
67 a_save_state_copy,
68 a_test1,
69 a_test2,
70 a_test3,
71 a_test4,
72 a_test5,
73 a_test6,
74 a_test7,
75 a_test_all;
76
77 LttEventPosition *a_event_position;
78
79 typedef struct _save_state {
80 guint count;
81 FILE *fp;
82 guint interval;
83 guint position;
84 guint size;
85 LttTime *write_time;
86 guint version;
87 } SaveState;
88
89
90 static void lttv_trace_option(void __UNUSED__ *hook_data)
91 {
92 LttTrace *trace;
93
94 trace = ltt_trace_open(a_trace);
95 if(trace == NULL) g_critical("cannot open trace %s", a_trace);
96 lttv_traceset_add(traceset, lttv_trace_new(trace));
97 }
98
99 static double get_time()
100 {
101 GTimeVal gt;
102
103 g_get_current_time(&gt);
104 return gt.tv_sec + (double)gt.tv_usec / (double)1000000.0;
105 }
106
107 static double run_one_test(LttvTracesetState *ts, LttTime start, LttTime end)
108 {
109 double t0, t1;
110
111 unsigned int i;
112
113 //lttv_traceset_context_add_hooks(&ts->parent,
114 //before_traceset, after_traceset, NULL, before_trace, after_trace,
115 //NULL, before_tracefile, after_tracefile, NULL, before_event, after_event);
116 lttv_process_traceset_begin(&ts->parent,
117 before_traceset,
118 before_trace,
119 before_tracefile,
120 event_hook,
121 NULL);
122
123 for(i = 0 ; i < lttv_traceset_number(traceset) ; i++) {
124 ((LttvTraceState *)(ts->parent.traces[i]))->save_interval =a_save_interval;
125 }
126
127 t0 = get_time();
128 lttv_state_traceset_seek_time_closest(ts, start);
129 //lttv_process_traceset(&ts->parent, end, G_MAXULONG);
130 lttv_process_traceset_middle(&ts->parent,
131 end,
132 G_MAXULONG,
133 NULL);
134 t1 = get_time();
135
136 //lttv_traceset_context_remove_hooks(&ts->parent,
137 //before_traceset, after_traceset, NULL, before_trace, after_trace,
138 //NULL, before_tracefile, after_tracefile, NULL, before_event, after_event);
139 lttv_process_traceset_end(&ts->parent,
140 after_traceset,
141 after_trace,
142 after_tracefile,
143 event_hook,
144 NULL);
145
146 return t1 - t0;
147 }
148
149
150 gboolean trace_event(void __UNUSED__ *hook_data, void *call_data)
151 {
152 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
153
154 guint nb_block, nb_event;
155
156 LttTracefile *tf;
157
158 ltt_event_position(tfs->parent.e, a_event_position);
159 ltt_event_position_get(a_event_position, &nb_block, &nb_event, &tf);
160 fprintf(stderr,"Event %s %lu.%09lu [%u %u]\n",
161 ltt_eventtype_name(ltt_event_eventtype(tfs->parent.e)),
162 tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec,
163 nb_block, nb_event);
164 return FALSE;
165 }
166
167
168 gboolean count_event(void *hook_data, void __UNUSED__ *call_data)
169 {
170 guint *pcount = (guint *)hook_data;
171
172 (*pcount)++;
173 return FALSE;
174 }
175
176
177 gboolean save_state_copy_event(void *hook_data, void *call_data)
178 {
179 SaveState __UNUSED__ *save_state = (SaveState *)hook_data;
180
181 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
182
183 LttvTraceState *ts = (LttvTraceState *)tfs->parent.t_context;
184
185 GString *filename;
186
187 FILE *fp;
188
189 if(ts->nb_event == 0 && strcmp(ltt_eventtype_name(
190 ltt_event_eventtype(tfs->parent.e)), "block_start") == 0) {
191 if(a_save_sample != NULL) {
192 filename = g_string_new("");
193 g_string_printf(filename, "%s.copy.%lu.%09lu.xml", a_save_sample,
194 tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec);
195 fp = fopen(filename->str, "w");
196 if(fp == NULL) g_error("Cannot open %s", filename->str);
197 g_string_free(filename, TRUE);
198 lttv_state_write(ts, tfs->parent.timestamp, fp);
199 fclose(fp);
200 } //else lttv_state_write(ts, tfs->parent.timestamp, save_state->fp);
201 }
202 return FALSE;
203 }
204
205
206 gboolean save_state_event(void *hook_data, void *call_data)
207 {
208 SaveState *save_state = (SaveState *)hook_data;
209
210 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
211
212 LttvTraceState *ts = (LttvTraceState *)tfs->parent.t_context;
213
214 GString *filename;
215
216 FILE *fp;
217
218 (save_state->count)++;
219 if(save_state->count % save_state->interval == 0 &&
220 save_state->position < save_state->size) {
221 if(a_save_sample != NULL) {
222 filename = g_string_new("");
223 g_string_printf(filename, "%s.%u.xml.%u", a_save_sample,
224 save_state->position, save_state->version);
225 fp = fopen(filename->str, "w");
226 if(fp == NULL) g_error("Cannot open %s", filename->str);
227 g_string_free(filename, TRUE);
228 lttv_state_write(ts, tfs->parent.timestamp, fp);
229 fclose(fp);
230 } //else lttv_state_write(ts, tfs->parent.timestamp, save_state->fp);
231
232 save_state->write_time[save_state->position] = tfs->parent.timestamp;
233 save_state->position++;
234 }
235 return FALSE;
236 }
237
238
239 static gboolean process_traceset(void __UNUSED__ *hook_data,
240 void __UNUSED__ *call_data)
241 {
242 LttvTracesetStats *tscs;
243
244 LttvTracesetState *ts;
245
246 LttvTracesetContext *tc;
247
248 GString *filename;
249
250 FILE *fp;
251
252 double t;
253
254 guint i, j, count, nb_control, nb_tracefile, nb_block, nb_event, nb_equal;
255
256 LttTrace *trace;
257
258 LttTracefile *tracefile, *tf;
259
260 LttEvent *event = ltt_event_new();
261
262 LttFacility *facility;
263
264 LttEventType *event_type;
265
266 LttTime time, previous_time;
267
268 /* start_count is always initialized in this function _if_ there is always
269 * a block_start before a block_end.
270 */
271 long long unsigned cycle_count, start_count=0, delta_cycle;
272
273 long long unsigned start_nsec, end_nsec, delta_nsec, added_nsec, added_nsec2;
274
275 double cycle_per_nsec, nsec_per_cycle;
276
277 long long interpolated_nsec, interpolated_nsec2, end_nsec_sec, end_nsec_nsec;
278
279 LttTime start_time;
280
281 LttTime zero_time = ltt_time_zero;
282
283 LttTime max_time = { G_MAXULONG, G_MAXULONG };
284
285 a_event_position = ltt_event_position_new();
286
287 if(a_dump_tracefiles != NULL) {
288 for(i = 0 ; i < lttv_traceset_number(traceset) ; i++) {
289 trace = lttv_trace(lttv_traceset_get(traceset, i));
290 nb_control = ltt_trace_control_tracefile_number(trace);
291 nb_tracefile = nb_control + ltt_trace_per_cpu_tracefile_number(trace);
292 for(j = 0 ; j < nb_tracefile ; j++) {
293 if(j < nb_control) {
294 tracefile = ltt_trace_control_tracefile_get(trace,j);
295 }
296 else {
297 tracefile = ltt_trace_per_cpu_tracefile_get(trace,j - nb_control);
298 }
299
300 filename = g_string_new("");
301 g_string_printf(filename, "%s.%u.%u.trace", a_dump_tracefiles, i, j);
302 fp = fopen(filename->str, "w");
303 if(fp == NULL) g_error("Cannot open %s", filename->str);
304 g_string_free(filename, TRUE);
305 ltt_tracefile_seek_time(tracefile, zero_time);
306 previous_time = zero_time;
307 nb_equal = 0;
308 while((ltt_tracefile_read(tracefile, event)) != NULL) {
309 facility = ltt_event_facility(event);
310 event_type = ltt_event_eventtype(event);
311 time = ltt_event_time(event);
312 cycle_count = ltt_event_cycle_count(event);
313 ltt_event_position(event, a_event_position);
314 ltt_event_position_get(a_event_position, &nb_block, &nb_event, &tf);
315 fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n",
316 ltt_facility_name(facility), ltt_eventtype_name(event_type),
317 cycle_count, (unsigned long)time.tv_sec,
318 (unsigned long)time.tv_nsec,
319 nb_block, nb_event);
320
321 if(ltt_time_compare(time, previous_time) < 0) {
322 g_warning("Time decreasing trace %d tracefile %d position %u/%u",
323 i, j, nb_block, nb_event);
324 }
325
326 if(strcmp(ltt_eventtype_name(event_type),"block_start") == 0) {
327 start_count = cycle_count;
328 start_time = time;
329 }
330 else if(strcmp(ltt_eventtype_name(event_type),"block_end") == 0) {
331 delta_cycle = cycle_count - start_count;
332 end_nsec_sec = (long long unsigned)time.tv_sec * (long long unsigned)1000000000;
333 end_nsec_nsec = time.tv_nsec;
334 end_nsec = end_nsec_sec + end_nsec_nsec;
335 start_nsec = (long long unsigned)start_time.tv_sec * (long long unsigned)1000000000 + (long long unsigned)start_time.tv_nsec;
336 delta_nsec = end_nsec - start_nsec;
337 cycle_per_nsec = (double)delta_cycle / (double)delta_nsec;
338 nsec_per_cycle = (double)delta_nsec / (double)delta_cycle;
339 added_nsec = (double)delta_cycle * nsec_per_cycle;
340 interpolated_nsec = start_nsec + added_nsec;
341 added_nsec2 = (double)delta_cycle / cycle_per_nsec;
342 interpolated_nsec2 = start_nsec + added_nsec2;
343
344 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);
345 }
346 else {
347 if(ltt_time_compare(time, previous_time) == 0) nb_equal++;
348 else if(nb_equal > 0) {
349 g_warning("Consecutive %d events with time %lu.%09lu",
350 nb_equal + 1, previous_time.tv_sec, previous_time.tv_nsec);
351 nb_equal = 0;
352 }
353 previous_time = time;
354 }
355 }
356 fclose(fp);
357 }
358 }
359 }
360
361 tscs = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
362 ts = &tscs->parent;
363 tc = &tscs->parent.parent;
364
365 lttv_context_init(tc, traceset);
366
367 /* For each case compute and print the elapsed time.
368 The first case is simply to run through all events with a
369 simple counter. */
370
371 if(a_test1 || a_test_all) {
372 count = 0;
373 lttv_hooks_add(event_hook, count_event, &count, LTTV_PRIO_DEFAULT);
374 t = run_one_test(ts, zero_time, max_time);
375 lttv_hooks_remove_data(event_hook, count_event, &count);
376 g_warning(
377 "Processing trace while counting events (%u events in %g seconds)",
378 count, t);
379 }
380
381 /* Run through all events computing the state. */
382
383 if(a_test2 || a_test_all) {
384 lttv_state_add_event_hooks(ts);
385 t = run_one_test(ts, zero_time, max_time);
386 lttv_state_remove_event_hooks(ts);
387 g_warning("Processing trace while updating state (%g seconds)", t);
388 }
389
390 /* Run through all events computing the state and writing it out
391 periodically. */
392
393 SaveState save_state;
394
395 save_state.interval = a_sample_interval;
396 save_state.size = a_sample_number;
397 save_state.fp = stderr;
398 save_state.write_time = g_new(LttTime, a_sample_number);
399
400
401 if(a_test3 || a_test_all) {
402 for(i = 0 ; i < 2 ; i++) {
403 save_state.count = 0;
404 save_state.position = 0;
405 save_state.version = i;
406 lttv_state_add_event_hooks(ts);
407 lttv_hooks_add(event_hook, save_state_event, &save_state,
408 LTTV_PRIO_DEFAULT);
409 t = run_one_test(ts, zero_time, max_time);
410 lttv_state_remove_event_hooks(ts);
411 lttv_hooks_remove_data(event_hook, save_state_event, &save_state);
412 g_warning("Processing while updating/writing state (%g seconds)", t);
413 }
414 }
415
416 /* Run through all events computing the stats. */
417
418 if(a_test4 || a_test_all) {
419 if(lttv_profile_memory) {
420 g_message("Memory summary before computing stats");
421 g_mem_profile();
422 }
423
424 lttv_stats_add_event_hooks(tscs);
425 t = run_one_test(ts, zero_time, max_time);
426 lttv_stats_remove_event_hooks(tscs);
427 g_warning("Processing trace while counting stats (%g seconds)", t);
428
429 if(lttv_profile_memory) {
430 g_message("Memory summary after computing stats");
431 g_mem_profile();
432 }
433
434 lttv_stats_sum_traceset(tscs);
435
436 if(lttv_profile_memory) {
437 g_message("Memory summary after summing stats");
438 g_mem_profile();
439 }
440
441 lttv_context_fini(tc);
442 lttv_context_init(tc, traceset);
443
444 if(lttv_profile_memory) {
445 g_message("Memory summary after cleaning up the stats");
446 g_mem_profile();
447 }
448 }
449
450 /* Run through all events computing the state and stats. */
451
452 if(a_test5 || a_test_all) {
453 if(lttv_profile_memory) {
454 g_message("Memory summary before computing state and stats");
455 g_mem_profile();
456 }
457
458 lttv_state_add_event_hooks(ts);
459 lttv_stats_add_event_hooks(tscs);
460 t = run_one_test(ts, zero_time, max_time);
461 lttv_state_remove_event_hooks(ts);
462 lttv_stats_remove_event_hooks(tscs);
463 g_warning(
464 "Processing trace while counting state and stats (%g seconds)", t);
465
466 if(lttv_profile_memory) {
467 g_message("Memory summary after computing and state and stats");
468 g_mem_profile();
469 }
470
471 lttv_context_fini(tc);
472 lttv_context_init(tc, traceset);
473
474 if(lttv_profile_memory) {
475 g_message("Memory summary after cleaning up the stats");
476 g_mem_profile();
477 }
478 }
479
480 /* Run through all events computing and saving the state. */
481
482 if(a_trace_event) lttv_hooks_add(event_hook, trace_event, NULL,
483 LTTV_PRIO_DEFAULT);
484
485 if(a_test6 || a_test_all) {
486 if(lttv_profile_memory) {
487 g_message("Memory summary before computing and saving state");
488 g_mem_profile();
489 }
490
491 lttv_state_add_event_hooks(ts);
492 lttv_state_save_add_event_hooks(ts);
493 if(a_save_state_copy)
494 lttv_hooks_add(event_hook, save_state_copy_event, &save_state,
495 LTTV_PRIO_DEFAULT);
496 t = run_one_test(ts, zero_time, max_time);
497 lttv_state_remove_event_hooks(ts);
498 lttv_state_save_remove_event_hooks(ts);
499 if(a_save_state_copy)
500 lttv_hooks_remove_data(event_hook,save_state_copy_event, &save_state);
501
502 g_warning("Processing trace while updating/saving state (%g seconds)", t);
503
504 if(lttv_profile_memory) {
505 g_message("Memory summary after computing/saving state");
506 g_mem_profile();
507 }
508 }
509
510 /* Seek a few times to each saved position */
511
512 if((a_test7 && a_test3) || a_test_all) {
513 g_assert(a_seek_number >= 0);
514 for(i = 0 ; i < (guint)a_seek_number ; i++) {
515 gint reverse_j; /* just to make sure j is unsigned */
516 for(reverse_j = save_state.position - 1 ; reverse_j >= 0 ; reverse_j--) {
517 j = (guint)reverse_j;
518 lttv_state_add_event_hooks(ts);
519 t = run_one_test(ts, save_state.write_time[j],
520 save_state.write_time[j]);
521 lttv_state_remove_event_hooks(ts);
522 g_warning("Seeking to %lu.%lu (%g seconds)",
523 save_state.write_time[j].tv_sec, save_state.write_time[j].tv_nsec,
524 t);
525
526 if(a_save_sample != NULL) {
527 filename = g_string_new("");
528 g_string_printf(filename, "%s.%d.xml.bak%d", a_save_sample, j, i);
529 fp = fopen(filename->str, "w");
530 if(fp == NULL) g_error("Cannot open %s", filename->str);
531 g_string_free(filename, TRUE);
532 lttv_state_write((LttvTraceState *)tc->traces[0],
533 save_state.write_time[j], fp);
534 fclose(fp);
535 }
536 //else lttv_state_write((LttvTraceState *)tc->traces[0],
537 // save_state.write_time[j], save_state.fp);
538 }
539 }
540 }
541
542 if(a_trace_event) lttv_hooks_remove_data(event_hook, trace_event, NULL);
543
544 g_free(save_state.write_time);
545 g_free(a_event_position);
546 lttv_context_fini(tc);
547 g_object_unref(tscs);
548 ltt_event_destroy(event);
549
550 if(lttv_profile_memory) {
551 g_message("Memory summary at the end of batchtest");
552 g_mem_profile();
553 }
554
555 g_info("BatchTest end process traceset");
556 return 0;
557 }
558
559
560 static void init()
561 {
562 LttvAttributeValue value;
563
564 LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
565
566 g_info("Init batchtest.c");
567
568 lttv_option_add("trace", 't',
569 "add a trace to the trace set to analyse",
570 "pathname of the directory containing the trace",
571 LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL);
572
573 a_trace_event = FALSE;
574
575 a_dump_tracefiles = NULL;
576 lttv_option_add("dump-tracefiles", 'D',
577 "Write event by event the content of tracefiles",
578 "basename for the files where to dump events",
579 LTTV_OPT_STRING, &a_dump_tracefiles, NULL, NULL);
580
581 a_save_sample = NULL;
582 lttv_option_add("save-sample", 's',
583 "Save state samples to multiple files",
584 "basename for the files containing the state samples",
585 LTTV_OPT_STRING, &a_save_sample, NULL, NULL);
586
587 a_save_state_copy = FALSE;
588 lttv_option_add("save-state-copy", 'S', "Write the state saved for seeking",
589 "", LTTV_OPT_NONE, &a_save_state_copy, NULL, NULL);
590
591 a_save_interval = 100000;
592 lttv_option_add("save-interval", 'i',
593 "Interval between saving state",
594 "number of events before a block start triggers saving state",
595 LTTV_OPT_INT, &a_save_interval, NULL, NULL);
596
597 a_sample_interval = 100000;
598 lttv_option_add("sample-interval", 'S',
599 "Interval between sampling state",
600 "number of events before sampling and writing state",
601 LTTV_OPT_INT, &a_sample_interval, NULL, NULL);
602
603 a_sample_number = 20;
604 lttv_option_add("sample-number", 'N',
605 "Number of state samples",
606 "maximum number",
607 LTTV_OPT_INT, &a_sample_number, NULL, NULL);
608
609 a_seek_number = 200;
610 lttv_option_add("seek-number", 'K',
611 "Number of seek",
612 "number",
613 LTTV_OPT_INT, &a_seek_number, NULL, NULL);
614
615 a_test1 = FALSE;
616 lttv_option_add("test1", '1', "Test just counting events", "",
617 LTTV_OPT_NONE, &a_test1, NULL, NULL);
618
619 a_test2 = FALSE;
620 lttv_option_add("test2", '2', "Test computing the state", "",
621 LTTV_OPT_NONE, &a_test2, NULL, NULL);
622
623 a_test3 = FALSE;
624 lttv_option_add("test3", '3', "Test computing the state, writing out a few",
625 "", LTTV_OPT_NONE, &a_test3, NULL, NULL);
626
627 a_test4 = FALSE;
628 lttv_option_add("test4", '4', "Test computing the stats", "",
629 LTTV_OPT_NONE, &a_test4, NULL, NULL);
630
631 a_test5 = FALSE;
632 lttv_option_add("test5", '5', "Test computing the state and stats", "",
633 LTTV_OPT_NONE, &a_test5, NULL, NULL);
634
635 a_test6 = FALSE;
636 lttv_option_add("test6", '6', "Test computing and saving the state", "",
637 LTTV_OPT_NONE, &a_test6, NULL, NULL);
638
639 a_test7 = FALSE;
640 lttv_option_add("test7", '7', "Test seeking to positions written out in 3",
641 "", LTTV_OPT_NONE, &a_test7, NULL, NULL);
642
643 a_test_all = FALSE;
644 lttv_option_add("testall", 'a', "Run all tests ", "",
645 LTTV_OPT_NONE, &a_test_all, NULL, NULL);
646
647 traceset = lttv_traceset_new();
648
649 before_traceset = lttv_hooks_new();
650 after_traceset = lttv_hooks_new();
651 before_trace = lttv_hooks_new();
652 after_trace = lttv_hooks_new();
653 before_tracefile = lttv_hooks_new();
654 after_tracefile = lttv_hooks_new();
655 //before_event = lttv_hooks_new();
656 //after_event = lttv_hooks_new();
657 event_hook = lttv_hooks_new();
658
659
660 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before",
661 LTTV_POINTER, &value));
662 *(value.v_pointer) = before_traceset;
663 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after",
664 LTTV_POINTER, &value));
665 *(value.v_pointer) = after_traceset;
666 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before",
667 LTTV_POINTER, &value));
668 *(value.v_pointer) = before_trace;
669 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after",
670 LTTV_POINTER, &value));
671 *(value.v_pointer) = after_trace;
672 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before",
673 LTTV_POINTER, &value));
674 *(value.v_pointer) = before_tracefile;
675 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after",
676 LTTV_POINTER, &value));
677 *(value.v_pointer) = after_tracefile;
678 //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before",
679 // LTTV_POINTER, &value));
680 //*(value.v_pointer) = before_event;
681 //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after",
682 // LTTV_POINTER, &value));
683 //*(value.v_pointer) = after_event;
684 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event",
685 LTTV_POINTER, &value));
686 *(value.v_pointer) = event_hook;
687 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before",
688 LTTV_POINTER, &value));
689 g_assert((main_hooks = *(value.v_pointer)) != NULL);
690 lttv_hooks_add(main_hooks, process_traceset, NULL, LTTV_PRIO_DEFAULT);
691 }
692
693
694 static void destroy()
695 {
696 guint i, nb;
697
698 LttvTrace *trace;
699
700 g_info("Destroy batchAnalysis.c");
701
702 lttv_option_remove("trace");
703 lttv_option_remove("dump-tracefiles");
704 lttv_option_remove("save-sample");
705 lttv_option_remove("save-state-copy");
706 lttv_option_remove("sample-interval");
707 lttv_option_remove("sample-number");
708 lttv_option_remove("seek-number");
709 lttv_option_remove("save-interval");
710 lttv_option_remove("test1");
711 lttv_option_remove("test2");
712 lttv_option_remove("test3");
713 lttv_option_remove("test4");
714 lttv_option_remove("test5");
715 lttv_option_remove("test6");
716 lttv_option_remove("test7");
717 lttv_option_remove("testall");
718
719 lttv_hooks_destroy(before_traceset);
720 lttv_hooks_destroy(after_traceset);
721 lttv_hooks_destroy(before_trace);
722 lttv_hooks_destroy(after_trace);
723 lttv_hooks_destroy(before_tracefile);
724 lttv_hooks_destroy(after_tracefile);
725 //lttv_hooks_destroy(before_event);
726 //lttv_hooks_destroy(after_event);
727 lttv_hooks_destroy(event_hook);
728 lttv_hooks_remove_data(main_hooks, process_traceset, NULL);
729
730 nb = lttv_traceset_number(traceset);
731 for(i = 0 ; i < nb ; i++) {
732 trace = lttv_traceset_get(traceset, i);
733 lttv_traceset_remove(traceset,i);
734 ltt_trace_close(lttv_trace(trace));
735 lttv_trace_destroy(trace);
736 }
737
738 lttv_traceset_destroy(traceset);
739 }
740
741
742 LTTV_MODULE("batchtest", "Batch processing of a trace for tests", \
743 "Run through a trace calling all the registered hooks for tests", \
744 init, destroy, "state", "stats", "option" )
This page took 0.049134 seconds and 4 git commands to generate.