4 #include <lttv/attribute.h>
8 /* This is the generic part of trace processing. All events within a
9 certain time interval are accessed and processing hooks are called for
10 each. The events are examined in monotonically increasing time to more
11 closely follow the traced system behavior.
13 Hooks are called at several different places during the processing:
14 before traceset, after traceset, check trace, before trace, after trace,
15 check tracefile, before tracefile, after tracefile,
16 check_event, before_event, before_event_by_id,
17 after_event, after_event_by_id.
19 In each case the "check" hooks are called first to determine if further
20 processing of the trace, tracefile or event is wanted. Then, the before
21 hooks and the after hooks are called. The before hooks for a traceset
22 are called before those for the contained traces, which are called before
23 those for the contained tracefiles. The after hooks are called in reverse
24 order. The event hooks are called after all the before_tracefile hooks
25 and before all the after_tracefile hooks.
27 The hooks receive two arguments, the hook_data and call_data. The hook_data
28 is specified when the hook is registered and typically links to the
29 object registering the hook (e.g. a graphical events viewer). The call_data
30 must contain all the context related to the call. The traceset hooks receive
31 the LttvTracesetContext provided by the caller. The trace hooks receive
32 the LttvTraceContext from the traces array in the LttvTracesetContext.
33 The tracefile and event hooks receive the LttvTracefileContext from
34 the tracefiles array in the LttvTraceContext. The LttEvent and LttTime
35 fields in the tracefile context are set to the current event and current
36 event time before calling the event hooks. No other context field is
39 The contexts in the traces and tracefiles arrays must be allocated by
40 the caller, either before the call or during the before hooks of the
41 enclosing traceset or trace. The order in the traces array must
42 correspond to the lttv_traceset_get function. The order in the tracefiles
43 arrays must correspond to the ltt_trace_control_tracefile_get and
44 ltt_trace_per_cpu_tracefile_get functions. The traceset, trace and
45 tracefile contexts may be subtyped as needed. Indeed, both the contexts
46 and the hooks are defined by the caller. */
48 #define LTTV_TRACESET_CONTEXT_TYPE (lttv_traceset_context_get_type ())
49 #define LTTV_TRACESET_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContext))
50 #define LTTV_TRACESET_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContextClass))
51 #define LTTV_IS_TRACESET_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_CONTEXT_TYPE))
52 #define LTTV_IS_TRACESET_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_CONTEXT_TYPE))
53 #define LTTV_TRACESET_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContextClass))
55 typedef struct _LttvTracesetContext LttvTracesetContext
;
56 typedef struct _LttvTracesetContextClass LttvTracesetContextClass
;
58 struct _LttvTracesetContext
{
64 LttvTraceContext
**traces
;
68 struct _LttvTracesetContextClass
{
71 void (*init
) (LttvTracesetContext
*self
, LttvTraceset
*ts
);
72 void (*fini
) (LttvTracesetContext
*self
);
73 LttvTracesetContext
* (*new_traceset_context
) (LttvTracesetContext
*self
);
74 LttvTraceContext
* (*new_trace_context
) (LttvTracesetContext
*self
);
75 LttvTracefileContext
* (*new_tracefile_context
) (LttvTracesetContext
*self
);
78 GType
lttv_traceset_context_get_type (void);
80 void lttv_context_init(LttvTracesetContext
*self
, LttvTraceset
*ts
);
82 void lttv_context_fini(LttvTracesetContext
*self
);
85 lttv_context_new_traceset_context(LttvTracesetContext
*self
);
88 lttv_context_new_trace_context(LttvTracesetContext
*self
);
90 LttvTracefileContext
*
91 lttv_context_new_tracefile_context(LttvTracesetContext
*self
);
94 #define LTTV_TRACE_CONTEXT_TYPE (lttv_trace_context_get_type ())
95 #define LTTV_TRACE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContext))
96 #define LTTV_TRACE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContextClass))
97 #define LTTV_IS_TRACE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_CONTEXT_TYPE))
98 #define LTTV_IS_TRACE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_CONTEXT_TYPE))
99 #define LTTV_TRACE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContextClass))
101 typedef struct _LttvTraceContext LttvTraceContext
;
102 typedef struct _LttvTraceContextClass LttvTraceContextClass
;
104 struct _LttvTraceContext
{
107 LttvTracesetContext
*ts_context
;
108 guint index
; /* in ts_context->traces */
113 LttvTracefileContext
**control_tracefiles
;
114 LttvTracefileContext
**per_cpu_tracefiles
;
118 struct _LttvTraceContextClass
{
122 GType
lttv_trace_context_get_type (void);
124 #define LTTV_TRACEFILE_CONTEXT_TYPE (lttv_tracefile_context_get_type ())
125 #define LTTV_TRACEFILE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContext))
126 #define LTTV_TRACEFILE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContextClass))
127 #define LTTV_IS_TRACEFILE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_CONTEXT_TYPE))
128 #define LTTV_IS_TRACEFILE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_CONTEXT_TYPE))
129 #define LTTV_TRACEFILE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContextClass))
131 typedef struct _LttvTracefileContext LttvTracefileContext
;
132 typedef struct _LttvTracefileContextClass LttvTracefileContextClass
;
134 struct _LttvTracefileContext
{
137 LttvTraceContext
*t_context
;
139 guint index
; /* in ts_context->control/per_cpu_tracefiles */
145 LttvHooks
*check_event
;
146 LttvHooks
*before_event
;
147 LttvHooksById
*before_event_by_id
;
148 LttvHooks
*after_event
;
149 LttvHooksById
*after_event_by_id
;
154 struct _LttvTracefileContextClass
{
158 GType
lttv_tracefile_context_get_type (void);
160 void lttv_process_trace(LttvTime start
, LttvTime end
, LttvTraceset
*traceset
,
161 LttvTracesetContext
*context
);
163 void lttv_traceset_context_add_hooks(LttvTracesetContext
*self
,
164 LttvHooks
*before_traceset
,
165 LttvHooks
*after_traceset
,
166 LttvHooks
*check_trace
,
167 LttvHooks
*before_trace
,
168 LttvHooks
*after_trace
,
169 LttvHooks
*check_event
,
170 LttvHooks
*before_event
,
171 LttvHooks
*after_event
)
173 void lttv_traceset_context_remove_hooks(LttvTracesetContext
*self
,
174 LttvHooks
*before_traceset
,
175 LttvHooks
*after_traceset
,
176 LttvHooks
*check_trace
,
177 LttvHooks
*before_trace
,
178 LttvHooks
*after_trace
,
179 LttvHooks
*check_event
,
180 LttvHooks
*before_event
,
181 LttvHooks
*after_event
)
183 #endif // PROCESSTRACE_H