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