icons
[lttv.git] / ltt / branches / poly / lttv / traceSet.c
CommitLineData
1b82f325 1/* A trace is a sequence of events gathered in the same tracing session. The
2 events may be stored in several tracefiles in the same directory.
3 A trace set is defined when several traces are to be analyzed together,
4 possibly to study the interactions between events in the different traces.
5*/
6
7struct _lttv_trace_set {
8 GPtrArray *traces;
9 GPtrArray *attributes;
10 lttv_attributes *a;
11};
12
13
14lttv_trace_set *lttv_trace_set_new()
15{
16 lttv_trace_set s;
17
18 s = g_new(lttv_trace_set, 1);
19 s->traces = g_ptr_array_new();
20 s->attributes = g_ptr_array_new();
21 s->a = lttv_attributes_new();
22}
23
24lttv_trace_set *lttv_trace_set_destroy(lttv_trace_set *s)
25{
26 int i, nb;
27
28 for(i = 0 ; i < s->attributes->len ; i++) {
29 lttv_attributes_destroy((lttv_attributes *)s->attributes->pdata[i]);
30 }
31 g_ptr_array_free(s->attributes);
32 g_ptr_array_free(s->traces);
33 lttv_attributes_destroy(s->a);
34 return g_free(s);
35}
36
37void lttv_trace_set_add(lttv_trace_set *s, lttv_trace *t)
38{
39 g_ptr_array_add(s,t);
40 g_ptr_array_add(s,lttv_attributes_new());
41}
42
43unsigned lttv_trace_set_number(lttv_trace_set *s)
44{
45 return s->traces.len;
46}
47
48
49lttv_trace *lttv_trace_set_get(lttv_trace_set *s, unsigned i)
50{
51 g_assert(s->traces->len <= i);
52 return s->traces.pdata[i];
53}
54
55
56lttv_trace *lttv_trace_set_remove(lttv_trace_set *s, unsigned i)
57{
58 return g_ptr_array_remove_index(s->traces,i);
59 lttv_attributes_destroy(g_ptr_array_remove_index(s->attributes,i));
60}
61
62
63/* A set of attributes is attached to each trace set, trace and tracefile
64 to store user defined data as needed. */
65
66lttv_attributes *lttv_trace_set_attributes(lttv_trace_set *s)
67{
68 return s->a;
69}
70
71lttv_attributes *lttv_trace_set_trace_attributes(lttv_trace_set *s, unsigned i)
72{
73 return t->a;
74}
75
76lttv_attributes *lttv_tracefile_attributes(lttv_tracefile *tf) {
77 return (lttv_attributes *)s->attributes->pdata[i];
78}
79
80
81static void lttv_analyse_trace(lttv_trace *t);
82
83static void lttv_analyse_tracefile(lttv_tracefile *t);
84
85lttv_trace_set_process(lttv_trace_set *s, ltt_time start, ltt_time end)
86{
87 int i, nb;
88 lttv_hooks *before, *after;
89 lttv_attributes *a;
90 ltt_trace *t;
91 lttv_filter *filter_data;
92
93 a = lttv_trace_set_attributes(s);
94 before = (lttv_hooks*)lttv_attributes_get_pointer_pathname(a,"hooks/before");
95 after = (lttv_hooks*)lttv_attributes_get_pointer_pathname(a,"hooks/after");
96 nb = lttv_trace_set_number(s);
97
98 lttv_hooks_call(before, s);
99
100 for(i = 0; i < nb; i++) {
101 t = lttv_trace_set_get(s,i);
102 a = lttv_trace_set_trace_attributes(s,i);
103 lttv_analyse_trace(t, a, start, end);
104 }
105
106 lttv_hooks_call(after, s);
107}
108
109
110static void lttv_analyse_trace(ltt_trace *t, lttv_attributes *a,
111 ltt_time start, ltt_time end)
112{
113 int i, nb_all_cpu, nb_per_cpu;
114 lttv_hooks *before, *after;
115
116 before = (lttv_hooks*)lttv_attributes_get_pointer_pathname(a,"hooks/before");
117 after = (lttv_hooks*)lttv_attributes_get_pointer_pathname(a,"hooks/after");
118
119 nb_all_cpu = ltt_trace_tracefile_number_all_cpu(t);
120 nb_per_cpu = ltt_trace_tracefile_number_per_cpu(t);
121
122 lttv_hooks_call(before, t);
123
124 for(i = 0; i < nb_all_cpu; i++) {
125 lttv_analyse_tracefile(ltt_trace_get_all_cpu(t,i), a, start, end);
126 }
127
128 for(i = 0; i < nb_per_cpu; i++) {
129 lttv_analyse_tracefile(ltt_trace_get_per_cpu(t,i), a, start, end);
130 }
131
132 lttv_hooks_call(after, t);
133}
134
135
136static void lttv_analyse_tracefile(ltt_tracefile *t, lttv_attributes *a,
137 ltt_time start, ltt_time end)
138{
139 ltt_event *event;
140 unsigned id;
141 lttv_hooks *before, *after, *event_hooks, *tracefile_check, *event_check;
142 lttv_hooks_by_id *event_hooks_by_id;
143 lttv_attributes *a;
144
145 before = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,
146 "hooks/tracefile/before");
147 after = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,
148 "hooks/tracefile/after");
149 event_hooks = (lttv_hooks*)lttv_attributes_get_pointer_pathname(a,
150 "hooks/event/selected");
151 event_hooks_by_id = (lttv_hooks_by_id*)
152 lttv_attributes_get_pointer_pathname(a, "hooks/event/byid");
153 tracefile_check = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,
154 "hooks/tracefile/check");
155 event_check = (lttv_hooks *)lttv_attributes_get_pointer_pathname(a,
156 "hooks/event/check");
157
158 lttv_hooks_call(before, t);
159
160 if(lttv_hooks_call_check(tracefile_check,t) &&
161 ( lttv_hooks_number(event_hooks) != 0 ||
162 lttv_hooks_by_id_number(event_hooks_by_id) != 0) {
163
164 ltt_tracefile_seek_time(t, start);
165 while((event = ltt_tracefile_read(t)) != NULL &&
166 ltt_event_time(event) < end) {
167 if(lttv_hooks_call_check(event_check)) {
168 lttv_hooks_call(event_hooks,event);
169 lttv_hooks_by_id_call(event_hooks_by_id,event,
170 ltt_event_type_id(event));
171 }
172 }
173 }
174 lttv_hooks_call(after, t);
175}
176
177
178
This page took 0.027666 seconds and 4 git commands to generate.