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.
7 struct _lttv_trace_set
{
14 lttv_trace_set
*lttv_trace_set_new()
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();
24 lttv_trace_set
*lttv_trace_set_destroy(lttv_trace_set
*s
)
28 for(i
= 0 ; i
< s
->attributes
->len
; i
++) {
29 lttv_attributes_destroy((lttv_attributes
*)s
->attributes
->pdata
[i
]);
31 g_ptr_array_free(s
->attributes
);
32 g_ptr_array_free(s
->traces
);
33 lttv_attributes_destroy(s
->a
);
37 void lttv_trace_set_add(lttv_trace_set
*s
, lttv_trace
*t
)
40 g_ptr_array_add(s
,lttv_attributes_new());
43 unsigned lttv_trace_set_number(lttv_trace_set
*s
)
49 lttv_trace
*lttv_trace_set_get(lttv_trace_set
*s
, unsigned i
)
51 g_assert(s
->traces
->len
<= i
);
52 return s
->traces
.pdata
[i
];
56 lttv_trace
*lttv_trace_set_remove(lttv_trace_set
*s
, unsigned i
)
58 return g_ptr_array_remove_index(s
->traces
,i
);
59 lttv_attributes_destroy(g_ptr_array_remove_index(s
->attributes
,i
));
63 /* A set of attributes is attached to each trace set, trace and tracefile
64 to store user defined data as needed. */
66 lttv_attributes
*lttv_trace_set_attributes(lttv_trace_set
*s
)
71 lttv_attributes
*lttv_trace_set_trace_attributes(lttv_trace_set
*s
, unsigned i
)
76 lttv_attributes
*lttv_tracefile_attributes(lttv_tracefile
*tf
) {
77 return (lttv_attributes
*)s
->attributes
->pdata
[i
];
81 static void lttv_analyse_trace(lttv_trace
*t
);
83 static void lttv_analyse_tracefile(lttv_tracefile
*t
);
85 lttv_trace_set_process(lttv_trace_set
*s
, ltt_time start
, ltt_time end
)
88 lttv_hooks
*before
, *after
;
91 lttv_filter
*filter_data
;
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
);
98 lttv_hooks_call(before
, s
);
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
);
106 lttv_hooks_call(after
, s
);
110 static void lttv_analyse_trace(ltt_trace
*t
, lttv_attributes
*a
,
111 ltt_time start
, ltt_time end
)
113 int i
, nb_all_cpu
, nb_per_cpu
;
114 lttv_hooks
*before
, *after
;
116 before
= (lttv_hooks
*)lttv_attributes_get_pointer_pathname(a
,"hooks/before");
117 after
= (lttv_hooks
*)lttv_attributes_get_pointer_pathname(a
,"hooks/after");
119 nb_all_cpu
= ltt_trace_tracefile_number_all_cpu(t
);
120 nb_per_cpu
= ltt_trace_tracefile_number_per_cpu(t
);
122 lttv_hooks_call(before
, t
);
124 for(i
= 0; i
< nb_all_cpu
; i
++) {
125 lttv_analyse_tracefile(ltt_trace_get_all_cpu(t
,i
), a
, start
, end
);
128 for(i
= 0; i
< nb_per_cpu
; i
++) {
129 lttv_analyse_tracefile(ltt_trace_get_per_cpu(t
,i
), a
, start
, end
);
132 lttv_hooks_call(after
, t
);
136 static void lttv_analyse_tracefile(ltt_tracefile
*t
, lttv_attributes
*a
,
137 ltt_time start
, ltt_time end
)
141 lttv_hooks
*before
, *after
, *event_hooks
, *tracefile_check
, *event_check
;
142 lttv_hooks_by_id
*event_hooks_by_id
;
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");
158 lttv_hooks_call(before
, t
);
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) {
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
));
174 lttv_hooks_call(after
, t
);
This page took 0.04513 seconds and 4 git commands to generate.