Commit | Line | Data |
---|---|---|
e363eae1 AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Alexandre Montplaisir - Initial API and implementation | |
11 | ******************************************************************************/ | |
12 | ||
13 | package org.eclipse.tracecompass.analysis.os.linux.core.trace; | |
14 | ||
15 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; | |
16 | ||
17 | import java.util.Collection; | |
18 | ||
19 | import org.eclipse.jdt.annotation.NonNull; | |
20 | ||
21 | import com.google.common.collect.ImmutableList; | |
22 | ||
23 | /** | |
24 | * A kernel event layout to be used by default. This can be useful for | |
25 | * data-driven traces for example, where they can provide whatever event names | |
26 | * they want. | |
27 | * | |
28 | * Due to historical reasons, the definitions are the same as LTTng event names. | |
29 | * | |
30 | * @author Alexandre Montplaisir | |
dbc7991d | 31 | * @since 1.0 |
e363eae1 AM |
32 | */ |
33 | public class DefaultEventLayout implements IKernelAnalysisEventLayout{ | |
34 | ||
35 | /* Event names */ | |
36 | private static final String IRQ_HANDLER_ENTRY = "irq_handler_entry"; //$NON-NLS-1$ | |
37 | private static final String IRQ_HANDLER_EXIT = "irq_handler_exit"; //$NON-NLS-1$ | |
38 | private static final String SOFTIRQ_ENTRY = "softirq_entry"; //$NON-NLS-1$ | |
39 | private static final String SOFTIRQ_EXIT = "softirq_exit"; //$NON-NLS-1$ | |
40 | private static final String SOFTIRQ_RAISE = "softirq_raise"; //$NON-NLS-1$ | |
fb3a499b FG |
41 | private static final String HRTIMER_EXPIRE_ENTRY = "hrtimer_expire_entry"; //$NON-NLS-1$ |
42 | private static final String HRTIMER_EXPIRE_EXIT = "hrtimer_expire_exit"; //$NON-NLS-1$ | |
e363eae1 | 43 | private static final String SCHED_SWITCH = "sched_switch"; //$NON-NLS-1$ |
3bf563da | 44 | private static final String SCHED_PI_SETPRIO = "sched_pi_setprio"; //$NON-NLS-1$ |
e363eae1 | 45 | |
fb3a499b FG |
46 | private static final String SCHED_TTWU = "sched_ttwu"; //$NON-NLS-1$ |
47 | private static final String SCHED_WAKEUP = "sched_wakeup"; //$NON-NLS-1$ | |
48 | private static final String SCHED_WAKEUP_NEW = "sched_wakeup_new"; //$NON-NLS-1$ | |
e363eae1 | 49 | private static final Collection<String> SCHED_WAKEUP_EVENTS = |
fb3a499b | 50 | checkNotNull(ImmutableList.of(SCHED_WAKEUP, SCHED_WAKEUP_NEW)); //$NON-NLS-1$ //$NON-NLS-2$ |
e363eae1 AM |
51 | |
52 | private static final String SCHED_PROCESS_FORK = "sched_process_fork"; //$NON-NLS-1$ | |
53 | private static final String SCHED_PROCESS_EXIT = "sched_process_exit"; //$NON-NLS-1$ | |
54 | private static final String SCHED_PROCESS_FREE = "sched_process_free"; //$NON-NLS-1$ | |
fb3a499b | 55 | private static final String SCHED_PROCESS_EXEC = "sched_process_exec"; //$NON-NLS-1$ |
e363eae1 AM |
56 | private static final String STATEDUMP_PROCESS_STATE = "lttng_statedump_process_state"; //$NON-NLS-1$ |
57 | ||
58 | private static final String SYSCALL_ENTRY_PREFIX = "sys_"; //$NON-NLS-1$ | |
59 | private static final String COMPAT_SYSCALL_ENTRY_PREFIX = "compat_sys_"; //$NON-NLS-1$ | |
60 | private static final String SYSCALL_EXIT_PREFIX = "exit_syscall"; //$NON-NLS-1$ | |
61 | ||
62 | /* Field names */ | |
63 | private static final String IRQ = "irq"; //$NON-NLS-1$ | |
64 | private static final String TID = "tid"; //$NON-NLS-1$ | |
65 | private static final String VEC = "vec"; //$NON-NLS-1$ | |
66 | private static final String PREV_TID = "prev_tid"; //$NON-NLS-1$ | |
67 | private static final String PREV_STATE = "prev_state"; //$NON-NLS-1$ | |
68 | private static final String NEXT_COMM = "next_comm"; //$NON-NLS-1$ | |
69 | private static final String NEXT_TID = "next_tid"; //$NON-NLS-1$ | |
70 | private static final String PARENT_TID = "parent_tid"; //$NON-NLS-1$ | |
71 | private static final String CHILD_COMM = "child_comm"; //$NON-NLS-1$ | |
72 | private static final String CHILD_TID = "child_tid"; //$NON-NLS-1$ | |
3bf563da CM |
73 | private static final String PRIO = "prio"; //$NON-NLS-1$ |
74 | private static final String NEW_PRIO = "newprio"; //$NON-NLS-1$ | |
75 | private static final String NEXT_PRIO = "next_prio"; //$NON-NLS-1$ | |
fb3a499b FG |
76 | private static final String COMM = "comm"; //$NON-NLS-1$ |
77 | private static final String NAME = "name"; //$NON-NLS-1$ | |
78 | private static final String STATUS = "status"; //$NON-NLS-1$ | |
79 | private static final String PREV_COMM = "prev_comm"; //$NON-NLS-1$ | |
80 | private static final String FILENAME = "filename"; //$NON-NLS-1$ | |
e363eae1 AM |
81 | |
82 | /** All instances are the same. Only provide a static instance getter */ | |
83 | private DefaultEventLayout() { | |
84 | } | |
85 | ||
86 | /** | |
87 | * The instance of this event layout | |
88 | * | |
89 | * This object is completely immutable, so no need to create additional | |
90 | * instances via the constructor. | |
91 | */ | |
92 | static final IKernelAnalysisEventLayout INSTANCE = new DefaultEventLayout(); | |
93 | ||
94 | // ------------------------------------------------------------------------ | |
95 | // Event names | |
96 | // ------------------------------------------------------------------------ | |
97 | ||
98 | @Override | |
99 | public String eventIrqHandlerEntry() { | |
100 | return IRQ_HANDLER_ENTRY; | |
101 | } | |
102 | ||
103 | @Override | |
104 | public String eventIrqHandlerExit() { | |
105 | return IRQ_HANDLER_EXIT; | |
106 | } | |
107 | ||
108 | @Override | |
109 | public String eventSoftIrqEntry() { | |
110 | return SOFTIRQ_ENTRY; | |
111 | } | |
112 | ||
113 | @Override | |
114 | public String eventSoftIrqExit() { | |
115 | return SOFTIRQ_EXIT; | |
116 | } | |
117 | ||
118 | @Override | |
119 | public String eventSoftIrqRaise() { | |
120 | return SOFTIRQ_RAISE; | |
121 | } | |
122 | ||
123 | @Override | |
124 | public String eventSchedSwitch() { | |
125 | return SCHED_SWITCH; | |
126 | } | |
127 | ||
dbc7991d AM |
128 | /** |
129 | * @since 1.0 | |
130 | */ | |
3bf563da CM |
131 | @Override |
132 | public String eventSchedPiSetprio() { | |
133 | return SCHED_PI_SETPRIO; | |
134 | } | |
135 | ||
e363eae1 AM |
136 | @Override |
137 | public Collection<String> eventsSchedWakeup() { | |
138 | return SCHED_WAKEUP_EVENTS; | |
139 | } | |
140 | ||
141 | @Override | |
142 | public String eventSchedProcessFork() { | |
143 | return SCHED_PROCESS_FORK; | |
144 | } | |
145 | ||
146 | @Override | |
147 | public String eventSchedProcessExit() { | |
148 | return SCHED_PROCESS_EXIT; | |
149 | } | |
150 | ||
151 | @Override | |
152 | public String eventSchedProcessFree() { | |
153 | return SCHED_PROCESS_FREE; | |
154 | } | |
155 | ||
156 | @Override | |
157 | public @NonNull String eventStatedumpProcessState() { | |
158 | return STATEDUMP_PROCESS_STATE; | |
159 | } | |
160 | ||
161 | @Override | |
162 | public String eventSyscallEntryPrefix() { | |
163 | return SYSCALL_ENTRY_PREFIX; | |
164 | } | |
165 | ||
166 | @Override | |
167 | public String eventCompatSyscallEntryPrefix() { | |
168 | return COMPAT_SYSCALL_ENTRY_PREFIX; | |
169 | } | |
170 | ||
171 | @Override | |
172 | public String eventSyscallExitPrefix() { | |
173 | return SYSCALL_EXIT_PREFIX; | |
174 | } | |
175 | ||
176 | // ------------------------------------------------------------------------ | |
177 | // Event field names | |
178 | // ------------------------------------------------------------------------ | |
179 | ||
180 | @Override | |
181 | public String fieldIrq() { | |
182 | return IRQ; | |
183 | } | |
184 | ||
185 | @Override | |
186 | public String fieldVec() { | |
187 | return VEC; | |
188 | } | |
189 | ||
190 | @Override | |
191 | public String fieldTid() { | |
192 | return TID; | |
193 | } | |
194 | ||
195 | @Override | |
196 | public String fieldPrevTid() { | |
197 | return PREV_TID; | |
198 | } | |
199 | ||
200 | @Override | |
201 | public String fieldPrevState() { | |
202 | return PREV_STATE; | |
203 | } | |
204 | ||
205 | @Override | |
206 | public String fieldNextComm() { | |
207 | return NEXT_COMM; | |
208 | } | |
209 | ||
210 | @Override | |
211 | public String fieldNextTid() { | |
212 | return NEXT_TID; | |
213 | } | |
214 | ||
215 | @Override | |
216 | public String fieldChildComm() { | |
217 | return CHILD_COMM; | |
218 | } | |
219 | ||
220 | @Override | |
221 | public String fieldParentTid() { | |
222 | return PARENT_TID; | |
223 | } | |
224 | ||
225 | @Override | |
226 | public String fieldChildTid() { | |
227 | return CHILD_TID; | |
228 | } | |
229 | ||
fb3a499b | 230 | /** @since 1.0 */ |
3bf563da CM |
231 | @Override |
232 | public String fieldPrio() { | |
233 | return PRIO; | |
234 | } | |
235 | ||
fb3a499b | 236 | /** @since 1.0 */ |
3bf563da CM |
237 | @Override |
238 | public String fieldNewPrio() { | |
239 | return NEW_PRIO; | |
240 | } | |
241 | ||
fb3a499b | 242 | /** @since 1.0 */ |
3bf563da CM |
243 | @Override |
244 | public String fieldNextPrio() { | |
245 | return NEXT_PRIO; | |
246 | } | |
247 | ||
fb3a499b FG |
248 | /** @since 2.0 */ |
249 | @Override | |
250 | public String fieldComm() { | |
251 | return COMM; | |
252 | } | |
253 | ||
254 | /** @since 2.0 */ | |
255 | @Override | |
256 | public String fieldName() { | |
257 | return NAME; | |
258 | } | |
259 | ||
260 | /** @since 2.0 */ | |
261 | @Override | |
262 | public String fieldStatus() { | |
263 | return STATUS; | |
264 | } | |
265 | ||
266 | /** @since 2.0 */ | |
267 | @Override | |
268 | public String fieldPrevComm() { | |
269 | return PREV_COMM; | |
270 | } | |
271 | ||
272 | /** @since 2.0 */ | |
273 | @Override | |
274 | public String fieldFilename() { | |
275 | return FILENAME; | |
276 | } | |
277 | ||
278 | /** @since 2.0 */ | |
279 | @Override | |
280 | public String eventSchedProcessExec() { | |
281 | return SCHED_PROCESS_EXEC; | |
282 | } | |
283 | ||
284 | /** @since 2.0 */ | |
285 | @Override | |
286 | public String eventSchedProcessWakeup() { | |
287 | return SCHED_WAKEUP; | |
288 | } | |
289 | ||
290 | /** @since 2.0 */ | |
291 | @Override | |
292 | public String eventSchedProcessWakeupNew() { | |
293 | return SCHED_WAKEUP_NEW; | |
294 | } | |
295 | ||
296 | /** @since 2.0 */ | |
297 | @Override | |
298 | public String eventHRTimerExpireEntry() { | |
299 | return HRTIMER_EXPIRE_ENTRY; | |
300 | } | |
301 | ||
302 | /** @since 2.0 */ | |
303 | @Override | |
304 | public String eventHRTimerExpireExit() { | |
305 | return HRTIMER_EXPIRE_EXIT; | |
306 | } | |
307 | ||
308 | /** | |
309 | * Event indicating the source of the wakeup signal. | |
310 | * | |
311 | * @return The name of the event | |
312 | * @since 2.0 | |
313 | */ | |
314 | public String eventSchedProcessTTWU() { | |
315 | return SCHED_TTWU; | |
316 | } | |
317 | ||
e363eae1 | 318 | } |