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