Commit | Line | Data |
---|---|---|
6e512b93 ASL |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2009 Ericsson\r | |
3 | * \r | |
4 | * All rights reserved. This program and the accompanying materials are\r | |
5 | * made available under the terms of the Eclipse Public License v1.0 which\r | |
6 | * accompanies this distribution, and is available at\r | |
7 | * http://www.eclipse.org/legal/epl-v10.html\r | |
8 | * \r | |
9 | * Contributors:\r | |
10 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation\r | |
11 | *******************************************************************************/\r | |
12 | package org.eclipse.linuxtools.lttng.ui.model.trange;\r | |
13 | \r | |
14 | import java.util.HashMap;\r | |
15 | import java.util.Map;\r | |
16 | \r | |
17 | import org.eclipse.linuxtools.lttng.state.StateStrings.BdevMode;\r | |
18 | import org.eclipse.linuxtools.lttng.state.StateStrings.CpuMode;\r | |
19 | import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode;\r | |
20 | import org.eclipse.linuxtools.lttng.state.StateStrings.IRQMode;\r | |
21 | import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;\r | |
22 | import org.eclipse.linuxtools.lttng.state.StateStrings.SoftIRQMode;\r | |
23 | import org.eclipse.linuxtools.lttng.state.StateStrings.TrapMode;\r | |
a72a38d9 | 24 | import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater;\r |
6e512b93 | 25 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r |
dfaf8391 | 26 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r |
63eecb47 | 27 | import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r |
6e512b93 ASL |
28 | \r |
29 | public class TimeRangeViewerProvider extends TmfTimeAnalysisProvider {\r | |
30 | // ========================================================================\r | |
31 | // Data\r | |
32 | // =======================================================================\r | |
33 | Map<String, StateColor> procStateToColor = new HashMap<String, StateColor>(\r | |
34 | 16);\r | |
35 | Map<String, StateColor> bdevStateToColor = new HashMap<String, StateColor>(\r | |
36 | 4);\r | |
37 | Map<String, StateColor> softIrqStateToColor = new HashMap<String, StateColor>(\r | |
38 | 4);\r | |
39 | Map<String, StateColor> trapStateToColor = new HashMap<String, StateColor>(\r | |
40 | 4);\r | |
41 | Map<String, StateColor> irqStateToColor = new HashMap<String, StateColor>(4);\r | |
42 | Map<String, StateColor> cpuStateToColor = new HashMap<String, StateColor>(8);\r | |
43 | \r | |
a72a38d9 ASL |
44 | private final ParamsUpdater fviewParameters;\r |
45 | \r | |
6e512b93 ASL |
46 | // ========================================================================\r |
47 | // Constructors\r | |
48 | // =======================================================================\r | |
a72a38d9 | 49 | public TimeRangeViewerProvider(ParamsUpdater paramsUpdater) {\r |
6e512b93 ASL |
50 | // Fill the statemode to color maps\r |
51 | fillProcessStateToColor();\r | |
52 | fillBdevStateToColor();\r | |
53 | fillSoftIRQStateToColor();\r | |
54 | fillTrapStateToColor();\r | |
55 | fillIrqStateToColor();\r | |
56 | fillCpuStateToColor();\r | |
a72a38d9 | 57 | fviewParameters = paramsUpdater;\r |
6e512b93 ASL |
58 | }\r |
59 | \r | |
60 | // ========================================================================\r | |
61 | // Methods\r | |
62 | // =======================================================================\r | |
63 | @Override\r | |
64 | public StateColor getEventColor(ITimeEvent event) {\r | |
65 | StateColor retColor = null;\r | |
66 | \r | |
67 | if (event instanceof TimeRangeEvent) {\r | |
68 | TimeRangeEvent devent = (TimeRangeEvent) event;\r | |
69 | String stateMode = devent.getStateMode();\r | |
70 | switch (devent.getEventType()) {\r | |
71 | case PROCESS_MODE:\r | |
72 | retColor = procStateToColor.get(stateMode);\r | |
73 | break;\r | |
74 | case BDEV_MODE:\r | |
75 | retColor = bdevStateToColor.get(stateMode);\r | |
76 | break;\r | |
77 | case IRQ_MODE:\r | |
78 | retColor = irqStateToColor.get(stateMode);\r | |
79 | break;\r | |
80 | case SOFT_IRQ_MODE:\r | |
81 | retColor = softIrqStateToColor.get(stateMode);\r | |
82 | break;\r | |
83 | case CPU_MODE:\r | |
84 | retColor = cpuStateToColor.get(stateMode);\r | |
85 | break;\r | |
86 | case TRAP_MODE:\r | |
87 | retColor = trapStateToColor.get(stateMode);\r | |
88 | break;\r | |
89 | }\r | |
90 | }\r | |
91 | \r | |
92 | if (retColor == null) {\r | |
93 | return StateColor.MAGENTA3;\r | |
94 | }\r | |
95 | return retColor;\r | |
96 | }\r | |
97 | \r | |
98 | /* (non-Javadoc)\r | |
99 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.api.TsfTmAbstractImplProvider#getStateName(org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.api.TsfTmAbstractImplProvider.StateColor)\r | |
100 | */\r | |
101 | @Override\r | |
102 | public String getStateName(StateColor color) {\r | |
103 | //Override to multiple instances of the widget, the same color can have multiple meanings\r | |
9c4eb5f7 | 104 | return "Not mapped"; //$NON-NLS-1$\r |
6e512b93 ASL |
105 | }\r |
106 | \r | |
107 | @Override\r | |
108 | public Map<String, String> getEventHoverToolTipInfo(ITimeEvent revent) {\r | |
109 | Map<String, String> toolTipEventMsgs = new HashMap<String, String>();\r | |
63eecb47 FC |
110 | //if the selected resource is a Process, add the Process type to the tool tip\r |
111 | if (revent instanceof TimeRangeComponent) {\r | |
112 | ITimeRangeComponent parent = ((TimeRangeComponent) revent)\r | |
113 | .getEventParent();\r | |
a72a38d9 ASL |
114 | \r |
115 | // if the event start time is unknown, indicate it to the user\r | |
116 | String extraInfo = "\ni.e. outside of data time window";\r | |
117 | long eventStart = revent.getTime();\r | |
118 | if (eventStart < fviewParameters.getStartTime()) {\r | |
119 | toolTipEventMsgs.put("Start Time:", "Actual Event Start Time is undefined" + extraInfo);\r | |
120 | // avoid repeated details\r | |
9c4eb5f7 | 121 | extraInfo = ""; //$NON-NLS-1$\r |
a72a38d9 ASL |
122 | }\r |
123 | \r | |
124 | long eventEnd = revent.getTime() + revent.getDuration();\r | |
125 | if (eventEnd > fviewParameters.getEndTime()) {\r | |
126 | toolTipEventMsgs.put("Stop Time:", "Actual Event Stop Time is undefined" + extraInfo);\r | |
127 | }\r | |
128 | \r | |
63eecb47 FC |
129 | if (parent != null && parent instanceof TimeRangeEventProcess) {\r |
130 | TimeRangeEventProcess localProcess = (TimeRangeEventProcess) parent;\r | |
a72a38d9 | 131 | toolTipEventMsgs.put("Process Type", localProcess.getProcessType());\r |
63eecb47 FC |
132 | }\r |
133 | }\r | |
6e512b93 ASL |
134 | \r |
135 | return toolTipEventMsgs;\r | |
136 | }\r | |
137 | \r | |
138 | @Override\r | |
139 | public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) {\r | |
140 | String name = null;\r | |
141 | //The relevant event name for the time range is the actual state mode\r | |
142 | if (event instanceof TimeRangeEvent) {\r | |
143 | TimeRangeEvent devent = (TimeRangeEvent) event;\r | |
144 | StringBuilder sb = new StringBuilder(devent.getStateMode());\r | |
145 | name = sb.toString();\r | |
146 | }\r | |
147 | \r | |
148 | if (name == null) {\r | |
9c4eb5f7 | 149 | return "Unknown"; //$NON-NLS-1$\r |
6e512b93 ASL |
150 | }\r |
151 | return name;\r | |
152 | }\r | |
153 | \r | |
154 | @Override\r | |
155 | public String getTraceClassName(ITmfTimeAnalysisEntry trace) {\r | |
9c4eb5f7 | 156 | String name = ""; //$NON-NLS-1$\r |
6e512b93 ASL |
157 | if (trace instanceof TimeRangeComposite) {\r |
158 | TimeRangeComposite dTrace = (TimeRangeComposite) trace;\r | |
159 | name = dTrace.getClassName();\r | |
160 | }\r | |
161 | return name;\r | |
162 | }\r | |
163 | \r | |
164 | private void fillCpuStateToColor() {\r | |
165 | cpuStateToColor.put(CpuMode.LTTV_CPU_UNKNOWN.getInName(),\r | |
166 | StateColor.BLACK);\r | |
167 | cpuStateToColor.put(CpuMode.LTTV_CPU_IDLE.getInName(), StateColor.GRAY);\r | |
168 | cpuStateToColor.put(CpuMode.LTTV_CPU_BUSY.getInName(),\r | |
169 | StateColor.LIGHT_BLUE);\r | |
170 | cpuStateToColor\r | |
171 | .put(CpuMode.LTTV_CPU_IRQ.getInName(), StateColor.ORANGE);\r | |
172 | cpuStateToColor.put(CpuMode.LTTV_CPU_SOFT_IRQ.getInName(),\r | |
173 | StateColor.PURPLE1);\r | |
174 | cpuStateToColor.put(CpuMode.LTTV_CPU_TRAP.getInName(), StateColor.GOLD);\r | |
175 | }\r | |
176 | \r | |
177 | private void fillIrqStateToColor() {\r | |
178 | irqStateToColor.put(IRQMode.LTTV_IRQ_UNKNOWN.getInName(),\r | |
179 | StateColor.BLACK);\r | |
180 | irqStateToColor.put(IRQMode.LTTV_IRQ_IDLE.getInName(), StateColor.GRAY);\r | |
181 | irqStateToColor.put(IRQMode.LTTV_IRQ_BUSY.getInName(),\r | |
182 | StateColor.ORANGE);\r | |
183 | }\r | |
184 | \r | |
185 | private void fillTrapStateToColor() {\r | |
186 | trapStateToColor.put(TrapMode.LTTV_TRAP_UNKNOWN.getInName(),\r | |
187 | StateColor.BLACK);\r | |
188 | trapStateToColor.put(TrapMode.LTTV_TRAP_IDLE.getInName(),\r | |
189 | StateColor.BLACK);\r | |
190 | trapStateToColor.put(TrapMode.LTTV_TRAP_BUSY.getInName(),\r | |
191 | StateColor.GOLD);\r | |
192 | }\r | |
193 | \r | |
194 | private void fillSoftIRQStateToColor() {\r | |
195 | softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_UNKNOWN.getInName(),\r | |
196 | StateColor.BLACK);\r | |
197 | softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_IDLE.getInName(),\r | |
198 | StateColor.BLACK);\r | |
199 | softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_PENDING.getInName(),\r | |
200 | StateColor.PINK1);\r | |
201 | softIrqStateToColor.put(SoftIRQMode.LTTV_SOFT_IRQ_BUSY.getInName(),\r | |
202 | StateColor.PURPLE1);\r | |
203 | }\r | |
204 | \r | |
205 | private void fillBdevStateToColor() {\r | |
206 | softIrqStateToColor.put(BdevMode.LTTV_BDEV_UNKNOWN.getInName(),\r | |
207 | StateColor.BLACK);\r | |
208 | softIrqStateToColor.put(BdevMode.LTTV_BDEV_IDLE.getInName(),\r | |
209 | StateColor.BLACK);\r | |
210 | softIrqStateToColor.put(BdevMode.LTTV_BDEV_BUSY_READING.getInName(),\r | |
211 | StateColor.DARK_BLUE);\r | |
212 | softIrqStateToColor.put(BdevMode.LTTV_BDEV_BUSY_WRITING.getInName(),\r | |
213 | StateColor.RED);\r | |
214 | }\r | |
215 | \r | |
216 | private void fillProcessStateToColor() {\r | |
217 | // Process Status\r | |
218 | procStateToColor.put(ProcessStatus.LTTV_STATE_UNNAMED.getInName(),\r | |
219 | StateColor.GRAY);\r | |
220 | procStateToColor.put(ProcessStatus.LTTV_STATE_DEAD.getInName(),\r | |
221 | StateColor.BLACK);\r | |
222 | procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT_FORK.getInName(),\r | |
63eecb47 | 223 | StateColor.DARK_GREEN);\r |
6e512b93 ASL |
224 | procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT_CPU.getInName(),\r |
225 | StateColor.DARK_YELLOW);\r | |
226 | procStateToColor.put(ProcessStatus.LTTV_STATE_EXIT.getInName(),\r | |
227 | StateColor.MAGENTA3);\r | |
228 | procStateToColor.put(ProcessStatus.LTTV_STATE_ZOMBIE.getInName(),\r | |
229 | StateColor.PURPLE1);\r | |
230 | procStateToColor.put(ProcessStatus.LTTV_STATE_WAIT.getInName(),\r | |
231 | StateColor.RED);\r | |
232 | \r | |
233 | // Execution Mode\r | |
234 | procStateToColor.put(ExecutionMode.LTTV_STATE_MODE_UNKNOWN.getInName(),\r | |
235 | StateColor.BLACK);\r | |
236 | procStateToColor.put(ExecutionMode.LTTV_STATE_USER_MODE.getInName(),\r | |
237 | StateColor.GREEN);\r | |
238 | procStateToColor.put(ExecutionMode.LTTV_STATE_SYSCALL.getInName(),\r | |
239 | StateColor.DARK_BLUE);\r | |
240 | procStateToColor.put(ExecutionMode.LTTV_STATE_TRAP.getInName(),\r | |
241 | StateColor.GOLD);\r | |
242 | procStateToColor.put(ExecutionMode.LTTV_STATE_IRQ.getInName(),\r | |
243 | StateColor.ORANGE);\r | |
244 | procStateToColor.put(ExecutionMode.LTTV_STATE_SOFT_IRQ.getInName(),\r | |
245 | StateColor.PINK1);\r | |
246 | }\r | |
247 | }\r |