main window call process_traceset for each viewer
[lttv.git] / ltt / branches / poly / include / lttv / processTrace.h
CommitLineData
dc877563 1#ifndef PROCESSTRACE_H
2#define PROCESSTRACE_H
3
ffd54a90 4#include <lttv/traceset.h>
dc877563 5#include <lttv/attribute.h>
6#include <lttv/hook.h>
7#include <ltt/ltt.h>
8
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.
13
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.
19
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.
27
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
38 modified.
39
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. */
48
ffd54a90 49
50typedef struct _LttvTracesetContext LttvTracesetContext;
51typedef struct _LttvTracesetContextClass LttvTracesetContextClass;
52
53typedef struct _LttvTraceContext LttvTraceContext;
54typedef struct _LttvTraceContextClass LttvTraceContextClass;
55
56typedef struct _LttvTracefileContext LttvTracefileContext;
57typedef struct _LttvTracefileContextClass LttvTracefileContextClass;
58
dc877563 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))
65
dc877563 66struct _LttvTracesetContext {
67 GObject parent;
68
69 LttvTraceset *ts;
70 LttvHooks *before;
71 LttvHooks *after;
72 LttvTraceContext **traces;
73 LttvAttribute *a;
308711e5 74 LttvAttribute *ts_a;
f7afe191 75 TimeInterval *Time_Span;
dc877563 76};
77
78struct _LttvTracesetContextClass {
79 GObjectClass parent;
80
81 void (*init) (LttvTracesetContext *self, LttvTraceset *ts);
82 void (*fini) (LttvTracesetContext *self);
83 LttvTracesetContext* (*new_traceset_context) (LttvTracesetContext *self);
84 LttvTraceContext* (*new_trace_context) (LttvTracesetContext *self);
85 LttvTracefileContext* (*new_tracefile_context) (LttvTracesetContext *self);
86};
87
88GType lttv_traceset_context_get_type (void);
89
90void lttv_context_init(LttvTracesetContext *self, LttvTraceset *ts);
91
92void lttv_context_fini(LttvTracesetContext *self);
93
94LttvTracesetContext *
95lttv_context_new_traceset_context(LttvTracesetContext *self);
96
97LttvTraceContext *
98lttv_context_new_trace_context(LttvTracesetContext *self);
99
100LttvTracefileContext *
101lttv_context_new_tracefile_context(LttvTracesetContext *self);
102
103
104#define LTTV_TRACE_CONTEXT_TYPE (lttv_trace_context_get_type ())
105#define LTTV_TRACE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContext))
106#define LTTV_TRACE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContextClass))
107#define LTTV_IS_TRACE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_CONTEXT_TYPE))
108#define LTTV_IS_TRACE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_CONTEXT_TYPE))
109#define LTTV_TRACE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContextClass))
110
dc877563 111struct _LttvTraceContext {
112 GObject parent;
113
114 LttvTracesetContext *ts_context;
115 guint index; /* in ts_context->traces */
ffd54a90 116 LttTrace *t;
308711e5 117 LttvTrace *vt;
dc877563 118 LttvHooks *check;
119 LttvHooks *before;
120 LttvHooks *after;
121 LttvTracefileContext **control_tracefiles;
122 LttvTracefileContext **per_cpu_tracefiles;
123 LttvAttribute *a;
308711e5 124 LttvAttribute *t_a;
dc877563 125};
126
127struct _LttvTraceContextClass {
128 GObjectClass parent;
129};
130
131GType lttv_trace_context_get_type (void);
132
133#define LTTV_TRACEFILE_CONTEXT_TYPE (lttv_tracefile_context_get_type ())
134#define LTTV_TRACEFILE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContext))
135#define LTTV_TRACEFILE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContextClass))
136#define LTTV_IS_TRACEFILE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_CONTEXT_TYPE))
137#define LTTV_IS_TRACEFILE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_CONTEXT_TYPE))
138#define LTTV_TRACEFILE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContextClass))
139
dc877563 140struct _LttvTracefileContext {
141 GObject parent;
142
143 LttvTraceContext *t_context;
144 gboolean control;
145 guint index; /* in ts_context->control/per_cpu_tracefiles */
ffd54a90 146 LttTracefile *tf;
dc877563 147 LttvHooks *check;
148 LttvHooks *before;
149 LttvHooks *after;
ffd54a90 150 LttEvent *e;
dc877563 151 LttvHooks *check_event;
152 LttvHooks *before_event;
153 LttvHooksById *before_event_by_id;
154 LttvHooks *after_event;
155 LttvHooksById *after_event_by_id;
ffd54a90 156 LttTime timestamp;
dc877563 157 LttvAttribute *a;
158};
159
160struct _LttvTracefileContextClass {
161 GObjectClass parent;
162};
163
164GType lttv_tracefile_context_get_type (void);
165
308711e5 166void lttv_process_traceset(LttvTracesetContext *self, LttTime end,
167 unsigned maxNumEvents);
168
169void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start);
170
171void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start);
dc877563 172
173void lttv_traceset_context_add_hooks(LttvTracesetContext *self,
174 LttvHooks *before_traceset,
175 LttvHooks *after_traceset,
176 LttvHooks *check_trace,
177 LttvHooks *before_trace,
178 LttvHooks *after_trace,
ffd54a90 179 LttvHooks *check_tracefile,
180 LttvHooks *before_tracefile,
181 LttvHooks *after_tracefile,
dc877563 182 LttvHooks *check_event,
183 LttvHooks *before_event,
ffd54a90 184 LttvHooks *after_event);
dc877563 185
186void lttv_traceset_context_remove_hooks(LttvTracesetContext *self,
187 LttvHooks *before_traceset,
188 LttvHooks *after_traceset,
189 LttvHooks *check_trace,
190 LttvHooks *before_trace,
191 LttvHooks *after_trace,
ffd54a90 192 LttvHooks *check_tracefile,
193 LttvHooks *before_tracefile,
194 LttvHooks *after_tracefile,
dc877563 195 LttvHooks *check_event,
196 LttvHooks *before_event,
ffd54a90 197 LttvHooks *after_event);
dc877563 198
b445142a 199typedef struct _LttvTraceHook {
200 LttvHook h;
201 guint id;
202 LttField *f1;
203 LttField *f2;
204 LttField *f3;
205} LttvTraceHook;
206
207
208/* Search in the trace for the id of the named event type within the named
209 facility. Then, find the three (if non null) named fields. All that
210 information is then used to fill the LttvTraceHook structure. This
211 is useful to find the specific id for an event within a trace, for
212 registering a hook using this structure as event data;
213 it already contains the (up to three) needed fields handles. */
214
215void lttv_trace_find_hook(LttTrace *t, char *facility, char *event_type,
216 char *field1, char *field2, char *field3, LttvHook h, LttvTraceHook *th);
217
dc877563 218#endif // PROCESSTRACE_H
This page took 0.034342 seconds and 4 git commands to generate.