Commit | Line | Data |
---|---|---|
03c71d1e ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 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 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.linuxtools.lttng.tests.state.handlers.before; | |
13 | ||
14 | import org.eclipse.linuxtools.lttng.TraceDebug; | |
15 | import org.eclipse.linuxtools.lttng.event.LttngEvent; | |
16 | import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode; | |
17 | import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionSubMode; | |
18 | import org.eclipse.linuxtools.lttng.state.StateStrings.Fields; | |
8827c197 | 19 | import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor; |
03c71d1e ASL |
20 | import org.eclipse.linuxtools.lttng.state.model.LttngExecutionState; |
21 | import org.eclipse.linuxtools.lttng.state.model.LttngProcessState; | |
22 | import org.eclipse.linuxtools.lttng.state.model.LttngTraceState; | |
23 | import org.eclipse.linuxtools.lttng.tests.state.handlers.AbsStateUpdate; | |
24 | ||
25 | /** | |
26 | * Process the system call entry event | |
27 | * | |
28 | * @author alvaro | |
29 | * | |
30 | */ | |
3b38ea61 | 31 | @SuppressWarnings("nls") |
03c71d1e ASL |
32 | class StateBeforeUpdateHandlers { |
33 | ||
8827c197 | 34 | final ILttngEventProcessor getSyscallEntryHandler() { |
03c71d1e ASL |
35 | AbsStateUpdate handler = new AbsStateUpdate() { |
36 | ||
37 | // @Override | |
d4011df2 | 38 | @Override |
03c71d1e ASL |
39 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
40 | // TraceDebug.debug("Before event called"); | |
41 | // | |
42 | Long cpu = trcEvent.getCpuId(); | |
43 | ||
44 | // No syscall_entry update for initialization process | |
45 | LttngProcessState process = traceSt.getRunning_process().get( | |
46 | cpu); | |
47 | ||
48 | pid = process.getPid(); | |
49 | if (pid == 0L) { | |
50 | return true; | |
51 | } | |
52 | ||
53 | // Get the expected event field | |
54 | Long syscall = getAFieldLong(trcEvent, traceSt, | |
55 | Fields.LTT_FIELD_SYSCALL_ID); | |
56 | if (syscall == null) { | |
57 | TraceDebug.debug("Syscall Field not found in Event: " | |
58 | + trcEvent.getMarkerName()); | |
59 | return true; | |
60 | } | |
61 | ||
62 | String submode = traceSt.getSyscall_names().get(syscall); | |
63 | ||
64 | if (submode == null) { | |
65 | TraceDebug.debug("Submode not found in Event"); | |
66 | submode = ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN | |
67 | .getInName(); | |
68 | } | |
69 | ||
70 | exState = new LttngExecutionState(); | |
71 | exState.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL); | |
72 | exState.setExec_submode(submode); | |
73 | exState.setEntry_Time(trcEvent.getTimestamp().getValue()); | |
74 | exState.setChange_Time(trcEvent.getTimestamp().getValue()); | |
75 | exState.setCum_cpu_time(0L); | |
76 | ||
77 | return false; | |
78 | } | |
79 | }; | |
80 | return handler; | |
81 | } | |
82 | ||
8827c197 | 83 | final ILttngEventProcessor getsySyscallExitHandler() { |
03c71d1e ASL |
84 | AbsStateUpdate handler = new AbsStateUpdate() { |
85 | ||
86 | // @Override | |
d4011df2 | 87 | @Override |
03c71d1e ASL |
88 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
89 | ||
90 | Long cpu = trcEvent.getCpuId(); | |
91 | LttngProcessState process = traceSt.getRunning_process().get( | |
92 | cpu); | |
93 | ||
94 | /* There can be no system call from PID 0 : unknown state */ | |
95 | pid = process.getPid(); | |
96 | if (pid == 0L) { | |
97 | return true; | |
98 | } | |
99 | ||
100 | // pop_state(cpu, StateStrings.ExecutionMode.LTTV_STATE_SYSCALL, | |
101 | // traceSt, trcEvent.getTimestamp()); | |
102 | return false; | |
103 | ||
104 | } | |
105 | }; | |
106 | return handler; | |
107 | } | |
108 | ||
109 | /** | |
110 | * Update stacks related to the parsing of an LttngEvent | |
111 | * | |
112 | * @return | |
113 | */ | |
8827c197 | 114 | final ILttngEventProcessor getTrapEntryHandler() { |
03c71d1e ASL |
115 | AbsStateUpdate handler = new AbsStateUpdate() { |
116 | ||
117 | // @Override | |
d4011df2 | 118 | @Override |
03c71d1e ASL |
119 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
120 | // Long cpu = trcEvent.getCpuId(); | |
121 | // | |
122 | // Long trap = getAFieldLong(trcEvent, traceSt, | |
123 | // Fields.LTT_FIELD_TRAP_ID); | |
124 | // if (trap == null) { | |
125 | // return true; | |
126 | // } | |
127 | // | |
128 | // String submode = traceSt.getSyscall_names() | |
129 | // .get(trap); | |
130 | // | |
131 | // if (submode == null) { | |
132 | // submode = ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN | |
133 | // .getInName(); | |
134 | // } | |
135 | // | |
136 | // /* update process state */ | |
137 | // push_state(cpu, StateStrings.ExecutionMode.LTTV_STATE_TRAP, | |
138 | // submode, trcEvent.getTimestamp(), traceSt); | |
139 | // | |
140 | // /* update cpu status */ | |
141 | // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu); | |
142 | // cpu_push_mode(cpust, StateStrings.CpuMode.LTTV_CPU_TRAP); | |
143 | // cpust.setLast_trap(trap); /* update trap status */ | |
144 | // | |
145 | // // update Trap State | |
146 | // LttngTrapState trap_state = traceSt.getTrap_states().get( | |
147 | // trap); | |
148 | // trap_state.incrementRunning(); | |
149 | ||
150 | return false; | |
151 | ||
152 | } | |
153 | }; | |
154 | return handler; | |
155 | } | |
156 | ||
157 | /** | |
158 | * | |
159 | * @return | |
160 | */ | |
8827c197 | 161 | final ILttngEventProcessor getTrapExitHandler() { |
03c71d1e ASL |
162 | AbsStateUpdate handler = new AbsStateUpdate() { |
163 | ||
164 | // @Override | |
d4011df2 | 165 | @Override |
03c71d1e ASL |
166 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
167 | // | |
168 | // Long cpu = trcEvent.getCpuId(); | |
169 | // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu); | |
170 | // Long trap = cpust.getLast_trap(); | |
171 | // | |
172 | // pop_state(cpu, ExecutionMode.LTTV_STATE_TRAP, traceSt, | |
173 | // trcEvent | |
174 | // .getTimestamp()); | |
175 | // | |
176 | // /* update cpu status */ | |
177 | // cpu_pop_mode(cpust); | |
178 | // | |
179 | // /* update trap status */ | |
180 | // if (trap != -1L) { | |
181 | // traceSt.getTrap_states().get(trap).decrementRunning(); | |
182 | // } | |
183 | return false; | |
184 | ||
185 | } | |
186 | }; | |
187 | return handler; | |
188 | } | |
189 | ||
190 | /** | |
191 | * | |
192 | * @return | |
193 | */ | |
8827c197 | 194 | final ILttngEventProcessor getIrqEntryHandler() { |
03c71d1e ASL |
195 | AbsStateUpdate handler = new AbsStateUpdate() { |
196 | ||
197 | // @Override | |
d4011df2 | 198 | @Override |
03c71d1e ASL |
199 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
200 | // | |
201 | // Long cpu = trcEvent.getCpuId(); | |
202 | // | |
203 | // Long irq = getAFieldLong(trcEvent, traceSt, | |
204 | // Fields.LTT_FIELD_IRQ_ID); | |
205 | // if (irq == null) { | |
206 | // return true; | |
207 | // } | |
208 | // | |
209 | // String submode; | |
210 | // submode = traceSt.getIrq_names().get(irq); | |
211 | // | |
212 | // if (submode == null) { | |
213 | // submode = | |
214 | // ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN.getInName(); | |
215 | // } | |
216 | // | |
217 | // /* | |
218 | // * Do something with the info about being in user or system | |
219 | // mode | |
220 | // * when int? | |
221 | // */ | |
222 | // push_state(cpu, ExecutionMode.LTTV_STATE_IRQ, submode, | |
223 | // trcEvent | |
224 | // .getTimestamp(), traceSt); | |
225 | // | |
226 | // /* update cpu state */ | |
227 | // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu); | |
228 | // cpu_push_mode(cpust, CpuMode.LTTV_CPU_IRQ); /* mode stack */ | |
229 | // cpust.setLast_irq(irq); /* last irq */ | |
230 | // | |
231 | // /* udpate irq state */ | |
232 | // irq_push_mode(traceSt.getIrq_states().get(irq), | |
233 | // IRQMode.LTTV_IRQ_BUSY); | |
234 | return false; | |
235 | ||
236 | } | |
237 | }; | |
238 | return handler; | |
239 | } | |
240 | ||
241 | /** | |
242 | * | |
243 | * @return | |
244 | */ | |
8827c197 | 245 | final ILttngEventProcessor getSoftIrqExitHandler() { |
03c71d1e ASL |
246 | AbsStateUpdate handler = new AbsStateUpdate() { |
247 | ||
248 | // @Override | |
d4011df2 | 249 | @Override |
03c71d1e ASL |
250 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
251 | // | |
252 | // Long cpu = trcEvent.getCpuId(); | |
253 | // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu); | |
254 | // Long softirq = cpust.getLast_soft_irq(); | |
255 | // pop_state(cpu, ExecutionMode.LTTV_STATE_SOFT_IRQ, traceSt, | |
256 | // trcEvent.getTimestamp()); | |
257 | // | |
258 | // /* update softirq status */ | |
259 | // if (softirq != -1) { | |
260 | // LttngSoftIRQState softIrqstate = traceSt | |
261 | // .getSoft_irq_states().get(softirq); | |
262 | // softIrqstate.decrementRunning(); | |
263 | // } | |
264 | // | |
265 | // /* update cpu status */ | |
266 | // cpu_pop_mode(cpust); | |
267 | ||
268 | return false; | |
269 | } | |
270 | }; | |
271 | return handler; | |
272 | } | |
273 | ||
274 | /** | |
275 | * | |
276 | * @return | |
277 | */ | |
8827c197 | 278 | final ILttngEventProcessor getIrqExitHandler() { |
03c71d1e ASL |
279 | AbsStateUpdate handler = new AbsStateUpdate() { |
280 | ||
281 | // @Override | |
d4011df2 | 282 | @Override |
03c71d1e ASL |
283 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
284 | // | |
285 | // Long cpu = trcEvent.getCpuId(); | |
286 | // | |
287 | // /* update process state */ | |
288 | // pop_state(cpu, ExecutionMode.LTTV_STATE_IRQ, traceSt, | |
289 | // trcEvent | |
290 | // .getTimestamp()); | |
291 | // | |
292 | // /* update cpu status */ | |
293 | // LTTngCPUState cpust = traceSt.getCpu_states().get(cpu); | |
294 | // cpu_pop_mode(cpust); | |
295 | // | |
296 | // /* update irq status */ | |
297 | // Long last_irq = cpust.getLast_irq(); | |
298 | // if (last_irq != -1L) { | |
299 | // LttngIRQState irq_state = traceSt.getIrq_states().get( | |
300 | // last_irq); | |
301 | // irq_pop_mode(irq_state); | |
302 | // } | |
303 | ||
304 | return false; | |
305 | ||
306 | } | |
307 | }; | |
308 | return handler; | |
309 | } | |
310 | ||
311 | /** | |
312 | * | |
313 | * @return | |
314 | */ | |
8827c197 | 315 | final ILttngEventProcessor getSoftIrqRaiseHandler() { |
03c71d1e ASL |
316 | AbsStateUpdate handler = new AbsStateUpdate() { |
317 | ||
318 | // @Override | |
d4011df2 | 319 | @Override |
03c71d1e ASL |
320 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
321 | // | |
322 | // // Long cpu = trcEvent.getCpuId(); | |
323 | // | |
324 | // // get event field | |
325 | // Long softirq = getAFieldLong(trcEvent, traceSt, | |
326 | // Fields.LTT_FIELD_SOFT_IRQ_ID); | |
327 | // | |
328 | // if (softirq == null) { | |
329 | // return true; | |
330 | // } | |
331 | // | |
332 | // // String submode; | |
333 | // // String[] softIrqNames = traceSt.getSoft_irq_names(); | |
334 | // // if (softirq < softIrqNames.length) { | |
335 | // // submode = softIrqNames[softirq]; | |
336 | // // } else { | |
337 | // // submode = "softirq " + softirq; | |
338 | // // } | |
339 | // | |
340 | // /* update softirq status */ | |
341 | // /* a soft irq raises are not cumulative */ | |
342 | // LttngSoftIRQState irqState = | |
343 | // traceSt.getSoft_irq_states().get( | |
344 | // softirq); | |
345 | // if (irqState != null) { | |
346 | // irqState.setPending(1L); | |
347 | // } else { | |
348 | // TraceDebug | |
349 | // .debug("unexpected soft irq id value: " + softirq); | |
350 | // } | |
351 | ||
352 | return false; | |
353 | ||
354 | } | |
355 | }; | |
356 | return handler; | |
357 | } | |
358 | ||
359 | /** | |
360 | * | |
361 | * @return | |
362 | */ | |
8827c197 | 363 | final ILttngEventProcessor getSoftIrqEntryHandler() { |
03c71d1e ASL |
364 | AbsStateUpdate handler = new AbsStateUpdate() { |
365 | ||
366 | // @Override | |
d4011df2 | 367 | @Override |
03c71d1e ASL |
368 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
369 | // | |
370 | // // obtrain cpu | |
371 | // Long cpu = trcEvent.getCpuId(); | |
372 | // | |
373 | // // get event field | |
374 | // Long softirq = getAFieldLong(trcEvent, traceSt, | |
375 | // Fields.LTT_FIELD_SOFT_IRQ_ID); | |
376 | // | |
377 | // if (softirq == null) { | |
378 | // return true; | |
379 | // } | |
380 | // | |
381 | // // obtain submode | |
382 | // Map<Long, String> softIrqNames = traceSt.getSoft_irq_names(); | |
383 | // String submode = softIrqNames.get(softirq); | |
384 | // if (submode == null) { | |
385 | // submode = "softirq " + softirq; | |
386 | // softIrqNames.put(softirq, submode); | |
387 | // } | |
388 | // | |
389 | // /* update softirq status */ | |
390 | // LttngSoftIRQState irqState = | |
391 | // traceSt.getSoft_irq_states().get( | |
392 | // softirq); | |
393 | // if (irqState != null) { | |
394 | // irqState.decrementPending(); | |
395 | // irqState.incrementRunning(); | |
396 | // } else { | |
397 | // TraceDebug | |
398 | // .debug("unexpected soft irq id value: " + softirq); | |
399 | // } | |
400 | // | |
401 | // /* update cpu state */ | |
402 | // LTTngCPUState cpu_state = traceSt.getCpu_states().get(cpu); | |
403 | // cpu_state.setLast_soft_irq(softirq); | |
404 | // cpu_push_mode(cpu_state, CpuMode.LTTV_CPU_SOFT_IRQ); | |
405 | // | |
406 | // /* update process execution mode state stack */ | |
407 | // push_state(cpu, ExecutionMode.LTTV_STATE_SOFT_IRQ, submode, | |
408 | // trcEvent.getTimestamp(), traceSt); | |
409 | ||
410 | return false; | |
411 | ||
412 | } | |
413 | }; | |
414 | return handler; | |
415 | } | |
416 | ||
417 | /** | |
418 | * Method to handle the event: LTT_EVENT_LIST_INTERRRUPT | |
419 | * | |
420 | * @return | |
421 | */ | |
8827c197 | 422 | final ILttngEventProcessor getEnumInterruptHandler() { |
03c71d1e ASL |
423 | AbsStateUpdate handler = new AbsStateUpdate() { |
424 | ||
425 | // @Override | |
d4011df2 | 426 | @Override |
03c71d1e ASL |
427 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
428 | // String action = getAFieldString(trcEvent, traceSt, | |
429 | // Fields.LTT_FIELD_ACTION); | |
430 | // Long irq = getAFieldLong(trcEvent, traceSt, | |
431 | // Fields.LTT_FIELD_IRQ_ID); | |
432 | // | |
433 | // Map<Long, String> irq_names = traceSt.getIrq_names(); | |
434 | // | |
435 | // irq_names.put(irq, action); | |
436 | return false; | |
437 | ||
438 | } | |
439 | }; | |
440 | return handler; | |
441 | } | |
442 | ||
443 | /** | |
444 | * Handle the event LTT_EVENT_REQUEST_ISSUE | |
445 | * | |
446 | * @return | |
447 | */ | |
8827c197 | 448 | final ILttngEventProcessor getBdevRequestIssueHandler() { |
03c71d1e ASL |
449 | AbsStateUpdate handler = new AbsStateUpdate() { |
450 | ||
451 | // @Override | |
d4011df2 | 452 | @Override |
03c71d1e ASL |
453 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
454 | // | |
455 | // // Get Fields | |
456 | // Long major = getAFieldLong(trcEvent, traceSt, | |
457 | // Fields.LTT_FIELD_MAJOR); | |
458 | // Long minor = getAFieldLong(trcEvent, traceSt, | |
459 | // Fields.LTT_FIELD_MINOR); | |
460 | // Long operation = getAFieldLong(trcEvent, traceSt, | |
461 | // Fields.LTT_FIELD_OPERATION); | |
462 | // | |
463 | // // calculate bdevcode | |
464 | // Long devcode = mkdev(major, minor); | |
465 | // | |
466 | // if (devcode == null) { | |
467 | // TraceDebug | |
468 | // .debug("incorrect calcualtion of bdevcode input( major: " | |
469 | // + major | |
470 | // + " minor: " | |
471 | // + minor | |
472 | // + " operation: " + operation); | |
473 | // return true; | |
474 | // } | |
475 | // | |
476 | // Map<Long, LttngBdevState> bdev_states = traceSt | |
477 | // .getBdev_states(); | |
478 | // // Get the instance | |
479 | // LttngBdevState bdevState = bdev_states.get(devcode); | |
480 | // if (bdevState == null) { | |
481 | // bdevState = new LttngBdevState(); | |
482 | // } | |
483 | // | |
484 | // // update the mode in the stack | |
485 | // if (operation == 0L) { | |
486 | // bdevState.getMode_stack().push( | |
487 | // BdevMode.LTTV_BDEV_BUSY_READING); | |
488 | // } else { | |
489 | // bdevState.getMode_stack().push( | |
490 | // BdevMode.LTTV_BDEV_BUSY_WRITING); | |
491 | // } | |
492 | // | |
493 | // // make sure it is included in the set | |
494 | // bdev_states.put(devcode, bdevState); | |
495 | return false; | |
496 | ||
497 | } | |
498 | }; | |
499 | return handler; | |
500 | } | |
501 | ||
502 | /** | |
503 | * <p> | |
504 | * Handling event: LTT_EVENT_REQUEST_COMPLETE | |
505 | * </p> | |
506 | * <p> | |
507 | * FIELDS(LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION | |
508 | * </p> | |
509 | * | |
510 | * @return | |
511 | */ | |
8827c197 | 512 | final ILttngEventProcessor getBdevRequestCompleteHandler() { |
03c71d1e ASL |
513 | AbsStateUpdate handler = new AbsStateUpdate() { |
514 | ||
515 | // @Override | |
d4011df2 | 516 | @Override |
03c71d1e ASL |
517 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
518 | // | |
519 | // // Get Fields | |
520 | // Long major = getAFieldLong(trcEvent, traceSt, | |
521 | // Fields.LTT_FIELD_MAJOR); | |
522 | // Long minor = getAFieldLong(trcEvent, traceSt, | |
523 | // Fields.LTT_FIELD_MINOR); | |
524 | // Long operation = getAFieldLong(trcEvent, traceSt, | |
525 | // Fields.LTT_FIELD_OPERATION); | |
526 | // | |
527 | // // calculate bdevcode | |
528 | // Long devcode = mkdev(major, minor); | |
529 | // | |
530 | // if (devcode == null) { | |
531 | // TraceDebug | |
532 | // .debug("incorrect calcualtion of bdevcode input( major: " | |
533 | // + major | |
534 | // + " minor: " | |
535 | // + minor | |
536 | // + " operation: " + operation); | |
537 | // return true; | |
538 | // } | |
539 | // | |
540 | // Map<Long, LttngBdevState> bdev_states = traceSt | |
541 | // .getBdev_states(); | |
542 | // // Get the instance | |
543 | // LttngBdevState bdevState = bdev_states.get(devcode); | |
544 | // if (bdevState == null) { | |
545 | // bdevState = new LttngBdevState(); | |
546 | // } | |
547 | // | |
548 | // /* update block device */ | |
549 | // bdev_pop_mode(bdevState); | |
550 | ||
551 | return false; | |
552 | ||
553 | } | |
554 | }; | |
555 | return handler; | |
556 | } | |
557 | ||
558 | /** | |
559 | * <p> | |
560 | * Handles event: LTT_EVENT_FUNCTION_ENTRY | |
561 | * </p> | |
562 | * <p> | |
563 | * FIELDS: LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE | |
564 | * </p> | |
565 | * | |
566 | * @return | |
567 | */ | |
8827c197 | 568 | final ILttngEventProcessor getFunctionEntryHandler() { |
03c71d1e ASL |
569 | AbsStateUpdate handler = new AbsStateUpdate() { |
570 | ||
571 | // @Override | |
d4011df2 | 572 | @Override |
03c71d1e ASL |
573 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
574 | // Long cpu = trcEvent.getCpuId(); | |
575 | // Long funcptr = getAFieldLong(trcEvent, traceSt, | |
576 | // Fields.LTT_FIELD_THIS_FN); | |
577 | // | |
578 | // push_function(traceSt, funcptr, cpu); | |
579 | return false; | |
580 | ||
581 | } | |
582 | }; | |
583 | return handler; | |
584 | } | |
585 | ||
586 | /** | |
587 | * | |
588 | * @return | |
589 | */ | |
8827c197 | 590 | final ILttngEventProcessor getFunctionExitHandler() { |
03c71d1e ASL |
591 | AbsStateUpdate handler = new AbsStateUpdate() { |
592 | ||
593 | // @Override | |
d4011df2 | 594 | @Override |
03c71d1e ASL |
595 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
596 | // | |
597 | // Long funcptr = getAFieldLong(trcEvent, traceSt, | |
598 | // Fields.LTT_FIELD_THIS_FN); | |
599 | // | |
600 | // pop_function(traceSt, trcEvent, funcptr); | |
601 | return false; | |
602 | ||
603 | } | |
604 | }; | |
605 | return handler; | |
606 | } | |
607 | ||
608 | /** | |
609 | * <p> | |
610 | * process event: LTT_EVENT_SYS_CALL_TABLE | |
611 | * </p> | |
612 | * <p> | |
613 | * fields: LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL | |
614 | * </p> | |
615 | * | |
616 | * @return | |
617 | */ | |
8827c197 | 618 | final ILttngEventProcessor getDumpSyscallHandler() { |
03c71d1e ASL |
619 | AbsStateUpdate handler = new AbsStateUpdate() { |
620 | ||
621 | // @Override | |
d4011df2 | 622 | @Override |
03c71d1e ASL |
623 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
624 | // // obtain the syscall id | |
625 | // Long id = getAFieldLong(trcEvent, traceSt, | |
626 | // Fields.LTT_FIELD_ID); | |
627 | // | |
628 | // // Long address = getAFieldLong(trcEvent, traceSt, | |
629 | // // Fields.LTT_FIELD_ADDRESS); | |
630 | // | |
631 | // // Obtain the symbol | |
632 | // String symbol = getAFieldString(trcEvent, traceSt, | |
633 | // Fields.LTT_FIELD_SYMBOL); | |
634 | // | |
635 | // // fill the symbol to the sycall_names collection | |
636 | // traceSt.getSyscall_names().put(id, symbol); | |
637 | ||
638 | return false; | |
639 | } | |
640 | }; | |
641 | return handler; | |
642 | } | |
643 | ||
644 | /** | |
645 | * <p> | |
646 | * Handles event: LTT_EVENT_KPROBE_TABLE | |
647 | * </p> | |
648 | * <p> | |
649 | * Fields: LTT_FIELD_IP, LTT_FIELD_SYMBOL | |
650 | * </p> | |
651 | * | |
652 | * @return | |
653 | */ | |
8827c197 | 654 | final ILttngEventProcessor getDumpKprobeHandler() { |
03c71d1e ASL |
655 | AbsStateUpdate handler = new AbsStateUpdate() { |
656 | ||
657 | // @Override | |
d4011df2 | 658 | @Override |
03c71d1e ASL |
659 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
660 | // | |
661 | // Long ip = getAFieldLong(trcEvent, traceSt, | |
662 | // Fields.LTT_FIELD_IP); | |
663 | // String symbol = getAFieldString(trcEvent, traceSt, | |
664 | // Fields.LTT_FIELD_SYMBOL); | |
665 | // | |
666 | // traceSt.getKprobe_table().put(ip, symbol); | |
667 | ||
668 | return false; | |
669 | ||
670 | } | |
671 | }; | |
672 | return handler; | |
673 | } | |
674 | ||
675 | /** | |
676 | * <p> | |
677 | * Handles: LTT_EVENT_SOFTIRQ_VEC | |
678 | * </p> | |
679 | * <p> | |
680 | * Fields: LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL | |
681 | * </p> | |
682 | * | |
683 | * @return | |
684 | */ | |
8827c197 | 685 | final ILttngEventProcessor getDumpSoftIrqHandler() { |
03c71d1e ASL |
686 | AbsStateUpdate handler = new AbsStateUpdate() { |
687 | ||
688 | // @Override | |
d4011df2 | 689 | @Override |
03c71d1e ASL |
690 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
691 | // | |
692 | // // Get id | |
693 | // Long id = getAFieldLong(trcEvent, traceSt, | |
694 | // Fields.LTT_FIELD_ID); | |
695 | // | |
696 | // // Address not needed | |
697 | // // Long address = ltt_event_get_long_unsigned(e, | |
698 | // // lttv_trace_get_hook_field(th, | |
699 | // // 1)); | |
700 | // | |
701 | // // Get symbol | |
702 | // String symbol = getAFieldString(trcEvent, traceSt, | |
703 | // Fields.LTT_FIELD_SYMBOL); | |
704 | // | |
705 | // // Register the soft irq name | |
706 | // traceSt.getSoft_irq_names().put(id, symbol); | |
707 | return false; | |
708 | ||
709 | } | |
710 | }; | |
711 | return handler; | |
712 | } | |
713 | ||
714 | /** | |
715 | * <p> | |
716 | * Handles: LTT_EVENT_SCHED_SCHEDULE | |
717 | * </p> | |
718 | * <p> | |
719 | * Fields: LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE | |
720 | * </p> | |
721 | * | |
722 | * @return | |
723 | */ | |
8827c197 | 724 | final ILttngEventProcessor getSchedChangeHandler() { |
03c71d1e ASL |
725 | AbsStateUpdate handler = new AbsStateUpdate() { |
726 | ||
727 | // @Override | |
d4011df2 | 728 | @Override |
03c71d1e ASL |
729 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
730 | // | |
731 | // Long cpu = trcEvent.getCpuId(); | |
732 | // TmfTimestamp eventTime = trcEvent.getTimestamp(); | |
733 | // | |
734 | // LttngProcessState process = traceSt.getRunning_process().get( | |
735 | // cpu); | |
736 | // | |
737 | // Long pid_out = getAFieldLong(trcEvent, traceSt, | |
738 | // Fields.LTT_FIELD_PREV_PID); | |
739 | // Long pid_in = getAFieldLong(trcEvent, traceSt, | |
740 | // Fields.LTT_FIELD_NEXT_PID); | |
741 | // Long state_out = getAFieldLong(trcEvent, traceSt, | |
742 | // Fields.LTT_FIELD_PREV_STATE); | |
743 | // | |
744 | // if (process != null) { | |
745 | // | |
746 | // /* | |
747 | // * We could not know but it was not the idle process | |
748 | // * executing. This should only happen at the beginning, | |
749 | // * before the first schedule event, and when the initial | |
750 | // * information (current process for each CPU) is missing. It | |
751 | // * is not obvious how we could, after the fact, compensate | |
752 | // * the wrongly attributed statistics. | |
753 | // */ | |
754 | // | |
755 | // // This test only makes sense once the state is known and if | |
756 | // // there | |
757 | // // is no | |
758 | // // missing events. We need to silently ignore schedchange | |
759 | // // coming | |
760 | // // after a | |
761 | // // process_free, or it causes glitches. (FIXME) | |
762 | // // if(unlikely(process->pid != pid_out)) { | |
763 | // // g_assert(process->pid == 0); | |
764 | // // } | |
765 | // if (process.getPid() == 0 | |
766 | // && process.getState().getExec_mode() == | |
767 | // ExecutionMode.LTTV_STATE_MODE_UNKNOWN) { | |
768 | // if (pid_out == 0) { | |
769 | // /* | |
770 | // * Scheduling out of pid 0 at beginning of the trace | |
771 | // * : we know for sure it is in syscall mode at this | |
772 | // * point. | |
773 | // */ | |
774 | // int stackSize = process.getExecution_stack().size(); | |
775 | // if (stackSize != 1) { | |
776 | // TraceDebug | |
777 | // .debug("unpexpected process execution stack size, expected 1, received: "); | |
778 | // } | |
779 | // | |
780 | // process.getState().setExec_mode( | |
781 | // ExecutionMode.LTTV_STATE_SYSCALL); | |
782 | // process.getState().setProc_status( | |
783 | // ProcessStatus.LTTV_STATE_WAIT); | |
784 | // process.getState().setChage_Time( | |
785 | // trcEvent.getTimestamp()); | |
786 | // process.getState().setEntry_Time( | |
787 | // trcEvent.getTimestamp()); | |
788 | // } | |
789 | // } else { | |
790 | // if (process.getState().getProc_status() == | |
791 | // ProcessStatus.LTTV_STATE_EXIT) { | |
792 | // process.getState().setProc_status( | |
793 | // ProcessStatus.LTTV_STATE_ZOMBIE); | |
794 | // process.getState().setChage_Time( | |
795 | // trcEvent.getTimestamp()); | |
796 | // } else { | |
797 | // if (state_out == 0L) { | |
798 | // process.getState().setProc_status( | |
799 | // ProcessStatus.LTTV_STATE_WAIT_CPU); | |
800 | // } else { | |
801 | // process.getState().setProc_status( | |
802 | // ProcessStatus.LTTV_STATE_WAIT); | |
803 | // } | |
804 | // | |
805 | // process.getState().setChage_Time( | |
806 | // trcEvent.getTimestamp()); | |
807 | // } | |
808 | // | |
809 | // if (state_out == 32L || state_out == 64L) { /* | |
810 | // * EXIT_DEAD | |
811 | // * || | |
812 | // * TASK_DEAD | |
813 | // */ | |
814 | // /* see sched.h for states */ | |
815 | // if (!exit_process(traceSt, process)) { | |
816 | // process.getState().setProc_status( | |
817 | // ProcessStatus.LTTV_STATE_DEAD); | |
818 | // process.getState().setChage_Time( | |
819 | // trcEvent.getTimestamp()); | |
820 | // } | |
821 | // } | |
822 | // } | |
823 | // } | |
824 | // process = lttv_state_find_process_or_create(traceSt, cpu, | |
825 | // pid_in, eventTime); | |
826 | // | |
827 | // traceSt.getRunning_process().put(cpu, process); | |
828 | // | |
829 | // process.getState().setProc_status(ProcessStatus.LTTV_STATE_RUN); | |
830 | // process.getState().setChage_Time(eventTime); | |
831 | // process.setCpu(cpu); | |
832 | // // process->state->s = LTTV_STATE_RUN; | |
833 | // // if(process->usertrace) | |
834 | // // process->usertrace->cpu = cpu; | |
835 | // // process->last_cpu_index = | |
836 | // // ltt_tracefile_num(((LttvTracefileContext*)s)->tf); | |
837 | // | |
838 | // // process->state->change = s->parent.timestamp; | |
839 | // | |
840 | // LTTngCPUState cpu_state = traceSt.getCpu_states().get(cpu); | |
841 | // /* update cpu status */ | |
842 | // if (pid_in == 0) { | |
843 | // | |
844 | // /* going to idle task */ | |
845 | // cpu_set_base_mode(cpu_state, CpuMode.LTTV_CPU_IDLE); | |
846 | // } else { | |
847 | // /* | |
848 | // * scheduling a real task. we must be careful here: if we | |
849 | // * just schedule()'ed to a process that is in a trap, we | |
850 | // * must put the cpu in trap mode | |
851 | // */ | |
852 | // cpu_set_base_mode(cpu_state, CpuMode.LTTV_CPU_BUSY); | |
853 | // if (process.getState().getExec_mode() == | |
854 | // ExecutionMode.LTTV_STATE_TRAP) { | |
855 | // cpu_push_mode(cpu_state, CpuMode.LTTV_CPU_TRAP); | |
856 | // } | |
857 | // } | |
858 | return false; | |
859 | ||
860 | } | |
861 | }; | |
862 | return handler; | |
863 | } | |
864 | ||
865 | /** | |
866 | * <p> | |
867 | * Handles: LTT_EVENT_PROCESS_FORK | |
868 | * </p> | |
869 | * <p> | |
870 | * Fields: FIELD_ARRAY(LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, | |
871 | * LTT_FIELD_CHILD_TGID) | |
872 | * </p> | |
873 | * | |
874 | * @return | |
875 | */ | |
8827c197 | 876 | final ILttngEventProcessor getProcessForkHandler() { |
03c71d1e ASL |
877 | AbsStateUpdate handler = new AbsStateUpdate() { |
878 | ||
879 | // @Override | |
d4011df2 | 880 | @Override |
03c71d1e ASL |
881 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
882 | // | |
883 | // Long cpu = trcEvent.getCpuId(); | |
884 | // LttngProcessState process = traceSt.getRunning_process().get( | |
885 | // cpu); | |
886 | // TmfTimestamp timeStamp = trcEvent.getTimestamp(); | |
887 | // | |
888 | // // /* Parent PID */ | |
889 | // // Long parent_pid = getAFieldLong(trcEvent, traceSt, | |
890 | // // Fields.LTT_FIELD_PARENT_PID); | |
891 | // | |
892 | // /* Child PID */ | |
893 | // /* In the Linux Kernel, there is one PID per thread. */ | |
894 | // Long child_pid = getAFieldLong(trcEvent, traceSt, | |
895 | // Fields.LTT_FIELD_CHILD_PID); | |
896 | // | |
897 | // /* Child TGID */ | |
898 | // /* tgid in the Linux kernel is the "real" POSIX PID. */ | |
899 | // Long child_tgid = getAFieldLong(trcEvent, traceSt, | |
900 | // Fields.LTT_FIELD_CHILD_TGID); | |
901 | // if (child_tgid == null) { | |
902 | // child_tgid = 0L; | |
903 | // } | |
904 | // | |
905 | // /* | |
906 | // * Mathieu : it seems like the process might have been | |
907 | // scheduled | |
908 | // * in before the fork, and, in a rare case, might be the | |
909 | // current | |
910 | // * process. This might happen in a SMP case where we don't | |
911 | // have | |
912 | // * enough precision on the clocks. | |
913 | // * | |
914 | // * Test reenabled after precision fixes on time. (Mathieu) | |
915 | // */ | |
916 | // // #if 0 | |
917 | // // zombie_process = lttv_state_find_process(ts, ANY_CPU, | |
918 | // // child_pid); | |
919 | // // | |
920 | // // if(unlikely(zombie_process != NULL)) { | |
921 | // // /* Reutilisation of PID. Only now we are sure that the old | |
922 | // // PID | |
923 | // // * has been released. FIXME : should know when release_task | |
924 | // // happens | |
925 | // // instead. | |
926 | // // */ | |
927 | // // guint num_cpus = ltt_trace_get_num_cpu(ts->parent.t); | |
928 | // // guint i; | |
929 | // // for(i=0; i< num_cpus; i++) { | |
930 | // // g_assert(zombie_process != ts->running_process[i]); | |
931 | // // } | |
932 | // // | |
933 | // // exit_process(s, zombie_process); | |
934 | // // } | |
935 | // // #endif //0 | |
936 | // | |
937 | // if (process.getPid() == child_pid) { | |
938 | // TraceDebug | |
939 | // .debug("Unexpected, process pid equal to child pid: " | |
940 | // + child_pid | |
941 | // + " Event Time: " | |
942 | // + trcEvent.getTimestamp()); | |
943 | // } | |
944 | // | |
945 | // // g_assert(process->pid != child_pid); | |
946 | // // FIXME : Add this test in the "known state" section | |
947 | // // g_assert(process->pid == parent_pid); | |
948 | // LttngProcessState child_process = lttv_state_find_process( | |
949 | // traceSt, ANY_CPU, child_pid); | |
950 | // if (child_process == null) { | |
951 | // child_process = create_process(traceSt, cpu, child_pid, | |
952 | // child_tgid, timeStamp); | |
953 | // } else { | |
954 | // /* | |
955 | // * The process has already been created : due to time | |
956 | // * imprecision between multiple CPUs : it has been scheduled | |
957 | // * in before creation. Note that we shouldn't have this kind | |
958 | // * of imprecision. | |
959 | // * | |
960 | // * Simply put a correct parent. | |
961 | // */ | |
962 | // StringBuilder sb = new StringBuilder("Process " + child_pid); | |
963 | // sb.append(" has been created at [" | |
964 | // + child_process.getCration_time() + "] "); | |
965 | // sb.append("and inserted at [" | |
966 | // + child_process.getInsertion_time() + "] "); | |
967 | // sb.append("before \nfork on cpu " + cpu + " Event time: [" | |
968 | // + trcEvent + "]\n."); | |
969 | // sb | |
970 | // .append("Probably an unsynchronized TSD problem on the traced machine."); | |
971 | // TraceDebug.debug(sb.toString()); | |
972 | // | |
973 | // // g_assert(0); /* This is a problematic case : the process | |
974 | // // has | |
975 | // // beencreated | |
976 | // // before the fork event */ | |
977 | // child_process.setPpid(process.getPid()); | |
978 | // child_process.setTgid(child_tgid); | |
979 | // } | |
980 | // | |
981 | // if (!child_process.getName().equals( | |
982 | // ProcessStatus.LTTV_STATE_UNNAMED.getInName())) { | |
983 | // TraceDebug.debug("Unexpected child process status: " | |
984 | // + child_process.getName()); | |
985 | // } | |
986 | // | |
987 | // child_process.setName(process.getName()); | |
988 | // child_process.setBrand(process.getBrand()); | |
989 | ||
990 | return false; | |
991 | ||
992 | } | |
993 | }; | |
994 | return handler; | |
995 | } | |
996 | ||
997 | /** | |
998 | * <p> | |
999 | * Handles: LTT_EVENT_KTHREAD_CREATE | |
1000 | * </p> | |
1001 | * <p> | |
1002 | * Fields: LTT_FIELD_PID | |
1003 | * </p> | |
1004 | * | |
1005 | * @return | |
1006 | */ | |
8827c197 | 1007 | final ILttngEventProcessor getProcessKernelThreadHandler() { |
03c71d1e ASL |
1008 | AbsStateUpdate handler = new AbsStateUpdate() { |
1009 | ||
1010 | // @Override | |
d4011df2 | 1011 | @Override |
03c71d1e ASL |
1012 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
1013 | // /* | |
1014 | // * We stamp a newly created process as kernel_thread. The | |
1015 | // thread | |
1016 | // * should not be running yet. | |
1017 | // */ | |
1018 | // | |
1019 | // LttngExecutionState exState; | |
1020 | // Long pid; | |
1021 | // LttngProcessState process; | |
1022 | // | |
1023 | // /* PID */ | |
1024 | // pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID); | |
1025 | // // s->parent.target_pid = pid; | |
1026 | // | |
1027 | // process = lttv_state_find_process_or_create(traceSt, ANY_CPU, | |
1028 | // pid, new TmfTimestamp()); | |
1029 | // | |
1030 | // if (!process.getState().getProc_status().equals( | |
1031 | // ProcessStatus.LTTV_STATE_DEAD)) { | |
1032 | // // Leave only the first element in the stack with execution | |
1033 | // // mode to | |
1034 | // // syscall | |
1035 | // Stack<LttngExecutionState> processExStack = process | |
1036 | // .getExecution_stack(); | |
1037 | // exState = processExStack.firstElement(); | |
1038 | // exState.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL); | |
1039 | // if (processExStack.size() > 1) { | |
1040 | // processExStack.clear(); | |
1041 | // processExStack.add(exState); | |
1042 | // } | |
1043 | // | |
1044 | // // update the process state to the only one in the stack | |
1045 | // process.setState(exState); | |
1046 | // } | |
1047 | // | |
1048 | // process.setType(ProcessType.LTTV_STATE_KERNEL_THREAD); | |
1049 | ||
1050 | return false; | |
1051 | ||
1052 | } | |
1053 | }; | |
1054 | return handler; | |
1055 | } | |
1056 | ||
1057 | /** | |
1058 | * <p> | |
1059 | * Handles: LTT_EVENT_PROCESS_EXIT | |
1060 | * </p> | |
1061 | * <p> | |
1062 | * LTT_FIELD_PID | |
1063 | * </p> | |
1064 | * | |
1065 | * @return | |
1066 | */ | |
8827c197 | 1067 | final ILttngEventProcessor getProcessExitHandler() { |
03c71d1e ASL |
1068 | AbsStateUpdate handler = new AbsStateUpdate() { |
1069 | ||
1070 | // @Override | |
d4011df2 | 1071 | @Override |
03c71d1e ASL |
1072 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
1073 | // | |
1074 | // Long pid; | |
1075 | // LttngProcessState process; | |
1076 | // | |
1077 | // pid = getAFieldLong(trcEvent, traceSt, | |
1078 | // Fields.LTT_FIELD_PID); | |
1079 | // // s->parent.target_pid = pid; | |
1080 | // | |
1081 | // // FIXME : Add this test in the "known state" section | |
1082 | // // g_assert(process->pid == pid); | |
1083 | // | |
1084 | // process = lttv_state_find_process(traceSt, ANY_CPU, pid); | |
1085 | // if (process != null) { | |
1086 | // process.getState().setProc_status( | |
1087 | // ProcessStatus.LTTV_STATE_EXIT); | |
1088 | // } | |
1089 | return false; | |
1090 | ||
1091 | } | |
1092 | }; | |
1093 | return handler; | |
1094 | } | |
1095 | ||
1096 | /** | |
1097 | * <p> | |
1098 | * Handles: LTT_EVENT_PROCESS_FREE | |
1099 | * </p> | |
1100 | * <p> | |
1101 | * Fields: LTT_FIELD_PID | |
1102 | * </p> | |
1103 | * | |
1104 | * @return | |
1105 | */ | |
8827c197 | 1106 | final ILttngEventProcessor getProcessFreeHandler() { |
03c71d1e ASL |
1107 | AbsStateUpdate handler = new AbsStateUpdate() { |
1108 | ||
1109 | // @Override | |
d4011df2 | 1110 | @Override |
03c71d1e ASL |
1111 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
1112 | // | |
1113 | // Long release_pid; | |
1114 | // LttngProcessState process; | |
1115 | // | |
1116 | // /* PID of the process to release */ | |
1117 | // release_pid = getAFieldLong(trcEvent, traceSt, | |
1118 | // Fields.LTT_FIELD_PID); | |
1119 | // // s->parent.target_pid = release_pid; | |
1120 | // | |
1121 | // if (release_pid == 0) { | |
1122 | // TraceDebug.debug("Unexpected release_pid: 0, Event time: " | |
1123 | // + trcEvent.getTimestamp()); | |
1124 | // } | |
1125 | // | |
1126 | // process = lttv_state_find_process(traceSt, ANY_CPU, | |
1127 | // release_pid); | |
1128 | // if (process != null) { | |
1129 | // exit_process(traceSt, process); | |
1130 | // } | |
1131 | ||
1132 | return false; | |
1133 | // DISABLED | |
1134 | // if(process != null) { | |
1135 | /* | |
1136 | * release_task is happening at kernel level : we can now safely | |
1137 | * release the data structure of the process | |
1138 | */ | |
1139 | // This test is fun, though, as it may happen that | |
1140 | // at time t : CPU 0 : process_free | |
1141 | // at time t+150ns : CPU 1 : schedule out | |
1142 | // Clearly due to time imprecision, we disable it. (Mathieu) | |
1143 | // If this weird case happen, we have no choice but to put the | |
1144 | // Currently running process on the cpu to 0. | |
1145 | // I re-enable it following time precision fixes. (Mathieu) | |
1146 | // Well, in the case where an process is freed by a process on | |
1147 | // another | |
1148 | // CPU | |
1149 | // and still scheduled, it happens that this is the schedchange | |
1150 | // that | |
1151 | // will | |
1152 | // drop the last reference count. Do not free it here! | |
1153 | ||
1154 | // int num_cpus = ltt_trace_get_num_cpu(ts->parent.t); | |
1155 | // guint i; | |
1156 | // for(i=0; i< num_cpus; i++) { | |
1157 | // //g_assert(process != ts->running_process[i]); | |
1158 | // if(process == ts->running_process[i]) { | |
1159 | // //ts->running_process[i] = lttv_state_find_process(ts, i, 0); | |
1160 | // break; | |
1161 | // } | |
1162 | // } | |
1163 | // if(i == num_cpus) /* process is not scheduled */ | |
1164 | // exit_process(s, process); | |
1165 | // } | |
1166 | // | |
1167 | // return false; | |
1168 | ||
1169 | } | |
1170 | }; | |
1171 | return handler; | |
1172 | } | |
1173 | ||
1174 | /** | |
1175 | * <p> | |
1176 | * Handles: LTT_EVENT_EXEC | |
1177 | * </p> | |
1178 | * <p> | |
1179 | * FIELDS: LTT_FIELD_FILENAME | |
1180 | * </p> | |
1181 | * | |
1182 | * @return | |
1183 | */ | |
8827c197 | 1184 | final ILttngEventProcessor getProcessExecHandler() { |
03c71d1e ASL |
1185 | AbsStateUpdate handler = new AbsStateUpdate() { |
1186 | ||
1187 | // @Override | |
d4011df2 | 1188 | @Override |
03c71d1e ASL |
1189 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
1190 | // | |
1191 | // Long cpu = trcEvent.getCpuId(); | |
1192 | // LttngProcessState process = traceSt.getRunning_process().get( | |
1193 | // cpu); | |
1194 | // | |
1195 | // // #if 0//how to use a sequence that must be transformed in a | |
1196 | // // string | |
1197 | // // /* PID of the process to release */ | |
1198 | // // guint64 name_len = ltt_event_field_element_number(e, | |
1199 | // // lttv_trace_get_hook_field(th, 0)); | |
1200 | // // //name = ltt_event_get_string(e, | |
1201 | // // lttv_trace_get_hook_field(th, 0)); | |
1202 | // // LttField *child = ltt_event_field_element_select(e, | |
1203 | // // lttv_trace_get_hook_field(th, 0), 0); | |
1204 | // // gchar *name_begin = | |
1205 | // // (gchar*)(ltt_event_data(e)+ltt_event_field_offset(e, | |
1206 | // child)); | |
1207 | // // gchar *null_term_name = g_new(gchar, name_len+1); | |
1208 | // // memcpy(null_term_name, name_begin, name_len); | |
1209 | // // null_term_name[name_len] = '\0'; | |
1210 | // // process->name = g_quark_from_string(null_term_name); | |
1211 | // // #endif //0 | |
1212 | // | |
1213 | // process.setName(getAFieldString(trcEvent, traceSt, | |
1214 | // Fields.LTT_FIELD_FILENAME)); | |
1215 | // process.setBrand(StateStrings.LTTV_STATE_UNBRANDED); | |
1216 | return false; | |
1217 | ||
1218 | } | |
1219 | }; | |
1220 | return handler; | |
1221 | } | |
1222 | ||
1223 | /** | |
1224 | * <p> | |
1225 | * LTT_EVENT_THREAD_BRAND | |
1226 | * </p> | |
1227 | * <p> | |
1228 | * FIELDS: LTT_FIELD_NAME | |
1229 | * </p> | |
1230 | * | |
1231 | * @return | |
1232 | */ | |
8827c197 | 1233 | final ILttngEventProcessor GetThreadBrandHandler() { |
03c71d1e ASL |
1234 | AbsStateUpdate handler = new AbsStateUpdate() { |
1235 | ||
1236 | // @Override | |
d4011df2 | 1237 | @Override |
03c71d1e ASL |
1238 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
1239 | // | |
1240 | // String name; | |
1241 | // Long cpu = trcEvent.getCpuId(); | |
1242 | // LttngProcessState process = traceSt.getRunning_process().get( | |
1243 | // cpu); | |
1244 | // | |
1245 | // name = getAFieldString(trcEvent, traceSt, | |
1246 | // Fields.LTT_FIELD_NAME); | |
1247 | // process.setBrand(name); | |
1248 | return false; | |
1249 | ||
1250 | } | |
1251 | }; | |
1252 | return handler; | |
1253 | } | |
1254 | ||
1255 | /** | |
1256 | * @return | |
1257 | */ | |
8827c197 | 1258 | final ILttngEventProcessor getStateDumpEndHandler() { |
03c71d1e ASL |
1259 | AbsStateUpdate handler = new AbsStateUpdate() { |
1260 | ||
1261 | // @Override | |
d4011df2 | 1262 | @Override |
03c71d1e ASL |
1263 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
1264 | // | |
1265 | // /* For all processes */ | |
1266 | // /* | |
1267 | // * if kernel thread, if stack[0] is unknown, set to syscall | |
1268 | // * mode, wait | |
1269 | // */ | |
1270 | // /* else, if stack[0] is unknown, set to user mode, running */ | |
1271 | // List<LttngProcessState> processes = traceSt.getProcesses(); | |
1272 | // TmfTimestamp time = trcEvent.getTimestamp(); | |
1273 | // | |
1274 | // for (LttngProcessState process : processes) { | |
1275 | // fix_process(process, time); | |
1276 | // } | |
1277 | ||
1278 | return false; | |
1279 | ||
1280 | } | |
1281 | }; | |
1282 | return handler; | |
1283 | } | |
1284 | ||
1285 | /** | |
1286 | * Private method used to establish the first execution state in the stack | |
1287 | * for a given process | |
1288 | * | |
1289 | * @param process | |
1290 | * @param timestamp | |
1291 | */ | |
1292 | // private void fix_process(LttngProcessState process, | |
1293 | // TmfTimestamp timestamp) { | |
1294 | // | |
1295 | // LttngExecutionState es; | |
1296 | // Stack<LttngExecutionState> procStack = process | |
1297 | // .getExecution_stack(); | |
1298 | // | |
1299 | // if (process.getType() == ProcessType.LTTV_STATE_KERNEL_THREAD) { | |
1300 | // es = procStack.firstElement(); | |
1301 | // | |
1302 | // if (es.getExec_mode() == ExecutionMode.LTTV_STATE_MODE_UNKNOWN) { | |
1303 | // es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL); | |
1304 | // es | |
1305 | // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE | |
1306 | // .getInName()); | |
1307 | // es.setEntry_Time(timestamp); | |
1308 | // es.setChage_Time(timestamp); | |
1309 | // es.setCum_cpu_time(0L); | |
1310 | // if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) { | |
1311 | // es.setProc_status(ProcessStatus.LTTV_STATE_WAIT); | |
1312 | // } | |
1313 | // } | |
1314 | // } else { | |
1315 | // es = procStack.firstElement(); | |
1316 | // if (es.getExec_mode() == ExecutionMode.LTTV_STATE_MODE_UNKNOWN) { | |
1317 | // es.setExec_mode(ExecutionMode.LTTV_STATE_USER_MODE); | |
1318 | // es | |
1319 | // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE | |
1320 | // .getInName()); | |
1321 | // es.setEntry_Time(timestamp); | |
1322 | // es.setChage_Time(timestamp); | |
1323 | // es.setCum_cpu_time(0L); | |
1324 | // if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) { | |
1325 | // es.setProc_status(ProcessStatus.LTTV_STATE_RUN); | |
1326 | // } | |
1327 | // | |
1328 | // if (procStack.size() == 1) { | |
1329 | // /* | |
1330 | // * Still in bottom unknown mode, means never did a | |
1331 | // * system call May be either in user mode, syscall | |
1332 | // * mode, running or waiting. | |
1333 | // */ | |
1334 | // /* | |
1335 | // * FIXME : we may be tagging syscall mode when being | |
1336 | // * user mode | |
1337 | // */ | |
1338 | // // Get a new execution State | |
1339 | // es = new LttngExecutionState(); | |
1340 | // | |
1341 | // // initialize values | |
1342 | // es.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL); | |
1343 | // es | |
1344 | // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE | |
1345 | // .getInName()); | |
1346 | // es.setEntry_Time(timestamp); | |
1347 | // es.setChage_Time(timestamp); | |
1348 | // es.setCum_cpu_time(0L); | |
1349 | // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED); | |
1350 | // | |
1351 | // // Push the new state to the stack | |
1352 | // procStack.push(es); | |
1353 | // } | |
1354 | // } | |
1355 | // } | |
1356 | // } | |
1357 | // }; | |
1358 | // return handler; | |
1359 | // } | |
1360 | ||
1361 | /** | |
1362 | * <p> | |
1363 | * Handles: LTT_EVENT_PROCESS_STATE | |
1364 | * </p> | |
1365 | * <p> | |
1366 | * FIELDS: LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME, | |
1367 | * LTT_FIELD_TYPE, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, LTT_FIELD_STATUS, | |
1368 | * LTT_FIELD_TGID | |
1369 | * </p> | |
1370 | * | |
1371 | * @return | |
1372 | */ | |
8827c197 | 1373 | final ILttngEventProcessor getEnumProcessStateHandler() { |
03c71d1e ASL |
1374 | AbsStateUpdate handler = new AbsStateUpdate() { |
1375 | ||
1376 | // @Override | |
d4011df2 | 1377 | @Override |
03c71d1e ASL |
1378 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
1379 | // | |
1380 | // Long parent_pid; | |
1381 | // Long pid; | |
1382 | // Long tgid; | |
1383 | // String command; | |
1384 | // Long cpu = trcEvent.getCpuId(); | |
1385 | // LttngProcessState process = traceSt.getRunning_process().get( | |
1386 | // cpu); | |
1387 | // LttngProcessState parent_process; | |
1388 | // String type; | |
1389 | // // String mode, submode, status; | |
1390 | // LttngExecutionState es; | |
1391 | // | |
1392 | // /* PID */ | |
1393 | // pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID); | |
1394 | // | |
1395 | // /* Parent PID */ | |
1396 | // parent_pid = getAFieldLong(trcEvent, traceSt, | |
1397 | // Fields.LTT_FIELD_PARENT_PID); | |
1398 | // | |
1399 | // /* Command name */ | |
1400 | // command = getAFieldString(trcEvent, traceSt, | |
1401 | // Fields.LTT_FIELD_NAME); | |
1402 | // | |
1403 | // /* TODO: type field, Values need to be verified */ | |
1404 | // /* type */ | |
1405 | // Long typeVal = getAFieldLong(trcEvent, traceSt, | |
1406 | // Fields.LTT_FIELD_TYPE); | |
1407 | // if (typeVal == 0L) { | |
1408 | // type = ProcessType.LTTV_STATE_KERNEL_THREAD.getInName(); | |
1409 | // } else { | |
1410 | // type = ProcessType.LTTV_STATE_USER_THREAD.getInName(); | |
1411 | // } | |
1412 | // | |
1413 | // // FIXME: type is rarely used, enum must match possible | |
1414 | // types. | |
1415 | // | |
1416 | // // /* mode */ | |
1417 | // // mode = getAFieldString(trcEvent, traceSt, | |
1418 | // // Fields.LTT_FIELD_MODE); | |
1419 | // // | |
1420 | // // /* submode */ | |
1421 | // // submode = getAFieldString(trcEvent, traceSt, | |
1422 | // // Fields.LTT_FIELD_SUBMODE); | |
1423 | // // | |
1424 | // // /* status */ | |
1425 | // // status = getAFieldString(trcEvent, traceSt, | |
1426 | // // Fields.LTT_FIELD_STATUS); | |
1427 | // | |
1428 | // /* TGID */ | |
1429 | // tgid = getAFieldLong(trcEvent, traceSt, | |
1430 | // Fields.LTT_FIELD_TGID); | |
1431 | // if (tgid == null) { | |
1432 | // tgid = 0L; | |
1433 | // } | |
1434 | // | |
1435 | // if (pid == 0) { | |
1436 | // for (Long acpu : traceSt.getCpu_states().keySet()) { | |
1437 | // process = lttv_state_find_process(traceSt, acpu, pid); | |
1438 | // if (process != null) { | |
1439 | // process.setPpid(parent_pid); | |
1440 | // process.setTgid(tgid); | |
1441 | // process.setName(command); | |
1442 | // process | |
1443 | // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD); | |
1444 | // } else { | |
1445 | // StringBuilder sb = new StringBuilder( | |
1446 | // "Unexpected, null process read from the TraceState list of processes, event time: " | |
1447 | // + trcEvent.getTimestamp()); | |
1448 | // TraceDebug.debug(sb.toString()); | |
1449 | // } | |
1450 | // } | |
1451 | // } else { | |
1452 | // /* | |
1453 | // * The process might exist if a process was forked while | |
1454 | // * performing the state dump. | |
1455 | // */ | |
1456 | // process = lttv_state_find_process(traceSt, ANY_CPU, pid); | |
1457 | // if (process == null) { | |
1458 | // parent_process = lttv_state_find_process(traceSt, | |
1459 | // ANY_CPU, parent_pid); | |
1460 | // process = create_process(traceSt, cpu, pid, tgid, | |
1461 | // command, trcEvent.getTimestamp()); | |
1462 | // if (parent_process != null) { | |
1463 | // process.setPpid(parent_process.getPid()); | |
1464 | // } | |
1465 | // | |
1466 | // /* Keep the stack bottom : a running user mode */ | |
1467 | // /* | |
1468 | // * Disabled because of inconsistencies in the current | |
1469 | // * statedump states. | |
1470 | // */ | |
1471 | // if (type.equals(ProcessType.LTTV_STATE_KERNEL_THREAD | |
1472 | // .getInName())) { | |
1473 | // /* | |
1474 | // * FIXME Kernel thread : can be in syscall or | |
1475 | // * interrupt or trap. | |
1476 | // */ | |
1477 | // /* | |
1478 | // * Will cause expected trap when in fact being | |
1479 | // * syscall (even after end of statedump event) Will | |
1480 | // * cause expected interrupt when being syscall. | |
1481 | // * (only before end of statedump event) | |
1482 | // */ | |
1483 | // process | |
1484 | // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD); | |
1485 | // | |
1486 | // // #if 0 | |
1487 | // // es->t = LTTV_STATE_SYSCALL; | |
1488 | // // es->s = status; | |
1489 | // // es->n = submode; | |
1490 | // // #endif //0 | |
1491 | // } else { | |
1492 | // /* | |
1493 | // * User space process : bottom : user mode either | |
1494 | // * currently running or scheduled out. can be | |
1495 | // * scheduled out because interrupted in (user mode | |
1496 | // * or in syscall) or because of an explicit call to | |
1497 | // * the scheduler in syscall. Note that the scheduler | |
1498 | // * call comes after the irq_exit, so never in | |
1499 | // * interrupt context. | |
1500 | // */ | |
1501 | // // temp workaround : set size to 1 : only have user | |
1502 | // // mode | |
1503 | // // bottom of stack. | |
1504 | // // will cause g_info message of expected syscall | |
1505 | // // mode when | |
1506 | // // in fact being | |
1507 | // // in user mode. Can also cause expected trap when | |
1508 | // // in fact | |
1509 | // // being user | |
1510 | // // mode in the event of a page fault reenabling | |
1511 | // // interrupts | |
1512 | // // in the handler. | |
1513 | // // Expected syscall and trap can also happen after | |
1514 | // // the end | |
1515 | // // of statedump | |
1516 | // // This will cause a | |
1517 | // // "popping last state on stack, ignoring it." | |
1518 | // | |
1519 | // // process->execution_stack = | |
1520 | // // g_array_set_size(process->execution_stack, 1); | |
1521 | // // es = process->state = | |
1522 | // // &g_array_index(process->execution_stack, | |
1523 | // // LttvExecutionState, 0); | |
1524 | // // a new process must have only one state in the | |
1525 | // // stack and | |
1526 | // // be the same as the current state | |
1527 | // // es = process.getState(); | |
1528 | // // es.setExec_mode(ExecutionMode.LTTV_STATE_MODE_UNKNOWN); | |
1529 | // // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED); | |
1530 | // // es | |
1531 | // // | |
1532 | // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN | |
1533 | // // .getInName()); | |
1534 | // | |
1535 | // // #if 0 | |
1536 | // // es->t = LTTV_STATE_USER_MODE; | |
1537 | // // es->s = status; | |
1538 | // // es->n = submode; | |
1539 | // // #endif //0 | |
1540 | // } | |
1541 | // // TODO: clean up comments above: Moved repeated code | |
1542 | // // from both | |
1543 | // // if / else blocks above, | |
1544 | // // comments left temporarily for easier visualization | |
1545 | // // and | |
1546 | // // comparision with c code | |
1547 | // es = process.getState(); | |
1548 | // es.setExec_mode(ExecutionMode.LTTV_STATE_MODE_UNKNOWN); | |
1549 | // es.setProc_status(ProcessStatus.LTTV_STATE_UNNAMED); | |
1550 | // es | |
1551 | // .setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN | |
1552 | // .getInName()); | |
1553 | // // #if 0 | |
1554 | // // /* UNKNOWN STATE */ | |
1555 | // // { | |
1556 | // // es = process->state = | |
1557 | // // &g_array_index(process->execution_stack, | |
1558 | // // LttvExecutionState, 1); | |
1559 | // // es->t = LTTV_STATE_MODE_UNKNOWN; | |
1560 | // // es->s = LTTV_STATE_UNNAMED; | |
1561 | // // es->n = LTTV_STATE_SUBMODE_UNKNOWN; | |
1562 | // // } | |
1563 | // // #endif //0 | |
1564 | // } else { | |
1565 | // /* | |
1566 | // * The process has already been created : Probably was | |
1567 | // * forked while dumping the process state or was simply | |
1568 | // * scheduled in prior to get the state dump event. | |
1569 | // */ | |
1570 | // process.setPpid(parent_pid); | |
1571 | // process.setTgid(tgid); | |
1572 | // process.setName(command); | |
1573 | // if (type.equals(ProcessType.LTTV_STATE_KERNEL_THREAD | |
1574 | // .getInName())) { | |
1575 | // process | |
1576 | // .setType(ProcessType.LTTV_STATE_KERNEL_THREAD); | |
1577 | // } else { | |
1578 | // process.setType(ProcessType.LTTV_STATE_USER_THREAD); | |
1579 | // } | |
1580 | // | |
1581 | // // es = | |
1582 | // // &g_array_index(process->execution_stack, | |
1583 | // // LttvExecutionState, | |
1584 | // // 0); | |
1585 | // // #if 0 | |
1586 | // // if(es->t == LTTV_STATE_MODE_UNKNOWN) { | |
1587 | // // if(type == LTTV_STATE_KERNEL_THREAD) | |
1588 | // // es->t = LTTV_STATE_SYSCALL; | |
1589 | // // else | |
1590 | // // es->t = LTTV_STATE_USER_MODE; | |
1591 | // // } | |
1592 | // // #endif //0 | |
1593 | // /* | |
1594 | // * Don't mess around with the stack, it will eventually | |
1595 | // * become ok after the end of state dump. | |
1596 | // */ | |
1597 | // } | |
1598 | // } | |
1599 | ||
1600 | return false; | |
1601 | ||
1602 | } | |
1603 | }; | |
1604 | return handler; | |
1605 | } | |
1606 | ||
1607 | } |