Refine the interactions between the hooks provided by the different modules.
[lttv.git] / ltt / branches / poly / include / lttv / processTrace.h
CommitLineData
dc877563 1#ifndef PROCESSTRACE_H
2#define PROCESSTRACE_H
3
4#include <lttv/attribute.h>
5#include <lttv/hook.h>
6#include <ltt/ltt.h>
7
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.
12
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.
18
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.
26
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
37 modified.
38
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. */
47
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))
54
55typedef struct _LttvTracesetContext LttvTracesetContext;
56typedef struct _LttvTracesetContextClass LttvTracesetContextClass;
57
58struct _LttvTracesetContext {
59 GObject parent;
60
61 LttvTraceset *ts;
62 LttvHooks *before;
63 LttvHooks *after;
64 LttvTraceContext **traces;
65 LttvAttribute *a;
66};
67
68struct _LttvTracesetContextClass {
69 GObjectClass parent;
70
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);
76};
77
78GType lttv_traceset_context_get_type (void);
79
80void lttv_context_init(LttvTracesetContext *self, LttvTraceset *ts);
81
82void lttv_context_fini(LttvTracesetContext *self);
83
84LttvTracesetContext *
85lttv_context_new_traceset_context(LttvTracesetContext *self);
86
87LttvTraceContext *
88lttv_context_new_trace_context(LttvTracesetContext *self);
89
90LttvTracefileContext *
91lttv_context_new_tracefile_context(LttvTracesetContext *self);
92
93
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))
100
101typedef struct _LttvTraceContext LttvTraceContext;
102typedef struct _LttvTraceContextClass LttvTraceContextClass;
103
104struct _LttvTraceContext {
105 GObject parent;
106
107 LttvTracesetContext *ts_context;
108 guint index; /* in ts_context->traces */
109 LttvTrace *t;
110 LttvHooks *check;
111 LttvHooks *before;
112 LttvHooks *after;
113 LttvTracefileContext **control_tracefiles;
114 LttvTracefileContext **per_cpu_tracefiles;
115 LttvAttribute *a;
116};
117
118struct _LttvTraceContextClass {
119 GObjectClass parent;
120};
121
122GType lttv_trace_context_get_type (void);
123
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))
130
131typedef struct _LttvTracefileContext LttvTracefileContext;
132typedef struct _LttvTracefileContextClass LttvTracefileContextClass;
133
134struct _LttvTracefileContext {
135 GObject parent;
136
137 LttvTraceContext *t_context;
138 gboolean control;
139 guint index; /* in ts_context->control/per_cpu_tracefiles */
140 LttvTracefile *tf;
141 LttvHooks *check;
142 LttvHooks *before;
143 LttvHooks *after;
144 LttvEvent *e;
145 LttvHooks *check_event;
146 LttvHooks *before_event;
147 LttvHooksById *before_event_by_id;
148 LttvHooks *after_event;
149 LttvHooksById *after_event_by_id;
150 LttTime *time;
151 LttvAttribute *a;
152};
153
154struct _LttvTracefileContextClass {
155 GObjectClass parent;
156};
157
158GType lttv_tracefile_context_get_type (void);
159
160void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset,
161 LttvTracesetContext *context);
162
163void 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)
172
173void 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)
182
183#endif // PROCESSTRACE_H
This page took 0.028285 seconds and 4 git commands to generate.