Some .h files should be accessible to user programmed modules and thus
[lttv.git] / ltt / branches / poly / lttv / batchAnalysis.c
CommitLineData
48f6f3c2 1/* This module inserts a hook in the program main loop. This hook processes
2 all the events in the main tracefile. */
3
4
5#include <lttv/lttv.h>
6#include <lttv/attribute.h>
7#include <lttv/hook.h>
8
9static void process_trace_set(void *hook_data, void *call_data)
10{
11 int i, nb;
12 lttv_attributes *a, *sa;
13 lttv_trace_set *s;
14 lttv_hooks *global_before, *before, *global_after, *after;
15 ltt_time start, end;
16 lttv_key *key;
17 lttv_hook f;
18 void *hook_data;
19
20 a = lttv_global_attributes();
21 global_before = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,
22 "hooks/trace_set/before");
23 global_after = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,
24 "hooks/trace_set/after");
25 s = (lttv_trace_set *)lttv_attributes_get_pointer_pathname(a,
26 "traceSet/main");
27
28 key = lttv_key_new_pathname("time/start");
29 start = lttv_attributes_get_time(a,key);
30 lttv_key_destroy(key);
31
32 key = lttv_key_new_pathname("time/end");
33 end = lttv_attributes_get_time(a,key);
34 lttv_key_destroy(key);
35
36 sa = lttv_trace_set_attributes(s);
37
38 before = (lttv_hooks *)lttv_attributes_get_pointer_pathname(sa,
39 "hooks/before");
40 if(before == NULL) {
41 before = lttv_hooks_new();
42 lttv_attributes_set_pointer_pathname(sa, "hooks/before", before);
43 }
44
45 after = (lttv_hooks *)lttv_attributes_get_pointer_pathname(sa,
46 "hooks/after");
47 if(after == NULL) {
48 after = lttv_hooks_new();
49 lttv_attributes_set_pointer_pathname(sa, "hooks/after", after);
50 }
51
52 nb = lttv_hooks_number(global_before);
53 for(i = 0 ; i < nb ; i++) {
54 lttv_hooks_get(global_before, i, &f, &hook_data);
55 lttv_hooks_add(before, f, hook_data);
56 }
57
58 nb = lttv_hooks_number(global_after);
59 for(i = 0 ; i < nb ; i++) {
60 lttv_hooks_get(global_after, i, &f, &hook_data);
61 lttv_hooks_add(after, f, hook_data);
62 }
63
64 lttv_trace_set_process(s, before_trace_set, after_trace_set, filter, start,
65 end);
66
67 nb = lttv_hooks_number(global_before);
68 for(i = 0 ; i < nb ; i++) {
69 lttv_hooks_get(global_before, i, &f, &hook_data);
70 lttv_hooks_remove(before, f, hook_data);
71 }
72
73 nb = lttv_hooks_number(global_after);
74 for(i = 0 ; i < nb ; i++) {
75 lttv_hooks_get(global_after, i, &f, &hook_data);
76 lttv_hooks_remove(after, f, hook_data);
77 }
78}
79
80
81void init(int argc, char **argv)
82{
83 lttv_attributes *a;
84 lttv_hooks *h;
85
86 a = lttv_global_attributes();
87 h = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,"hooks/main");
88 lttv_hooks_add(h, process_trace_set, NULL);
89}
90
91
92void destroy()
93{
94 lttv_attributes *a;
95 lttv_hooks *h;
96
97 a = lttv_global_attributes();
98 h = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,"hooks/main");
99 lttv_hooks_remove(h, process_trace_set, NULL);
100}
101
102
103
104
This page took 0.032169 seconds and 4 git commands to generate.