Commit | Line | Data |
---|---|---|
6e512b93 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are made | |
5 | * 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 | * | |
860cadcf FC |
9 | * Contributors: |
10 | * Alvaro Sanchez-Leon - Initial implementation | |
11 | * Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission | |
6e512b93 ASL |
12 | *******************************************************************************/ |
13 | package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor; | |
14 | ||
15 | import java.util.Vector; | |
16 | ||
6c13869b FC |
17 | import org.eclipse.linuxtools.lttng.core.event.LttngEvent; |
18 | import org.eclipse.linuxtools.lttng.core.state.StateStrings.Events; | |
19 | import org.eclipse.linuxtools.lttng.core.state.evProcessor.ILttngEventProcessor; | |
20 | import org.eclipse.linuxtools.lttng.core.state.model.LttngProcessState; | |
21 | import org.eclipse.linuxtools.lttng.core.state.model.LttngTraceState; | |
6e512b93 ASL |
22 | import org.eclipse.linuxtools.lttng.ui.TraceDebug; |
23 | import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent; | |
24 | import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent; | |
25 | import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; | |
26 | ||
27 | /** | |
28 | * Creates specific finish state data request | |
29 | * | |
30 | * @author alvaro | |
31 | * | |
32 | */ | |
33 | public class FlowFinishUpdateHandler extends AbsFlowTRangeUpdate | |
34 | implements ILttngEventProcessor { | |
35 | ||
36 | public Events getEventHandleType() { | |
37 | // No specific event | |
38 | return null; | |
39 | } | |
40 | ||
a79913eb | 41 | @SuppressWarnings("deprecation") |
d4011df2 | 42 | @Override |
6e512b93 | 43 | public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) { |
a72a38d9 ASL |
44 | // The end of the last state is unknown since it's beyond the requested time range window. Create this last |
45 | // event to half page after the visible window but not beyond the end of trace | |
46 | long endOfTrace = traceSt.getContext().getTraceTimeWindow().getEndTime().getValue(); | |
47 | long halfWindow = (params.getEndTime() - params.getStartTime()) / 2; | |
48 | ||
49 | // End of event common to all processes within the trace for this specific request | |
50 | long endOfEvent = params.getEndTime() + halfWindow; | |
51 | if (endOfEvent > endOfTrace) { | |
52 | endOfEvent = endOfTrace; | |
53 | } | |
54 | ||
3b38ea61 | 55 | TraceDebug.debug("Number of localProcesses: " + procContainer.readItems().length); //$NON-NLS-1$ |
6e512b93 ASL |
56 | // to identify the process relevant to the traceState |
57 | String traceId = traceSt.getTraceId(); | |
58 | int numLocalFound = 0; | |
59 | int numLocalNotFound = 0; | |
60 | int numWithNoChildren = 0; | |
61 | for (TimeRangeEventProcess localProcess : procContainer.readItems()) { | |
62 | LttngProcessState stateProcess = lttv_state_find_process(traceSt, | |
63 | localProcess.getCpu(), localProcess.getPid()); | |
64 | ||
65 | // Drawing the last state for processes related to the current trace | |
66 | // id. | |
67 | if (!localProcess.getTraceID().equals(traceId)) { | |
68 | continue; | |
69 | } | |
70 | ||
71 | // Check if the process is in the state provider, it is the case | |
72 | // when the requested time frame did not include any events for a | |
73 | // process | |
74 | if (stateProcess == null) { | |
75 | // Get Start time from the end time of previous event | |
76 | Vector<TimeRangeComponent> childrenEvents = localProcess | |
77 | .getTraceEvents(); | |
78 | long nextGoodTime; | |
79 | String stateMode; | |
80 | if (childrenEvents.size() > 0) { | |
81 | TimeRangeComponent prevEvent = childrenEvents | |
82 | .get(childrenEvents.size() - 1); | |
83 | if (prevEvent instanceof TimeRangeEvent) { | |
84 | TimeRangeEvent prevTimeRange = (TimeRangeEvent) prevEvent; | |
85 | // calculate the next good time to draw the event | |
86 | // nextGoodTime = prevTimeRange.getStopTime() + 1; | |
87 | nextGoodTime = localProcess.getNext_good_time(); | |
88 | stateMode = prevTimeRange.getStateMode(); | |
89 | ||
90 | // Draw with the Local information since the current | |
91 | // request did | |
92 | // not contain events related to this process | |
a72a38d9 | 93 | makeDraw(traceSt, nextGoodTime, endOfEvent, localProcess, params, stateMode); |
6e512b93 | 94 | } else { |
3b38ea61 | 95 | TraceDebug.debug("previous event not instance of TimeRangeEvent?: " //$NON-NLS-1$ |
a72a38d9 | 96 | + prevEvent.getClass().getSimpleName()); |
6e512b93 ASL |
97 | } |
98 | } else { | |
99 | numWithNoChildren++; | |
100 | } | |
101 | ||
102 | numLocalNotFound++; | |
103 | continue; | |
104 | } | |
a72a38d9 | 105 | |
6e512b93 ASL |
106 | numLocalFound++; |
107 | // Draw the last state for this process | |
a72a38d9 | 108 | makeDraw(traceSt, endOfEvent, stateProcess, localProcess, params); |
6e512b93 ASL |
109 | } |
110 | ||
3b38ea61 FC |
111 | TraceDebug.debug("Print Last Event: NumLocalFound " + numLocalFound //$NON-NLS-1$ |
112 | + "; NumLocalNotFound: " + numLocalNotFound //$NON-NLS-1$ | |
113 | + "; NumWithNoChildren: " + numWithNoChildren); //$NON-NLS-1$ | |
6e512b93 ASL |
114 | |
115 | return false; | |
116 | } | |
117 | ||
118 | } |