4 #include <lttv/traceset.h>
5 #include <lttv/attribute.h>
9 /* This is the generic part of trace processing. All events within a
10 certain time interval are accessed and processing hooks are called for
11 each. The events are examined in monotonically increasing time to more
12 closely follow the traced system behavior.
14 Hooks are called at several different places during the processing:
15 before traceset, after traceset, check trace, before trace, after trace,
16 check tracefile, before tracefile, after tracefile,
17 check_event, before_event, before_event_by_id,
18 after_event, after_event_by_id.
20 In each case the "check" hooks are called first to determine if further
21 processing of the trace, tracefile or event is wanted. Then, the before
22 hooks and the after hooks are called. The before hooks for a traceset
23 are called before those for the contained traces, which are called before
24 those for the contained tracefiles. The after hooks are called in reverse
25 order. The event hooks are called after all the before_tracefile hooks
26 and before all the after_tracefile hooks.
28 The hooks receive two arguments, the hook_data and call_data. The hook_data
29 is specified when the hook is registered and typically links to the
30 object registering the hook (e.g. a graphical events viewer). The call_data
31 must contain all the context related to the call. The traceset hooks receive
32 the LttvTracesetContext provided by the caller. The trace hooks receive
33 the LttvTraceContext from the traces array in the LttvTracesetContext.
34 The tracefile and event hooks receive the LttvTracefileContext from
35 the tracefiles array in the LttvTraceContext. The LttEvent and LttTime
36 fields in the tracefile context are set to the current event and current
37 event time before calling the event hooks. No other context field is
40 The contexts in the traces and tracefiles arrays must be allocated by
41 the caller, either before the call or during the before hooks of the
42 enclosing traceset or trace. The order in the traces array must
43 correspond to the lttv_traceset_get function. The order in the tracefiles
44 arrays must correspond to the ltt_trace_control_tracefile_get and
45 ltt_trace_per_cpu_tracefile_get functions. The traceset, trace and
46 tracefile contexts may be subtyped as needed. Indeed, both the contexts
47 and the hooks are defined by the caller. */
50 typedef struct _LttvTracesetContext LttvTracesetContext
;
51 typedef struct _LttvTracesetContextClass LttvTracesetContextClass
;
53 typedef struct _LttvTraceContext LttvTraceContext
;
54 typedef struct _LttvTraceContextClass LttvTraceContextClass
;
56 typedef struct _LttvTracefileContext LttvTracefileContext
;
57 typedef struct _LttvTracefileContextClass LttvTracefileContextClass
;
59 #define LTTV_TRACESET_CONTEXT_TYPE (lttv_traceset_context_get_type ())
60 #define LTTV_TRACESET_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContext))
61 #define LTTV_TRACESET_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContextClass))
62 #define LTTV_IS_TRACESET_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_CONTEXT_TYPE))
63 #define LTTV_IS_TRACESET_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_CONTEXT_TYPE))
64 #define LTTV_TRACESET_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContextClass))
66 struct _LttvTracesetContext
{
72 LttvTraceContext
**traces
;
76 struct _LttvTracesetContextClass
{
79 void (*init
) (LttvTracesetContext
*self
, LttvTraceset
*ts
);
80 void (*fini
) (LttvTracesetContext
*self
);
81 LttvTracesetContext
* (*new_traceset_context
) (LttvTracesetContext
*self
);
82 LttvTraceContext
* (*new_trace_context
) (LttvTracesetContext
*self
);
83 LttvTracefileContext
* (*new_tracefile_context
) (LttvTracesetContext
*self
);
86 GType
lttv_traceset_context_get_type (void);
88 void lttv_context_init(LttvTracesetContext
*self
, LttvTraceset
*ts
);
90 void lttv_context_fini(LttvTracesetContext
*self
);
93 lttv_context_new_traceset_context(LttvTracesetContext
*self
);
96 lttv_context_new_trace_context(LttvTracesetContext
*self
);
98 LttvTracefileContext
*
99 lttv_context_new_tracefile_context(LttvTracesetContext
*self
);
102 #define LTTV_TRACE_CONTEXT_TYPE (lttv_trace_context_get_type ())
103 #define LTTV_TRACE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContext))
104 #define LTTV_TRACE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContextClass))
105 #define LTTV_IS_TRACE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_CONTEXT_TYPE))
106 #define LTTV_IS_TRACE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_CONTEXT_TYPE))
107 #define LTTV_TRACE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContextClass))
109 struct _LttvTraceContext
{
112 LttvTracesetContext
*ts_context
;
113 guint index
; /* in ts_context->traces */
118 LttvTracefileContext
**control_tracefiles
;
119 LttvTracefileContext
**per_cpu_tracefiles
;
123 struct _LttvTraceContextClass
{
127 GType
lttv_trace_context_get_type (void);
129 #define LTTV_TRACEFILE_CONTEXT_TYPE (lttv_tracefile_context_get_type ())
130 #define LTTV_TRACEFILE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContext))
131 #define LTTV_TRACEFILE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContextClass))
132 #define LTTV_IS_TRACEFILE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_CONTEXT_TYPE))
133 #define LTTV_IS_TRACEFILE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_CONTEXT_TYPE))
134 #define LTTV_TRACEFILE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContextClass))
136 struct _LttvTracefileContext
{
139 LttvTraceContext
*t_context
;
141 guint index
; /* in ts_context->control/per_cpu_tracefiles */
147 LttvHooks
*check_event
;
148 LttvHooks
*before_event
;
149 LttvHooksById
*before_event_by_id
;
150 LttvHooks
*after_event
;
151 LttvHooksById
*after_event_by_id
;
156 struct _LttvTracefileContextClass
{
160 GType
lttv_tracefile_context_get_type (void);
162 void lttv_process_trace(LttTime start
, LttTime end
, LttvTraceset
*traceset
,
163 LttvTracesetContext
*context
);
165 void lttv_traceset_context_add_hooks(LttvTracesetContext
*self
,
166 LttvHooks
*before_traceset
,
167 LttvHooks
*after_traceset
,
168 LttvHooks
*check_trace
,
169 LttvHooks
*before_trace
,
170 LttvHooks
*after_trace
,
171 LttvHooks
*check_tracefile
,
172 LttvHooks
*before_tracefile
,
173 LttvHooks
*after_tracefile
,
174 LttvHooks
*check_event
,
175 LttvHooks
*before_event
,
176 LttvHooks
*after_event
);
178 void lttv_traceset_context_remove_hooks(LttvTracesetContext
*self
,
179 LttvHooks
*before_traceset
,
180 LttvHooks
*after_traceset
,
181 LttvHooks
*check_trace
,
182 LttvHooks
*before_trace
,
183 LttvHooks
*after_trace
,
184 LttvHooks
*check_tracefile
,
185 LttvHooks
*before_tracefile
,
186 LttvHooks
*after_tracefile
,
187 LttvHooks
*check_event
,
188 LttvHooks
*before_event
,
189 LttvHooks
*after_event
);
191 #endif // PROCESSTRACE_H