1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
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;
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.
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,
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. */
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>
39 #include <ltt/facility.h>
41 #define __UNUSED__ __attribute__((__unused__))
43 static LttvTraceset
*traceset
;
59 static char *a_dump_tracefiles
;
61 static char *a_save_sample
;
81 static GQuark QUARK_BLOCK_START
,
84 LttEventPosition
*a_event_position
;
86 typedef struct _save_state
{
97 static void lttv_trace_option(void __UNUSED__
*hook_data
)
101 trace
= ltt_trace_open(a_trace
);
102 if(trace
== NULL
) g_critical("cannot open trace %s", a_trace
);
103 lttv_traceset_add(traceset
, lttv_trace_new(trace
));
106 static double get_time()
110 g_get_current_time(>
);
111 return gt
.tv_sec
+ (double)gt
.tv_usec
/ (double)1000000.0;
114 static double run_one_test(LttvTracesetState
*ts
, LttTime start
, LttTime end
)
120 //lttv_traceset_context_add_hooks(&ts->parent,
121 //before_traceset, after_traceset, NULL, before_trace, after_trace,
122 //NULL, before_tracefile, after_tracefile, NULL, before_event, after_event);
123 lttv_process_traceset_begin(&ts
->parent
,
130 for(i
= 0 ; i
< lttv_traceset_number(traceset
) ; i
++) {
131 ((LttvTraceState
*)(ts
->parent
.traces
[i
]))->save_interval
=a_save_interval
;
135 lttv_state_traceset_seek_time_closest(ts
, start
);
136 //lttv_process_traceset(&ts->parent, end, G_MAXULONG);
137 lttv_process_traceset_middle(&ts
->parent
,
143 //lttv_traceset_context_remove_hooks(&ts->parent,
144 //before_traceset, after_traceset, NULL, before_trace, after_trace,
145 //NULL, before_tracefile, after_tracefile, NULL, before_event, after_event);
146 lttv_process_traceset_end(&ts
->parent
,
157 gboolean
trace_event(void __UNUSED__
*hook_data
, void *call_data
)
159 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
161 guint nb_block
, offset
;
166 LttEvent
*e
= ltt_tracefile_get_event(tfs
->parent
.tf
);
167 ltt_event_position(e
, a_event_position
);
168 ltt_event_position_get(a_event_position
, &tf
, &nb_block
, &offset
, &tsc
);
169 fprintf(stderr
,"Event %s %lu.%09lu [%u %u tsc %llu]\n",
170 g_quark_to_string(ltt_eventtype_name(ltt_event_eventtype(e
))),
171 tfs
->parent
.timestamp
.tv_sec
, tfs
->parent
.timestamp
.tv_nsec
,
172 nb_block
, offset
, tsc
);
177 gboolean
count_event(void *hook_data
, void __UNUSED__
*call_data
)
179 guint
*pcount
= (guint
*)hook_data
;
186 gboolean
save_state_copy_event(void *hook_data
, void *call_data
)
188 SaveState __UNUSED__
*save_state
= (SaveState
*)hook_data
;
190 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
192 LttvTraceState
*ts
= (LttvTraceState
*)tfs
->parent
.t_context
;
194 LttEvent
*e
= ltt_tracefile_get_event(tfs
->parent
.tf
);
200 if(ts
->nb_event
== 0 &&
201 ltt_eventtype_name(ltt_event_eventtype(e
))
202 == QUARK_BLOCK_START
) {
203 if(a_save_sample
!= NULL
) {
204 filename
= g_string_new("");
205 g_string_printf(filename
, "%s.copy.%lu.%09lu.xml", a_save_sample
,
206 tfs
->parent
.timestamp
.tv_sec
, tfs
->parent
.timestamp
.tv_nsec
);
207 fp
= fopen(filename
->str
, "w");
208 if(fp
== NULL
) g_error("Cannot open %s", filename
->str
);
209 g_string_free(filename
, TRUE
);
210 lttv_state_write(ts
, tfs
->parent
.timestamp
, fp
);
212 } //else lttv_state_write(ts, tfs->parent.timestamp, save_state->fp);
218 gboolean
save_state_event(void *hook_data
, void *call_data
)
220 SaveState
*save_state
= (SaveState
*)hook_data
;
222 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
224 LttvTraceState
*ts
= (LttvTraceState
*)tfs
->parent
.t_context
;
230 (save_state
->count
)++;
231 if(save_state
->count
% save_state
->interval
== 0 &&
232 save_state
->position
< save_state
->size
) {
233 if(a_save_sample
!= NULL
) {
234 filename
= g_string_new("");
235 g_string_printf(filename
, "%s.%u.xml.%u", a_save_sample
,
236 save_state
->position
, save_state
->version
);
237 fp
= fopen(filename
->str
, "w");
238 if(fp
== NULL
) g_error("Cannot open %s", filename
->str
);
239 g_string_free(filename
, TRUE
);
240 lttv_state_write(ts
, tfs
->parent
.timestamp
, fp
);
242 } //else lttv_state_write(ts, tfs->parent.timestamp, save_state->fp);
244 save_state
->write_time
[save_state
->position
] = tfs
->parent
.timestamp
;
245 save_state
->position
++;
251 static void sanitize_name(gchar
*name
)
253 while(*name
!= '\0') {
254 if(*name
== '/') *name
= '_';
261 static void compute_tracefile(LttTracefile
*tracefile
, void *hook_data
)
264 guint nb_equal
, nb_block
, offset
;
267 LttTime time
, previous_time
;
268 LttEvent
*event
= ltt_tracefile_get_event(tracefile
);
269 LttFacility
*facility
;
270 LttEventType
*event_type
;
272 gchar mod_name
[PATH_MAX
];
274 /* start_count is always initialized in this function _if_ there is always
275 * a block_start before a block_end.
277 long long unsigned cycle_count
, start_count
=0, delta_cycle
;
280 filename
= g_string_new("");
281 strcpy(mod_name
, g_quark_to_string(ltt_tracefile_name(tracefile
)));
283 sanitize_name(mod_name
);
285 g_warning("test %s test", g_quark_to_string(ltt_tracefile_name(tracefile
)));
286 g_string_printf(filename
, "%s.%s.%u.trace", a_dump_tracefiles
,
287 mod_name
, ltt_tracefile_num(tracefile
));
288 fp
= fopen(filename
->str
, "w");
289 if(fp
== NULL
) g_error("Cannot open %s", filename
->str
);
290 g_string_free(filename
, TRUE
);
291 err
= ltt_tracefile_seek_time(tracefile
, ltt_time_zero
);
294 previous_time
= ltt_time_zero
;
298 LttTracefile
*tf_pos
;
299 facility
= ltt_event_facility(event
);
300 event_type
= ltt_event_eventtype(event
);
301 time
= ltt_event_time(event
);
302 ltt_event_position(event
, a_event_position
);
303 ltt_event_position_get(a_event_position
, &tf_pos
, &nb_block
, &offset
, &tsc
);
304 //fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n",
305 fprintf(fp
, "%s.%s: %llu %lu.%09lu position %u/%u, tracefile %s\n",
306 g_quark_to_string(ltt_facility_name(facility
)),
307 g_quark_to_string(ltt_eventtype_name(event_type
)),
308 tsc
, (unsigned long)time
.tv_sec
,
309 (unsigned long)time
.tv_nsec
,
311 g_quark_to_string(ltt_tracefile_name(tracefile
)));
313 if(ltt_time_compare(time
, previous_time
) < 0) {
314 g_warning("Time decreasing trace %s tracefile %s cpu %u position %u/%u",
315 g_quark_to_string(ltt_trace_name(ltt_tracefile_get_trace(tracefile
))),
316 g_quark_to_string(ltt_tracefile_name(tracefile
)),
317 ltt_tracefile_num(tracefile
), nb_block
, offset
);
318 g_warning("last time %lu.%lu vs current %lu.%lu",
319 previous_time
.tv_sec
, previous_time
.tv_nsec
,
320 time
.tv_sec
, time
.tv_nsec
);
324 if(ltt_eventtype_name(event_type
) == QUARK_BLOCK_START
) {
325 start_count
= cycle_count
;
328 else if(ltt_eventtype_name(event_type
) == QUARK_BLOCK_END
) {
329 delta_cycle
= cycle_count
- start_count
;
330 end_nsec_sec
= (long long unsigned)time
.tv_sec
* (long long unsigned)1000000000;
331 end_nsec_nsec
= time
.tv_nsec
;
332 end_nsec
= end_nsec_sec
+ end_nsec_nsec
;
333 start_nsec
= (long long unsigned)start_time
.tv_sec
* (long long unsigned)1000000000 + (long long unsigned)start_time
.tv_nsec
;
334 delta_nsec
= end_nsec
- start_nsec
;
335 cycle_per_nsec
= (double)delta_cycle
/ (double)delta_nsec
;
336 nsec_per_cycle
= (double)delta_nsec
/ (double)delta_cycle
;
337 added_nsec
= (double)delta_cycle
* nsec_per_cycle
;
338 interpolated_nsec
= start_nsec
+ added_nsec
;
339 added_nsec2
= (double)delta_cycle
/ cycle_per_nsec
;
340 interpolated_nsec2
= start_nsec
+ added_nsec2
;
342 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
);
346 if(ltt_time_compare(time
, previous_time
) == 0) nb_equal
++;
347 else if(nb_equal
> 0) {
348 g_warning("Consecutive %d events with time %lu.%09lu",
349 nb_equal
+ 1, previous_time
.tv_sec
, previous_time
.tv_nsec
);
352 previous_time
= time
;
354 } while((!ltt_tracefile_read(tracefile
)));
360 static gboolean
process_traceset(void __UNUSED__
*hook_data
,
361 void __UNUSED__
*call_data
)
364 LttvTracesetStats
*tscs
;
366 LttvTracesetState
*ts
;
368 LttvTracesetContext
*tc
;
374 //guint count, nb_control, nb_tracefile, nb_block, nb_event;
375 //guint i, j, count, nb_control, nb_tracefile, nb_block, nb_event, nb_equal;
380 long long unsigned start_nsec
, end_nsec
, delta_nsec
, added_nsec
, added_nsec2
;
382 double cycle_per_nsec
, nsec_per_cycle
;
384 long long interpolated_nsec
, interpolated_nsec2
, end_nsec_sec
, end_nsec_nsec
;
388 LttTime max_time
= { G_MAXULONG
, G_MAXULONG
};
390 a_event_position
= ltt_event_position_new();
392 GData
**tracefiles_groups
;
394 struct compute_tracefile_group_args args
;
396 args
.func
= compute_tracefile
;
397 args
.func_args
= NULL
;
399 if(a_dump_tracefiles
!= NULL
) {
400 for(i
= 0 ; i
< lttv_traceset_number(traceset
) ; i
++) {
401 trace
= lttv_trace(lttv_traceset_get(traceset
, i
));
402 tracefiles_groups
= ltt_trace_get_tracefiles_groups(trace
);
404 g_datalist_foreach(tracefiles_groups
,
405 (GDataForeachFunc
)compute_tracefile_group
,
411 tscs
= g_object_new(LTTV_TRACESET_STATS_TYPE
, NULL
);
413 tc
= &tscs
->parent
.parent
;
415 lttv_context_init(tc
, traceset
);
417 /* For each case compute and print the elapsed time.
418 The first case is simply to run through all events with a
421 if(a_test1
|| a_test_all
) {
423 lttv_hooks_add(event_hook
, count_event
, &count
, LTTV_PRIO_DEFAULT
);
424 t
= run_one_test(ts
, ltt_time_zero
, max_time
);
425 lttv_hooks_remove_data(event_hook
, count_event
, &count
);
427 "Processing trace while counting events (%u events in %g seconds)",
431 /* Run through all events computing the state. */
433 if(a_test2
|| a_test_all
) {
434 lttv_state_add_event_hooks(ts
);
435 t
= run_one_test(ts
, ltt_time_zero
, max_time
);
436 lttv_state_remove_event_hooks(ts
);
437 g_warning("Processing trace while updating state (%g seconds)", t
);
440 /* Run through all events computing the state and writing it out
443 SaveState save_state
;
445 save_state
.interval
= a_sample_interval
;
446 save_state
.size
= a_sample_number
;
447 save_state
.fp
= stderr
;
448 save_state
.write_time
= g_new(LttTime
, a_sample_number
);
451 if(a_test3
|| a_test_all
) {
452 for(i
= 0 ; i
< 2 ; i
++) {
453 save_state
.count
= 0;
454 save_state
.position
= 0;
455 save_state
.version
= i
;
456 lttv_state_add_event_hooks(ts
);
457 lttv_hooks_add(event_hook
, save_state_event
, &save_state
,
459 t
= run_one_test(ts
, ltt_time_zero
, max_time
);
460 lttv_state_remove_event_hooks(ts
);
461 lttv_hooks_remove_data(event_hook
, save_state_event
, &save_state
);
462 g_warning("Processing while updating/writing state (%g seconds)", t
);
466 /* Run through all events computing the stats. */
468 if(a_test4
|| a_test_all
) {
469 if(lttv_profile_memory
) {
470 g_message("Memory summary before computing stats");
474 lttv_stats_add_event_hooks(tscs
);
475 t
= run_one_test(ts
, ltt_time_zero
, max_time
);
476 lttv_stats_remove_event_hooks(tscs
);
477 g_warning("Processing trace while counting stats (%g seconds)", t
);
479 if(lttv_profile_memory
) {
480 g_message("Memory summary after computing stats");
484 lttv_stats_sum_traceset(tscs
);
486 if(lttv_profile_memory
) {
487 g_message("Memory summary after summing stats");
491 lttv_context_fini(tc
);
492 lttv_context_init(tc
, traceset
);
494 if(lttv_profile_memory
) {
495 g_message("Memory summary after cleaning up the stats");
500 /* Run through all events computing the state and stats. */
502 if(a_test5
|| a_test_all
) {
503 if(lttv_profile_memory
) {
504 g_message("Memory summary before computing state and stats");
508 lttv_state_add_event_hooks(ts
);
509 lttv_stats_add_event_hooks(tscs
);
510 t
= run_one_test(ts
, ltt_time_zero
, max_time
);
511 lttv_state_remove_event_hooks(ts
);
512 lttv_stats_remove_event_hooks(tscs
);
514 "Processing trace while counting state and stats (%g seconds)", t
);
516 if(lttv_profile_memory
) {
517 g_message("Memory summary after computing and state and stats");
521 lttv_context_fini(tc
);
522 lttv_context_init(tc
, traceset
);
524 if(lttv_profile_memory
) {
525 g_message("Memory summary after cleaning up the stats");
530 /* Run through all events computing and saving the state. */
532 if(a_trace_event
) lttv_hooks_add(event_hook
, trace_event
, NULL
,
535 if(a_test6
|| a_test_all
) {
536 if(lttv_profile_memory
) {
537 g_message("Memory summary before computing and saving state");
541 lttv_state_add_event_hooks(ts
);
542 lttv_state_save_add_event_hooks(ts
);
543 if(a_save_state_copy
)
544 lttv_hooks_add(event_hook
, save_state_copy_event
, &save_state
,
546 t
= run_one_test(ts
, ltt_time_zero
, max_time
);
547 lttv_state_remove_event_hooks(ts
);
548 lttv_state_save_remove_event_hooks(ts
);
549 if(a_save_state_copy
)
550 lttv_hooks_remove_data(event_hook
,save_state_copy_event
, &save_state
);
552 g_warning("Processing trace while updating/saving state (%g seconds)", t
);
554 if(lttv_profile_memory
) {
555 g_message("Memory summary after computing/saving state");
560 /* Seek a few times to each saved position */
562 if((a_test7
&& a_test3
) || a_test_all
) {
563 g_assert(a_seek_number
>= 0);
564 for(i
= 0 ; i
< (guint
)a_seek_number
; i
++) {
565 gint reverse_j
; /* just to make sure j is unsigned */
566 for(reverse_j
= save_state
.position
- 1 ; reverse_j
>= 0 ; reverse_j
--) {
567 j
= (guint
)reverse_j
;
568 lttv_state_add_event_hooks(ts
);
569 t
= run_one_test(ts
, save_state
.write_time
[j
],
570 save_state
.write_time
[j
]);
571 lttv_state_remove_event_hooks(ts
);
572 g_warning("Seeking to %lu.%lu (%g seconds)",
573 save_state
.write_time
[j
].tv_sec
, save_state
.write_time
[j
].tv_nsec
,
576 if(a_save_sample
!= NULL
) {
577 filename
= g_string_new("");
578 g_string_printf(filename
, "%s.%d.xml.bak%d", a_save_sample
, j
, i
);
579 fp
= fopen(filename
->str
, "w");
580 if(fp
== NULL
) g_error("Cannot open %s", filename
->str
);
581 g_string_free(filename
, TRUE
);
582 lttv_state_write((LttvTraceState
*)tc
->traces
[0],
583 save_state
.write_time
[j
], fp
);
586 //else lttv_state_write((LttvTraceState *)tc->traces[0],
587 // save_state.write_time[j], save_state.fp);
592 if(a_trace_event
) lttv_hooks_remove_data(event_hook
, trace_event
, NULL
);
594 g_free(save_state
.write_time
);
595 g_free(a_event_position
);
596 lttv_context_fini(tc
);
597 g_object_unref(tscs
);
599 if(lttv_profile_memory
) {
600 g_message("Memory summary at the end of batchtest");
604 g_info("BatchTest end process traceset");
611 LttvAttributeValue value
;
613 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
615 g_info("Init batchtest.c");
618 QUARK_BLOCK_START
= g_quark_from_string("block_start");
619 QUARK_BLOCK_END
= g_quark_from_string("block_end");
622 lttv_option_add("trace", 't',
623 "add a trace to the trace set to analyse",
624 "pathname of the directory containing the trace",
625 LTTV_OPT_STRING
, &a_trace
, lttv_trace_option
, NULL
);
627 a_trace_event
= FALSE
;
629 a_dump_tracefiles
= NULL
;
630 lttv_option_add("dump-tracefiles", 'D',
631 "Write event by event the content of tracefiles",
632 "basename for the files where to dump events",
633 LTTV_OPT_STRING
, &a_dump_tracefiles
, NULL
, NULL
);
635 a_save_sample
= NULL
;
636 lttv_option_add("save-sample", 's',
637 "Save state samples to multiple files",
638 "basename for the files containing the state samples",
639 LTTV_OPT_STRING
, &a_save_sample
, NULL
, NULL
);
641 a_save_state_copy
= FALSE
;
642 lttv_option_add("save-state-copy", 'S', "Write the state saved for seeking",
643 "", LTTV_OPT_NONE
, &a_save_state_copy
, NULL
, NULL
);
645 a_save_interval
= 100000;
646 lttv_option_add("save-interval", 'i',
647 "Interval between saving state",
648 "number of events before a block start triggers saving state",
649 LTTV_OPT_INT
, &a_save_interval
, NULL
, NULL
);
651 a_sample_interval
= 100000;
652 lttv_option_add("sample-interval", 'S',
653 "Interval between sampling state",
654 "number of events before sampling and writing state",
655 LTTV_OPT_INT
, &a_sample_interval
, NULL
, NULL
);
657 a_sample_number
= 20;
658 lttv_option_add("sample-number", 'N',
659 "Number of state samples",
661 LTTV_OPT_INT
, &a_sample_number
, NULL
, NULL
);
664 lttv_option_add("seek-number", 'K',
667 LTTV_OPT_INT
, &a_seek_number
, NULL
, NULL
);
670 lttv_option_add("test1", '1', "Test just counting events", "",
671 LTTV_OPT_NONE
, &a_test1
, NULL
, NULL
);
674 lttv_option_add("test2", '2', "Test computing the state", "",
675 LTTV_OPT_NONE
, &a_test2
, NULL
, NULL
);
678 lttv_option_add("test3", '3', "Test computing the state, writing out a few",
679 "", LTTV_OPT_NONE
, &a_test3
, NULL
, NULL
);
682 lttv_option_add("test4", '4', "Test computing the stats", "",
683 LTTV_OPT_NONE
, &a_test4
, NULL
, NULL
);
686 lttv_option_add("test5", '5', "Test computing the state and stats", "",
687 LTTV_OPT_NONE
, &a_test5
, NULL
, NULL
);
690 lttv_option_add("test6", '6', "Test computing and saving the state", "",
691 LTTV_OPT_NONE
, &a_test6
, NULL
, NULL
);
694 lttv_option_add("test7", '7', "Test seeking to positions written out in 3",
695 "", LTTV_OPT_NONE
, &a_test7
, NULL
, NULL
);
698 lttv_option_add("testall", 'a', "Run all tests ", "",
699 LTTV_OPT_NONE
, &a_test_all
, NULL
, NULL
);
701 traceset
= lttv_traceset_new();
703 before_traceset
= lttv_hooks_new();
704 after_traceset
= lttv_hooks_new();
705 before_trace
= lttv_hooks_new();
706 after_trace
= lttv_hooks_new();
707 before_tracefile
= lttv_hooks_new();
708 after_tracefile
= lttv_hooks_new();
709 //before_event = lttv_hooks_new();
710 //after_event = lttv_hooks_new();
711 event_hook
= lttv_hooks_new();
714 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/before",
715 LTTV_POINTER
, &value
));
716 *(value
.v_pointer
) = before_traceset
;
717 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/after",
718 LTTV_POINTER
, &value
));
719 *(value
.v_pointer
) = after_traceset
;
720 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/before",
721 LTTV_POINTER
, &value
));
722 *(value
.v_pointer
) = before_trace
;
723 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/after",
724 LTTV_POINTER
, &value
));
725 *(value
.v_pointer
) = after_trace
;
726 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/before",
727 LTTV_POINTER
, &value
));
728 *(value
.v_pointer
) = before_tracefile
;
729 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/after",
730 LTTV_POINTER
, &value
));
731 *(value
.v_pointer
) = after_tracefile
;
732 //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before",
733 // LTTV_POINTER, &value));
734 //*(value.v_pointer) = before_event;
735 //g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after",
736 // LTTV_POINTER, &value));
737 //*(value.v_pointer) = after_event;
738 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/event",
739 LTTV_POINTER
, &value
));
740 *(value
.v_pointer
) = event_hook
;
741 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
742 LTTV_POINTER
, &value
));
743 g_assert((main_hooks
= *(value
.v_pointer
)) != NULL
);
744 lttv_hooks_add(main_hooks
, process_traceset
, NULL
, LTTV_PRIO_DEFAULT
);
748 static void destroy()
754 g_info("Destroy batchAnalysis.c");
756 lttv_option_remove("trace");
757 lttv_option_remove("dump-tracefiles");
758 lttv_option_remove("save-sample");
759 lttv_option_remove("save-state-copy");
760 lttv_option_remove("sample-interval");
761 lttv_option_remove("sample-number");
762 lttv_option_remove("seek-number");
763 lttv_option_remove("save-interval");
764 lttv_option_remove("test1");
765 lttv_option_remove("test2");
766 lttv_option_remove("test3");
767 lttv_option_remove("test4");
768 lttv_option_remove("test5");
769 lttv_option_remove("test6");
770 lttv_option_remove("test7");
771 lttv_option_remove("testall");
773 lttv_hooks_destroy(before_traceset
);
774 lttv_hooks_destroy(after_traceset
);
775 lttv_hooks_destroy(before_trace
);
776 lttv_hooks_destroy(after_trace
);
777 lttv_hooks_destroy(before_tracefile
);
778 lttv_hooks_destroy(after_tracefile
);
779 //lttv_hooks_destroy(before_event);
780 //lttv_hooks_destroy(after_event);
781 lttv_hooks_destroy(event_hook
);
782 lttv_hooks_remove_data(main_hooks
, process_traceset
, NULL
);
784 nb
= lttv_traceset_number(traceset
);
785 for(i
= 0 ; i
< nb
; i
++) {
786 trace
= lttv_traceset_get(traceset
, i
);
787 lttv_traceset_remove(traceset
,i
);
788 ltt_trace_close(lttv_trace(trace
));
789 lttv_trace_destroy(trace
);
792 lttv_traceset_destroy(traceset
);
796 LTTV_MODULE("batchtest", "Batch processing of a trace for tests", \
797 "Run through a trace calling all the registered hooks for tests", \
798 init
, destroy
, "state", "stats", "option" )