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