Bug 378402: Implementation of ControlFlow view and Resources view for
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / controlflow / ControlFlowPresentationProvider.java
CommitLineData
72b5abb1
PT
1/*******************************************************************************\r
2 * Copyright (c) 2012 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 * Patrick Tasse - Initial API and implementation\r
11 *******************************************************************************/\r
12\r
13package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;\r
14\r
15import java.util.HashMap;\r
16import java.util.Map;\r
17\r
18import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;\r
19import org.eclipse.linuxtools.lttng2.kernel.core.trace.Attributes;\r
20import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;\r
21import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;\r
22import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;\r
23import org.eclipse.linuxtools.tmf.core.statesystem.IStateSystemQuerier;\r
24import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;\r
25import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;\r
26import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;\r
27import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
28import org.eclipse.swt.graphics.RGB;\r
29\r
30public class ControlFlowPresentationProvider extends TimeGraphPresentationProvider {\r
31\r
32 private enum State {\r
33 UNKNOWN (new RGB(100, 100, 100)),\r
34 WAIT (new RGB(200, 200, 0)),\r
35 USERMODE (new RGB(0, 200, 0)),\r
36 SYSCALL (new RGB(0, 0, 200)),\r
37 INTERRUPTED (new RGB(200, 100, 100));\r
38\r
39 public final RGB rgb;\r
40\r
41 private State (RGB rgb) {\r
42 this.rgb = rgb;\r
43 }\r
44 }\r
45\r
46 @Override \r
47 public String getStateTypeName() {\r
48 return Messages.ControlFlowView_stateTypeName;\r
49 }\r
50\r
51 @Override\r
52 public StateItem[] getStateTable() {\r
53 StateItem[] stateTable = new StateItem[State.values().length];\r
54 for (int i = 0; i < stateTable.length; i++) {\r
55 State state = State.values()[i];\r
56 stateTable[i] = new StateItem(state.rgb, state.toString());\r
57 }\r
58 return stateTable;\r
59 }\r
60\r
61 @Override\r
62 public int getStateTableIndex(ITimeEvent event) {\r
63 if (event instanceof ControlFlowEvent) {\r
64 int status = ((ControlFlowEvent) event).getStatus();\r
65 if (status == Attributes.STATUS_WAIT) {\r
66 return State.WAIT.ordinal();\r
67 } else if (status == Attributes.STATUS_RUN_USERMODE) {\r
68 return State.USERMODE.ordinal();\r
69 } else if (status == Attributes.STATUS_RUN_SYSCALL) {\r
70 return State.SYSCALL.ordinal();\r
71 } else if (status == Attributes.STATUS_INTERRUPTED) {\r
72 return State.INTERRUPTED.ordinal();\r
73 }\r
74 }\r
75 return State.UNKNOWN.ordinal();\r
76 }\r
77\r
78 @Override\r
79 public String getEventName(ITimeEvent event) {\r
80 if (event instanceof ControlFlowEvent) {\r
81 int status = ((ControlFlowEvent) event).getStatus();\r
82 if (status == Attributes.STATUS_WAIT) {\r
83 return State.WAIT.toString();\r
84 } else if (status == Attributes.STATUS_RUN_USERMODE) {\r
85 return State.USERMODE.toString();\r
86 } else if (status == Attributes.STATUS_RUN_SYSCALL) {\r
87 return State.SYSCALL.toString();\r
88 } else if (status == Attributes.STATUS_INTERRUPTED) {\r
89 return State.INTERRUPTED.toString();\r
90 }\r
91 }\r
92 return State.UNKNOWN.toString();\r
93 }\r
94\r
95 @Override\r
96 public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
97 Map<String, String> retMap = new HashMap<String, String>();\r
98 if (event instanceof ControlFlowEvent) {\r
99 int status = ((ControlFlowEvent) event).getStatus();\r
100 if (status == Attributes.STATUS_RUN_SYSCALL) {\r
101 ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();\r
102 IStateSystemQuerier ssq = entry.getTrace().getStateSystem();\r
103 try {\r
104 int syscallQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.SYSTEM_CALL);\r
105 ITmfStateInterval value = ssq.querySingleState(event.getTime(), syscallQuark);\r
106 if (!value.getStateValue().isNull()) {\r
107 ITmfStateValue state = value.getStateValue();\r
108 retMap.put(Messages.ControlFlowView_attributeSyscallName, state.toString());\r
109 }\r
110\r
111 } catch (AttributeNotFoundException e) {\r
112 e.printStackTrace();\r
113 } catch (TimeRangeException e) {\r
114 e.printStackTrace();\r
115 }\r
116 } \r
117 }\r
118\r
119 return retMap;\r
120 }\r
121\r
122}\r
This page took 0.035697 seconds and 5 git commands to generate.