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