Test that we really have libbabeltrace-ctf
[lttv.git] / lttv / lttv / contextmacros.h
1 /* This file is part of the Linux Trace Toolkit trace reading library
2 * Copyright (C) 2004 Mathieu Desnoyers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License Version 2.1 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 02111-1307, USA.
17 */
18
19 /* This is a header that contains macro helpers to give an object-oriented
20 * access to the Trace context, state and statistics.
21 */
22
23
24 #include <ltt/trace.h>
25 #include <lttv/tracecontext.h>
26 #include <lttv/state.h>
27 #include <lttv/stats.h>
28
29 /************ TracesetContext get methods ***************/
30
31 /* LTTV_TRACESET_CONTEXT_GET_TRACE_CONTEXT
32 *
33 * Input : LttvTracesetContext *tsc
34 * int trace number (0 .. num_traces -1)
35 * returns : (LttvTraceContext *)
36 */
37 #define LTTV_TRACESET_CONTEXT_GET_TRACE_CONTEXT(tsc, trace_num)\
38 (tsc->traces[trace_num])
39
40 /* LTTV_TRACESET_CONTEXT_GET_NUM_TRACES
41 *
42 * Input : LttvTracesetContext *tsc
43 * returns : (guint) the number of traces
44 */
45 #define LTTV_TRACESET_CONTEXT_GET_NUM_TRACES(tsc)\
46 (lttv_traceset_number(tsc->ts))
47
48 /* LTTV_TRACESET_CONTEXT_GET_TRACESET_STATS
49 *
50 * Input : LttvTracesetContext *tsc
51 * returns : (LttvTracesetStats*)
52 */
53 #define LTTV_TRACESET_CONTEXT_GET_TRACESET_STATS(tsc)\
54 ((LttvTracesetStats*)tsc)
55
56
57 /************ TraceContext get methods ***************/
58
59 /* LTTV_TRACE_CONTEXT_GET_TRACESET_CONTEXT
60 *
61 * Input : LttvTraceContext *tc
62 * returns : (LttvTracesetContext *)
63 */
64 #define LTTV_TRACE_CONTEXT_GET_TRACESET_CONTEXT(tc)\
65 (tc->ts_context)
66
67 /* LTTV_TRACE_CONTEXT_GET_TRACE_INDEX
68 *
69 * Input : LttvTraceContext *tc
70 * returns : (guint) trace context index in its traceset context.
71 */
72 #define LTTV_TRACE_CONTEXT_GET_TRACE_INDEX(tc)\
73 (tc->index)
74
75
76
77 /* LTTV_TRACE_CONTEXT_GET_TRACE_STATE
78 *
79 * Input : LttvTraceContext *tc
80 * returns : (LttvTraceState *)
81 */
82 #define LTTV_TRACE_CONTEXT_GET_TRACE_STATE(tc)\
83 ((LttvTraceState*)tc)
84
85 /* LTTV_TRACE_CONTEXT_GET_TRACE_STATS
86 *
87 * Input : LttvTraceContext *tc
88 * returns : (LttvTraceStats *)
89 */
90 #define LTTV_TRACE_CONTEXT_GET_TRACE_STATS(tc)\
91 ((LttvTraceStats*)tc)
92
93 /* LTTV_TRACE_CONTEXT_GET_CPU_TRACEFILE_CONTEXT
94 *
95 * Input : LttvTraceContext *tc
96 * guint cpu_index (0 .. number_cpu-1)
97 * returns : (LttvTracefileContext*)
98 */
99 #define LTTV_TRACE_CONTEXT_GET_CPU_TRACEFILE_CONTEXT(tc, cpu_index)\
100 ( tc->tracefiles[cpu_index + ltt_trace_control_tracefile_number(tc->t)] )
101
102 /* LTTV_TRACE_CONTEXT_GET_NUMBER_CPU
103 *
104 * input : LttvTraceContext *tc
105 * returns : (guint) number_cpu
106 */
107 #define LTTV_TRACE_CONTEXT_GET_NUMBER_CPU(tc)\
108 ( ltt_trace_per_cpu_tracefile_number(tc->t) )
109
110
111 /* LTTV_TRACE_CONTEXT_GET_CONTROL_TRACEFILE_CONTEXT
112 *
113 * Input : LttvTraceContext *tc
114 * guint control_index (0 .. number_control-1)
115 * returns : (LttvTracefileContext*)
116 */
117 #define LTTV_TRACE_CONTEXT_GET_CONTROL_TRACEFILE_CONTEXT(tc, control_index)\
118 (tc->tracefiles[control_index])
119
120 /* LTTV_TRACE_CONTEXT_GET_NUMBER_CONTROL
121 *
122 * Input : LttvTraceContext *tc
123 * returns : (guint) number_control
124 */
125 #define LTTV_TRACE_CONTEXT_GET_NUMBER_CONTROL(tc)\
126 ( ltt_trace_control_tracefile_number(tc->t) )
127
128 /* LTTV_TRACE_CONTEXT_GET_TRACE
129 *
130 * Input : LttvTraceContext *tc
131 * returns : (LttvTrace*)
132 *
133 * NOTE : see traceset.h for LttvTrace methods
134 */
135 #define LTTV_TRACE_CONTEXT_GET_TRACE(tc)\
136 (tc->vt)
137
138
139
140
141
142 /************ TracefileContext get methods ***************/
143
144 /* LTTV_TRACEFILE_CONTEXT_GET_TRACE_CONTEXT
145 *
146 * Input : LttvTracefileContext *tfc
147 * returns : (LttvTraceContext*)
148 */
149 #define LTTV_TRACEFILE_CONTEXT_GET_TRACE_CONTEXT(tfc)\
150 (tfc->t_context)
151
152 /* LTTV_TRACEFILE_CONTEXT_GET_EVENT
153 *
154 * Input : LttvTracefileContext *tfc
155 * returns : (LttEvent *)
156 */
157 #define LTTV_TRACEFILE_CONTEXT_GET_EVENT(tfc)\
158 (tfc->e)
159
160 /* LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATE
161 *
162 * Input : LttvTracefileContext *tfc
163 * returns : (LttvTracefileState *)
164 */
165 #define LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATE(tfc)\
166 ((LttvTracefileState*)tfc)
167
168 /* LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATS
169 *
170 * Input : LttvTracefileContext *tfc
171 * returns : (LttvTracefileStats *)
172 */
173 #define LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATS(tfc)\
174 ((LttvTracefileStats*)tfc)
175
176 /* LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_INDEX
177 *
178 * Returns the tracefile index.
179 *
180 * It checks if it's a control tracefile or a cpu tracefile and returns the
181 * cpu_index or control_index, depending of the case.
182 *
183 * Input : LttvTracefileContext *tfc
184 * returns : (guint) cpu_index or control_index.
185 */
186 #define LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_INDEX(tfc)\
187 (tfc->control?\
188 tfc->index:\
189 tfc->index-ltt_trace_control_tracefile_number(tfc->t_context->t))
190
191
192
193 /************ TraceState get methods ***************/
194
195 /* LTTV_TRACE_STATE_GET_TRACE_CONTEXT
196 *
197 * Input : LttvTraceState *tse
198 * returns : (LttvTraceContext*)
199 *
200 */
201 #define LTTV_TRACE_STATE_GET_TRACE_CONTEXT(tse)\
202 ((LttvTraceContext*)tse)
203
204 /* LTTV_TRACE_STATE_GET_EVENTTYPE_NAME
205 *
206 * Input : LttvTraceState *tse
207 * guint eventtype_number
208 * returns : (GQuark)
209 *
210 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
211 */
212 #define LTTV_TRACE_STATE_GET_EVENTTYPE_NAME(tse, eventtype_number)\
213 (tse->eventtype_names[eventtype_number])
214
215 /* LTTV_TRACE_STATE_GET_SYSCALL_NAME
216 *
217 * Input : LttvTraceState *tse
218 * guint syscall_number
219 * returns : (GQuark)
220 *
221 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
222 */
223 #define LTTV_TRACE_STATE_GET_SYSCALL_NAME(tse, syscall_number)\
224 (tse->syscall_names[syscall_number])
225
226 /* LTTV_TRACE_STATE_GET_TRAP_NAME
227 *
228 * Input : LttvTraceState *tse
229 * guint trap_number
230 * returns : (GQuark)
231 *
232 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
233 */
234 #define LTTV_TRACE_STATE_GET_TRAP_NAME(tse, trap_number)\
235 (tse->trap_names[trap_number])
236
237 /* LTTV_TRACE_STATE_GET_IRQ_NAME
238 *
239 * Input : LttvTraceState *tse
240 * guint irq_number
241 * returns : (GQuark)
242 *
243 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
244 */
245 #define LTTV_TRACE_STATE_GET_IRQ_NAME(tse, irq_number)\
246 (tse->irq_names[irq_number])
247
248
249 /* LTTV_TRACE_STATE_GET_PROCESS_STATE
250 *
251 * Input : LttvTraceState *tse
252 * guint pid
253 * guint cpu_index (0 .. number_cpu-1)
254 * returns : (LttvProcessState *)
255 *
256 * NOTE : if pid is 0, the special process corresponding to the CPU that
257 * corresponds to the tracefile will be returned.
258 * if pid is different than 0, the process returned may be running
259 * on any cpu of the trace.
260 */
261 #define LTTV_TRACE_STATE_GET_PROCESS_STATE(tse, pid, cpu_index)\
262 (lttv_state_find_process( \
263 (LttvTraceFileState*)tse->parent->tracefiles[\
264 cpu_index+\
265 ltt_trace_control_tracefile_number((LttvTraceContext*)tse->t)], pid))
266
267
268 /* LTTV_TRACE_STATE_GET_NUMBER_CPU
269 *
270 * input : LttvTraceState *tse
271 * returns : (guint) number_cpu
272 */
273 #define LTTV_TRACE_STATE_GET_NUMBER_CPU(tse)\
274 ( ltt_trace_per_cpu_tracefile_number((LttvTraceState*)tse->t) )
275
276
277
278
279 /************ TracefileState get methods ***************/
280
281 /* LTTV_TRACEFILE_STATE_GET_TRACEFILE_CONTEXT
282 *
283 * Input : LttvTracefileState *tfse
284 * returns : (LttvTracefileContext*)
285 *
286 */
287 #define LTTV_TRACEFILE_STATE_GET_TRACEFILE_CONTEXT(tfse)\
288 ((LttvTracefileContext*)tfse)
289
290
291 /* LTTV_TRACEFILE_STATE_GET_CURRENT_PROCESS_STATE
292 *
293 * Returns the state of the current process.
294 *
295 * Input : LttvTracefileState *tfse
296 * returns : (LttvProcessState *)
297 */
298 #define LTTV_TRACEFILE_STATE_GET_CURRENT_PROCESS_STATE(tfse)\
299 (tfse->process)
300
301 /* LTTV_TRACEFILE_STATE_GET_CPU_NAME
302 *
303 * Input : LttvTracefileState *tfse
304 * returns : (GQuark)
305 *
306 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
307 */
308 #define LTTV_TRACEFILE_STATE_GET_CPU_NAME(tfse)\
309 (tfse->cpu_name)
310
311
312 /* LTTV_TRACEFILE_STATE_GET_PROCESS_STATE
313 *
314 * Input : LttvTracefileState *tfse
315 * guint pid
316 * returns : (LttvProcessState *)
317 *
318 * NOTE : if pid is 0, the special process corresponding to the CPU that
319 * corresponds to the tracefile will be returned.
320 * if pid is different than 0, the process returned may be running
321 * on any cpu of the trace.
322 */
323 #define LTTV_TRACEFILE_STATE_GET_PROCESS_STATE(tfse, pid)\
324 (lttv_state_find_process(tfse, pid))
325
326
327
328
329
330 /************ ProcessState get methods ***************/
331 /* Use direct access to LttvProcessState members for other attributes */
332 /* see struct _LttvProcessState definition in state.h */
333
334 /* LTTV_PROCESS_STATE_GET_CURRENT_EXECUTION_STATE
335 *
336 * Input : LttvProcessState *pse
337 * returns : (LttvExecutionState*)
338 */
339 #define LTTV_PROCESS_STATE_GET_EXECUTION_STATE(pse)\
340 (pse->state)
341
342 /* LTTV_PROCESS_STATE_GET_NESTED_EXECUTION_STATE
343 *
344 * Input : LttvProcessState *pse
345 * guint nest_number (0 to num_nest-1)
346 * returns : (LttvExecutionState*)
347 */
348 #define LTTV_PROCESS_STATE_GET_NESTED_EXECUTION_STATE(pse, num_nest)\
349 (&g_array_index(pse->execution_stack,LttvExecutionState,num_nest))
350
351
352 /* LTTV_PROCESS_STATE_GET_NUM_NESTED_EXECUTION_STATES
353 *
354 * Returns the number of nested execution states currently on the stack.
355 *
356 * Input : LttvProcessState *pse
357 * returns : (guint)
358 */
359 #define LTTV_PROCESS_STATE_GET_NUM_NESTED_EXECUTION_STATES(pse)\
360 (pse->execution_stack->len)
361
362
363 /************ ExecutionState get methods ***************/
364 /* Use direct access to LttvExecutionState members to access attributes */
365 /* see struct _LttvExecutionState definition in state.h */
366
367
368
369
370
371
372 /* Statistics */
373
374
375
376
This page took 0.039287 seconds and 4 git commands to generate.