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