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>
8 #include <lttv/processTrace.h>
9 #include <lttv/state.h>
11 static LttvTraceset
*traceset
;
27 void lttv_trace_option(void *hook_data
)
31 trace
= ltt_trace_open(a_trace
);
32 if(trace
== NULL
) g_critical("cannot open trace %s", a_trace
);
33 lttv_traceset_add(traceset
, trace
);
37 static void process_traceset(void *hook_data
, void *call_data
)
39 LttvTracesetState
*tc
;
43 tc
= g_object_new(LTTV_TRACESET_STATE
);
44 lttv_context_init(LTTV_TRACESET_CONTEXT(tc
), traceset
);
46 lttv_traceset_context_add_hooks(LTTV_TRACESET_CONTEXT(tc
),
47 before_traceset
, after_traceset
, before_trace
, after_trace
,
48 before_tracefile
, after_tracefile
, before_event
, after_event
);
49 lttv_state_add_event_hooks(tc
);
53 end
.tv_sec
= G_MAXULONG
;
54 end
.tv_nsec
= G_MAXULONG
;
56 lttv_process_trace(start
, end
, traceset
, tc
);
57 lttv_traceset_context_remove_hooks(LTTV_TRACESET_CONTEXT(tc
),
58 before_traceset
, after_traceset
, before_trace
, after_trace
,
59 before_tracefile
, after_tracefile
, before_event
, after_event
);
61 lttv_state_remove_event_hooks(tc
);
62 lttv_context_fini(LTTV_TRACESET_CONTEXT(tc
));
67 void init(int argc
, char **argv
)
69 LttvAttribute_value
*value
;
71 LttvIAttributes
*attributes
= LTTV_IATTRIBUTES(lttv_global_attributes());
73 lttv_option_add("trace", 't',
74 "add a trace to the trace set to analyse",
75 "pathname of the directory containing the trace",
76 LTTV_OPT_STRING
, &aTrace
, lttv_trace_option
, NULL
);
78 traceset
= lttv_traceset_new();
80 before_traceset
= lttv_hooks_new();
81 after_traceset
= lttv_hooks_new();
82 before_trace
= lttv_hooks_new();
83 after_trace
= lttv_hooks_new();
84 before_tracefile
= lttv_hooks_new();
85 after_tracefile
= lttv_hooks_new();
86 before_event
= lttv_hooks_new();
87 after_event
= lttv_hooks_new();
89 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/before",
90 LTTV_POINTER
, &value
));
91 *(value
->v_pointer
) = before_traceset
;
92 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/after",
93 LTTV_POINTER
, &value
));
94 *(value
->v_pointer
) = after_traceset
;
95 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/before",
96 LTTV_POINTER
, &value
));
97 *(value
->v_pointer
) = before_trace
;
98 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/after",
99 LTTV_POINTER
, &value
));
100 *(value
->v_pointer
) = after_trace
;
101 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/before",
102 LTTV_POINTER
, &value
));
103 *(value
->v_pointer
) = before_tracefile
;
104 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/after",
105 LTTV_POINTER
, &value
));
106 *(value
->v_pointer
) = after_tracefile
;
107 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/event/before",
108 LTTV_POINTER
, &value
));
109 *(value
->v_pointer
) = before_event
;
110 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/event/after",
111 LTTV_POINTER
, &value
));
112 *(value
->v_pointer
) = after_event
;
114 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
115 LTTV_POINTER
, &value
));
116 g_assert((main_hooks
= *(value
->v_pointer
)) != NULL
);
117 lttv_hooks_add(main_hooks
, process_traceset
, NULL
);
125 lttv_hooks_remove(main_hooks
, process_traceset
, NULL
);
127 lttv_option_remove("trace");
129 lttv_hooks_destroy(before_traceset
);
130 lttv_hooks_destroy(after_traceset
);
131 lttv_hooks_destroy(before_trace
);
132 lttv_hooks_destroy(after_trace
);
133 lttv_hooks_destroy(before_tracefile
);
134 lttv_hooks_destroy(after_tracefile
);
135 lttv_hooks_destroy(before_event
);
136 lttv_hooks_destroy(after_event
);
138 nb
= lttv_traceset_number(traceset
);
139 for(i
= 0 ; i
< nb
, i
++) {
140 ltt_trace_close(lttv_traceset_get(traceset
);
This page took 0.031451 seconds and 4 git commands to generate.