1 /* This file is part of the Linux Trace Toolkit trace reading library
2 * Copyright (C) 2004 Mathieu Desnoyers
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.
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.
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.
19 /* This is a header that contains macro helpers to give an object-oriented
20 * access to the Trace context, state and statistics.
24 #include <ltt/trace.h>
25 #include <lttv/tracecontext.h>
26 #include <lttv/state.h>
27 #include <lttv/stats.h>
29 /************ TracesetContext get methods ***************/
31 /* LTTV_TRACESET_CONTEXT_GET_TRACE_CONTEXT
33 * Input : LttvTracesetContext *tsc
34 * int trace number (0 .. num_traces -1)
35 * returns : (LttvTraceContext *)
37 #define LTTV_TRACESET_CONTEXT_GET_TRACE_CONTEXT(tsc, trace_num)\
38 (tsc->traces[trace_num])
40 /* LTTV_TRACESET_CONTEXT_GET_NUM_TRACES
42 * Input : LttvTracesetContext *tsc
43 * returns : (guint) the number of traces
45 #define LTTV_TRACESET_CONTEXT_GET_NUM_TRACES(tsc)\
46 (lttv_traceset_number(tsc->ts))
48 /* LTTV_TRACESET_CONTEXT_GET_TRACESET_STATS
50 * Input : LttvTracesetContext *tsc
51 * returns : (LttvTracesetStats*)
53 #define LTTV_TRACESET_CONTEXT_GET_TRACESET_STATS(tsc)\
54 ((LttvTracesetStats*)tsc)
57 /************ TraceContext get methods ***************/
59 /* LTTV_TRACE_CONTEXT_GET_TRACESET_CONTEXT
61 * Input : LttvTraceContext *tc
62 * returns : (LttvTracesetContext *)
64 #define LTTV_TRACE_CONTEXT_GET_TRACESET_CONTEXT(tc)\
67 /* LTTV_TRACE_CONTEXT_GET_TRACE_INDEX
69 * Input : LttvTraceContext *tc
70 * returns : (guint) trace context index in its traceset context.
72 #define LTTV_TRACE_CONTEXT_GET_TRACE_INDEX(tc)\
77 /* LTTV_TRACE_CONTEXT_GET_TRACE_STATE
79 * Input : LttvTraceContext *tc
80 * returns : (LttvTraceState *)
82 #define LTTV_TRACE_CONTEXT_GET_TRACE_STATE(tc)\
85 /* LTTV_TRACE_CONTEXT_GET_TRACE_STATS
87 * Input : LttvTraceContext *tc
88 * returns : (LttvTraceStats *)
90 #define LTTV_TRACE_CONTEXT_GET_TRACE_STATS(tc)\
93 /* LTTV_TRACE_CONTEXT_GET_CPU_TRACEFILE_CONTEXT
95 * Input : LttvTraceContext *tc
96 * guint cpu_index (0 .. number_cpu-1)
97 * returns : (LttvTracefileContext*)
99 #define LTTV_TRACE_CONTEXT_GET_CPU_TRACEFILE_CONTEXT(tc, cpu_index)\
100 ( tc->tracefiles[cpu_index + ltt_trace_control_tracefile_number(tc->t)] )
102 /* LTTV_TRACE_CONTEXT_GET_NUMBER_CPU
104 * input : LttvTraceContext *tc
105 * returns : (guint) number_cpu
107 #define LTTV_TRACE_CONTEXT_GET_NUMBER_CPU(tc)\
108 ( ltt_trace_per_cpu_tracefile_number(tc->t) )
111 /* LTTV_TRACE_CONTEXT_GET_CONTROL_TRACEFILE_CONTEXT
113 * Input : LttvTraceContext *tc
114 * guint control_index (0 .. number_control-1)
115 * returns : (LttvTracefileContext*)
117 #define LTTV_TRACE_CONTEXT_GET_CONTROL_TRACEFILE_CONTEXT(tc, control_index)\
118 (tc->tracefiles[control_index])
120 /* LTTV_TRACE_CONTEXT_GET_NUMBER_CONTROL
122 * Input : LttvTraceContext *tc
123 * returns : (guint) number_control
125 #define LTTV_TRACE_CONTEXT_GET_NUMBER_CONTROL(tc)\
126 ( ltt_trace_control_tracefile_number(tc->t) )
128 /* LTTV_TRACE_CONTEXT_GET_TRACE
130 * Input : LttvTraceContext *tc
131 * returns : (LttvTrace*)
133 * NOTE : see traceset.h for LttvTrace methods
135 #define LTTV_TRACE_CONTEXT_GET_TRACE(tc)\
142 /************ TracefileContext get methods ***************/
144 /* LTTV_TRACEFILE_CONTEXT_GET_TRACE_CONTEXT
146 * Input : LttvTracefileContext *tfc
147 * returns : (LttvTraceContext*)
149 #define LTTV_TRACEFILE_CONTEXT_GET_TRACE_CONTEXT(tfc)\
152 /* LTTV_TRACEFILE_CONTEXT_GET_EVENT
154 * Input : LttvTracefileContext *tfc
155 * returns : (LttEvent *)
157 #define LTTV_TRACEFILE_CONTEXT_GET_EVENT(tfc)\
160 /* LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATE
162 * Input : LttvTracefileContext *tfc
163 * returns : (LttvTracefileState *)
165 #define LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATE(tfc)\
166 ((LttvTracefileState*)tfc)
168 /* LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATS
170 * Input : LttvTracefileContext *tfc
171 * returns : (LttvTracefileStats *)
173 #define LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_STATS(tfc)\
174 ((LttvTracefileStats*)tfc)
176 /* LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_INDEX
178 * Returns the tracefile index.
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.
183 * Input : LttvTracefileContext *tfc
184 * returns : (guint) cpu_index or control_index.
186 #define LTTV_TRACEFILE_CONTEXT_GET_TRACEFILE_INDEX(tfc)\
189 tfc->index-ltt_trace_control_tracefile_number(tfc->t_context->t))
193 /************ TraceState get methods ***************/
195 /* LTTV_TRACE_STATE_GET_TRACE_CONTEXT
197 * Input : LttvTraceState *tse
198 * returns : (LttvTraceContext*)
201 #define LTTV_TRACE_STATE_GET_TRACE_CONTEXT(tse)\
202 ((LttvTraceContext*)tse)
204 /* LTTV_TRACE_STATE_GET_EVENTTYPE_NAME
206 * Input : LttvTraceState *tse
207 * guint eventtype_number
210 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
212 #define LTTV_TRACE_STATE_GET_EVENTTYPE_NAME(tse, eventtype_number)\
213 (tse->eventtype_names[eventtype_number])
215 /* LTTV_TRACE_STATE_GET_SYSCALL_NAME
217 * Input : LttvTraceState *tse
218 * guint syscall_number
221 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
223 #define LTTV_TRACE_STATE_GET_SYSCALL_NAME(tse, syscall_number)\
224 (tse->syscall_names[syscall_number])
226 /* LTTV_TRACE_STATE_GET_TRAP_NAME
228 * Input : LttvTraceState *tse
232 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
234 #define LTTV_TRACE_STATE_GET_TRAP_NAME(tse, trap_number)\
235 (tse->trap_names[trap_number])
237 /* LTTV_TRACE_STATE_GET_IRQ_NAME
239 * Input : LttvTraceState *tse
243 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
245 #define LTTV_TRACE_STATE_GET_IRQ_NAME(tse, irq_number)\
246 (tse->irq_names[irq_number])
249 /* LTTV_TRACE_STATE_GET_PROCESS_STATE
251 * Input : LttvTraceState *tse
253 * guint cpu_index (0 .. number_cpu-1)
254 * returns : (LttvProcessState *)
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.
261 #define LTTV_TRACE_STATE_GET_PROCESS_STATE(tse, pid, cpu_index)\
262 (lttv_state_find_process( \
263 (LttvTraceFileState*)tse->parent->tracefiles[\
265 ltt_trace_control_tracefile_number((LttvTraceContext*)tse->t)], pid))
268 /* LTTV_TRACE_STATE_GET_NUMBER_CPU
270 * input : LttvTraceState *tse
271 * returns : (guint) number_cpu
273 #define LTTV_TRACE_STATE_GET_NUMBER_CPU(tse)\
274 ( ltt_trace_per_cpu_tracefile_number((LttvTraceState*)tse->t) )
279 /************ TracefileState get methods ***************/
281 /* LTTV_TRACEFILE_STATE_GET_TRACEFILE_CONTEXT
283 * Input : LttvTracefileState *tfse
284 * returns : (LttvTracefileContext*)
287 #define LTTV_TRACEFILE_STATE_GET_TRACEFILE_CONTEXT(tfse)\
288 ((LttvTracefileContext*)tfse)
291 /* LTTV_TRACEFILE_STATE_GET_CURRENT_PROCESS_STATE
293 * Returns the state of the current process.
295 * Input : LttvTracefileState *tfse
296 * returns : (LttvProcessState *)
298 #define LTTV_TRACEFILE_STATE_GET_CURRENT_PROCESS_STATE(tfse)\
301 /* LTTV_TRACEFILE_STATE_GET_CPU_NAME
303 * Input : LttvTracefileState *tfse
306 * NOTE : use g_quark_to_string to convert a GQuark into a static char *
308 #define LTTV_TRACEFILE_STATE_GET_CPU_NAME(tfse)\
312 /* LTTV_TRACEFILE_STATE_GET_PROCESS_STATE
314 * Input : LttvTracefileState *tfse
316 * returns : (LttvProcessState *)
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.
323 #define LTTV_TRACEFILE_STATE_GET_PROCESS_STATE(tfse, pid)\
324 (lttv_state_find_process(tfse, pid))
330 /************ ProcessState get methods ***************/
331 /* Use direct access to LttvProcessState members for other attributes */
332 /* see struct _LttvProcessState definition in state.h */
334 /* LTTV_PROCESS_STATE_GET_CURRENT_EXECUTION_STATE
336 * Input : LttvProcessState *pse
337 * returns : (LttvExecutionState*)
339 #define LTTV_PROCESS_STATE_GET_EXECUTION_STATE(pse)\
342 /* LTTV_PROCESS_STATE_GET_NESTED_EXECUTION_STATE
344 * Input : LttvProcessState *pse
345 * guint nest_number (0 to num_nest-1)
346 * returns : (LttvExecutionState*)
348 #define LTTV_PROCESS_STATE_GET_NESTED_EXECUTION_STATE(pse, num_nest)\
349 (&g_array_index(pse->execution_stack,LttvExecutionState,num_nest))
352 /* LTTV_PROCESS_STATE_GET_NUM_NESTED_EXECUTION_STATES
354 * Returns the number of nested execution states currently on the stack.
356 * Input : LttvProcessState *pse
359 #define LTTV_PROCESS_STATE_GET_NUM_NESTED_EXECUTION_STATES(pse)\
360 (pse->execution_stack->len)
363 /************ ExecutionState get methods ***************/
364 /* Use direct access to LttvExecutionState members to access attributes */
365 /* see struct _LttvExecutionState definition in state.h */
This page took 0.036375 seconds and 4 git commands to generate.