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