Change licence to GPLv2 for files moved from the old ltt directory to lttv
[lttv.git] / lttv / lttv / contextmacros.h
CommitLineData
e6a3b6bd 1/* This file is part of the Linux Trace Toolkit trace reading library
2 * Copyright (C) 2004 Mathieu Desnoyers
3 *
adc007f3
YB
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
e6a3b6bd 7 *
adc007f3 8 * This program is distributed in the hope that it will be useful,
e6a3b6bd 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
adc007f3
YB
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
e6a3b6bd 12 *
adc007f3
YB
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA
e6a3b6bd 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)\
90e19f82 38 (tsc->traces[trace_num])
e6a3b6bd 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)\
90e19f82 46 (lttv_traceset_number(tsc->ts))
e6a3b6bd 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)\
90e19f82 54 ((LttvTracesetStats*)tsc)
e6a3b6bd 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)\
90e19f82 65 (tc->ts_context)
e6a3b6bd 66
68f6d57a 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)\
90e19f82 73 (tc->index)
68f6d57a 74
75
e6a3b6bd 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)\
90e19f82 83 ((LttvTraceState*)tc)
e6a3b6bd 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)\
90e19f82 91 ((LttvTraceStats*)tc)
e6a3b6bd 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)\
90e19f82 100 ( tc->tracefiles[cpu_index + ltt_trace_control_tracefile_number(tc->t)] )
e6a3b6bd 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)\
90e19f82 108 ( ltt_trace_per_cpu_tracefile_number(tc->t) )
e6a3b6bd 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)\
90e19f82 118 (tc->tracefiles[control_index])
e6a3b6bd 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)\
90e19f82 126 ( ltt_trace_control_tracefile_number(tc->t) )
e6a3b6bd 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)\
90e19f82 136 (tc->vt)
e6a3b6bd 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)\
90e19f82 150 (tfc->t_context)
e6a3b6bd 151
152/* LTTV_TRACEFILE_CONTEXT_GET_EVENT
153 *
154 * Input : LttvTracefileContext *tfc
155 * returns : (LttEvent *)
156 */
157#define LTTV_TRACEFILE_CONTEXT_GET_EVENT(tfc)\
90e19f82 158 (tfc->e)
e6a3b6bd 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)\
90e19f82 166 ((LttvTracefileState*)tfc)
e6a3b6bd 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)\
90e19f82 174 ((LttvTracefileStats*)tfc)
e6a3b6bd 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)\
90e19f82
AM
187 (tfc->control?\
188 tfc->index:\
189 tfc->index-ltt_trace_control_tracefile_number(tfc->t_context->t))
e6a3b6bd 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)\
90e19f82 202 ((LttvTraceContext*)tse)
e6a3b6bd 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)\
90e19f82 213 (tse->eventtype_names[eventtype_number])
e6a3b6bd 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 */
b51ef47c 223#define LTTV_TRACE_STATE_GET_SYSCALL_NAME(tse, syscall_number)\
90e19f82 224 (tse->syscall_names[syscall_number])
e6a3b6bd 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)\
90e19f82 235 (tse->trap_names[trap_number])
e6a3b6bd 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 */
b51ef47c 245#define LTTV_TRACE_STATE_GET_IRQ_NAME(tse, irq_number)\
90e19f82 246 (tse->irq_names[irq_number])
e6a3b6bd 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)\
90e19f82
AM
262 (lttv_state_find_process( \
263 (LttvTraceFileState*)tse->parent->tracefiles[\
264 cpu_index+\
265 ltt_trace_control_tracefile_number((LttvTraceContext*)tse->t)], pid))
e6a3b6bd 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)\
90e19f82 274 ( ltt_trace_per_cpu_tracefile_number((LttvTraceState*)tse->t) )
e6a3b6bd 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)\
90e19f82 288 ((LttvTracefileContext*)tfse)
e6a3b6bd 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)\
90e19f82 299 (tfse->process)
e6a3b6bd 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)\
90e19f82 309 (tfse->cpu_name)
e6a3b6bd 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)\
90e19f82 324 (lttv_state_find_process(tfse, pid))
e6a3b6bd 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)\
90e19f82 340 (pse->state)
e6a3b6bd 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)\
90e19f82 349 (&g_array_index(pse->execution_stack,LttvExecutionState,num_nest))
e6a3b6bd 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)\
90e19f82 360 (pse->execution_stack->len)
e6a3b6bd 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.075989 seconds and 4 git commands to generate.