1 /* This module inserts a hook in the program main loop. This hook processes
2 all the events in the main tracefile. */
6 #include <lttv/attribute.h>
9 static void process_trace_set(void *hook_data
, void *call_data
)
12 lttv_attributes
*a
, *sa
;
14 lttv_hooks
*global_before
, *before
, *global_after
, *after
;
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
,
28 key
= lttv_key_new_pathname("time/start");
29 start
= lttv_attributes_get_time(a
,key
);
30 lttv_key_destroy(key
);
32 key
= lttv_key_new_pathname("time/end");
33 end
= lttv_attributes_get_time(a
,key
);
34 lttv_key_destroy(key
);
36 sa
= lttv_trace_set_attributes(s
);
38 before
= (lttv_hooks
*)lttv_attributes_get_pointer_pathname(sa
,
41 before
= lttv_hooks_new();
42 lttv_attributes_set_pointer_pathname(sa
, "hooks/before", before
);
45 after
= (lttv_hooks
*)lttv_attributes_get_pointer_pathname(sa
,
48 after
= lttv_hooks_new();
49 lttv_attributes_set_pointer_pathname(sa
, "hooks/after", after
);
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
);
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
);
64 lttv_trace_set_process(s
, before_trace_set
, after_trace_set
, filter
, start
,
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
);
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
);
81 void init(int argc
, char **argv
)
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
);
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
);
This page took 0.033056 seconds and 4 git commands to generate.