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