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