22 |
22 |
23 import java.awt.event.ActionEvent; |
23 import java.awt.event.ActionEvent; |
24 import java.awt.event.ActionListener; |
24 import java.awt.event.ActionListener; |
25 import java.awt.event.FocusEvent; |
25 import java.awt.event.FocusEvent; |
26 import java.awt.event.FocusListener; |
26 import java.awt.event.FocusListener; |
27 import java.util.Collection; |
|
28 import java.util.Enumeration; |
27 import java.util.Enumeration; |
29 import java.util.Hashtable; |
28 import java.util.Hashtable; |
30 import java.util.Iterator; |
|
31 import java.util.LinkedList; |
|
32 import java.util.Vector; |
29 import java.util.Vector; |
33 |
30 |
34 import org.eclipse.draw2d.FigureCanvas; |
31 import org.eclipse.draw2d.FigureCanvas; |
35 import org.eclipse.draw2d.Graphics; |
32 import org.eclipse.draw2d.Graphics; |
36 import org.eclipse.draw2d.MouseEvent; |
33 import org.eclipse.draw2d.MouseEvent; |
37 import org.eclipse.draw2d.MouseListener; |
34 import org.eclipse.draw2d.MouseListener; |
38 import org.eclipse.draw2d.MouseMotionListener; |
35 import org.eclipse.draw2d.MouseMotionListener; |
39 import org.eclipse.draw2d.Panel; |
36 import org.eclipse.draw2d.Panel; |
40 import org.eclipse.jface.viewers.CheckboxTableViewer; |
37 import org.eclipse.jface.action.Action; |
41 import org.eclipse.swt.SWT; |
38 import org.eclipse.swt.SWT; |
42 import org.eclipse.swt.events.MouseMoveListener; |
39 import org.eclipse.swt.events.MouseMoveListener; |
|
40 import org.eclipse.swt.events.SelectionAdapter; |
|
41 import org.eclipse.swt.events.SelectionEvent; |
43 import org.eclipse.swt.graphics.Color; |
42 import org.eclipse.swt.graphics.Color; |
44 import org.eclipse.swt.graphics.GC; |
43 import org.eclipse.swt.graphics.GC; |
45 import org.eclipse.swt.graphics.Point; |
44 import org.eclipse.swt.graphics.Point; |
46 import org.eclipse.swt.graphics.RGB; |
45 import org.eclipse.swt.graphics.RGB; |
47 import org.eclipse.swt.graphics.Rectangle; |
46 import org.eclipse.swt.graphics.Rectangle; |
48 import org.eclipse.swt.layout.FormLayout; |
47 import org.eclipse.swt.layout.FormLayout; |
49 import org.eclipse.swt.widgets.Composite; |
48 import org.eclipse.swt.widgets.Composite; |
50 import org.eclipse.swt.widgets.Label; |
49 import org.eclipse.swt.widgets.Menu; |
|
50 import org.eclipse.swt.widgets.MenuItem; |
51 import org.eclipse.swt.widgets.Sash; |
51 import org.eclipse.swt.widgets.Sash; |
52 |
52 |
|
53 import com.nokia.carbide.cpp.internal.pi.address.GppModelAdapter; |
|
54 import com.nokia.carbide.cpp.internal.pi.address.GppTraceGraphSMP; |
53 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository; |
55 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository; |
54 import com.nokia.carbide.cpp.internal.pi.analyser.ProfileVisualiser; |
56 import com.nokia.carbide.cpp.internal.pi.analyser.ProfileVisualiser; |
55 import com.nokia.carbide.cpp.internal.pi.model.GenericSampledTrace; |
|
56 import com.nokia.carbide.cpp.internal.pi.model.ProfiledBinary; |
57 import com.nokia.carbide.cpp.internal.pi.model.ProfiledBinary; |
57 import com.nokia.carbide.cpp.internal.pi.model.ProfiledFunction; |
58 import com.nokia.carbide.cpp.internal.pi.model.ProfiledFunction; |
58 import com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric; |
59 import com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric; |
59 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThread; |
60 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThread; |
60 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThreshold; |
61 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThreshold; |
|
62 import com.nokia.carbide.cpp.internal.pi.plugin.model.IContextMenu; |
|
63 import com.nokia.carbide.cpp.internal.pi.plugin.model.ITitleBarMenu; |
61 import com.nokia.carbide.cpp.internal.pi.visual.Defines; |
64 import com.nokia.carbide.cpp.internal.pi.visual.Defines; |
62 import com.nokia.carbide.cpp.internal.pi.visual.GenericTable; |
65 import com.nokia.carbide.cpp.internal.pi.visual.GenericTable; |
63 import com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph; |
66 import com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph; |
64 import com.nokia.carbide.cpp.internal.pi.visual.GraphComposite; |
67 import com.nokia.carbide.cpp.internal.pi.visual.GraphComposite; |
65 import com.nokia.carbide.cpp.internal.pi.visual.PIEvent; |
68 import com.nokia.carbide.cpp.internal.pi.visual.PIEvent; |
66 import com.nokia.carbide.cpp.internal.pi.visual.PIEventListener; |
|
67 import com.nokia.carbide.cpp.internal.pi.visual.PIVisualSharedData; |
|
68 import com.nokia.carbide.cpp.pi.editors.PIPageEditor; |
69 import com.nokia.carbide.cpp.pi.editors.PIPageEditor; |
69 import com.nokia.carbide.cpp.pi.util.ColorPalette; |
70 import com.nokia.carbide.cpp.pi.util.ColorPalette; |
70 |
71 import com.nokia.carbide.cpp.pi.visual.IGenericTraceGraph; |
71 |
72 |
72 public class GppTraceGraph extends GenericTraceGraph implements ActionListener, |
73 /** |
73 FocusListener, |
74 * Each instance of this class represents one trace graph for profiling |
74 PIEventListener, |
75 * CPU activity. |
75 MouseMotionListener, |
76 * |
76 MouseListener, |
77 */ |
77 MouseMoveListener |
78 public class GppTraceGraph extends GenericTraceGraph implements IGppTraceGraph, |
78 { |
79 ActionListener, FocusListener, MouseMotionListener, MouseListener, |
79 private GppTraceGraph thisTraceGraph; |
80 MouseMoveListener, ITitleBarMenu, IContextMenu { |
|
81 |
|
82 /** |
|
83 * amount of space at bottom of graph to contain things like x-axis units |
|
84 * and button icons |
|
85 */ |
|
86 public static final int X_LEGEND_HEIGHT = 50; |
|
87 |
|
88 /** |
|
89 * When the graph is drawn, this is the finest granularity drawn. E.g., |
|
90 * assume a granularity of 100, and a sample every ms. If the 1st function |
|
91 * draw appears in 5 samples from 101ms to 200ms and 10 samples from 200ms |
|
92 * to 300ms then the graph will show a point at height 5 at time 200 |
|
93 * connected by a line to a point at height 10 at time 300. |
|
94 */ |
|
95 static final int GRANULARITY_VALUE = 100; |
80 |
96 |
81 // amount of space at bottom of graph to contain things like x-axis units and button icons |
97 /** constant to indicate graph is a bar graph */ |
82 public static final int xLegendHeight = 50; |
98 public static final int BAR_MODE_ON = 3; |
|
99 /** constant to indicate graph is stacked-area graph */ |
|
100 public static final int BAR_MODE_OFF = 4; |
|
101 |
|
102 private static final String EMPTY_STRING = "";//$NON-NLS-1$ |
|
103 |
|
104 protected GppVisualiserPanel vPanel; |
|
105 protected String title; |
|
106 protected String shortTitle; |
|
107 |
|
108 /* |
|
109 * Depending on this trace graph's graphIndex, one of these will be the base |
|
110 * table, and others will be derived from its selections. The other tables |
|
111 * will appear and disappear based on drawMode. |
|
112 * |
|
113 * E.g., say that for graphIndex = 0, the base table is threadTable. Then |
|
114 * this graph can represent the draw modes of: THREADS THREADS_BINARIES |
|
115 * THREADS_BINARIES_FUNCTIONS THREADS_FUNCTIONS THREADS_FUNCTIONS_BINARIES |
|
116 */ |
|
117 protected AddrThreadTable threadTable; |
|
118 protected AddrBinaryTable binaryTable; |
|
119 protected AddrFunctionTable functionTable; |
83 |
120 |
84 // When the graph is drawn, this is the finest granularity drawn. E.g., assume |
|
85 // a granularity of 100, and a sample every ms. If the 1st function draw appears |
|
86 // in 5 samples from 101ms to 200ms and 10 samples from 200ms to 300ms then the |
|
87 // graph will show a point at height 5 at time 200 connected by a line to a |
|
88 // point at height 10 at time 300. |
|
89 private static int granularityValue = 100; |
|
90 |
|
91 private GppVisualiserPanel vPanel; |
|
92 |
|
93 /* |
121 /* |
94 * Depending on this trace graph's graphIndex, one of these will be |
122 * Depending on this trace graph's graphIndex, one of these will match the |
95 * the base table, and others will be derived from its selections. |
123 * entire trace's profiled vector, while the others will be derived from |
96 * The other tables will appear and disappear based on drawMode. |
124 * drilldown selections. The other vectors will only be meaningful depending |
97 * |
125 * on the drawMode. |
98 * E.g., say that for graphIndex = 0, the base table is threadTable. |
126 */ |
99 * Then this graph can represent the draw modes of: |
127 protected Vector<ProfiledGeneric> profiledThreads = new Vector<ProfiledGeneric>(); |
100 * THREADS |
128 protected Vector<ProfiledGeneric> profiledBinaries = new Vector<ProfiledGeneric>(); |
101 * THREADS_BINARIES |
129 protected Vector<ProfiledGeneric> profiledFunctions = new Vector<ProfiledGeneric>(); |
102 * THREADS_BINARIES_FUNCTIONS |
130 |
103 * THREADS_FUNCTIONS |
131 private Vector<ProfiledGeneric> sortedProfiledThreads = new Vector<ProfiledGeneric>(); |
104 * THREADS_FUNCTIONS_BINARIES |
132 private Vector<ProfiledGeneric> sortedProfiledBinaries = new Vector<ProfiledGeneric>(); |
105 */ |
|
106 private AddrThreadTable threadTable; |
|
107 private AddrBinaryTable binaryTable; |
|
108 private AddrFunctionTable functionTable; |
|
109 |
|
110 /* |
|
111 * Depending on this trace graph's graphIndex, one of these will match |
|
112 * the entire trace's profiled vector, while the others will be derived |
|
113 * from drilldown selections. The other vectors will only be meaningful |
|
114 * depending on the drawMode. |
|
115 */ |
|
116 private Vector<ProfiledGeneric> profiledThreads = new Vector<ProfiledGeneric>(); |
|
117 private Vector<ProfiledGeneric> profiledBinaries = new Vector<ProfiledGeneric>(); |
|
118 private Vector<ProfiledGeneric> profiledFunctions = new Vector<ProfiledGeneric>(); |
|
119 |
|
120 private Vector<ProfiledGeneric> sortedProfiledThreads = new Vector<ProfiledGeneric>(); |
|
121 private Vector<ProfiledGeneric> sortedProfiledBinaries = new Vector<ProfiledGeneric>(); |
|
122 private Vector<ProfiledGeneric> sortedProfiledFunctions = new Vector<ProfiledGeneric>(); |
133 private Vector<ProfiledGeneric> sortedProfiledFunctions = new Vector<ProfiledGeneric>(); |
123 |
134 |
124 private ProfiledThreshold thresholdThread = new ProfiledThreshold("dummy[0]::dummy_0"); //$NON-NLS-1$ |
135 protected ProfiledThreshold thresholdThread; |
125 private ProfiledThreshold thresholdBinary = new ProfiledThreshold("\\dummy"); //$NON-NLS-1$ |
136 private ProfiledThreshold thresholdBinary; |
126 private ProfiledThreshold thresholdFunction = new ProfiledThreshold("dummy::dummy()"); //$NON-NLS-1$ |
137 private ProfiledThreshold thresholdFunction; |
127 |
138 |
128 // when multiple tables are visible, they are separated by sashes |
139 // when multiple tables are visible, they are separated by sashes |
129 private Sash leftSash; |
140 private Sash leftSash; |
130 private Sash rightSash; |
141 private Sash rightSash; |
131 |
142 |
132 public static final int NOFILL = 0; |
143 protected int drawMode = Defines.THREADS; |
133 public static final int FILLSELECTED = 1; |
|
134 public static final int FILLALL = 2; |
|
135 public static final int BAR_MODE_ON = 3; |
|
136 public static final int BAR_MODE_OFF = 4; |
|
137 |
|
138 private int drawMode = Defines.THREADS; |
|
139 public int barMode = BAR_MODE_OFF; |
|
140 |
144 |
141 private int uid; |
145 /** current graph drawing mode: either bar or stacked-area graph */ |
142 |
146 public int barMode = BAR_MODE_OFF; |
143 private static class BarGraphData |
147 |
144 { |
148 protected int uid; |
|
149 |
|
150 private static class BarGraphData { |
145 public int x; |
151 public int x; |
146 public Color color; |
152 public Color color; |
147 } |
153 } |
148 |
154 |
149 private Vector<BarGraphData> barGraphData; |
155 private Vector<BarGraphData> barGraphData; |
150 |
156 |
151 public GppTraceGraph(int graphIndex, GppTrace trace, int uid) |
157 /** |
152 { |
158 * The model adapter hides some of the SMP specifics. It must be created |
153 super((GenericSampledTrace)trace); |
159 * during initialisation of this graph. |
154 |
160 */ |
155 int granularityValue = trace.samples.size() > GppTraceGraph.granularityValue ? GppTraceGraph.granularityValue : trace.samples.size(); |
161 protected GppModelAdapter adapter; |
156 |
162 |
157 this.thisTraceGraph = this; |
163 /** main Composite of legend view */ |
158 this.graphIndex = graphIndex; |
164 private Composite holdTablesComposite; |
159 |
165 |
|
166 |
|
167 /** |
|
168 * Constructor |
|
169 * |
|
170 * @param graphIndex |
|
171 * the unique index of this graph |
|
172 * @param trace |
|
173 * the trace data model to use |
|
174 * @param uid |
|
175 * the Uid of the editor session |
|
176 */ |
|
177 public GppTraceGraph(int graphIndex, GppTrace trace, int uid) { |
|
178 super(trace); |
|
179 this.graphIndex = graphIndex; |
|
180 this.uid = uid; |
|
181 |
|
182 } |
|
183 |
|
184 /** |
|
185 * Initialises the graph. |
|
186 * |
|
187 * @param pageIndex |
|
188 * page index of the page which displays the graph |
|
189 * @param trace |
|
190 * the trace model |
|
191 */ |
|
192 public void init(int pageIndex, GppTrace trace) { |
|
193 doCreateAdapter(); |
|
194 doSetTitle(); |
|
195 int granularityValue = trace.samples.size() > GppTraceGraph.GRANULARITY_VALUE ? GppTraceGraph.GRANULARITY_VALUE |
|
196 : trace.samples.size(); |
|
197 |
160 // create the graph's 3 table objects - without any table items yet |
198 // create the graph's 3 table objects - without any table items yet |
161 ProfileVisualiser pV = NpiInstanceRepository.getInstance().getProfilePage(uid, graphIndex); |
199 ProfileVisualiser pV = NpiInstanceRepository.getInstance() |
162 Composite holdTables = new Composite(pV.getBottomComposite(), SWT.NONE); |
200 .getProfilePage(uid, pageIndex); |
163 holdTables.setLayout(new FormLayout()); |
201 holdTablesComposite = trace.createLegendComposite(pageIndex, graphIndex, pV.getBottomComposite(), getShortTitle()); |
164 |
202 holdTablesComposite.setLayout(new FormLayout()); |
165 this.threadTable = new AddrThreadTable(this, holdTables); |
203 |
166 this.binaryTable = new AddrBinaryTable(this, holdTables); |
204 createLegendTables(holdTablesComposite); |
167 this.functionTable = new AddrFunctionTable(this, holdTables); |
|
168 |
|
169 this.uid = uid; |
|
170 |
|
171 Label graphTitle = pV.getTitle(); |
|
172 Label graphTitle2 = pV.getTitle2(); |
|
173 if (graphTitle2 != null) |
|
174 graphTitle2.setText(""); //$NON-NLS-1$ |
|
175 |
205 |
176 // initialize the threshold counts |
206 // initialize the threshold counts |
177 int totalSampleCount = trace.getSampleAmount(); |
207 int totalSampleCount = trace.getSampleAmount(); |
178 NpiInstanceRepository.getInstance().setPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountThread", new Integer(new Double(totalSampleCount * (Double)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdLoadThread") + 0.5).intValue())); //$NON-NLS-1$ //$NON-NLS-2$ |
208 |
179 NpiInstanceRepository.getInstance().setPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountBinary", new Integer(new Double(totalSampleCount * (Double)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdLoadBinary") + 0.5).intValue())); //$NON-NLS-1$ //$NON-NLS-2$ |
209 // CH: this is called too many times (those values are global for the |
180 NpiInstanceRepository.getInstance().setPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountFunction", new Integer(new Double(totalSampleCount * (Double)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdLoadFunction") + 0.5).intValue())); //$NON-NLS-1$ //$NON-NLS-2$ |
210 // whole trace) -> can we move it to GppTrace? |
181 |
211 NpiInstanceRepository |
182 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
212 .getInstance() |
|
213 .setPersistState( |
|
214 uid, |
|
215 "com.nokia.carbide.cpp.pi.address.thresholdCountThread", Integer.valueOf(new Double(totalSampleCount * (Double) NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdLoadThread") + 0.5).intValue())); //$NON-NLS-1$ //$NON-NLS-2$ |
|
216 NpiInstanceRepository |
|
217 .getInstance() |
|
218 .setPersistState( |
|
219 uid, |
|
220 "com.nokia.carbide.cpp.pi.address.thresholdCountBinary", Integer.valueOf(new Double(totalSampleCount * (Double) NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdLoadBinary") + 0.5).intValue())); //$NON-NLS-1$ //$NON-NLS-2$ |
|
221 NpiInstanceRepository |
|
222 .getInstance() |
|
223 .setPersistState( |
|
224 uid, |
|
225 "com.nokia.carbide.cpp.pi.address.thresholdCountFunction", Integer.valueOf(new Double(totalSampleCount * (Double) NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdLoadFunction") + 0.5).intValue())); //$NON-NLS-1$ //$NON-NLS-2$ |
|
226 |
|
227 int samplingInterval = (Integer) NpiInstanceRepository.getInstance() |
|
228 .activeUidGetPersistState( |
|
229 "com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
183 |
230 |
184 // initialize the threshold items |
231 // initialize the threshold items |
185 thresholdThread.setColor(trace.getThreadColorPalette().getColor(thresholdThread.getNameString())); |
232 int bucketDuration = granularityValue * samplingInterval; |
186 thresholdThread.setActivityMarkCount((trace.samples.size() + granularityValue) / granularityValue + 1); |
233 int numberOfBuckets = GppTraceUtil.calculateNumberOfBuckets(trace |
187 for (int i = 0; i < trace.samples.size() + granularityValue; i += granularityValue) |
234 .getLastSampleTime(), granularityValue); |
188 { |
235 |
189 thresholdThread.zeroActivityMarkValues(i * samplingInterval); |
236 thresholdThread = new ProfiledThreshold( |
190 } |
237 "dummy[0]::dummy_0", trace.getCPUCount(), trace.getGraphCount()); //$NON-NLS-1$ |
191 thresholdBinary.setColor(trace.getBinaryColorPalette().getColor(thresholdBinary.getNameString())); |
238 thresholdBinary = new ProfiledThreshold( |
192 thresholdBinary.setActivityMarkCount((trace.samples.size() + granularityValue) / granularityValue + 1); |
239 "\\dummy", trace.getCPUCount(), trace.getGraphCount()); //$NON-NLS-1$ |
193 for (int i = 0; i < trace.samples.size() + granularityValue; i += granularityValue) |
240 thresholdFunction = new ProfiledThreshold( |
194 { |
241 "dummy::dummy()", trace.getCPUCount(), trace.getGraphCount()); //$NON-NLS-1$ |
195 thresholdBinary.zeroActivityMarkValues(i * samplingInterval); |
242 thresholdThread.setColor(trace.getThreadColorPalette().getColor( |
196 } |
243 thresholdThread.getNameString())); |
197 thresholdFunction.setColor(trace.getFunctionColorPalette().getColor(thresholdFunction.getNameString())); |
244 thresholdThread.createBuckets(numberOfBuckets); |
198 thresholdFunction.setActivityMarkCount((trace.samples.size() + granularityValue) / granularityValue + 1); |
245 thresholdThread.initialiseBuckets(bucketDuration); |
199 for (int i = 0; i < trace.samples.size() + granularityValue; i += granularityValue) |
246 thresholdBinary.setColor(trace.getBinaryColorPalette().getColor( |
200 { |
247 thresholdBinary.getNameString())); |
201 thresholdFunction.zeroActivityMarkValues(i * samplingInterval); |
248 thresholdBinary.createBuckets(numberOfBuckets); |
202 } |
249 thresholdBinary.initialiseBuckets(bucketDuration); |
203 |
250 thresholdFunction.setColor(trace.getFunctionColorPalette().getColor( |
204 // all the trace data is known, and you have it sorted 3 different ways |
251 thresholdFunction.getNameString())); |
205 // so set the drawmode, create the page's base table, and set the graph title |
252 thresholdFunction.createBuckets(numberOfBuckets); |
206 if (graphIndex == PIPageEditor.THREADS_PAGE) { |
253 thresholdFunction.initialiseBuckets(bucketDuration); |
|
254 |
|
255 int graphType = adapter.getGraphType(); |
|
256 |
|
257 if (graphType == PIPageEditor.THREADS_PAGE) { |
207 this.drawMode = Defines.THREADS; |
258 this.drawMode = Defines.THREADS; |
208 |
259 int threshold = (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountThread"); //$NON-NLS-1$ |
209 // tables will show threads in decreasing total sample order, but |
260 |
210 // then put them back in increasing sample order so that the graph |
261 for (ProfiledGeneric profiled : trace.getSortedThreads()) { |
211 // shows most common (e.g., EKern) threads on top |
262 if (adapter.getTotalSampleCount(profiled) > 0){ |
212 this.profiledThreads.clear(); |
263 if (adapter.getTotalSampleCount(profiled) < threshold){//check below threshold |
213 for (int i = trace.getSortedThreads().size() - 1; i >= 0; i--) |
264 adapter.addItem(thresholdThread, graphIndex, profiled, adapter.getTotalSampleCount(profiled)); |
214 this.profiledThreads.add(trace.getSortedThreads().get(i)); |
265 } else { |
215 filterSortedByThreshold(graphIndex, |
266 profiledThreads.add(profiled); |
216 (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountThread"), //$NON-NLS-1$ |
267 } |
217 thresholdThread, this.profiledThreads); |
268 } |
|
269 } |
|
270 |
218 this.threadTable.setTableViewer(Defines.THREADS); |
271 this.threadTable.setTableViewer(Defines.THREADS); |
219 |
|
220 this.profiledThreads = trace.getSortedThreads(); |
272 this.profiledThreads = trace.getSortedThreads(); |
221 graphTitle.setText(Messages.getString("GppTraceGraph.threadLoad")); //$NON-NLS-1$ |
273 } else if (graphType == PIPageEditor.BINARIES_PAGE) { |
222 } else |
|
223 if (graphIndex == PIPageEditor.BINARIES_PAGE) { |
|
224 this.drawMode = Defines.BINARIES; |
274 this.drawMode = Defines.BINARIES; |
225 |
275 int threshold = (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountBinary"); //$NON-NLS-1$ |
226 // tables will show binaries in decreasing total sample order, but |
276 |
227 // then put them back in increasing sample order so that the graph |
277 for (ProfiledGeneric profiled : trace.getSortedBinaries()) { |
228 // shows most common (e.g., EKern) binaries on top |
278 if (adapter.getTotalSampleCount(profiled) > 0){ |
229 this.profiledBinaries.clear(); |
279 if (adapter.getTotalSampleCount(profiled) < threshold){//check below threshold |
230 for (int i = trace.getSortedBinaries().size() - 1; i >= 0; i--) |
280 adapter.addItem(thresholdBinary, graphIndex, profiled, adapter.getTotalSampleCount(profiled)); |
231 this.profiledBinaries.add(trace.getSortedBinaries().get(i)); |
281 } else { |
232 filterSortedByThreshold(graphIndex, (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountBinary"), //$NON-NLS-1$ |
282 profiledBinaries.add(profiled); |
233 thresholdBinary, this.profiledBinaries); |
283 } |
|
284 |
|
285 } |
|
286 } |
|
287 |
234 this.binaryTable.setTableViewer(Defines.BINARIES); |
288 this.binaryTable.setTableViewer(Defines.BINARIES); |
235 |
289 |
236 this.profiledBinaries = trace.getSortedBinaries(); |
290 this.profiledBinaries = trace.getSortedBinaries(); |
237 graphTitle.setText(Messages.getString("GppTraceGraph.binaryLoad")); //$NON-NLS-1$ |
291 } else if (graphType == PIPageEditor.FUNCTIONS_PAGE) { |
238 } else |
|
239 if (graphIndex == PIPageEditor.FUNCTIONS_PAGE) { |
|
240 this.drawMode = Defines.FUNCTIONS; |
292 this.drawMode = Defines.FUNCTIONS; |
241 |
293 int threshold = (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountFunction"); //$NON-NLS-1$ |
242 // tables will show functions in decreasing total sample order, but |
294 |
243 // then put them back in increasing sample order so that the graph |
295 for (ProfiledGeneric profiled : trace.getSortedFunctions()) { |
244 // shows most common (e.g., EKern) functions on top |
296 if (adapter.getTotalSampleCount(profiled) > 0){ |
245 this.profiledFunctions.clear(); |
297 if (adapter.getTotalSampleCount(profiled) < threshold){//check below threshold |
246 for (int i = trace.getSortedFunctions().size() - 1; i >= 0; i--) |
298 adapter.addItem(thresholdFunction, graphIndex, profiled, adapter.getTotalSampleCount(profiled)); |
247 this.profiledFunctions.add(trace.getSortedFunctions().get(i)); |
299 } else { |
248 filterSortedByThreshold(graphIndex, (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountFunction"), //$NON-NLS-1$ |
300 profiledFunctions.add(profiled); |
249 thresholdFunction, this.profiledFunctions); |
301 } |
|
302 } |
|
303 } |
250 this.functionTable.setTableViewer(Defines.FUNCTIONS); |
304 this.functionTable.setTableViewer(Defines.FUNCTIONS); |
251 |
305 |
252 this.profiledFunctions = trace.getSortedFunctions(); |
306 this.profiledFunctions = trace.getSortedFunctions(); |
253 graphTitle.setText(Messages.getString("GppTraceGraph.FunctionLoad")); //$NON-NLS-1$ |
307 } else { |
254 } else |
308 throw new IllegalStateException(Messages |
255 { |
309 .getString("GppTraceGraph.traceGraphInternalErrorIn")); //$NON-NLS-1$ |
|
310 } |
|
311 |
|
312 |
|
313 // since the trace can be shown any of 3 ways (by thread, by binary, or |
|
314 // by function), make sure that all 3 are ready for display |
|
315 // Sse sorted vector to be consistent with other call to |
|
316 // genericRefreshCumulativeThreadTable() |
|
317 // fix issue with wrong color on newly opened npi file before a change |
|
318 // in the table |
|
319 if (this.profiledThreads.size() > 0) { |
|
320 genericRefreshCumulativeThreadTable(this.profiledThreads.elements()); |
|
321 genericRefreshCumulativeThreadTable(this.sortedProfiledThreads |
|
322 .elements()); |
|
323 } |
|
324 if (this.profiledBinaries.size() > 0) { |
|
325 genericRefreshCumulativeThreadTable(this.profiledBinaries |
|
326 .elements()); |
|
327 genericRefreshCumulativeThreadTable(this.sortedProfiledBinaries |
|
328 .elements()); |
|
329 } |
|
330 if (this.profiledFunctions.size() > 0) { |
|
331 genericRefreshCumulativeThreadTable(this.profiledFunctions |
|
332 .elements()); |
|
333 genericRefreshCumulativeThreadTable(this.sortedProfiledFunctions |
|
334 .elements()); |
|
335 } |
|
336 |
|
337 if (this.profiledThreads.size() <= 0 |
|
338 && this.profiledBinaries.size() <= 0 |
|
339 && this.profiledFunctions.size() <= 0) { |
256 try { |
340 try { |
257 throw new Exception(Messages.getString("GppTraceGraph.traceGraphInternalErrorIn")); //$NON-NLS-1$ |
341 throw new Exception(Messages |
|
342 .getString("GppTraceGraph.traceGraphInternalErrorAt")); //$NON-NLS-1$ |
258 } catch (Exception e) { |
343 } catch (Exception e) { |
259 e.printStackTrace(); |
344 e.printStackTrace(); |
260 } |
345 } |
261 } |
346 } |
262 |
|
263 // since the trace can be shown any of 3 ways (by thread, by binary, or |
|
264 // by function), make sure that all 3 are ready for display |
|
265 // Sse sorted vector to be consistent with other call to genericRefreshCumulativeThreadTable() |
|
266 // fix issue with wrong color on newly opened npi file before a change in the table |
|
267 if (this.profiledThreads.size() > 0) { |
|
268 genericRefreshCumulativeThreadTable(this.profiledThreads.elements()); |
|
269 genericRefreshCumulativeThreadTable(this.sortedProfiledThreads.elements()); |
|
270 } |
|
271 if (this.profiledBinaries.size() > 0) { |
|
272 genericRefreshCumulativeThreadTable(this.profiledBinaries.elements()); |
|
273 genericRefreshCumulativeThreadTable(this.sortedProfiledBinaries.elements()); |
|
274 } |
|
275 if (this.profiledFunctions.size() > 0) { |
|
276 genericRefreshCumulativeThreadTable(this.profiledFunctions.elements()); |
|
277 genericRefreshCumulativeThreadTable(this.sortedProfiledFunctions.elements()); |
|
278 } |
|
279 |
|
280 if ( this.profiledThreads.size() <= 0 |
|
281 && this.profiledBinaries.size() <= 0 |
|
282 && this.profiledFunctions.size() <= 0) { |
|
283 try { |
|
284 throw new Exception(Messages.getString("GppTraceGraph.traceGraphInternalErrorAt")); //$NON-NLS-1$ |
|
285 } catch (Exception e) { |
|
286 e.printStackTrace(); |
|
287 } |
|
288 } |
|
289 |
347 |
290 this.vPanel = new GppVisualiserPanel(this); |
348 this.vPanel = new GppVisualiserPanel(this); |
291 } |
349 |
292 |
350 } |
|
351 |
|
352 /** |
|
353 * Sets the graph-specific title |
|
354 */ |
|
355 protected void doSetTitle() { |
|
356 title = Messages.getString("GppTraceGraph.1"); //$NON-NLS-1$ |
|
357 shortTitle = Messages.getString("GppTraceGraph.0"); //$NON-NLS-1$ |
|
358 } |
|
359 |
|
360 /** |
|
361 * Creates a GppModelAdapter |
|
362 */ |
|
363 protected void doCreateAdapter() { |
|
364 adapter = new GppModelAdapter(this.graphIndex); |
|
365 } |
|
366 |
|
367 /** |
|
368 * Creates the three legend tables for this graph (for threads, binaries, |
|
369 * functions) |
|
370 * |
|
371 * @param holdTablesComposite |
|
372 */ |
|
373 protected void createLegendTables(Composite holdTablesComposite) { |
|
374 this.threadTable = new AddrThreadTable(this, holdTablesComposite, adapter); |
|
375 this.binaryTable = new AddrBinaryTable(this, holdTablesComposite, adapter); |
|
376 this.functionTable = new AddrFunctionTable(this, holdTablesComposite, adapter); |
|
377 } |
|
378 |
293 /* |
379 /* |
294 * Combine all vectors elements that are below the threshold into a single |
380 * (non-Javadoc) |
295 * vector element. Assumes that the input vector is sorted by decreasing sample count. |
381 * |
296 */ |
382 * @see com.nokia.carbide.cpp.pi.address.IGppTraceGraph#getGppTrace() |
297 private void filterSortedByThreshold(int graphIndex, int thresholdCount, ProfiledThreshold pThreshold, Vector<ProfiledGeneric> pGenerics) |
383 */ |
298 { |
|
299 // count and remove items below the threshold |
|
300 for (int i = pGenerics.size() - 1; i >= 0; i--) { |
|
301 if (pGenerics.elementAt(i).getTotalSampleCount() < thresholdCount) { |
|
302 pThreshold.addItem(graphIndex, pGenerics.elementAt(i), 0); |
|
303 pGenerics.removeElementAt(i); |
|
304 } else { |
|
305 break; |
|
306 } |
|
307 } |
|
308 } |
|
309 |
|
310 public GppTrace getGppTrace() { |
384 public GppTrace getGppTrace() { |
311 return (GppTrace)this.getTrace(); |
385 return (GppTrace) this.getTrace(); |
312 } |
386 } |
313 |
387 |
314 public int getGraphIndex() |
388 /* |
315 { |
389 * (non-Javadoc) |
316 return this.graphIndex; |
390 * |
317 } |
391 * @see |
318 |
392 * com.nokia.carbide.cpp.internal.pi.visual.PIEventListener#piEventReceived |
319 public void piEventReceived(PIEvent be) |
393 * (com.nokia.carbide.cpp.internal.pi.visual.PIEvent) |
320 { |
394 */ |
321 switch (be.getType()) |
395 public void piEventReceived(PIEvent be) { |
322 { |
396 switch (be.getType()) { |
323 // determine the threads that can be shown, and get rid of all drilldowns |
397 // determine the threads that can be shown, and get rid of all |
324 case PIEvent.THRESHOLD_THREAD_CHANGED: |
398 // drilldowns |
325 if (this.getGraphIndex() == PIPageEditor.THREADS_PAGE) |
399 case PIEvent.THRESHOLD_THREAD_CHANGED: |
326 this.getThreadTable().action("changeThresholdThread"); //$NON-NLS-1$ |
400 if (this.getGraphIndex() == PIPageEditor.THREADS_PAGE) |
327 switch (this.drawMode) { |
401 this.getThreadTable().action("changeThresholdThread"); //$NON-NLS-1$ |
328 case Defines.THREADS: |
402 switch (this.drawMode) { |
329 case Defines.THREADS_FUNCTIONS: |
403 case Defines.THREADS: |
330 case Defines.THREADS_FUNCTIONS_BINARIES: |
404 case Defines.THREADS_FUNCTIONS: |
331 case Defines.THREADS_BINARIES: |
405 case Defines.THREADS_FUNCTIONS_BINARIES: |
332 case Defines.THREADS_BINARIES_FUNCTIONS: |
406 case Defines.THREADS_BINARIES: |
333 case Defines.BINARIES_THREADS: |
407 case Defines.THREADS_BINARIES_FUNCTIONS: |
334 case Defines.BINARIES_THREADS_FUNCTIONS: |
408 case Defines.BINARIES_THREADS: |
335 case Defines.BINARIES_FUNCTIONS_THREADS: |
409 case Defines.BINARIES_THREADS_FUNCTIONS: |
336 case Defines.FUNCTIONS_THREADS: |
410 case Defines.BINARIES_FUNCTIONS_THREADS: |
337 case Defines.FUNCTIONS_THREADS_BINARIES: |
411 case Defines.FUNCTIONS_THREADS: |
338 case Defines.FUNCTIONS_BINARIES_THREADS: |
412 case Defines.FUNCTIONS_THREADS_BINARIES: |
339 this.setGraphImageChanged(true); |
413 case Defines.FUNCTIONS_BINARIES_THREADS: |
340 default: |
414 this.setGraphImageChanged(true); |
341 break; |
|
342 } |
|
343 break; |
|
344 case PIEvent.THRESHOLD_BINARY_CHANGED: |
|
345 if (this.getGraphIndex() == PIPageEditor.BINARIES_PAGE) |
|
346 this.getBinaryTable().action("changeThresholdBinary"); //$NON-NLS-1$ |
|
347 switch (this.drawMode) { |
|
348 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
349 case Defines.THREADS_BINARIES: |
|
350 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
351 case Defines.BINARIES: |
|
352 case Defines.BINARIES_THREADS: |
|
353 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
354 case Defines.BINARIES_FUNCTIONS: |
|
355 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
356 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
357 case Defines.FUNCTIONS_BINARIES: |
|
358 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
359 this.setGraphImageChanged(true); |
|
360 default: |
|
361 break; |
|
362 } |
|
363 break; |
|
364 case PIEvent.THRESHOLD_FUNCTION_CHANGED: |
|
365 if (this.getGraphIndex() == PIPageEditor.FUNCTIONS_PAGE) |
|
366 this.getFunctionTable().action("changeThresholdFunction"); //$NON-NLS-1$ |
|
367 switch (this.drawMode) { |
|
368 case Defines.THREADS_FUNCTIONS: |
|
369 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
370 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
371 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
372 case Defines.BINARIES_FUNCTIONS: |
|
373 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
374 case Defines.FUNCTIONS: |
|
375 case Defines.FUNCTIONS_THREADS: |
|
376 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
377 case Defines.FUNCTIONS_BINARIES: |
|
378 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
379 this.setGraphImageChanged(true); |
|
380 default: |
|
381 break; |
|
382 } |
|
383 break; |
|
384 // when the selection area changes, change the percent loads |
|
385 // and the sample counts in all tables of this GPP graph |
|
386 case PIEvent.SELECTION_AREA_CHANGED: |
|
387 // this is the first GPP graph to be told of the selection area change, |
|
388 // so it gathers the overall trace information |
|
389 GppTrace trace = (GppTrace)this.getTrace(); |
|
390 trace.setSelectedArea(); |
|
391 |
|
392 // take care of the threshold members |
|
393 int sampleCount = 0; |
|
394 int thresholdCount; |
|
395 |
|
396 if (graphIndex == PIPageEditor.THREADS_PAGE) { |
|
397 thresholdCount = (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountThread"); //$NON-NLS-1$ |
|
398 if (thresholdCount > 0) { |
|
399 for (int i = 0; i < profiledThreads.size(); i++) |
|
400 if (profiledThreads.elementAt(i).getTotalSampleCount() < thresholdCount) |
|
401 sampleCount += profiledThreads.elementAt(i).getSampleCount(graphIndex); |
|
402 thresholdThread.setSampleCount(this.graphIndex, sampleCount); |
|
403 } |
|
404 } else if (graphIndex == PIPageEditor.BINARIES_PAGE) { |
|
405 thresholdCount = (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountBinary"); //$NON-NLS-1$ |
|
406 if (thresholdCount > 0) { |
|
407 for (int i = 0; i < profiledBinaries.size(); i++) |
|
408 if (profiledBinaries.elementAt(i).getTotalSampleCount() < thresholdCount) |
|
409 sampleCount += profiledBinaries.elementAt(i).getSampleCount(graphIndex); |
|
410 thresholdBinary.setSampleCount(this.graphIndex, sampleCount); |
|
411 } |
|
412 } else if (graphIndex == PIPageEditor.FUNCTIONS_PAGE) { |
|
413 thresholdCount = (Integer)NpiInstanceRepository.getInstance().getPersistState(uid, "com.nokia.carbide.cpp.pi.address.thresholdCountFunction"); //$NON-NLS-1$ |
|
414 if (thresholdCount > 0) { |
|
415 for (int i = 0; i < profiledFunctions.size(); i++) |
|
416 if (profiledFunctions.elementAt(i).getTotalSampleCount() < thresholdCount) |
|
417 sampleCount += profiledFunctions.elementAt(i).getSampleCount(graphIndex); |
|
418 thresholdFunction.setSampleCount(this.graphIndex, sampleCount); |
|
419 } |
|
420 } |
|
421 |
|
422 double startTime = PIPageEditor.currentPageEditor().getStartTime(); |
|
423 double endTime = PIPageEditor.currentPageEditor().getEndTime(); |
|
424 |
|
425 // send this message to the 2 other GPP graphs |
|
426 PIEvent be2 = new PIEvent(be.getValueObject(), |
|
427 PIEvent.SELECTION_AREA_CHANGED2); |
|
428 |
|
429 // update the selection area shown |
|
430 for (int i = 0; i < 3; i++) |
|
431 { |
|
432 GppTraceGraph graph = trace.getGppGraph(i, getUid()); |
|
433 |
|
434 if (graph != this) { |
|
435 graph.piEventReceived(be2); |
|
436 // once per graph, update the selection interval shown |
|
437 graph.getCompositePanel().getVisualiser().getTimeString().setText(ProfileVisualiser.getTimeInterval(startTime, endTime)); |
|
438 } |
|
439 |
|
440 // change the graph's selected time interval |
|
441 graph.setSelectionStart((double) startTime * 1000); |
|
442 graph.setSelectionEnd((double) endTime * 1000); |
|
443 graph.parentComponent.setSelectionFields((int)(startTime * 1000), (int)(endTime * 1000)); |
|
444 } |
|
445 |
|
446 this.parentComponent.getSashForm().redraw(); |
|
447 be = be2; |
|
448 // FALL THROUGH |
|
449 case PIEvent.SELECTION_AREA_CHANGED2: |
|
450 { |
|
451 // this code lets each graph's base thread/binary/function table update the other tables |
|
452 switch (drawMode) |
|
453 { |
|
454 case Defines.THREADS: |
|
455 case Defines.THREADS_FUNCTIONS: |
|
456 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
457 case Defines.THREADS_BINARIES: |
|
458 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
459 { |
|
460 this.threadTable.piEventReceived(be); |
|
461 break; |
|
462 } |
|
463 case Defines.BINARIES: |
|
464 case Defines.BINARIES_THREADS: |
|
465 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
466 case Defines.BINARIES_FUNCTIONS: |
|
467 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
468 { |
|
469 this.binaryTable.piEventReceived(be); |
|
470 break; |
|
471 } |
|
472 case Defines.FUNCTIONS: |
|
473 case Defines.FUNCTIONS_THREADS: |
|
474 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
475 case Defines.FUNCTIONS_BINARIES: |
|
476 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
477 { |
|
478 this.functionTable.piEventReceived(be); |
|
479 break; |
|
480 } |
|
481 } |
|
482 |
|
483 this.vPanel.refreshCumulativeThreadTable(); |
|
484 this.setGraphImageChanged(true); // any selection change to drill down will change graph |
|
485 this.repaint(); |
|
486 break; |
|
487 } |
|
488 |
|
489 // in the graph, show all values from the rightmost table |
|
490 case PIEvent.SET_FILL_ALL_THREADS: |
|
491 this.setGraphImageChanged(true); // any selection change to drill down will change graph |
|
492 this.vPanel.piEventReceived(be); |
|
493 break; |
|
494 |
|
495 // in the graph, don't fill between the lines will the color of |
|
496 // the line above |
|
497 case PIEvent.SET_FILL_OFF: |
|
498 this.setGraphImageChanged(true); // any selection change to drill down will change graph |
|
499 this.vPanel.piEventReceived(be); |
|
500 break; |
|
501 |
|
502 // in the graph, show bars |
|
503 case PIEvent.GPP_SET_BAR_GRAPH_ON: |
|
504 this.vPanel.piEventReceived(be); |
|
505 break; |
|
506 |
|
507 // in the graph, show polylines |
|
508 case PIEvent.GPP_SET_BAR_GRAPH_OFF: |
|
509 this.vPanel.piEventReceived(be); |
|
510 break; |
|
511 |
|
512 // in the graph, show only the values from selected rows in the |
|
513 // rightmost table |
|
514 case PIEvent.SET_FILL_SELECTED_THREAD: |
|
515 this.setGraphImageChanged(true); // any selection change to drill down will change graph |
|
516 this.vPanel.piEventReceived(be); |
|
517 break; |
|
518 |
|
519 // Redraw the graph because the thread table's selected values have changed. |
|
520 // The thread table is handled (setting of array of selected threads |
|
521 // and table redraw) by the table selection listener or mouse listener. |
|
522 case PIEvent.CHANGED_THREAD_TABLE: |
|
523 switch (drawMode) |
|
524 { |
|
525 case Defines.THREADS_BINARIES: |
|
526 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
527 case Defines.THREADS_FUNCTIONS: |
|
528 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
529 { |
|
530 this.threadTable.piEventReceived(be); |
|
531 break; |
|
532 } |
|
533 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
534 { |
|
535 this.binaryTable.piEventReceived(be); |
|
536 break; |
|
537 } |
|
538 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
539 { |
|
540 this.functionTable.piEventReceived(be); |
|
541 break; |
|
542 } |
|
543 case Defines.THREADS: |
|
544 case Defines.BINARIES: |
|
545 case Defines.BINARIES_THREADS: |
|
546 case Defines.BINARIES_FUNCTIONS: |
|
547 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
548 case Defines.FUNCTIONS: |
|
549 case Defines.FUNCTIONS_THREADS: |
|
550 case Defines.FUNCTIONS_BINARIES: |
|
551 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
552 default: |
|
553 break; |
|
554 } |
|
555 |
|
556 this.vPanel.refreshCumulativeThreadTable(); |
|
557 this.repaint(); |
|
558 //if fill selected, the graph is drawn again |
|
559 this.vPanel.piEventReceived(be); |
|
560 break; |
|
561 |
|
562 // Redraw the graph because the binary table's selected values have changed. |
|
563 // The binary table is handled (setting of array of selected binaries |
|
564 // and table redraw) by the table selection listener or mouse listener. |
|
565 case PIEvent.CHANGED_BINARY_TABLE: |
|
566 switch(drawMode) |
|
567 { |
|
568 case Defines.BINARIES_THREADS: |
|
569 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
570 case Defines.BINARIES_FUNCTIONS: |
|
571 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
572 { |
|
573 this.binaryTable.piEventReceived(be); |
|
574 break; |
|
575 } |
|
576 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
577 { |
|
578 this.threadTable.piEventReceived(be); |
|
579 break; |
|
580 } |
|
581 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
582 { |
|
583 this.functionTable.piEventReceived(be); |
|
584 break; |
|
585 } |
|
586 case Defines.THREADS: |
|
587 case Defines.THREADS_BINARIES: |
|
588 case Defines.THREADS_FUNCTIONS: |
|
589 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
590 case Defines.BINARIES: |
|
591 case Defines.FUNCTIONS: |
|
592 case Defines.FUNCTIONS_THREADS: |
|
593 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
594 case Defines.FUNCTIONS_BINARIES: |
|
595 default: |
|
596 break; |
|
597 } |
|
598 |
|
599 this.vPanel.refreshCumulativeThreadTable(); |
|
600 this.repaint(); |
|
601 //if fill selected, the graph is drawn again |
|
602 this.vPanel.piEventReceived(be); |
|
603 break; |
|
604 |
|
605 // Redraw the graph because the function table's selected values have changed. |
|
606 // The function table is handled (setting of array of selected functions |
|
607 // and table redraw) by the table selection listener or mouse listener. |
|
608 case PIEvent.CHANGED_FUNCTION_TABLE: |
|
609 switch(drawMode) |
|
610 { |
|
611 case Defines.FUNCTIONS_THREADS: |
|
612 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
613 case Defines.FUNCTIONS_BINARIES: |
|
614 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
615 { |
|
616 this.functionTable.piEventReceived(be); |
|
617 break; |
|
618 } |
|
619 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
620 { |
|
621 this.threadTable.piEventReceived(be); |
|
622 break; |
|
623 } |
|
624 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
625 { |
|
626 this.binaryTable.piEventReceived(be); |
|
627 break; |
|
628 } |
|
629 case Defines.THREADS: |
|
630 case Defines.THREADS_BINARIES: |
|
631 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
632 case Defines.THREADS_FUNCTIONS: |
|
633 case Defines.BINARIES: |
|
634 case Defines.BINARIES_THREADS: |
|
635 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
636 case Defines.BINARIES_FUNCTIONS: |
|
637 case Defines.FUNCTIONS: |
|
638 default: |
|
639 break; |
|
640 } |
|
641 |
|
642 this.vPanel.refreshCumulativeThreadTable(); |
|
643 this.repaint(); |
|
644 this.vPanel.piEventReceived(be); |
|
645 break; |
|
646 |
|
647 case PIEvent.MOUSE_PRESSED: |
|
648 switch (drawMode) { |
|
649 case Defines.THREADS: |
|
650 { |
|
651 break; |
|
652 } |
|
653 case Defines.BINARIES: |
|
654 { |
|
655 break; |
|
656 } |
|
657 case Defines.FUNCTIONS: |
|
658 { |
|
659 break; |
|
660 } |
|
661 default: |
|
662 { |
|
663 break; |
|
664 } |
|
665 } |
|
666 this.parentComponent.setActive(this); |
|
667 break; |
|
668 |
|
669 default: |
415 default: |
670 break; |
416 break; |
671 } |
417 } |
672 } |
418 break; |
673 |
419 case PIEvent.THRESHOLD_BINARY_CHANGED: |
674 public void actionPerformed(ActionEvent ae) |
420 if (this.getGraphIndex() == PIPageEditor.BINARIES_PAGE) |
675 { |
421 this.getBinaryTable().action("changeThresholdBinary"); //$NON-NLS-1$ |
676 } |
422 switch (this.drawMode) { |
677 |
423 case Defines.THREADS_FUNCTIONS_BINARIES: |
678 public void action(String actionString) |
424 case Defines.THREADS_BINARIES: |
679 { |
425 case Defines.THREADS_BINARIES_FUNCTIONS: |
680 System.out.println(Messages.getString("GppTraceGraph.actionString")+actionString); //$NON-NLS-1$ |
426 case Defines.BINARIES: |
681 |
|
682 if (actionString.equals("resetToCurrentMode")) //$NON-NLS-1$ |
|
683 { |
|
684 if (drawMode == Defines.THREADS_FUNCTIONS) |
|
685 this.setDrawMode(Defines.THREADS); |
|
686 else if (drawMode == Defines.BINARIES_FUNCTIONS) |
|
687 this.setDrawMode(Defines.BINARIES); |
|
688 else |
|
689 System.out.println(Messages.getString("GppTraceGraph.drawMode") + drawMode); //should not print this ever //$NON-NLS-1$ |
|
690 } |
|
691 else |
|
692 { |
|
693 switch (drawMode) |
|
694 { |
|
695 case Defines.THREADS: |
|
696 case Defines.THREADS_FUNCTIONS: |
|
697 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
698 case Defines.THREADS_BINARIES: |
|
699 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
700 { |
|
701 this.threadTable.action(actionString); |
|
702 break; |
|
703 } |
|
704 case Defines.BINARIES: |
|
705 case Defines.BINARIES_THREADS: |
|
706 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
707 case Defines.BINARIES_FUNCTIONS: |
|
708 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
709 { |
|
710 this.binaryTable.action(actionString); |
|
711 break; |
|
712 } |
|
713 case Defines.FUNCTIONS: |
|
714 case Defines.FUNCTIONS_THREADS: |
|
715 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
716 case Defines.FUNCTIONS_BINARIES: |
|
717 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
718 { |
|
719 this.functionTable.action(actionString); |
|
720 break; |
|
721 } |
|
722 } |
|
723 } |
|
724 } |
|
725 |
|
726 public void focusGained(FocusEvent fe) |
|
727 { |
|
728 } |
|
729 |
|
730 public void focusLost(FocusEvent fe) |
|
731 { |
|
732 } |
|
733 |
|
734 public void mouseDragged(MouseEvent me) { |
|
735 } |
|
736 |
|
737 public void mouseEntered(MouseEvent me) { |
|
738 } |
|
739 |
|
740 public void mouseExited(MouseEvent me) { |
|
741 } |
|
742 |
|
743 public void mouseHover(MouseEvent me) { |
|
744 } |
|
745 |
|
746 public void mousePressed(MouseEvent me) { |
|
747 } |
|
748 |
|
749 public void mouseReleased(MouseEvent me) { |
|
750 } |
|
751 |
|
752 public void mouseDoubleClicked(MouseEvent me) |
|
753 { |
|
754 Object[] result = this.getProfiledGenericUnderMouse(me); |
|
755 if ((result == null)) |
|
756 { |
|
757 return; |
|
758 } |
|
759 |
|
760 ProfiledGeneric pg = (ProfiledGeneric)result[0]; |
|
761 GenericTable gtu = null; |
|
762 |
|
763 switch (drawMode) |
|
764 { |
|
765 case Defines.THREADS: |
|
766 case Defines.BINARIES_THREADS: |
427 case Defines.BINARIES_THREADS: |
767 case Defines.FUNCTIONS_THREADS: |
428 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
429 case Defines.BINARIES_FUNCTIONS: |
768 case Defines.BINARIES_FUNCTIONS_THREADS: |
430 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
431 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
432 case Defines.FUNCTIONS_BINARIES: |
769 case Defines.FUNCTIONS_BINARIES_THREADS: |
433 case Defines.FUNCTIONS_BINARIES_THREADS: |
770 { |
434 this.setGraphImageChanged(true); |
771 gtu = this.threadTable; |
435 default: |
772 break; |
436 break; |
773 } |
437 } |
774 case Defines.BINARIES: |
438 break; |
775 case Defines.THREADS_BINARIES: |
439 case PIEvent.THRESHOLD_FUNCTION_CHANGED: |
|
440 if (this.getGraphIndex() == PIPageEditor.FUNCTIONS_PAGE) |
|
441 this.getFunctionTable().action("changeThresholdFunction"); //$NON-NLS-1$ |
|
442 switch (this.drawMode) { |
|
443 case Defines.THREADS_FUNCTIONS: |
776 case Defines.THREADS_FUNCTIONS_BINARIES: |
444 case Defines.THREADS_FUNCTIONS_BINARIES: |
777 case Defines.FUNCTIONS_BINARIES: |
|
778 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
779 { |
|
780 gtu = this.binaryTable; |
|
781 break; |
|
782 } |
|
783 case Defines.FUNCTIONS: |
|
784 case Defines.THREADS_FUNCTIONS: |
|
785 case Defines.BINARIES_FUNCTIONS: |
|
786 case Defines.THREADS_BINARIES_FUNCTIONS: |
445 case Defines.THREADS_BINARIES_FUNCTIONS: |
787 case Defines.BINARIES_THREADS_FUNCTIONS: |
446 case Defines.BINARIES_THREADS_FUNCTIONS: |
788 { |
447 case Defines.BINARIES_FUNCTIONS: |
789 gtu = this.functionTable; |
448 case Defines.BINARIES_FUNCTIONS_THREADS: |
790 break; |
449 case Defines.FUNCTIONS: |
791 } |
450 case Defines.FUNCTIONS_THREADS: |
|
451 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
452 case Defines.FUNCTIONS_BINARIES: |
|
453 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
454 this.setGraphImageChanged(true); |
792 default: |
455 default: |
793 break; |
456 break; |
794 } |
457 } |
795 |
458 break; |
796 if (pg != null) |
459 // when the selection area changes, change the percent loads |
|
460 // and the sample counts in all tables of this GPP graph |
|
461 case PIEvent.SELECTION_AREA_CHANGED: |
|
462 // this is the first GPP graph to be told of the selection area |
|
463 // change, |
|
464 // so it gathers the overall trace information |
|
465 double doubleStartTime = PIPageEditor.currentPageEditor() |
|
466 .getStartTime(); |
|
467 double doubleEndTime = PIPageEditor.currentPageEditor() |
|
468 .getEndTime(); |
|
469 GppTrace trace = (GppTrace) this.getTrace(); |
|
470 trace.setSelectedArea(doubleStartTime, doubleEndTime); |
|
471 |
|
472 // take care of the threshold members |
|
473 int sampleCount = 0; |
|
474 int thresholdCount; |
|
475 |
|
476 if (graphIndex == PIPageEditor.THREADS_PAGE) { |
|
477 thresholdCount = (Integer) NpiInstanceRepository |
|
478 .getInstance() |
|
479 .getPersistState(uid, |
|
480 "com.nokia.carbide.cpp.pi.address.thresholdCountThread"); //$NON-NLS-1$ |
|
481 if (thresholdCount > 0) { |
|
482 for (int i = 0; i < profiledThreads.size(); i++) |
|
483 if (profiledThreads.elementAt(i).getTotalSampleCount() < thresholdCount) |
|
484 sampleCount += profiledThreads.elementAt(i) |
|
485 .getSampleCount(graphIndex); |
|
486 thresholdThread |
|
487 .setSampleCount(this.graphIndex, sampleCount); |
|
488 } |
|
489 } else if (graphIndex == PIPageEditor.BINARIES_PAGE) { |
|
490 thresholdCount = (Integer) NpiInstanceRepository |
|
491 .getInstance() |
|
492 .getPersistState(uid, |
|
493 "com.nokia.carbide.cpp.pi.address.thresholdCountBinary"); //$NON-NLS-1$ |
|
494 if (thresholdCount > 0) { |
|
495 for (int i = 0; i < profiledBinaries.size(); i++) |
|
496 if (profiledBinaries.elementAt(i).getTotalSampleCount() < thresholdCount) |
|
497 sampleCount += profiledBinaries.elementAt(i) |
|
498 .getSampleCount(graphIndex); |
|
499 thresholdBinary |
|
500 .setSampleCount(this.graphIndex, sampleCount); |
|
501 } |
|
502 } else if (graphIndex == PIPageEditor.FUNCTIONS_PAGE) { |
|
503 thresholdCount = (Integer) NpiInstanceRepository |
|
504 .getInstance() |
|
505 .getPersistState(uid, |
|
506 "com.nokia.carbide.cpp.pi.address.thresholdCountFunction"); //$NON-NLS-1$ |
|
507 if (thresholdCount > 0) { |
|
508 for (int i = 0; i < profiledFunctions.size(); i++) |
|
509 if (profiledFunctions.elementAt(i) |
|
510 .getTotalSampleCount() < thresholdCount) |
|
511 sampleCount += profiledFunctions.elementAt(i) |
|
512 .getSampleCount(graphIndex); |
|
513 thresholdFunction.setSampleCount(this.graphIndex, |
|
514 sampleCount); |
|
515 } |
|
516 } |
|
517 |
|
518 double startTime = PIPageEditor.currentPageEditor().getStartTime(); |
|
519 double endTime = PIPageEditor.currentPageEditor().getEndTime(); |
|
520 |
|
521 // send this message to the other GPP graphs |
|
522 PIEvent be2 = new PIEvent(be.getValueObject(), |
|
523 PIEvent.SELECTION_AREA_CHANGED2); |
|
524 |
|
525 // update the selection area shown |
|
526 for (int i = 0; i < trace.getGraphCount(); i++) { |
|
527 IGppTraceGraph graph = trace.getGppGraph(i, getUid()); |
|
528 |
|
529 if (graph != this) { |
|
530 graph.piEventReceived(be2); |
|
531 // once per graph, update the selection interval shown |
|
532 graph.getCompositePanel().getVisualiser().updateStatusBarTimeInterval(startTime, endTime); |
|
533 } |
|
534 |
|
535 // change the graph's selected time interval |
|
536 graph.setSelectionStart(startTime * 1000); |
|
537 graph.setSelectionEnd(endTime * 1000); |
|
538 graph.getCompositePanel().setSelectionFields( |
|
539 (int) (startTime * 1000), (int) (endTime * 1000)); |
|
540 } |
|
541 |
|
542 this.parentComponent.getSashForm().redraw(); |
|
543 be = be2; |
|
544 // FALL THROUGH |
|
545 case PIEvent.SELECTION_AREA_CHANGED2: { |
|
546 // this code lets each graph's base thread/binary/function table |
|
547 // update the other tables |
|
548 switch (drawMode) { |
|
549 case Defines.THREADS: |
|
550 case Defines.THREADS_FUNCTIONS: |
|
551 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
552 case Defines.THREADS_BINARIES: |
|
553 case Defines.THREADS_BINARIES_FUNCTIONS: { |
|
554 this.threadTable.piEventReceived(be); |
|
555 break; |
|
556 } |
|
557 case Defines.BINARIES: |
|
558 case Defines.BINARIES_THREADS: |
|
559 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
560 case Defines.BINARIES_FUNCTIONS: |
|
561 case Defines.BINARIES_FUNCTIONS_THREADS: { |
|
562 this.binaryTable.piEventReceived(be); |
|
563 break; |
|
564 } |
|
565 case Defines.FUNCTIONS: |
|
566 case Defines.FUNCTIONS_THREADS: |
|
567 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
568 case Defines.FUNCTIONS_BINARIES: |
|
569 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
570 this.functionTable.piEventReceived(be); |
|
571 break; |
|
572 } |
|
573 } |
|
574 |
|
575 this.vPanel.refreshCumulativeThreadTable(); |
|
576 this.setGraphImageChanged(true); // any selection change to drill |
|
577 // down will change graph |
|
578 this.repaint(); |
|
579 break; |
|
580 } |
|
581 |
|
582 // in the graph, show all values from the rightmost table |
|
583 case PIEvent.SET_FILL_ALL_THREADS: |
|
584 this.setGraphImageChanged(true); // any selection change to drill |
|
585 // down will change graph |
|
586 this.vPanel.piEventReceived(be); |
|
587 break; |
|
588 |
|
589 // in the graph, don't fill between the lines will the color of |
|
590 // the line above |
|
591 case PIEvent.SET_FILL_OFF: |
|
592 this.setGraphImageChanged(true); // any selection change to drill |
|
593 // down will change graph |
|
594 this.vPanel.piEventReceived(be); |
|
595 break; |
|
596 |
|
597 // in the graph, show bars |
|
598 case PIEvent.GPP_SET_BAR_GRAPH_ON: |
|
599 this.vPanel.piEventReceived(be); |
|
600 break; |
|
601 |
|
602 // in the graph, show polylines |
|
603 case PIEvent.GPP_SET_BAR_GRAPH_OFF: |
|
604 this.vPanel.piEventReceived(be); |
|
605 break; |
|
606 |
|
607 // in the graph, show only the values from selected rows in the |
|
608 // rightmost table |
|
609 case PIEvent.SET_FILL_SELECTED_THREAD: |
|
610 this.setGraphImageChanged(true); // any selection change to drill |
|
611 // down will change graph |
|
612 this.vPanel.piEventReceived(be); |
|
613 break; |
|
614 |
|
615 // Redraw the graph because the thread table's selected values have |
|
616 // changed. |
|
617 // The thread table is handled (setting of array of selected threads |
|
618 // and table redraw) by the table selection listener or mouse listener. |
|
619 case PIEvent.CHANGED_THREAD_TABLE: |
|
620 switch (drawMode) { |
|
621 case Defines.THREADS_BINARIES: |
|
622 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
623 case Defines.THREADS_FUNCTIONS: |
|
624 case Defines.THREADS_FUNCTIONS_BINARIES: { |
|
625 this.threadTable.piEventReceived(be); |
|
626 break; |
|
627 } |
|
628 case Defines.BINARIES_THREADS_FUNCTIONS: { |
|
629 this.binaryTable.piEventReceived(be); |
|
630 break; |
|
631 } |
|
632 case Defines.FUNCTIONS_THREADS_BINARIES: { |
|
633 this.functionTable.piEventReceived(be); |
|
634 break; |
|
635 } |
|
636 case Defines.THREADS: |
|
637 case Defines.BINARIES: |
|
638 case Defines.BINARIES_THREADS: |
|
639 case Defines.BINARIES_FUNCTIONS: |
|
640 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
641 case Defines.FUNCTIONS: |
|
642 case Defines.FUNCTIONS_THREADS: |
|
643 case Defines.FUNCTIONS_BINARIES: |
|
644 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
645 default: |
|
646 break; |
|
647 } |
|
648 |
|
649 this.vPanel.refreshCumulativeThreadTable(); |
|
650 this.repaint(); |
|
651 // if fill selected, the graph is drawn again |
|
652 this.vPanel.piEventReceived(be); |
|
653 break; |
|
654 |
|
655 // Redraw the graph because the binary table's selected values have |
|
656 // changed. |
|
657 // The binary table is handled (setting of array of selected binaries |
|
658 // and table redraw) by the table selection listener or mouse listener. |
|
659 case PIEvent.CHANGED_BINARY_TABLE: |
|
660 switch (drawMode) { |
|
661 case Defines.BINARIES_THREADS: |
|
662 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
663 case Defines.BINARIES_FUNCTIONS: |
|
664 case Defines.BINARIES_FUNCTIONS_THREADS: { |
|
665 this.binaryTable.piEventReceived(be); |
|
666 break; |
|
667 } |
|
668 case Defines.THREADS_BINARIES_FUNCTIONS: { |
|
669 this.threadTable.piEventReceived(be); |
|
670 break; |
|
671 } |
|
672 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
673 this.functionTable.piEventReceived(be); |
|
674 break; |
|
675 } |
|
676 case Defines.THREADS: |
|
677 case Defines.THREADS_BINARIES: |
|
678 case Defines.THREADS_FUNCTIONS: |
|
679 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
680 case Defines.BINARIES: |
|
681 case Defines.FUNCTIONS: |
|
682 case Defines.FUNCTIONS_THREADS: |
|
683 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
684 case Defines.FUNCTIONS_BINARIES: |
|
685 default: |
|
686 break; |
|
687 } |
|
688 |
|
689 this.vPanel.refreshCumulativeThreadTable(); |
|
690 this.repaint(); |
|
691 // if fill selected, the graph is drawn again |
|
692 this.vPanel.piEventReceived(be); |
|
693 break; |
|
694 |
|
695 // Redraw the graph because the function table's selected values have |
|
696 // changed. |
|
697 // The function table is handled (setting of array of selected functions |
|
698 // and table redraw) by the table selection listener or mouse listener. |
|
699 case PIEvent.CHANGED_FUNCTION_TABLE: |
|
700 switch (drawMode) { |
|
701 case Defines.FUNCTIONS_THREADS: |
|
702 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
703 case Defines.FUNCTIONS_BINARIES: |
|
704 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
705 this.functionTable.piEventReceived(be); |
|
706 break; |
|
707 } |
|
708 case Defines.THREADS_FUNCTIONS_BINARIES: { |
|
709 this.threadTable.piEventReceived(be); |
|
710 break; |
|
711 } |
|
712 case Defines.BINARIES_FUNCTIONS_THREADS: { |
|
713 this.binaryTable.piEventReceived(be); |
|
714 break; |
|
715 } |
|
716 case Defines.THREADS: |
|
717 case Defines.THREADS_BINARIES: |
|
718 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
719 case Defines.THREADS_FUNCTIONS: |
|
720 case Defines.BINARIES: |
|
721 case Defines.BINARIES_THREADS: |
|
722 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
723 case Defines.BINARIES_FUNCTIONS: |
|
724 case Defines.FUNCTIONS: |
|
725 default: |
|
726 break; |
|
727 } |
|
728 |
|
729 this.vPanel.refreshCumulativeThreadTable(); |
|
730 this.repaint(); |
|
731 this.vPanel.piEventReceived(be); |
|
732 break; |
|
733 |
|
734 case PIEvent.MOUSE_PRESSED: |
|
735 switch (drawMode) { |
|
736 case Defines.THREADS: { |
|
737 break; |
|
738 } |
|
739 case Defines.BINARIES: { |
|
740 break; |
|
741 } |
|
742 case Defines.FUNCTIONS: { |
|
743 break; |
|
744 } |
|
745 default: { |
|
746 break; |
|
747 } |
|
748 } |
|
749 this.parentComponent.setActive(this); |
|
750 break; |
|
751 |
|
752 case PIEvent.SCALE_CHANGED: |
|
753 this.setGraphImageChanged(true); |
|
754 break; |
|
755 |
|
756 default: |
|
757 break; |
|
758 } |
|
759 } |
|
760 |
|
761 /* |
|
762 * (non-Javadoc) |
|
763 * |
|
764 * @see |
|
765 * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
766 */ |
|
767 public void actionPerformed(ActionEvent ae) { |
|
768 } |
|
769 |
|
770 /* |
|
771 * (non-Javadoc) |
|
772 * |
|
773 * @see |
|
774 * com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#action(java |
|
775 * .lang.String) |
|
776 */ |
|
777 @Override |
|
778 public void action(String actionString) { |
|
779 System.out |
|
780 .println(Messages.getString("GppTraceGraph.actionString") + actionString); //$NON-NLS-1$ |
|
781 |
|
782 if (actionString.equals("resetToCurrentMode")) //$NON-NLS-1$ |
797 { |
783 { |
|
784 if (drawMode == Defines.THREADS_FUNCTIONS) |
|
785 this.setDrawMode(Defines.THREADS); |
|
786 else if (drawMode == Defines.BINARIES_FUNCTIONS) |
|
787 this.setDrawMode(Defines.BINARIES); |
|
788 else |
|
789 System.out |
|
790 .println(Messages.getString("GppTraceGraph.drawMode") + drawMode); //should not print this ever //$NON-NLS-1$ |
|
791 } else { |
|
792 switch (drawMode) { |
|
793 case Defines.THREADS: |
|
794 case Defines.THREADS_FUNCTIONS: |
|
795 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
796 case Defines.THREADS_BINARIES: |
|
797 case Defines.THREADS_BINARIES_FUNCTIONS: { |
|
798 this.threadTable.action(actionString); |
|
799 break; |
|
800 } |
|
801 case Defines.BINARIES: |
|
802 case Defines.BINARIES_THREADS: |
|
803 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
804 case Defines.BINARIES_FUNCTIONS: |
|
805 case Defines.BINARIES_FUNCTIONS_THREADS: { |
|
806 this.binaryTable.action(actionString); |
|
807 break; |
|
808 } |
|
809 case Defines.FUNCTIONS: |
|
810 case Defines.FUNCTIONS_THREADS: |
|
811 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
812 case Defines.FUNCTIONS_BINARIES: |
|
813 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
814 this.functionTable.action(actionString); |
|
815 break; |
|
816 } |
|
817 } |
|
818 } |
|
819 } |
|
820 |
|
821 /* |
|
822 * (non-Javadoc) |
|
823 * |
|
824 * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) |
|
825 */ |
|
826 public void focusGained(FocusEvent fe) { |
|
827 } |
|
828 |
|
829 /* |
|
830 * (non-Javadoc) |
|
831 * |
|
832 * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent) |
|
833 */ |
|
834 public void focusLost(FocusEvent fe) { |
|
835 } |
|
836 |
|
837 /* |
|
838 * (non-Javadoc) |
|
839 * |
|
840 * @see |
|
841 * org.eclipse.draw2d.MouseMotionListener#mouseDragged(org.eclipse.draw2d |
|
842 * .MouseEvent) |
|
843 */ |
|
844 public void mouseDragged(MouseEvent me) { |
|
845 } |
|
846 |
|
847 /* |
|
848 * (non-Javadoc) |
|
849 * |
|
850 * @see |
|
851 * org.eclipse.draw2d.MouseMotionListener#mouseEntered(org.eclipse.draw2d |
|
852 * .MouseEvent) |
|
853 */ |
|
854 public void mouseEntered(MouseEvent me) { |
|
855 } |
|
856 |
|
857 /* |
|
858 * (non-Javadoc) |
|
859 * |
|
860 * @see |
|
861 * org.eclipse.draw2d.MouseMotionListener#mouseExited(org.eclipse.draw2d |
|
862 * .MouseEvent) |
|
863 */ |
|
864 public void mouseExited(MouseEvent me) { |
|
865 } |
|
866 |
|
867 /* |
|
868 * (non-Javadoc) |
|
869 * |
|
870 * @see |
|
871 * org.eclipse.draw2d.MouseMotionListener#mouseHover(org.eclipse.draw2d. |
|
872 * MouseEvent) |
|
873 */ |
|
874 public void mouseHover(MouseEvent me) { |
|
875 } |
|
876 |
|
877 /* |
|
878 * (non-Javadoc) |
|
879 * |
|
880 * @see |
|
881 * org.eclipse.draw2d.MouseListener#mousePressed(org.eclipse.draw2d.MouseEvent |
|
882 * ) |
|
883 */ |
|
884 public void mousePressed(MouseEvent me) { |
|
885 } |
|
886 |
|
887 /* |
|
888 * (non-Javadoc) |
|
889 * |
|
890 * @see |
|
891 * org.eclipse.draw2d.MouseListener#mouseReleased(org.eclipse.draw2d.MouseEvent |
|
892 * ) |
|
893 */ |
|
894 public void mouseReleased(MouseEvent me) { |
|
895 } |
|
896 |
|
897 /* |
|
898 * (non-Javadoc) |
|
899 * |
|
900 * @see |
|
901 * org.eclipse.draw2d.MouseListener#mouseDoubleClicked(org.eclipse.draw2d |
|
902 * .MouseEvent) |
|
903 */ |
|
904 public void mouseDoubleClicked(MouseEvent me) { |
|
905 Object[] result = this.getProfiledGenericUnderMouseImproved(me, false); |
|
906 if ((result == null)) { |
|
907 return; |
|
908 } |
|
909 |
|
910 ProfiledGeneric pg = (ProfiledGeneric) result[0]; |
|
911 GenericTable gtu = getLegendTableForGraph(); |
|
912 |
|
913 if (pg != null) { |
798 if (gtu.getIndex(pg) == null) |
914 if (gtu.getIndex(pg) == null) |
799 return; |
915 return; |
800 int[] index = new int[1]; |
916 int[] index = new int[1]; |
801 index[0] = gtu.getIndex(pg).intValue(); |
917 index[0] = gtu.getIndex(pg).intValue(); |
802 gtu.setSelectedIndicesXOR(index); |
918 gtu.setSelectedIndicesXOR(index); |
803 } |
919 } |
804 } |
920 } |
805 |
921 |
806 private Object[] getProfiledGenericUnderMouse(MouseEvent me) |
922 /** |
807 { |
923 * For a stacked-area chart, this method retrieves the ProfiledGeneric |
|
924 * currently pointed to by the mouse. It also determines the percentage |
|
925 * activity load of this ProfiledGeneric in the current bucket. The load |
|
926 * will also be determined if no ProfiledGeneric is currently pointed to |
|
927 * (unresolved items). |
|
928 * |
|
929 * |
|
930 * @param me |
|
931 * @return Object[2] of which [0] is the ProfiledGeneric (may be null) and |
|
932 * [1] is a String containing the load |
|
933 */ |
|
934 private Object[] getProfiledGenericUnderMouseImproved(MouseEvent me, boolean includeLoadString) { |
808 Object[] result = new Object[2]; |
935 Object[] result = new Object[2]; |
809 double x = me.x * this.getScale(); |
936 |
|
937 int adjustedX = me.x; |
|
938 if (me.x >= (this.getSize().width)) { |
|
939 adjustedX = this.getSize().width - 1; |
|
940 } |
|
941 double x = getTimeForXCoordinate(adjustedX, this.getScale()); |
|
942 if (x > PIPageEditor.currentPageEditor().getMaxEndTime() * 1000) { |
|
943 return result; |
|
944 } |
|
945 |
810 double y = me.y; |
946 double y = me.y; |
|
947 |
|
948 y = y * 100 / (this.getVisualSize().height - GppTraceGraph.X_LEGEND_HEIGHT); |
|
949 y = 100 - y; |
|
950 if (y <= 0){ |
|
951 return result; |
|
952 } |
811 |
953 |
812 y = y * 100 / (this.getVisualSize().height - GppTraceGraph.xLegendHeight); |
954 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState( |
813 y = 100 - y; |
955 "com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
814 if (y <= 0) |
956 int granularityValue = ((GppTrace) (this.getTrace())).getGranularity(); |
815 return null; |
957 |
|
958 int bucket = getBucketForTime(x); |
|
959 |
|
960 //since the value is drawn at bucket mid-point, we need to work out whether |
|
961 //x is to the left or right of the midpoint, in other words |
|
962 //whether we need to take into account the gradient from the previous |
|
963 //bucket or the next bucket |
|
964 int offset = ((int)(x / samplingInterval)) % granularityValue; //offset into the bucket |
|
965 int d = offset - (int)(granularityValue/2); //distance in samples off bucket mid-point, negative for left |
|
966 double prt = Math.abs(d / (granularityValue * 1d)); //expressed as proportion |
|
967 double saveLastPeak = 0f; |
816 |
968 |
817 // mouse event may return out of range X, that may |
969 for (ProfiledGeneric p : getSortedProfiledsForGraph()) { |
|
970 if (!p.isEnabled(graphIndex)){ |
|
971 continue; |
|
972 } |
|
973 float[] cum = p.getCumulativeList(graphIndex); |
|
974 float[] val = adapter.getActivityList(p); |
|
975 if (cum == null || val == null || bucket >= cum.length){ |
|
976 return result; |
|
977 } |
|
978 |
|
979 float lowCur = cum[bucket]; |
|
980 float topCur = cum[bucket] + val[bucket]; |
|
981 |
|
982 float lowNext = 0; |
|
983 float topNext = 0; |
|
984 |
|
985 double lowDiff = 0; |
|
986 double topDiff = 0; |
|
987 |
|
988 if (d < 0 && bucket > 0) { |
|
989 // use gradient of previous bucket |
|
990 lowNext = cum[bucket - 1]; |
|
991 topNext = cum[bucket - 1] + val[bucket - 1]; |
|
992 |
|
993 } else if (d > 0 && bucket < cum.length - 2) { |
|
994 // use gradient of next bucket |
|
995 lowNext = cum[bucket + 1]; |
|
996 topNext = cum[bucket + 1] + val[bucket + 1]; |
|
997 |
|
998 } |
|
999 lowDiff = (lowNext - lowCur) * prt; |
|
1000 topDiff = (topNext - topCur) * prt; |
|
1001 |
|
1002 // check whether y is in the profiled's value range |
|
1003 if (y >= lowCur + lowDiff && y < topCur + topDiff) { |
|
1004 result[0] = p; |
|
1005 if (includeLoadString){ |
|
1006 //round to 2 dec places |
|
1007 result[1] = String.format("%.2f", (topCur + topDiff - lowCur - lowDiff));//$NON-NLS-1$ |
|
1008 } |
|
1009 return result; |
|
1010 } |
|
1011 saveLastPeak = topCur + topDiff; |
|
1012 } |
|
1013 |
|
1014 if (includeLoadString){ |
|
1015 // within the area of not shown profiled items |
|
1016 result[0] = null; |
|
1017 result[1] = String.format("%.2f", (100 - saveLastPeak));//$NON-NLS-1$ |
|
1018 } |
|
1019 |
|
1020 return result; |
|
1021 } |
|
1022 |
|
1023 /** |
|
1024 * Returns the bucket index for the given time |
|
1025 * @param time |
|
1026 * @return |
|
1027 */ |
|
1028 private int getBucketForTime(double time) { |
|
1029 return ((int) (time / ((GppTrace) (this.getTrace())).getBucketDuration())); |
|
1030 } |
|
1031 |
|
1032 /** |
|
1033 * @return the sorted collection of ProfiledGeneric appropriate for the |
|
1034 * current draw mode of the graph |
|
1035 */ |
|
1036 public Vector<ProfiledGeneric> getSortedProfiledsForGraph() { |
|
1037 switch (drawMode) { |
|
1038 case Defines.THREADS: |
|
1039 case Defines.BINARIES_THREADS: |
|
1040 case Defines.FUNCTIONS_THREADS: |
|
1041 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
1042 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
1043 return sortedProfiledThreads ; |
|
1044 } |
|
1045 case Defines.BINARIES: |
|
1046 case Defines.THREADS_BINARIES: |
|
1047 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
1048 case Defines.FUNCTIONS_BINARIES: |
|
1049 case Defines.FUNCTIONS_THREADS_BINARIES: { |
|
1050 return sortedProfiledBinaries; |
|
1051 } |
|
1052 case Defines.FUNCTIONS: |
|
1053 case Defines.THREADS_FUNCTIONS: |
|
1054 case Defines.BINARIES_FUNCTIONS: |
|
1055 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
1056 case Defines.BINARIES_THREADS_FUNCTIONS: { |
|
1057 return sortedProfiledFunctions; |
|
1058 } |
|
1059 } |
|
1060 throw new IllegalArgumentException(); |
|
1061 } |
|
1062 |
|
1063 /** |
|
1064 * @return the sorted collection of ProfiledGeneric appropriate for the |
|
1065 * current draw mode of the graph |
|
1066 */ |
|
1067 private GenericAddrTable getLegendTableForGraph() { |
|
1068 |
|
1069 switch (drawMode) { |
|
1070 case Defines.THREADS: |
|
1071 case Defines.BINARIES_THREADS: |
|
1072 case Defines.FUNCTIONS_THREADS: |
|
1073 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
1074 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
1075 return this.threadTable; |
|
1076 } |
|
1077 case Defines.BINARIES: |
|
1078 case Defines.THREADS_BINARIES: |
|
1079 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
1080 case Defines.FUNCTIONS_BINARIES: |
|
1081 case Defines.FUNCTIONS_THREADS_BINARIES: { |
|
1082 return this.binaryTable; |
|
1083 } |
|
1084 case Defines.FUNCTIONS: |
|
1085 case Defines.THREADS_FUNCTIONS: |
|
1086 case Defines.BINARIES_FUNCTIONS: |
|
1087 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
1088 case Defines.BINARIES_THREADS_FUNCTIONS: { |
|
1089 return this.functionTable; |
|
1090 } |
|
1091 } |
|
1092 throw new IllegalArgumentException(); |
|
1093 } |
|
1094 |
|
1095 /** |
|
1096 * Converts the passed X-coordiate into a time value (in milliseconds) using |
|
1097 * the scale provided. Makes sure the return value is non-negative. |
|
1098 * |
|
1099 * @param x |
|
1100 * the x coordinate to use |
|
1101 * @param scale |
|
1102 * the scale to use |
|
1103 * @return time in milliseconds |
|
1104 */ |
|
1105 protected double getTimeForXCoordinate(int x, double scale) { |
|
1106 double time = x * scale; |
|
1107 // mouse event may return out of range X, that may |
818 // crash when we use it to index data array |
1108 // crash when we use it to index data array |
819 x = x >= 0 ? x : 0; |
1109 time = time >= 0 ? time : 0; |
820 |
1110 return time; |
821 if (x > PIPageEditor.currentPageEditor().getMaxEndTime() * 1000) |
1111 |
822 return null; |
1112 } |
823 |
1113 |
824 if (me.x >= (int)(this.getSize().width)) { |
1114 /* |
825 x = (this.getSize().width - 1) * this.getScale(); |
1115 * (non-Javadoc) |
826 } |
1116 * |
827 |
1117 * @see |
828 GppTrace gppTrace = (GppTrace) (this.getTrace()); |
1118 * org.eclipse.draw2d.MouseMotionListener#mouseMoved(org.eclipse.draw2d. |
829 |
1119 * MouseEvent) |
830 Enumeration<ProfiledGeneric> enumer = null; |
1120 */ |
831 switch (drawMode) |
1121 public void mouseMoved(MouseEvent me) { |
832 { |
1122 double x = getTimeForXCoordinate(me.x, this.getScale()); |
|
1123 double y = me.y; |
|
1124 |
|
1125 if (y >= this.getVisualSizeY() - GppTraceGraph.X_LEGEND_HEIGHT |
|
1126 || x >= PIPageEditor.currentPageEditor().getMaxEndTime() * 1000) { |
|
1127 //don't set the tooltip to null here since it might affect other plugins, such as button plugin |
|
1128 return; |
|
1129 } |
|
1130 |
|
1131 if (NpiInstanceRepository.getInstance() == null |
|
1132 || NpiInstanceRepository |
|
1133 .getInstance() |
|
1134 .activeUidGetPersistState( |
|
1135 "com.nokia.carbide.cpp.pi.address.samplingInterval") == null) //$NON-NLS-1$) |
|
1136 return; |
|
1137 |
|
1138 int samplingInterval = (Integer) NpiInstanceRepository.getInstance() |
|
1139 .activeUidGetPersistState( |
|
1140 "com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
|
1141 |
|
1142 if (this.barMode == GppTraceGraph.BAR_MODE_ON) { |
|
1143 GppSample samp = getSampleUnderMouse(me.x, this.getScale(), |
|
1144 samplingInterval); |
|
1145 if (samp == null) { |
|
1146 this.setToolTipText(null); |
|
1147 return; |
|
1148 } |
|
1149 switch (drawMode) { |
833 case Defines.THREADS: |
1150 case Defines.THREADS: |
834 case Defines.BINARIES_THREADS: |
1151 case Defines.BINARIES_THREADS: |
835 case Defines.FUNCTIONS_THREADS: |
1152 case Defines.FUNCTIONS_THREADS: |
836 case Defines.BINARIES_FUNCTIONS_THREADS: |
1153 case Defines.BINARIES_FUNCTIONS_THREADS: |
837 case Defines.FUNCTIONS_BINARIES_THREADS: |
1154 case Defines.FUNCTIONS_BINARIES_THREADS: { |
838 { |
1155 try { |
839 enumer = gppTrace.getSortedThreadsElements(); |
1156 this.setToolTipText(samp.sampleSynchTime + "ms @" + //$NON-NLS-1$ |
840 break; |
1157 Long.toHexString(samp.programCounter) + " " + //$NON-NLS-1$ |
|
1158 samp.thread.process.name + "::" + //$NON-NLS-1$ |
|
1159 samp.thread.threadName + "_" + //$NON-NLS-1$ |
|
1160 samp.thread.threadId); |
|
1161 } catch (NullPointerException e2) { |
|
1162 this |
|
1163 .setToolTipText(Messages |
|
1164 .getString("GppTraceGraph.cannotResolveThreadName")); //$NON-NLS-1$ |
|
1165 } |
|
1166 break; |
841 } |
1167 } |
842 case Defines.BINARIES: |
1168 case Defines.BINARIES: |
843 case Defines.THREADS_BINARIES: |
1169 case Defines.THREADS_BINARIES: |
844 case Defines.THREADS_FUNCTIONS_BINARIES: |
1170 case Defines.THREADS_FUNCTIONS_BINARIES: |
845 case Defines.FUNCTIONS_BINARIES: |
1171 case Defines.FUNCTIONS_BINARIES: |
846 case Defines.FUNCTIONS_THREADS_BINARIES: |
1172 case Defines.FUNCTIONS_THREADS_BINARIES: { |
847 { |
1173 try { |
848 enumer = gppTrace.getSortedBinariesElements(); |
1174 if (samp.getCurrentFunctionSym().getFunctionBinary().getBinaryName() |
|
1175 .endsWith(Messages |
|
1176 .getString("GppTraceGraph.NotFound"))) //$NON-NLS-1$ |
|
1177 throw new NullPointerException(); |
|
1178 this.setToolTipText(samp.sampleSynchTime + "ms @" + //$NON-NLS-1$ |
|
1179 Long.toHexString(samp.programCounter) + " " + //$NON-NLS-1$ |
|
1180 samp.getCurrentFunctionSym().getFunctionBinary().getBinaryName()); |
|
1181 } catch (NullPointerException e) { |
|
1182 try { |
|
1183 this |
|
1184 .setToolTipText(samp.sampleSynchTime + "ms @" + //$NON-NLS-1$ |
|
1185 Long.toHexString(samp.programCounter) |
|
1186 + " " + //$NON-NLS-1$ |
|
1187 samp.getCurrentFunctionItt().getFunctionBinary().getBinaryName()); |
|
1188 } catch (NullPointerException e2) { |
|
1189 this |
|
1190 .setToolTipText(Messages |
|
1191 .getString("GppTraceGraph.cannotResolveBinaryName")); //$NON-NLS-1$ |
|
1192 } |
|
1193 } |
849 break; |
1194 break; |
850 } |
1195 } |
851 case Defines.FUNCTIONS: |
1196 case Defines.FUNCTIONS: |
852 case Defines.THREADS_FUNCTIONS: |
1197 case Defines.THREADS_FUNCTIONS: |
853 case Defines.BINARIES_FUNCTIONS: |
1198 case Defines.BINARIES_FUNCTIONS: |
854 case Defines.THREADS_BINARIES_FUNCTIONS: |
1199 case Defines.THREADS_BINARIES_FUNCTIONS: |
855 case Defines.BINARIES_THREADS_FUNCTIONS: |
1200 case Defines.BINARIES_THREADS_FUNCTIONS: { |
856 { |
1201 try { |
857 enumer = gppTrace.getSortedFunctionsElements(); |
1202 if (samp.getCurrentFunctionSym().getFunctionBinary().getBinaryName() |
858 break; |
1203 .endsWith(Messages |
|
1204 .getString("GppTraceGraph.notFound"))) //$NON-NLS-1$ |
|
1205 throw new NullPointerException(); |
|
1206 |
|
1207 this.setToolTipText(samp.sampleSynchTime + "ms @" + //$NON-NLS-1$ |
|
1208 Long.toHexString(samp.programCounter) + " " + //$NON-NLS-1$ |
|
1209 samp.getCurrentFunctionSym().getFunctionName()); |
|
1210 } catch (NullPointerException e) { |
|
1211 try { |
|
1212 this.setToolTipText(samp.sampleSynchTime + "ms @" + //$NON-NLS-1$ |
|
1213 Long.toHexString(samp.programCounter) + " " + //$NON-NLS-1$ |
|
1214 samp.getCurrentFunctionItt().getFunctionName()); |
|
1215 } catch (NullPointerException e2) { |
|
1216 this |
|
1217 .setToolTipText(Messages |
|
1218 .getString("GppTraceGraph.cannotResolveFunctionName")); //$NON-NLS-1$ |
|
1219 } |
|
1220 } |
|
1221 break; |
859 } |
1222 } |
860 default: |
1223 default: |
861 break; |
1224 return; |
862 } |
1225 } |
863 |
1226 |
864 if (enumer == null) |
1227 return; // return for barMode == GppTraceGraph.BAR_MODE_ON |
865 return null; |
1228 } |
866 |
1229 |
867 Vector<ProfiledGeneric> activeThreads = new Vector<ProfiledGeneric>(); |
1230 // barMode == GppTraceGraph.BAR_MODE_OFF |
868 while(enumer.hasMoreElements()) |
1231 |
869 { |
1232 Object[] result = this.getProfiledGenericUnderMouseImproved(me, true); |
870 ProfiledGeneric pg = (ProfiledGeneric)enumer.nextElement(); |
1233 if (result == null || (result[0] == null && result[1] == null)) { |
871 if (pg.isEnabled(this.graphIndex)) |
|
872 { |
|
873 activeThreads.add(pg); |
|
874 } |
|
875 } |
|
876 |
|
877 int cumPrev = 0; |
|
878 int cumNext = 0; |
|
879 |
|
880 int topPrev = 0; |
|
881 int topNext = 0; |
|
882 |
|
883 double cumDiff = 0; |
|
884 double topDiff = 0; |
|
885 |
|
886 ProfiledGeneric currentProfiled = null; |
|
887 |
|
888 enumer = activeThreads.elements(); |
|
889 if (enumer.hasMoreElements()) |
|
890 currentProfiled = enumer.nextElement(); |
|
891 |
|
892 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
|
893 int granularityValue = gppTrace.samples.size() > GppTraceGraph.granularityValue ? GppTraceGraph.granularityValue : gppTrace.samples.size(); |
|
894 |
|
895 while (true) |
|
896 { |
|
897 if (currentProfiled != null) |
|
898 { |
|
899 int[] cum = currentProfiled.getCumulativeList(graphIndex); |
|
900 int[] val = currentProfiled.getActivityList(); |
|
901 if (cum == null || val == null) |
|
902 return null; |
|
903 |
|
904 int current = ((int)(x / samplingInterval)) / granularityValue; |
|
905 |
|
906 if ((current >= cum.length) || (current + 1 >= cum.length)) |
|
907 return null; |
|
908 |
|
909 cumPrev = cum[current]; |
|
910 cumNext = cum[current + 1]; |
|
911 |
|
912 topPrev = val[current]; |
|
913 topNext = val[current + 1]; |
|
914 |
|
915 cumDiff = (cumNext - cumPrev) * ((double)((x / samplingInterval) % granularityValue) / (granularityValue * 1d)); |
|
916 topDiff = (topNext - topPrev) * ((double)((x / samplingInterval) % granularityValue) / (granularityValue * 1d)); |
|
917 } |
|
918 else |
|
919 { |
|
920 if (y >= cumPrev + topPrev + topDiff + cumDiff) |
|
921 { |
|
922 currentProfiled = null; |
|
923 break; |
|
924 } |
|
925 else |
|
926 { |
|
927 break; |
|
928 } |
|
929 } |
|
930 |
|
931 if (y >= cumPrev + cumDiff && y < cumPrev + topPrev + topDiff + cumDiff ) |
|
932 { |
|
933 break; |
|
934 } |
|
935 else |
|
936 { |
|
937 if (enumer.hasMoreElements()) |
|
938 { |
|
939 currentProfiled = (ProfiledGeneric)enumer.nextElement(); |
|
940 } |
|
941 else |
|
942 { |
|
943 currentProfiled = null; |
|
944 } |
|
945 } |
|
946 } |
|
947 |
|
948 if (currentProfiled != null) |
|
949 { |
|
950 String loadString = "" + (topPrev + topDiff); //$NON-NLS-1$ |
|
951 int index = loadString.indexOf('.'); |
|
952 |
|
953 if (index > 0 && ((index + 2) < loadString.length())) |
|
954 loadString = loadString.substring(0, index + 2); |
|
955 |
|
956 result[0] = currentProfiled; |
|
957 result[1] = loadString; |
|
958 } |
|
959 else |
|
960 { |
|
961 String totalString = "" + (100 - (cumPrev + topPrev + topDiff + cumDiff)); //$NON-NLS-1$ |
|
962 int index = totalString.indexOf('.'); |
|
963 |
|
964 if (index > 0 && ((index + 2) < totalString.length())) |
|
965 totalString = totalString.substring(0, index + 2); |
|
966 |
|
967 result[0] = null; |
|
968 result[1] = totalString; |
|
969 } |
|
970 return result; |
|
971 } |
|
972 |
|
973 public void mouseMoved(MouseEvent me) |
|
974 { |
|
975 double x = me.x * this.getScale(); |
|
976 double y = me.y; |
|
977 |
|
978 // mouse event may return out of range X, that may |
|
979 // crash when we use it to index data array |
|
980 x = x >= 0 ? x : 0; |
|
981 |
|
982 if ( y >= this.getVisualSizeY() - GppTraceGraph.xLegendHeight |
|
983 || x >= PIPageEditor.currentPageEditor().getMaxEndTime() * 1000) |
|
984 { |
|
985 this.setToolTipText(null); |
1234 this.setToolTipText(null); |
986 return; |
1235 return; |
987 } |
1236 } |
988 |
1237 |
989 if ( NpiInstanceRepository.getInstance() == null |
1238 if (me.x >= (this.getSize().width)) { |
990 || NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval") == null) //$NON-NLS-1$) |
|
991 return; |
|
992 |
|
993 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
|
994 |
|
995 if (this.barMode == GppTraceGraph.BAR_MODE_ON) { |
|
996 GppSample samp = (GppSample)((GenericSampledTrace)this.getTrace()).getSample(((int)(x + .0005))/samplingInterval); |
|
997 switch (drawMode) |
|
998 { |
|
999 case Defines.THREADS: |
|
1000 case Defines.BINARIES_THREADS: |
|
1001 case Defines.FUNCTIONS_THREADS: |
|
1002 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
1003 case Defines.FUNCTIONS_BINARIES_THREADS: |
|
1004 { |
|
1005 try { |
|
1006 this.setToolTipText(samp.sampleSynchTime+"ms @"+ //$NON-NLS-1$ |
|
1007 Long.toHexString(samp.programCounter)+" "+ //$NON-NLS-1$ |
|
1008 samp.thread.process.name+"::"+ //$NON-NLS-1$ |
|
1009 samp.thread.threadName+"_"+ //$NON-NLS-1$ |
|
1010 samp.thread.threadId);} |
|
1011 catch (NullPointerException e2) |
|
1012 { |
|
1013 this.setToolTipText(Messages.getString("GppTraceGraph.cannotResolveThreadName")); //$NON-NLS-1$ |
|
1014 } |
|
1015 break; |
|
1016 } |
|
1017 case Defines.BINARIES: |
|
1018 case Defines.THREADS_BINARIES: |
|
1019 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
1020 case Defines.FUNCTIONS_BINARIES: |
|
1021 case Defines.FUNCTIONS_THREADS_BINARIES: |
|
1022 { |
|
1023 try { |
|
1024 if (samp.currentFunctionSym.functionBinary.binaryName.endsWith(Messages.getString("GppTraceGraph.NotFound"))) //$NON-NLS-1$ |
|
1025 throw new NullPointerException(); |
|
1026 this.setToolTipText(samp.sampleSynchTime+"ms @"+ //$NON-NLS-1$ |
|
1027 Long.toHexString(samp.programCounter)+" "+ //$NON-NLS-1$ |
|
1028 samp.currentFunctionSym.functionBinary.binaryName); |
|
1029 } catch (NullPointerException e) |
|
1030 { |
|
1031 try { |
|
1032 this.setToolTipText(samp.sampleSynchTime+"ms @"+ //$NON-NLS-1$ |
|
1033 Long.toHexString(samp.programCounter)+" "+ //$NON-NLS-1$ |
|
1034 samp.currentFunctionItt.functionBinary.binaryName);} |
|
1035 catch (NullPointerException e2) |
|
1036 { |
|
1037 this.setToolTipText(Messages.getString("GppTraceGraph.cannotResolveBinaryName")); //$NON-NLS-1$ |
|
1038 } |
|
1039 } |
|
1040 break; |
|
1041 } |
|
1042 case Defines.FUNCTIONS: |
|
1043 case Defines.THREADS_FUNCTIONS: |
|
1044 case Defines.BINARIES_FUNCTIONS: |
|
1045 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
1046 case Defines.BINARIES_THREADS_FUNCTIONS: |
|
1047 { |
|
1048 try { |
|
1049 if (samp.currentFunctionSym.functionBinary.binaryName.endsWith(Messages.getString("GppTraceGraph.notFound"))) //$NON-NLS-1$ |
|
1050 throw new NullPointerException(); |
|
1051 |
|
1052 this.setToolTipText(samp.sampleSynchTime+"ms @"+ //$NON-NLS-1$ |
|
1053 Long.toHexString(samp.programCounter)+" "+ //$NON-NLS-1$ |
|
1054 samp.currentFunctionSym.functionName);} |
|
1055 catch (NullPointerException e) |
|
1056 { |
|
1057 try{this.setToolTipText(samp.sampleSynchTime+"ms @"+ //$NON-NLS-1$ |
|
1058 Long.toHexString(samp.programCounter)+" "+ //$NON-NLS-1$ |
|
1059 samp.currentFunctionItt.functionName);} |
|
1060 catch (NullPointerException e2) |
|
1061 { |
|
1062 this.setToolTipText(Messages.getString("GppTraceGraph.cannotResolveFunctionName")); //$NON-NLS-1$ |
|
1063 } |
|
1064 } |
|
1065 break; |
|
1066 } |
|
1067 default: |
|
1068 return; |
|
1069 } |
|
1070 |
|
1071 return; // return for barMode == GppTraceGraph.BAR_MODE_ON |
|
1072 } |
|
1073 |
|
1074 // barMode == GppTraceGraph.BAR_MODE_OFF |
|
1075 |
|
1076 Object[] result = this.getProfiledGenericUnderMouse(me); |
|
1077 if (result == null) |
|
1078 { |
|
1079 this.setToolTipText(null); |
|
1080 return; |
|
1081 } |
|
1082 |
|
1083 if (me.x >= (int)(this.getSize().width)) { |
|
1084 x = (this.getSize().width - 1) * this.getScale(); |
1239 x = (this.getSize().width - 1) * this.getScale(); |
1085 } |
1240 } |
1086 |
1241 |
1087 ProfiledGeneric pg = null; |
1242 ProfiledGeneric pg = (ProfiledGeneric) result[0]; |
1088 switch (drawMode) |
1243 |
1089 { |
1244 String string = (String) result[1]; |
|
1245 if (pg == null) { |
|
1246 switch (drawMode) { |
1090 case Defines.THREADS: |
1247 case Defines.THREADS: |
1091 case Defines.BINARIES_THREADS: |
1248 case Defines.BINARIES_THREADS: |
1092 case Defines.FUNCTIONS_THREADS: |
1249 case Defines.FUNCTIONS_THREADS: |
1093 case Defines.BINARIES_FUNCTIONS_THREADS: |
1250 case Defines.BINARIES_FUNCTIONS_THREADS: |
1094 case Defines.FUNCTIONS_BINARIES_THREADS: |
1251 case Defines.FUNCTIONS_BINARIES_THREADS: { |
1095 { |
1252 this |
1096 pg = (ProfiledThread)result[0]; |
1253 .setToolTipText(string |
1097 break; |
1254 + "% " + Messages.getString("GppTraceGraph.unknownOrExcludedThreads")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
1255 break; |
1098 } |
1256 } |
1099 case Defines.BINARIES: |
1257 case Defines.BINARIES: |
1100 case Defines.THREADS_BINARIES: |
1258 case Defines.THREADS_BINARIES: |
1101 case Defines.THREADS_FUNCTIONS_BINARIES: |
1259 case Defines.THREADS_FUNCTIONS_BINARIES: |
1102 case Defines.FUNCTIONS_BINARIES: |
1260 case Defines.FUNCTIONS_BINARIES: |
1103 case Defines.FUNCTIONS_THREADS_BINARIES: |
1261 case Defines.FUNCTIONS_THREADS_BINARIES: { |
1104 { |
1262 this |
1105 pg = (ProfiledBinary)result[0]; |
1263 .setToolTipText(string |
|
1264 + "% " + Messages.getString("GppTraceGraph.unknownOrExcludedBinaries")); //$NON-NLS-1$ //$NON-NLS-2$ |
1106 break; |
1265 break; |
1107 } |
1266 } |
1108 case Defines.FUNCTIONS: |
1267 case Defines.FUNCTIONS: |
1109 case Defines.THREADS_FUNCTIONS: |
1268 case Defines.THREADS_FUNCTIONS: |
1110 case Defines.BINARIES_FUNCTIONS: |
1269 case Defines.BINARIES_FUNCTIONS: |
1111 case Defines.THREADS_BINARIES_FUNCTIONS: |
1270 case Defines.THREADS_BINARIES_FUNCTIONS: |
1112 case Defines.BINARIES_THREADS_FUNCTIONS: |
1271 case Defines.BINARIES_THREADS_FUNCTIONS: { |
1113 { |
1272 this |
1114 pg = (ProfiledFunction)result[0]; |
1273 .setToolTipText(string |
1115 break; |
1274 + "% " + Messages.getString("GppTraceGraph.unknownOrExcludedFunctions")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
1275 break; |
1116 } |
1276 } |
1117 default: |
1277 default: |
1118 break; |
1278 break; |
1119 } |
1279 } |
1120 |
1280 } else { |
1121 String string = (String)result[1]; |
1281 this.setToolTipText(string + "% " + pg.getNameString()); //$NON-NLS-1$ |
1122 if (pg == null) |
1282 } |
1123 { |
1283 } |
1124 switch (drawMode) |
1284 |
1125 { |
1285 /** |
1126 case Defines.THREADS: |
1286 * Returns the closest matching sample with the given x-coordinate. May |
1127 case Defines.BINARIES_THREADS: |
1287 * return null if there isn't a matching sample in the immediate vicinity of |
1128 case Defines.FUNCTIONS_THREADS: |
1288 * x. This method is typically used in bar mode. |
1129 case Defines.BINARIES_FUNCTIONS_THREADS: |
1289 * |
1130 case Defines.FUNCTIONS_BINARIES_THREADS: |
1290 * @param xPoint |
1131 { |
1291 * @param scale |
1132 this.setToolTipText(string + "% " + Messages.getString("GppTraceGraph.unknownOrExcludedThreads")); //$NON-NLS-1$ //$NON-NLS-2$ |
1292 * @param samplingInterval |
1133 break; |
1293 * @return |
1134 } |
1294 */ |
1135 case Defines.BINARIES: |
1295 protected GppSample getSampleUnderMouse(int xPoint, double scale, |
1136 case Defines.THREADS_BINARIES: |
1296 int samplingInterval) { |
1137 case Defines.THREADS_FUNCTIONS_BINARIES: |
1297 GppTrace trace = (GppTrace)this.getTrace(); |
1138 case Defines.FUNCTIONS_BINARIES: |
1298 GppSample match = null; |
1139 case Defines.FUNCTIONS_THREADS_BINARIES: |
1299 double x = xPoint * scale; |
1140 { |
1300 x = x >= 0 ? x : 0; |
1141 this.setToolTipText(string + "% " + Messages.getString("GppTraceGraph.unknownOrExcludedBinaries")); //$NON-NLS-1$ //$NON-NLS-2$ |
1301 double xStart = (xPoint -5 ) * scale; |
1142 break; |
1302 double xEnd = (xPoint +5) * scale; |
1143 } |
1303 |
1144 case Defines.FUNCTIONS: |
1304 int start = ((int)(xStart + .0005) * trace.getCPUCount())/samplingInterval; |
1145 case Defines.THREADS_FUNCTIONS: |
1305 if (start < 0){ |
1146 case Defines.BINARIES_FUNCTIONS: |
1306 start = 0; |
1147 case Defines.THREADS_BINARIES_FUNCTIONS: |
1307 } else if (start >= trace.getSampleAmount()){ |
1148 case Defines.BINARIES_THREADS_FUNCTIONS: |
1308 start = trace.getSampleAmount()-1; |
1149 { |
1309 } |
1150 this.setToolTipText(string + "% " + Messages.getString("GppTraceGraph.unknownOrExcludedFunctions")); //$NON-NLS-1$ //$NON-NLS-2$ |
1310 |
1151 break; |
1311 int end = ((int)(xEnd + .0005) * trace.getCPUCount())/samplingInterval; |
1152 } |
1312 if (end >= trace.getSampleAmount()){ |
1153 default: |
1313 end = trace.getSampleAmount()-1; |
1154 break; |
1314 } |
1155 } |
1315 |
1156 } |
1316 //loop through samples with the correct CPU id in close vicinity, and find the closest one to the given x-coordinate |
1157 else |
1317 for (int i = start; i <= end; i++) { |
1158 { |
1318 GppSample tmp = trace.getSortedGppSamples()[i]; |
1159 this.setToolTipText(string + "% " + pg.getNameString()); //$NON-NLS-1$ |
1319 if (doCheckSampleMatch(tmp) && (match == null || Math.abs(tmp.sampleSynchTime - x) < Math.abs(match.sampleSynchTime - x)) && isSampleEnabled(tmp)){ |
1160 } |
1320 match = tmp; |
|
1321 } |
|
1322 } |
|
1323 |
|
1324 return match; |
1161 } |
1325 } |
1162 |
1326 |
1163 public GenericTable getTableUtils() |
1327 /** |
1164 { |
1328 * According to current graph index and drawing mode, check whether this |
1165 switch (drawMode) |
1329 * sample is enabled |
1166 { |
1330 * @param sample the sample to use |
1167 case Defines.THREADS: |
1331 * @return true, if enabled, false if disabled or cannot be determined |
1168 case Defines.BINARIES_THREADS: |
1332 */ |
1169 case Defines.FUNCTIONS_THREADS: |
1333 private boolean isSampleEnabled(GppSample sample) { |
1170 case Defines.BINARIES_FUNCTIONS_THREADS: |
1334 |
1171 case Defines.FUNCTIONS_BINARIES_THREADS: |
1335 switch (drawMode) { |
1172 { |
1336 case Defines.THREADS: |
1173 return this.threadTable; |
1337 return isSampleEnabled(sample, true, false, false); |
1174 } |
1338 case Defines.BINARIES: |
1175 case Defines.BINARIES: |
1339 return isSampleEnabled(sample, false, true, false); |
1176 case Defines.THREADS_BINARIES: |
1340 case Defines.FUNCTIONS: |
1177 case Defines.THREADS_FUNCTIONS_BINARIES: |
1341 return isSampleEnabled(sample, false, false, true); |
1178 case Defines.FUNCTIONS_BINARIES: |
1342 case Defines.BINARIES_THREADS: |
1179 case Defines.FUNCTIONS_THREADS_BINARIES: |
1343 case Defines.THREADS_BINARIES: |
1180 { |
1344 return isSampleEnabled(sample, true, true, false); |
1181 return this.binaryTable; |
1345 case Defines.FUNCTIONS_THREADS: |
1182 } |
1346 case Defines.THREADS_FUNCTIONS: |
1183 case Defines.FUNCTIONS: |
1347 return isSampleEnabled(sample, true, false, true); |
1184 case Defines.THREADS_FUNCTIONS: |
1348 case Defines.FUNCTIONS_BINARIES: |
1185 case Defines.BINARIES_FUNCTIONS: |
1349 case Defines.BINARIES_FUNCTIONS: |
1186 case Defines.THREADS_BINARIES_FUNCTIONS: |
1350 return isSampleEnabled(sample, false, true, true); |
1187 case Defines.BINARIES_THREADS_FUNCTIONS: |
1351 case Defines.BINARIES_FUNCTIONS_THREADS: |
1188 { |
1352 case Defines.FUNCTIONS_BINARIES_THREADS: |
1189 return this.functionTable; |
1353 case Defines.THREADS_FUNCTIONS_BINARIES: |
1190 } |
1354 case Defines.FUNCTIONS_THREADS_BINARIES: |
1191 default: |
1355 case Defines.THREADS_BINARIES_FUNCTIONS: |
1192 break; |
1356 case Defines.BINARIES_THREADS_FUNCTIONS: |
1193 } |
1357 return isSampleEnabled(sample, true, true, true); |
1194 |
1358 } |
1195 System.out.println(Messages.getString("GppTraceGraph.debugDrawMode") + drawMode); //$NON-NLS-1$ |
1359 throw new IllegalArgumentException(); |
1196 return null; |
1360 } |
1197 } |
1361 |
1198 |
1362 /** |
1199 public GppVisualiserPanel getVisualiserPanel() |
1363 * Check whether a combination of thread / function / binary for this sample |
1200 { |
1364 * is enabled in the current graph. |
|
1365 * @param sample |
|
1366 * @param checkThreads |
|
1367 * @param checkBinaries |
|
1368 * @param checkFunctions |
|
1369 * @return |
|
1370 */ |
|
1371 private boolean isSampleEnabled(GppSample sample, boolean checkThreads, boolean checkBinaries, |
|
1372 boolean checkFunctions) { |
|
1373 |
|
1374 boolean ret = true; |
|
1375 GppTrace trace = (GppTrace) this.getTrace(); |
|
1376 |
|
1377 if (checkThreads){ |
|
1378 ret &= trace.getIndexedThreads().get(sample.threadIndex).isEnabled(graphIndex); |
|
1379 } |
|
1380 if (checkBinaries){ |
|
1381 ret &= trace.getIndexedBinaries().get(sample.binaryIndex).isEnabled(graphIndex); |
|
1382 } |
|
1383 if (checkFunctions){ |
|
1384 ret &= trace.getIndexedFunctions().get(sample.functionIndex).isEnabled(graphIndex); |
|
1385 } |
|
1386 return ret; |
|
1387 } |
|
1388 |
|
1389 /** |
|
1390 * Check the sample fulfils conditions for getSampleUnderMouse() |
|
1391 * @return true if it fulfils matching conditions, false otherwise |
|
1392 */ |
|
1393 protected boolean doCheckSampleMatch(GppSample sample){ |
|
1394 return true; |
|
1395 } |
|
1396 |
|
1397 public GenericTable getTableUtils() { |
|
1398 switch (drawMode) { |
|
1399 case Defines.THREADS: |
|
1400 case Defines.BINARIES_THREADS: |
|
1401 case Defines.FUNCTIONS_THREADS: |
|
1402 case Defines.BINARIES_FUNCTIONS_THREADS: |
|
1403 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
1404 return this.threadTable; |
|
1405 } |
|
1406 case Defines.BINARIES: |
|
1407 case Defines.THREADS_BINARIES: |
|
1408 case Defines.THREADS_FUNCTIONS_BINARIES: |
|
1409 case Defines.FUNCTIONS_BINARIES: |
|
1410 case Defines.FUNCTIONS_THREADS_BINARIES: { |
|
1411 return this.binaryTable; |
|
1412 } |
|
1413 case Defines.FUNCTIONS: |
|
1414 case Defines.THREADS_FUNCTIONS: |
|
1415 case Defines.BINARIES_FUNCTIONS: |
|
1416 case Defines.THREADS_BINARIES_FUNCTIONS: |
|
1417 case Defines.BINARIES_THREADS_FUNCTIONS: { |
|
1418 return this.functionTable; |
|
1419 } |
|
1420 default: |
|
1421 break; |
|
1422 } |
|
1423 |
|
1424 System.out |
|
1425 .println(Messages.getString("GppTraceGraph.debugDrawMode") + drawMode); //$NON-NLS-1$ |
|
1426 return null; |
|
1427 } |
|
1428 |
|
1429 public GppVisualiserPanel getVisualiserPanel() { |
1201 return this.vPanel; |
1430 return this.vPanel; |
1202 } |
1431 } |
1203 |
1432 |
1204 public AddrThreadTable getThreadTable() { |
1433 public AddrThreadTable getThreadTable() { |
1205 return this.threadTable; |
1434 return this.threadTable; |
1206 } |
1435 } |
1207 |
1436 |
1208 public AddrBinaryTable getBinaryTable() { |
1437 public AddrBinaryTable getBinaryTable() { |
1209 return this.binaryTable; |
1438 return this.binaryTable; |
1210 } |
1439 } |
1211 |
1440 |
1212 public AddrFunctionTable getFunctionTable() { |
1441 public AddrFunctionTable getFunctionTable() { |
1213 return this.functionTable; |
1442 return this.functionTable; |
1214 } |
1443 } |
1215 |
1444 |
1216 public void setThreadTableViewer(CheckboxTableViewer tableViewer) { |
1445 /* |
1217 this.threadTable.setTableViewer(tableViewer); |
1446 * (non-Javadoc) |
1218 } |
1447 * |
1219 |
1448 * @see |
1220 public void setBinaryTableViewer(CheckboxTableViewer tableViewer) { |
1449 * com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#paint(org. |
1221 this.binaryTable.setTableViewer(tableViewer);; |
1450 * eclipse.draw2d.Panel, org.eclipse.draw2d.Graphics) |
1222 } |
1451 */ |
1223 |
1452 @Override |
1224 public void setFunctionTableViewer(CheckboxTableViewer tableViewer) { |
1453 public void paint(Panel panel, Graphics graphics) { |
1225 this.functionTable.setTableViewer(tableViewer); |
|
1226 } |
|
1227 |
|
1228 public void paint(Panel panel, Graphics graphics) |
|
1229 { |
|
1230 this.setSize(panel.getClientArea().width, panel.getClientArea().height); |
1454 this.setSize(panel.getClientArea().width, panel.getClientArea().height); |
1231 this.vPanel.paintComponent(panel, graphics); |
1455 this.vPanel.paintComponent(panel, graphics); |
1232 } |
1456 } |
1233 |
1457 |
1234 public void paintLeftLegend(FigureCanvas figureCanvas, GC gc) |
1458 /* |
1235 { |
1459 * (non-Javadoc) |
|
1460 * |
|
1461 * @see |
|
1462 * com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#paintLeftLegend |
|
1463 * (org.eclipse.draw2d.FigureCanvas, org.eclipse.swt.graphics.GC) |
|
1464 */ |
|
1465 @Override |
|
1466 public void paintLeftLegend(FigureCanvas figureCanvas, GC gc) { |
1236 GC localGC = gc; |
1467 GC localGC = gc; |
1237 |
1468 |
1238 if (gc == null) |
1469 if (gc == null) |
1239 gc = new GC(PIPageEditor.currentPageEditor().getSite().getShell()); |
1470 gc = new GC(PIPageEditor.currentPageEditor().getSite().getShell()); |
1240 |
1471 |
1241 Rectangle rect = ((GraphComposite) figureCanvas.getParent()).figureCanvas.getClientArea(); |
1472 Rectangle rect = ((GraphComposite) figureCanvas.getParent()).figureCanvas |
1242 |
1473 .getClientArea(); |
|
1474 |
1243 int visY = rect.height; |
1475 int visY = rect.height; |
1244 |
1476 |
1245 float visYfloat = visY - GppTraceGraph.xLegendHeight; |
1477 float visYfloat = visY - GppTraceGraph.X_LEGEND_HEIGHT; |
1246 |
1478 |
1247 if (visYfloat < 0f) |
1479 if (visYfloat < 0f) |
1248 visYfloat = 0f; |
1480 visYfloat = 0f; |
1249 |
1481 |
1250 gc.setForeground(ColorPalette.getColor(new RGB(100, 100, 100))); |
1482 gc.setForeground(ColorPalette.getColor(new RGB(100, 100, 100))); |
1251 gc.setBackground(ColorPalette.getColor(new RGB(255, 255, 255))); |
1483 gc.setBackground(ColorPalette.getColor(new RGB(255, 255, 255))); |
1252 |
1484 |
1253 // write each next number if there is space |
1485 // write each next number if there is space |
1254 // float values will be slightly smaller than the actual result |
1486 // float values will be slightly smaller than the actual result |
1255 // and they will be incremented by one, since rounding to int |
1487 // and they will be incremented by one, since rounding to int |
1256 // discards the remaining decimals |
1488 // discards the remaining decimals |
1257 int percent = 100; |
1489 int percent = 100; |
1258 int previousBottom = 0; // bottom of the previous legend drawn |
1490 int previousBottom = 0; // bottom of the previous legend drawn |
1259 for (float y = 0f; percent >= 0; y += visYfloat * 10000f / 100001f, percent -= 10) |
1491 for (float y = 0f; percent >= 0; y += visYfloat * 10000f / 100001f, percent -= 10) { |
1260 { |
|
1261 String legend = "" + percent + "%"; //$NON-NLS-1$ //$NON-NLS-2$ |
1492 String legend = "" + percent + "%"; //$NON-NLS-1$ //$NON-NLS-2$ |
1262 Point extent = gc.stringExtent(legend); |
1493 Point extent = gc.stringExtent(legend); |
1263 |
1494 |
1264 gc.drawLine(GenericTraceGraph.yLegendWidth - 3, (int)y + 1, GenericTraceGraph.yLegendWidth, (int)y + 1); |
1495 gc.drawLine(IGenericTraceGraph.Y_LEGEND_WIDTH - 3, (int) y + 1, |
1265 |
1496 IGenericTraceGraph.Y_LEGEND_WIDTH, (int) y + 1); |
1266 if ((int)y >= previousBottom) |
1497 |
1267 { |
1498 if ((int) y >= previousBottom) { |
1268 gc.drawString(legend, GenericTraceGraph.yLegendWidth - extent.x - 4, (int)y); |
1499 gc.drawString(legend, IGenericTraceGraph.Y_LEGEND_WIDTH |
1269 previousBottom = (int)y + extent.y; |
1500 - extent.x - 4, (int) y); |
1270 } |
1501 previousBottom = (int) y + extent.y; |
1271 } |
1502 } |
1272 |
1503 } |
|
1504 |
1273 if (localGC == null) { |
1505 if (localGC == null) { |
1274 gc.dispose(); |
1506 gc.dispose(); |
1275 figureCanvas.redraw(); |
1507 figureCanvas.redraw(); |
1276 } |
1508 } |
1277 } |
1509 } |
1278 |
1510 |
1279 public void repaint() |
1511 /* |
1280 { |
1512 * (non-Javadoc) |
|
1513 * |
|
1514 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#repaint() |
|
1515 */ |
|
1516 @Override |
|
1517 public void repaint() { |
1281 this.parentComponent.repaintComponent(); |
1518 this.parentComponent.repaintComponent(); |
1282 } |
1519 } |
1283 |
1520 |
1284 public void drawBarsGpp(Vector<ProfiledGeneric> profiledGenerics, Graphics graphics, Object[] selection) |
1521 /* |
1285 { |
1522 * (non-Javadoc) |
1286 if ( this.updateCumulativeThreadTableIsNeeded |
1523 * |
1287 || this.barGraphData == null) |
1524 * @see |
1288 { |
1525 * com.nokia.carbide.cpp.pi.address.IGppTraceGraph#drawBarsGpp(java.util |
|
1526 * .Vector, org.eclipse.draw2d.Graphics, java.lang.Object[]) |
|
1527 */ |
|
1528 public void drawBarsGpp(Vector<ProfiledGeneric> profiledGenerics, |
|
1529 Graphics graphics, Object[] selection) { |
|
1530 if (this.updateCumulativeThreadTableIsNeeded |
|
1531 || this.barGraphData == null) { |
1289 this.updateBarGraphData(profiledGenerics); |
1532 this.updateBarGraphData(profiledGenerics); |
1290 } |
1533 } |
1291 |
1534 |
1292 this.updateIfNeeded(profiledGenerics); |
1535 this.updateIfNeeded(profiledGenerics); |
1293 |
1536 |
1294 Enumeration<BarGraphData> barEnum = this.barGraphData.elements(); |
1537 Enumeration<BarGraphData> barEnum = this.barGraphData.elements(); |
1295 |
1538 |
1296 int drawX = -1; |
1539 int drawX = -1; |
1297 int lastDrawX = -10; |
1540 int lastDrawX = -10; |
1298 double scale = this.getScale(); |
1541 double scale = this.getScale(); |
1299 int y = this.getVisualSizeY() - 51; |
1542 int y = this.getVisualSizeY() - 51; |
1300 org.eclipse.draw2d.geometry.Rectangle visibleArea = this.getVisibleArea(graphics); |
1543 org.eclipse.draw2d.geometry.Rectangle visibleArea = this |
1301 |
1544 .getVisibleArea(graphics); |
1302 while(barEnum.hasMoreElements()) |
1545 |
1303 { |
1546 while (barEnum.hasMoreElements()) { |
1304 BarGraphData bgd = barEnum.nextElement(); |
1547 BarGraphData bgd = barEnum.nextElement(); |
1305 drawX = (int)(((double)bgd.x) / scale); |
1548 drawX = (int) ((bgd.x) / scale); |
1306 |
1549 |
1307 if ( drawX >= visibleArea.x |
1550 if (drawX >= visibleArea.x |
1308 && drawX < visibleArea.x + visibleArea.width ) |
1551 && drawX < visibleArea.x + visibleArea.width) { |
1309 { |
|
1310 if (debug) |
1552 if (debug) |
1311 System.out.println(Messages.getString("GppTraceGraph.draw") + drawX + " " + scale + " " + bgd.x); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
1553 System.out |
1312 if (drawX != lastDrawX) |
1554 .println(Messages.getString("GppTraceGraph.draw") + drawX + " " + scale + " " + bgd.x); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
1313 { |
1555 if (drawX != lastDrawX) { |
1314 graphics.setForegroundColor(bgd.color); |
1556 graphics.setForegroundColor(bgd.color); |
1315 graphics.drawLine(drawX, 0, drawX, y); |
1557 graphics.drawLine(drawX, 0, drawX, y); |
1316 lastDrawX = drawX; |
1558 lastDrawX = drawX; |
1317 } |
1559 } |
1318 } |
1560 } |
1319 } |
1561 } |
1320 } |
1562 } |
1321 |
1563 |
1322 public void updateBarGraphData(Vector profiledGenerics) |
1564 /** |
1323 { |
1565 * Updates this.barGraphData. |
|
1566 * |
|
1567 * @param profiledGenerics |
|
1568 * Vector of either sortedThreads / sortedBinaries / |
|
1569 * sortedFunctions |
|
1570 */ |
|
1571 private void updateBarGraphData(Vector<ProfiledGeneric> profiledGenerics) { |
1324 if (this.barGraphData == null) |
1572 if (this.barGraphData == null) |
1325 this.barGraphData = new Vector<BarGraphData>(); |
1573 this.barGraphData = new Vector<BarGraphData>(); |
1326 this.barGraphData.clear(); |
1574 this.barGraphData.clear(); |
1327 |
1575 |
1328 int x = 0; |
1576 int x = 0; |
1329 |
1577 |
1330 // find the first enabled profiled generic |
1578 // find the first enabled profiled generic |
1331 int firstEnabled; |
1579 int firstEnabled; |
1332 for (firstEnabled = 0; firstEnabled < profiledGenerics.size(); firstEnabled++) |
1580 for (firstEnabled = 0; firstEnabled < profiledGenerics.size(); firstEnabled++) |
1333 if (((ProfiledGeneric)profiledGenerics.get(firstEnabled)).isEnabled(this.graphIndex)) |
1581 if (((ProfiledGeneric) profiledGenerics.get(firstEnabled)) |
1334 break; |
1582 .isEnabled(this.graphIndex)) |
1335 |
1583 break; |
|
1584 |
1336 // return if there are no enabled profiled generics |
1585 // return if there are no enabled profiled generics |
1337 if (firstEnabled == profiledGenerics.size()) |
1586 if (firstEnabled == profiledGenerics.size()) |
1338 return; |
1587 return; |
1339 |
1588 |
1340 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
1589 int samplingInterval = (Integer) NpiInstanceRepository.getInstance() |
1341 Enumeration samples = ((GenericSampledTrace)this.getTrace()).getSamples(); |
1590 .activeUidGetPersistState( |
1342 while (samples.hasMoreElements()) |
1591 "com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
1343 { |
1592 for (GppSample gs : ((GppTrace) this |
1344 GppSample gs = (GppSample)samples.nextElement(); |
1593 .getTrace()).getSortedGppSamples()) { |
1345 |
1594 if (!sampleInChart(gs)) { |
1346 // for each of the tens of thousands of samples, loop through each of the |
1595 continue; |
1347 // perhaps thousands of functions, hundreds of binaries, or tens of threads |
1596 } |
1348 for (int i = firstEnabled; i < profiledGenerics.size(); i++) |
1597 |
1349 { |
1598 // for each of the tens of thousands of samples, loop through each |
|
1599 // of the |
|
1600 // perhaps thousands of functions, hundreds of binaries, or tens of |
|
1601 // threads |
|
1602 // CH: the following is inefficient and needs refactoring (GppTrace |
|
1603 // has a Vector<ProfiledThread> profiledThreads etc. which are |
|
1604 // already sorted by index) |
|
1605 for (int i = firstEnabled; i < profiledGenerics.size(); i++) { |
1350 // find the next enabled profiled generic, if any |
1606 // find the next enabled profiled generic, if any |
1351 while ( (i < profiledGenerics.size() |
1607 while ((i < profiledGenerics.size() && !((ProfiledGeneric) profiledGenerics |
1352 && !((ProfiledGeneric)profiledGenerics.get(i)).isEnabled(this.graphIndex))) |
1608 .get(i)).isEnabled(this.graphIndex))) |
1353 i++; |
1609 i++; |
1354 if (i >= profiledGenerics.size()) |
1610 if (i >= profiledGenerics.size()) |
1355 break; |
1611 break; |
1356 |
1612 |
1357 ProfiledGeneric pg = (ProfiledGeneric)profiledGenerics.get(i); |
1613 ProfiledGeneric pg = (ProfiledGeneric) profiledGenerics.get(i); |
1358 |
1614 |
1359 if ( ((pg instanceof ProfiledThread) && (pg.getIndex() == gs.threadIndex)) |
1615 if (((pg instanceof ProfiledThread) && (pg.getIndex() == gs.threadIndex)) |
1360 || ((pg instanceof ProfiledBinary) && (pg.getIndex() == gs.binaryIndex)) |
1616 || ((pg instanceof ProfiledBinary) && (pg.getIndex() == gs.binaryIndex)) |
1361 || ((pg instanceof ProfiledFunction) && (pg.getIndex() == gs.functionIndex))) { |
1617 || ((pg instanceof ProfiledFunction) && (pg.getIndex() == gs.functionIndex))) { |
1362 BarGraphData bgd = new BarGraphData(); |
1618 BarGraphData bgd = new BarGraphData(); |
1363 bgd.color = pg.getColor(); |
1619 bgd.color = pg.getColor(); |
1364 bgd.x = x; |
1620 //bgd.x = x; |
|
1621 bgd.x = (int)gs.sampleSynchTime; |
1365 this.barGraphData.add(bgd); |
1622 this.barGraphData.add(bgd); |
1366 break; |
1623 break; |
1367 } |
1624 } |
1368 } |
1625 } |
1369 x += samplingInterval; |
1626 x += samplingInterval; |
1370 } |
1627 |
1371 } |
1628 } |
1372 |
1629 |
1373 public void refreshDataFromTrace() |
1630 } |
1374 { |
1631 |
1375 refreshDataFromTrace((GppTrace)this.getTrace()); |
1632 /** |
1376 |
1633 * Returns true if this sample is applicable to this chart. This method is |
1377 if (this.vPanel != null) |
1634 * intended to be overridden, for example for SMP charts where samples |
1378 { |
1635 * belong to the chart with the matching CPU number. |
1379 this.vPanel.refreshCumulativeThreadTable(); |
1636 * |
1380 } |
1637 * @param gs |
1381 } |
1638 * the sample to check |
1382 |
1639 * @return true, if sample belongs to chart, false otherwise |
1383 public static void refreshDataFromTrace(GppTrace gppTrace) |
1640 */ |
1384 { |
1641 protected boolean sampleInChart(GppSample gs) { |
1385 Enumeration enumer = gppTrace.getSamples(); |
1642 return true; |
1386 |
1643 } |
1387 int granularityValue = gppTrace.samples.size() > GppTraceGraph.granularityValue ? GppTraceGraph.granularityValue : gppTrace.samples.size(); |
1644 |
1388 |
1645 // /* |
1389 Hashtable<String,ProfiledGeneric> profiledThreads = new Hashtable<String,ProfiledGeneric>(); |
1646 // * Because a table to the left of a function table has changed, update |
1390 Hashtable<String,ProfiledGeneric> profiledBinaries = new Hashtable<String,ProfiledGeneric>(); |
1647 // * the function table. |
1391 Hashtable<String,ProfiledGeneric> profiledFunctions = new Hashtable<String,ProfiledGeneric>(); |
1648 // * If there is no table to the right of this one, redraw the graph based |
1392 |
1649 // * on the changed data. |
1393 Hashtable<ProfiledGeneric,Integer> threadPercentages = new Hashtable<ProfiledGeneric,Integer>(); |
1650 // */ |
1394 Hashtable<ProfiledGeneric,Integer> binaryPercentages = new Hashtable<ProfiledGeneric,Integer>(); |
1651 // public void refreshProfiledThreadData(int drawMode) |
1395 Hashtable<ProfiledGeneric,Integer> functionPercentages = new Hashtable<ProfiledGeneric,Integer>(); |
1652 // { |
1396 |
1653 // // Must have a table to its left |
1397 int threadCount = 0; |
1654 // if ( (drawMode != Defines.BINARIES_THREADS) |
1398 int binaryCount = 0; |
1655 // && (drawMode != Defines.BINARIES_THREADS_FUNCTIONS) |
1399 int functionCount = 0; |
1656 // && (drawMode != Defines.BINARIES_FUNCTIONS_THREADS) |
1400 int count = 0; |
1657 // && (drawMode != Defines.FUNCTIONS_THREADS) |
1401 int timeStamp = 0; |
1658 // && (drawMode != Defines.FUNCTIONS_THREADS_BINARIES) |
1402 int stepValue = granularityValue; |
1659 // && (drawMode != Defines.FUNCTIONS_BINARIES_THREADS) |
1403 char threadSymbol = 'A'; |
1660 // ) |
1404 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
1661 // { |
1405 |
1662 // System.out.println(Messages.getString("GppTraceGraph.wrongDrawMode")); //$NON-NLS-1$ |
1406 Vector<ProfiledGeneric> sortedProfiledThreads = gppTrace.getSortedThreads(); |
1663 // return; |
1407 Vector<ProfiledGeneric> sortedProfiledBinaries = gppTrace.getSortedBinaries(); |
1664 // } |
1408 Vector<ProfiledGeneric> sortedProfiledFunctions = gppTrace.getSortedFunctions(); |
1665 // |
1409 |
1666 // // boolean to use inside loops (should trust a compiler to optimize this |
1410 Vector<ProfiledGeneric> unsortedProfiledThreads = gppTrace.getIndexedThreads(); |
1667 // out of the loop...) |
1411 Vector<ProfiledGeneric> unsortedProfiledBinaries = gppTrace.getIndexedBinaries(); |
1668 // boolean basedOnBinaries = (drawMode == Defines.BINARIES_THREADS) |
1412 Vector<ProfiledGeneric> unsortedProfiledFunctions = gppTrace.getIndexedFunctions(); |
1669 // || (drawMode == Defines.BINARIES_THREADS_FUNCTIONS) |
1413 |
1670 // || (drawMode == Defines.FUNCTIONS_BINARIES_THREADS); |
1414 // reset these list so we can call refreshDataFromTrace mulitple times (e.g. import) while keeping size consistent |
1671 // |
1415 sortedProfiledThreads.clear(); |
1672 // Hashtable<String,ProfiledThread> profiledThreads = new |
1416 sortedProfiledBinaries.clear(); |
1673 // Hashtable<String,ProfiledThread>(); |
1417 sortedProfiledFunctions.clear(); |
1674 // |
1418 |
1675 // GenericSampledTrace trace = (GenericSampledTrace)this.getTrace(); |
1419 unsortedProfiledThreads.clear(); |
1676 // int granularityValue = trace.samples.size() > |
1420 unsortedProfiledBinaries.clear(); |
1677 // GppTraceGraph.GRANULARITY_VALUE ? GppTraceGraph.GRANULARITY_VALUE : |
1421 unsortedProfiledFunctions.clear(); |
1678 // trace.samples.size(); |
1422 |
1679 // |
1423 boolean exit = false; |
1680 // String[] selectedItems; |
1424 while (exit == false) |
1681 // int[] selectedFunctionHashCodes = null; |
1425 { |
1682 // int[] selectedBinaryHashCodes = null; |
1426 exit = !enumer.hasMoreElements(); |
1683 // int count = 0; |
1427 if (exit == true) |
1684 // int timeStamp = 0; |
1428 { |
1685 // int stepValue = granularityValue; |
1429 // for the final samples, modify the step value |
1686 // int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
1430 // so that they will also be included |
1687 // boolean exit = false; |
1431 // now there are no new samples, so proceed directly to |
1688 // |
1432 // adding the final values to the percent list |
1689 // Hashtable<ProfiledThread,Integer> percentages = new |
1433 stepValue = count; |
1690 // Hashtable<ProfiledThread,Integer>(); |
1434 } |
1691 // PIVisualSharedData shared = this.getSharedDataInstance(); |
1435 else |
1692 // |
1436 { |
1693 // if (basedOnBinaries) |
1437 count++; |
1694 // { |
1438 |
1695 // selectedItems = shared.GPP_SelectedBinaryNames; |
1439 // there is at least one new sample in the enumeration, so resolve it |
1696 // if (selectedItems == null) |
1440 GppSample sample = (GppSample)enumer.nextElement(); |
1697 // { |
1441 String threadName = sample.thread.process.name + "::" + sample.thread.threadName + "_" + sample.thread.threadId; //$NON-NLS-1$ //$NON-NLS-2$ |
1698 // selectedItems = new String[0]; |
1442 String binaryName = getBinaryName(sample); |
1699 // } |
1443 String functionName = getFunctionName(sample); |
1700 // int[] tmpHashCodes = new int[selectedItems.length]; |
1444 |
1701 // for (int i = 0; i < selectedItems.length; i++) |
1445 ProfiledThread pThread = null; |
1702 // { |
1446 ProfiledBinary pBinary = null; |
1703 // String tmp = selectedItems[i]; |
1447 ProfiledFunction pFunction = null; |
1704 // tmpHashCodes[i] = tmp.hashCode(); |
1448 |
1705 // } |
1449 // handle new thread names |
1706 // selectedBinaryHashCodes = tmpHashCodes; |
1450 if (profiledThreads.containsKey(threadName)) |
1707 // } |
1451 { |
1708 // else |
1452 pThread = (ProfiledThread)profiledThreads.get(threadName); |
1709 // { |
1453 if (pThread.getThreadId() != sample.thread.threadId.intValue()) |
1710 // selectedItems = shared.GPP_SelectedFunctionNames; |
1454 { |
1711 // if (selectedItems == null) |
1455 // this was not the same thread, even though the |
1712 // { |
1456 // name was the same |
1713 // selectedItems = new String[0]; |
1457 pThread = null; |
1714 // } |
1458 } |
1715 // int[] tmpHashCodes = new int[selectedItems.length]; |
|
1716 // for (int i = 0; i < selectedItems.length; i++) |
|
1717 // { |
|
1718 // String tmp = selectedItems[i]; |
|
1719 // tmpHashCodes[i] = tmp.hashCode(); |
|
1720 // } |
|
1721 // selectedFunctionHashCodes = tmpHashCodes; |
|
1722 // } |
|
1723 // |
|
1724 // for (Enumeration enumer = trace.getSamples(); !exit;) |
|
1725 // { |
|
1726 // exit = !enumer.hasMoreElements(); |
|
1727 // if (exit) |
|
1728 // { |
|
1729 // // for the final samples, modify the step value |
|
1730 // // so that they will also be included |
|
1731 // // now there are no new samples, so proceed directly to |
|
1732 // // adding the final values to the percent list |
|
1733 // stepValue = count; |
|
1734 // } |
|
1735 // else |
|
1736 // { |
|
1737 // count++; |
|
1738 // int compareValue = 0; |
|
1739 // boolean match = false; |
|
1740 // GppSample sample = (GppSample)enumer.nextElement(); |
|
1741 // if (basedOnBinaries) |
|
1742 // { |
|
1743 // compareValue = GppTraceGraphUtil.getBinaryName(sample).hashCode(); |
|
1744 // for (int i = 0; i < selectedBinaryHashCodes.length; i++) |
|
1745 // { |
|
1746 // if (compareValue == selectedBinaryHashCodes[i]) |
|
1747 // { |
|
1748 // match = true; |
|
1749 // break; |
|
1750 // } |
|
1751 // } |
|
1752 // } |
|
1753 // else |
|
1754 // { |
|
1755 // compareValue = GppTraceGraphUtil.getFunctionName(sample).hashCode(); |
|
1756 // for (int i = 0; i < selectedFunctionHashCodes.length; i++) |
|
1757 // { |
|
1758 // if (compareValue == selectedFunctionHashCodes[i]) |
|
1759 // { |
|
1760 // match = true; |
|
1761 // break; |
|
1762 // } |
|
1763 // } |
|
1764 // } |
|
1765 // |
|
1766 // if (match) |
|
1767 // { |
|
1768 // ProfiledThread pt = null; |
|
1769 // String name = sample.thread.threadName; |
|
1770 // if (profiledThreads.containsKey(name)) |
|
1771 // { |
|
1772 // pt = profiledThreads.get(name); |
|
1773 // } |
|
1774 // |
|
1775 // if (pt == null) |
|
1776 // { |
|
1777 // pt = new ProfiledThread(); |
|
1778 // |
|
1779 // pt.setNameString(name); |
|
1780 // pt.setColor(((GppTrace)this.getTrace()).getThreadColorPalette().getColor(name)); |
|
1781 // pt.setThreadId(sample.thread.threadId.intValue()); |
|
1782 // |
|
1783 // pt.setActivityMarkCount((trace.samples.size() + granularityValue) / |
|
1784 // granularityValue + 1); |
|
1785 // for (int i = 0; i < timeStamp + stepValue * samplingInterval; i += |
|
1786 // stepValue * samplingInterval) |
|
1787 // { |
|
1788 // pt.zeroActivityMarkValues(i); |
|
1789 // } |
|
1790 // pt.setEnabled(this.graphIndex, true); |
|
1791 // profiledThreads.put(name, pt); |
|
1792 // } |
|
1793 // |
|
1794 // if (percentages.containsKey(pt)) |
|
1795 // { |
|
1796 // Integer value = percentages.get(pt); |
|
1797 // value = Integer.valueOf(value.intValue()+1); |
|
1798 // percentages.remove(pt); |
|
1799 // percentages.put(pt,value); |
|
1800 // } |
|
1801 // else |
|
1802 // { |
|
1803 // percentages.put(pt,Integer.valueOf(1)); |
|
1804 // } |
|
1805 // } |
|
1806 // } |
|
1807 // |
|
1808 // if (stepValue != 0 && count == stepValue) |
|
1809 // { |
|
1810 // Vector<ProfiledGeneric> v = new |
|
1811 // Vector<ProfiledGeneric>(profiledThreads.values()); |
|
1812 // Enumeration<ProfiledGeneric> pfEnum = v.elements(); |
|
1813 // while (pfEnum.hasMoreElements()) |
|
1814 // { |
|
1815 // ProfiledThread updatePt = (ProfiledThread)pfEnum.nextElement(); |
|
1816 // if (percentages.containsKey(updatePt)) |
|
1817 // { |
|
1818 // int samples = ((percentages.get(updatePt))).intValue(); |
|
1819 // int finalPerc = (samples * 100) / stepValue; |
|
1820 // updatePt.addActivityMarkValues(timeStamp + stepValue * samplingInterval, |
|
1821 // finalPerc, samples); |
|
1822 // } |
|
1823 // else |
|
1824 // { |
|
1825 // updatePt.zeroActivityMarkValues(timeStamp + stepValue * |
|
1826 // samplingInterval); |
|
1827 // } |
|
1828 // } |
|
1829 // |
|
1830 // percentages.clear(); |
|
1831 // count = 0; |
|
1832 // timeStamp += stepValue * samplingInterval; |
|
1833 // } |
|
1834 // } |
|
1835 // |
|
1836 // this.threadTable.getTable().deselectAll(); |
|
1837 // this.threadTable.updateProfiledAndItemData(true); |
|
1838 // this.threadTable.getTable().redraw(); |
|
1839 // |
|
1840 // // if this is not the last table, set the selected names to set up |
|
1841 // // the next table |
|
1842 // if ( (drawMode == Defines.BINARIES_THREADS_FUNCTIONS) |
|
1843 // || (drawMode == Defines.FUNCTIONS_THREADS_BINARIES)) |
|
1844 // { |
|
1845 // this.threadTable.setSelectedNames(); |
|
1846 // } |
|
1847 // else |
|
1848 // { |
|
1849 // // This may not be needed needed |
|
1850 // shared.GPP_SelectedThreadNames = new String[0]; |
|
1851 // } |
|
1852 // } |
|
1853 // |
|
1854 // /* |
|
1855 // * Because a table to the left of a binary table has changed, update |
|
1856 // * the binary table. |
|
1857 // * If there is no table to the right of this one, redraw the graph based |
|
1858 // * on the changed data. |
|
1859 // */ |
|
1860 // public void refreshProfiledBinaryData(int drawMode) |
|
1861 // { |
|
1862 // // Must have a table to its left |
|
1863 // if ( (drawMode != Defines.THREADS_BINARIES) |
|
1864 // && (drawMode != Defines.THREADS_BINARIES_FUNCTIONS) |
|
1865 // && (drawMode != Defines.THREADS_FUNCTIONS_BINARIES) |
|
1866 // && (drawMode != Defines.FUNCTIONS_BINARIES) |
|
1867 // && (drawMode != Defines.FUNCTIONS_BINARIES_THREADS) |
|
1868 // && (drawMode != Defines.FUNCTIONS_THREADS_BINARIES) |
|
1869 // ) |
|
1870 // { |
|
1871 // System.out.println(Messages.getString("GppTraceGraph.wrongDrawMode")); //$NON-NLS-1$ |
|
1872 // return; |
|
1873 // } |
|
1874 // |
|
1875 // // boolean to use inside loops (never trust a compiler...) |
|
1876 // boolean basedOnThreads = (drawMode == Defines.THREADS_BINARIES) |
|
1877 // || (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) |
|
1878 // || (drawMode == Defines.FUNCTIONS_THREADS_BINARIES); |
|
1879 // |
|
1880 // Hashtable<String,ProfiledBinary> profiledBinaries = new |
|
1881 // Hashtable<String,ProfiledBinary>(); |
|
1882 // |
|
1883 // GenericSampledTrace trace = (GenericSampledTrace)this.getTrace(); |
|
1884 // int granularityValue = trace.samples.size() > |
|
1885 // GppTraceGraph.GRANULARITY_VALUE ? GppTraceGraph.GRANULARITY_VALUE : |
|
1886 // trace.samples.size(); |
|
1887 // |
|
1888 // String[] selectedItems; |
|
1889 // int[] selectedThreadIds = null; |
|
1890 // int[] selectedFunctionHashCodes = null; |
|
1891 // int count = 0; |
|
1892 // int timeStamp = 0; |
|
1893 // int stepValue = granularityValue; |
|
1894 // int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
|
1895 // boolean exit = false; |
|
1896 // |
|
1897 // Hashtable<ProfiledBinary,Integer> percentages = new |
|
1898 // Hashtable<ProfiledBinary,Integer>(); |
|
1899 // PIVisualSharedData shared = this.getSharedDataInstance(); |
|
1900 // |
|
1901 // if (basedOnThreads) |
|
1902 // { |
|
1903 // selectedItems = shared.GPP_SelectedThreadNames; |
|
1904 // if (selectedItems == null) |
|
1905 // { |
|
1906 // selectedItems = new String[0]; |
|
1907 // } |
|
1908 // int[] tmpThreadIds = new int[selectedItems.length]; |
|
1909 // for (int i = 0; i < selectedItems.length; i++) |
|
1910 // { |
|
1911 // String tmp = selectedItems[i].substring(selectedItems[i].lastIndexOf('_') |
|
1912 // + 1, |
|
1913 // selectedItems[i].length()); |
|
1914 // tmpThreadIds[i] = Integer.parseInt(tmp); |
|
1915 // } |
|
1916 // selectedThreadIds = tmpThreadIds; |
|
1917 // } |
|
1918 // else |
|
1919 // { |
|
1920 // selectedItems = shared.GPP_SelectedFunctionNames; |
|
1921 // if (selectedItems == null) |
|
1922 // { |
|
1923 // selectedItems = new String[0]; |
|
1924 // } |
|
1925 // int[] tmpHashCodes = new int[selectedItems.length]; |
|
1926 // for (int i = 0; i < selectedItems.length; i++) |
|
1927 // { |
|
1928 // String tmp = selectedItems[i]; |
|
1929 // tmpHashCodes[i] = tmp.hashCode(); |
|
1930 // } |
|
1931 // selectedFunctionHashCodes = tmpHashCodes; |
|
1932 // } |
|
1933 // |
|
1934 // for (Enumeration enumer = trace.getSamples(); !exit;) |
|
1935 // { |
|
1936 // exit = !enumer.hasMoreElements(); |
|
1937 // if (exit) |
|
1938 // { |
|
1939 // // for the final samples, modify the step value |
|
1940 // // so that they will also be included |
|
1941 // // now there are no new samples, so proceed directly to |
|
1942 // // adding the final values to the percent list |
|
1943 // stepValue = count; |
|
1944 // } |
|
1945 // else |
|
1946 // { |
|
1947 // count++; |
|
1948 // int compareValue = 0; |
|
1949 // boolean match = false; |
|
1950 // GppSample sample = (GppSample)enumer.nextElement(); |
|
1951 // if (basedOnThreads) |
|
1952 // { |
|
1953 // compareValue = sample.thread.threadId.intValue(); |
|
1954 // for (int i = 0; i < selectedThreadIds.length; i++) |
|
1955 // { |
|
1956 // if (compareValue == selectedThreadIds[i]) |
|
1957 // { |
|
1958 // match = true; |
|
1959 // break; |
|
1960 // } |
|
1961 // } |
|
1962 // } |
|
1963 // else |
|
1964 // { |
|
1965 // compareValue = GppTraceGraphUtil.getFunctionName(sample).hashCode(); |
|
1966 // for (int i = 0; i < selectedFunctionHashCodes.length; i++) |
|
1967 // { |
|
1968 // if (compareValue == selectedFunctionHashCodes[i]) |
|
1969 // { |
|
1970 // match = true; |
|
1971 // break; |
|
1972 // } |
|
1973 // } |
|
1974 // } |
|
1975 // |
|
1976 // if (match) |
|
1977 // { |
|
1978 // ProfiledBinary pb = null; |
|
1979 // String name = GppTraceGraphUtil.getFunctionName(sample); |
|
1980 // if (profiledBinaries.containsKey(name)) |
|
1981 // { |
|
1982 // pb = profiledBinaries.get(name); |
|
1983 // } |
|
1984 // |
|
1985 // if (pb == null) |
|
1986 // { |
|
1987 // pb = new ProfiledBinary(); |
|
1988 // |
|
1989 // pb.setNameString(name); |
|
1990 // pb.setColor(((GppTrace)this.getTrace()).getBinaryColorPalette().getColor(name)); |
|
1991 // |
|
1992 // pb.setActivityMarkCount((trace.samples.size() + granularityValue) / |
|
1993 // granularityValue + 1); |
|
1994 // for (int i = 0; i < timeStamp + stepValue * samplingInterval; i += |
|
1995 // stepValue * samplingInterval) |
|
1996 // { |
|
1997 // pb.zeroActivityMarkValues(i); |
|
1998 // } |
|
1999 // profiledBinaries.put(name, pb); |
|
2000 // } |
|
2001 // |
|
2002 // if (percentages.containsKey(pb)) |
|
2003 // { |
|
2004 // Integer value = percentages.get(pb); |
|
2005 // value = Integer.valueOf(value.intValue()+1); |
|
2006 // percentages.remove(pb); |
|
2007 // percentages.put(pb,value); |
|
2008 // } |
|
2009 // else |
|
2010 // { |
|
2011 // percentages.put(pb,Integer.valueOf(1)); |
|
2012 // } |
|
2013 // } |
|
2014 // } |
|
2015 // |
|
2016 // if (stepValue != 0 && count == stepValue) |
|
2017 // { |
|
2018 // Vector<ProfiledGeneric> v = new |
|
2019 // Vector<ProfiledGeneric>(profiledBinaries.values()); |
|
2020 // Enumeration<ProfiledGeneric> pfEnum = v.elements(); |
|
2021 // while (pfEnum.hasMoreElements()) |
|
2022 // { |
|
2023 // ProfiledFunction updatePf = (ProfiledFunction)pfEnum.nextElement(); |
|
2024 // if (percentages.containsKey(updatePf)) |
|
2025 // { |
|
2026 // int samples = ((percentages.get(updatePf))).intValue(); |
|
2027 // int finalPerc = (samples * 100) / stepValue; |
|
2028 // updatePf.addActivityMarkValues(timeStamp + stepValue * samplingInterval, |
|
2029 // finalPerc, samples); |
|
2030 // } |
|
2031 // else |
|
2032 // { |
|
2033 // updatePf.zeroActivityMarkValues(timeStamp + stepValue * |
|
2034 // samplingInterval); |
|
2035 // } |
|
2036 // } |
|
2037 // |
|
2038 // percentages.clear(); |
|
2039 // count = 0; |
|
2040 // timeStamp += stepValue * samplingInterval; |
|
2041 // } |
|
2042 // } |
|
2043 // |
|
2044 // this.binaryTable.getTable().deselectAll(); |
|
2045 // this.binaryTable.updateProfiledAndItemData(true); |
|
2046 // this.binaryTable.getTable().redraw(); |
|
2047 // |
|
2048 // // if this is not the last table, set the selected names to set up |
|
2049 // // the next table |
|
2050 // if ( (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) |
|
2051 // || (drawMode == Defines.FUNCTIONS_BINARIES_THREADS)) |
|
2052 // { |
|
2053 // this.binaryTable.setSelectedNames(); |
|
2054 // } |
|
2055 // else |
|
2056 // { |
|
2057 // // This may not be needed |
|
2058 // shared.GPP_SelectedBinaryNames = new String[0]; |
|
2059 // } |
|
2060 // } |
|
2061 |
|
2062 // public void updateGraph() |
|
2063 // { |
|
2064 // if (drawMode == Defines.BINARIES) |
|
2065 // { |
|
2066 // vPanel.refreshCumulativeThreadTable(); |
|
2067 // } |
|
2068 // else if (drawMode == Defines.THREADS) |
|
2069 // { |
|
2070 // vPanel.refreshCumulativeThreadTable(); |
|
2071 // } |
|
2072 // |
|
2073 // this.repaint(); |
|
2074 // } |
|
2075 |
|
2076 public void updateThreadTablePriorities( |
|
2077 Hashtable<Integer, String> priorities) { |
|
2078 this.threadTable.addPriorityColumn(priorities); |
|
2079 } |
|
2080 |
|
2081 public int getDrawMode() { |
|
2082 return drawMode; |
|
2083 } |
|
2084 |
|
2085 public void setDrawMode(int drawMode) { |
|
2086 if ((drawMode == Defines.THREADS) |
|
2087 || (drawMode == Defines.THREADS_FUNCTIONS) |
|
2088 || (drawMode == Defines.THREADS_FUNCTIONS_BINARIES) |
|
2089 || (drawMode == Defines.THREADS_BINARIES) |
|
2090 || (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) |
|
2091 || (drawMode == Defines.BINARIES) |
|
2092 || (drawMode == Defines.BINARIES_THREADS) |
|
2093 || (drawMode == Defines.BINARIES_THREADS_FUNCTIONS) |
|
2094 || (drawMode == Defines.BINARIES_FUNCTIONS) |
|
2095 || (drawMode == Defines.BINARIES_FUNCTIONS_THREADS) |
|
2096 || (drawMode == Defines.FUNCTIONS) |
|
2097 || (drawMode == Defines.FUNCTIONS_THREADS) |
|
2098 || (drawMode == Defines.FUNCTIONS_THREADS_BINARIES) |
|
2099 || (drawMode == Defines.FUNCTIONS_BINARIES) |
|
2100 || (drawMode == Defines.FUNCTIONS_BINARIES_THREADS)) { |
|
2101 if (this.drawMode != drawMode) { |
|
2102 this.setGraphImageChanged(true); |
|
2103 this.drawMode = drawMode; |
|
2104 refreshMode(); |
|
2105 if (this.graphChangeListener != null){ |
|
2106 graphChangeListener.onTitleChange(getTitle()); |
1459 } |
2107 } |
1460 |
2108 } |
1461 if (pThread == null) |
2109 } else { |
1462 { |
2110 throw new IllegalArgumentException(Messages |
1463 pThread = new ProfiledThread(); |
2111 .getString("GppTraceGraph.unknownDrawMode")); //$NON-NLS-1$ |
1464 |
2112 } |
1465 pThread.setIndex(threadCount++); |
2113 } |
1466 pThread.setNameValues(threadSymbol++, threadName); |
2114 |
1467 pThread.setColor(gppTrace.getThreadColorPalette().getColor(threadName)); |
2115 private void refreshMode() { |
1468 |
2116 this.vPanel.refreshCumulativeThreadTable(); |
1469 pThread.setThreadId(sample.thread.threadId.intValue()); |
2117 } |
1470 |
|
1471 pThread.setActivityMarkCount((gppTrace.samples.size() + granularityValue) / granularityValue + 1); |
|
1472 for (int i = 0; i < timeStamp + stepValue * samplingInterval; i += stepValue * samplingInterval) |
|
1473 { |
|
1474 pThread.zeroActivityMarkValues(i); |
|
1475 } |
|
1476 profiledThreads.put(threadName, pThread); |
|
1477 sortedProfiledThreads.add((ProfiledGeneric)pThread); |
|
1478 unsortedProfiledThreads.add((ProfiledGeneric)pThread); |
|
1479 } |
|
1480 |
|
1481 pThread.incTotalSampleCount(); |
|
1482 sample.threadIndex = pThread.getIndex(); |
|
1483 |
|
1484 if (threadPercentages.containsKey(pThread)) |
|
1485 { |
|
1486 Integer value = (Integer)threadPercentages.get(pThread); |
|
1487 value = new Integer(value.intValue()+1); |
|
1488 threadPercentages.remove(pThread); |
|
1489 threadPercentages.put(pThread, value); |
|
1490 } |
|
1491 else |
|
1492 { |
|
1493 threadPercentages.put(pThread, new Integer(1)); |
|
1494 } |
|
1495 |
|
1496 // handle new binary names |
|
1497 if (profiledBinaries.containsKey(binaryName)) |
|
1498 { |
|
1499 pBinary = (ProfiledBinary)profiledBinaries.get(binaryName); |
|
1500 } |
|
1501 |
|
1502 if (pBinary == null) |
|
1503 { |
|
1504 pBinary = new ProfiledBinary(); |
|
1505 |
|
1506 pBinary.setIndex(binaryCount++); |
|
1507 pBinary.setNameString(binaryName); |
|
1508 pBinary.setColor(gppTrace.getBinaryColorPalette().getColor(binaryName)); |
|
1509 |
|
1510 pBinary.setActivityMarkCount((gppTrace.samples.size() + granularityValue) / granularityValue + 1); |
|
1511 for (int i = 0; i < timeStamp + stepValue * samplingInterval; i += stepValue * samplingInterval) |
|
1512 { |
|
1513 pBinary.zeroActivityMarkValues(i); |
|
1514 } |
|
1515 profiledBinaries.put(binaryName,pBinary); |
|
1516 sortedProfiledBinaries.add((ProfiledGeneric)pBinary); |
|
1517 unsortedProfiledBinaries.add((ProfiledGeneric)pBinary); |
|
1518 } |
|
1519 |
|
1520 pBinary.incTotalSampleCount(); |
|
1521 sample.binaryIndex = pBinary.getIndex(); |
|
1522 |
|
1523 if (binaryPercentages.containsKey(pBinary)) |
|
1524 { |
|
1525 Integer value = (Integer)binaryPercentages.get(pBinary); |
|
1526 value = new Integer(value.intValue()+1); |
|
1527 binaryPercentages.remove(pBinary); |
|
1528 binaryPercentages.put(pBinary,value); |
|
1529 } |
|
1530 else |
|
1531 { |
|
1532 binaryPercentages.put(pBinary, new Integer(1)); |
|
1533 } |
|
1534 |
|
1535 // handle new function names |
|
1536 if (profiledFunctions.containsKey(functionName)) |
|
1537 { |
|
1538 pFunction = (ProfiledFunction)profiledFunctions.get(functionName); |
|
1539 } |
|
1540 |
|
1541 if (pFunction == null) |
|
1542 { |
|
1543 pFunction = new ProfiledFunction(); |
|
1544 |
|
1545 pFunction.setIndex(functionCount++); |
|
1546 pFunction.setNameString(functionName); |
|
1547 pFunction.setFunctionAddress(getFunctionAddress(sample)); |
|
1548 pFunction.setFunctionBinaryName(binaryName); |
|
1549 pFunction.setColor(gppTrace.getFunctionColorPalette().getColor(functionName)); |
|
1550 |
|
1551 pFunction.setActivityMarkCount((gppTrace.samples.size() + granularityValue) / granularityValue + 1); |
|
1552 for (int i = 0; i < timeStamp + stepValue * samplingInterval; i += stepValue * samplingInterval) |
|
1553 { |
|
1554 pFunction.zeroActivityMarkValues(i); |
|
1555 } |
|
1556 profiledFunctions.put(functionName,pFunction); |
|
1557 sortedProfiledFunctions.add((ProfiledGeneric)pFunction); |
|
1558 unsortedProfiledFunctions.add((ProfiledGeneric)pFunction); |
|
1559 } |
|
1560 |
|
1561 pFunction.incTotalSampleCount(); |
|
1562 sample.functionIndex = pFunction.getIndex(); |
|
1563 |
|
1564 if (functionPercentages.containsKey(pFunction)) |
|
1565 { |
|
1566 Integer value = (Integer)functionPercentages.get(pFunction); |
|
1567 value = new Integer(value.intValue()+1); |
|
1568 functionPercentages.remove(pFunction); |
|
1569 functionPercentages.put(pFunction,value); |
|
1570 } |
|
1571 else |
|
1572 { |
|
1573 functionPercentages.put(pFunction, new Integer(1)); |
|
1574 } |
|
1575 } |
|
1576 |
|
1577 // for each stepValue (or final values) samples |
|
1578 // add the data to the profiled threads, binaries, functions |
|
1579 if (stepValue != 0 && count == stepValue) |
|
1580 { |
|
1581 Vector<ProfiledGeneric> tmpVector; |
|
1582 |
|
1583 tmpVector = new Vector<ProfiledGeneric>(profiledThreads.values()); |
|
1584 Enumeration<ProfiledGeneric> ptEnum = tmpVector.elements(); |
|
1585 while (ptEnum.hasMoreElements()) |
|
1586 { |
|
1587 ProfiledThread updatePt = (ProfiledThread)ptEnum.nextElement(); |
|
1588 if (threadPercentages.containsKey(updatePt)) |
|
1589 { |
|
1590 int samples = ((Integer)(threadPercentages.get(updatePt))).intValue(); |
|
1591 int finalPerc = (samples * 100) / stepValue; |
|
1592 updatePt.addActivityMarkValues(timeStamp + stepValue * samplingInterval, finalPerc, samples); |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 updatePt.zeroActivityMarkValues(timeStamp + stepValue * samplingInterval); |
|
1597 } |
|
1598 } |
|
1599 |
|
1600 tmpVector = new Vector<ProfiledGeneric>(profiledBinaries.values()); |
|
1601 Enumeration<ProfiledGeneric> pbEnum = tmpVector.elements(); |
|
1602 while (pbEnum.hasMoreElements()) |
|
1603 { |
|
1604 ProfiledBinary updatePb = (ProfiledBinary)pbEnum.nextElement(); |
|
1605 if (binaryPercentages.containsKey(updatePb)) |
|
1606 { |
|
1607 int samples = ((Integer)(binaryPercentages.get(updatePb))).intValue(); |
|
1608 int finalPerc = (samples * 100) / stepValue; |
|
1609 updatePb.addActivityMarkValues(timeStamp + stepValue * samplingInterval, finalPerc, samples); |
|
1610 } |
|
1611 else |
|
1612 { |
|
1613 updatePb.zeroActivityMarkValues(timeStamp + stepValue * samplingInterval); |
|
1614 } |
|
1615 } |
|
1616 |
|
1617 tmpVector = new Vector<ProfiledGeneric>(profiledFunctions.values()); |
|
1618 Enumeration<ProfiledGeneric> pfEnum = tmpVector.elements(); |
|
1619 while (pfEnum.hasMoreElements()) |
|
1620 { |
|
1621 ProfiledFunction updatePf = (ProfiledFunction)pfEnum.nextElement(); |
|
1622 if (functionPercentages.containsKey(updatePf)) |
|
1623 { |
|
1624 int samples = ((Integer)(functionPercentages.get(updatePf))).intValue(); |
|
1625 int finalPerc = (samples * 100) / stepValue; |
|
1626 updatePf.addActivityMarkValues(timeStamp + stepValue * samplingInterval, finalPerc, samples); |
|
1627 } |
|
1628 else |
|
1629 { |
|
1630 updatePf.zeroActivityMarkValues(timeStamp + stepValue * samplingInterval); |
|
1631 } |
|
1632 } |
|
1633 |
|
1634 threadPercentages.clear(); |
|
1635 binaryPercentages.clear(); |
|
1636 functionPercentages.clear(); |
|
1637 count = 0; |
|
1638 timeStamp += stepValue * samplingInterval; |
|
1639 } |
|
1640 } |
|
1641 |
|
1642 // if there is no end point for a profiled element with samples, set the end to the last sample in the trace |
|
1643 for (Enumeration<ProfiledGeneric> e = profiledThreads.elements(); e.hasMoreElements(); ) { |
|
1644 ProfiledGeneric pg = e.nextElement(); |
|
1645 |
|
1646 if (pg.getRealLastSample() == -1 && pg.getTotalSampleCount() != 0) |
|
1647 pg.setLastSample(gppTrace.samples.size() * samplingInterval); |
|
1648 } |
|
1649 |
|
1650 for (Enumeration<ProfiledGeneric> e = profiledBinaries.elements(); e.hasMoreElements(); ) { |
|
1651 ProfiledGeneric pg = e.nextElement(); |
|
1652 |
|
1653 if (pg.getRealLastSample() == -1 && pg.getTotalSampleCount() != 0) |
|
1654 pg.setLastSample(gppTrace.samples.size() * samplingInterval); |
|
1655 } |
|
1656 |
|
1657 for (Enumeration<ProfiledGeneric> e = profiledFunctions.elements(); e.hasMoreElements(); ) { |
|
1658 ProfiledGeneric pg = e.nextElement(); |
|
1659 |
|
1660 if (pg.getRealLastSample() == -1 && pg.getTotalSampleCount() != 0) |
|
1661 pg.setLastSample(gppTrace.samples.size() * samplingInterval); |
|
1662 } |
|
1663 |
|
1664 // sort the thread, binary, and function vectors by load |
|
1665 sortProfiledGenerics(profiledThreads, gppTrace); |
|
1666 sortProfiledGenerics(profiledBinaries, gppTrace); |
|
1667 sortProfiledGenerics(profiledFunctions, gppTrace); |
|
1668 |
|
1669 // the trace-level count arrays are initialized to 0 |
|
1670 gppTrace.setThreadSampleCounts(new int[profiledThreads.size()]); |
|
1671 gppTrace.setBinarySampleCounts(new int[profiledBinaries.size()]); |
|
1672 gppTrace.setFunctionSampleCounts(new int[profiledFunctions.size()]); |
|
1673 } |
|
1674 |
|
1675 /* |
|
1676 * Because a table to the left of a function table has changed, update |
|
1677 * the function table. |
|
1678 * If there is no table to the right of this one, redraw the graph based |
|
1679 * on the changed data. |
|
1680 */ |
|
1681 public void refreshProfiledThreadData(int drawMode) |
|
1682 { |
|
1683 // Must have a table to its left |
|
1684 if ( (drawMode != Defines.BINARIES_THREADS) |
|
1685 && (drawMode != Defines.BINARIES_THREADS_FUNCTIONS) |
|
1686 && (drawMode != Defines.BINARIES_FUNCTIONS_THREADS) |
|
1687 && (drawMode != Defines.FUNCTIONS_THREADS) |
|
1688 && (drawMode != Defines.FUNCTIONS_THREADS_BINARIES) |
|
1689 && (drawMode != Defines.FUNCTIONS_BINARIES_THREADS) |
|
1690 ) |
|
1691 { |
|
1692 System.out.println(Messages.getString("GppTraceGraph.wrongDrawMode")); //$NON-NLS-1$ |
|
1693 return; |
|
1694 } |
|
1695 |
|
1696 // boolean to use inside loops (should trust a compiler to optimize this out of the loop...) |
|
1697 boolean basedOnBinaries = (drawMode == Defines.BINARIES_THREADS) |
|
1698 || (drawMode == Defines.BINARIES_THREADS_FUNCTIONS) |
|
1699 || (drawMode == Defines.FUNCTIONS_BINARIES_THREADS); |
|
1700 |
|
1701 Hashtable<String,ProfiledThread> profiledThreads = new Hashtable<String,ProfiledThread>(); |
|
1702 |
|
1703 GenericSampledTrace trace = (GenericSampledTrace)this.getTrace(); |
|
1704 int granularityValue = trace.samples.size() > GppTraceGraph.granularityValue ? GppTraceGraph.granularityValue : trace.samples.size(); |
|
1705 |
|
1706 String[] selectedItems; |
|
1707 int[] selectedFunctionHashCodes = null; |
|
1708 int[] selectedBinaryHashCodes = null; |
|
1709 int count = 0; |
|
1710 int timeStamp = 0; |
|
1711 int stepValue = granularityValue; |
|
1712 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
|
1713 boolean exit = false; |
|
1714 |
|
1715 Hashtable<ProfiledThread,Integer> percentages = new Hashtable<ProfiledThread,Integer>(); |
|
1716 PIVisualSharedData shared = this.getSharedDataInstance(); |
|
1717 |
|
1718 if (basedOnBinaries) |
|
1719 { |
|
1720 selectedItems = shared.GPP_SelectedBinaryNames; |
|
1721 if (selectedItems == null) |
|
1722 { |
|
1723 selectedItems = new String[0]; |
|
1724 } |
|
1725 int[] tmpHashCodes = new int[selectedItems.length]; |
|
1726 for (int i = 0; i < selectedItems.length; i++) |
|
1727 { |
|
1728 String tmp = selectedItems[i]; |
|
1729 tmpHashCodes[i] = tmp.hashCode(); |
|
1730 } |
|
1731 selectedBinaryHashCodes = tmpHashCodes; |
|
1732 } |
|
1733 else |
|
1734 { |
|
1735 selectedItems = shared.GPP_SelectedFunctionNames; |
|
1736 if (selectedItems == null) |
|
1737 { |
|
1738 selectedItems = new String[0]; |
|
1739 } |
|
1740 int[] tmpHashCodes = new int[selectedItems.length]; |
|
1741 for (int i = 0; i < selectedItems.length; i++) |
|
1742 { |
|
1743 String tmp = selectedItems[i]; |
|
1744 tmpHashCodes[i] = tmp.hashCode(); |
|
1745 } |
|
1746 selectedFunctionHashCodes = tmpHashCodes; |
|
1747 } |
|
1748 |
|
1749 for (Enumeration enumer = trace.getSamples(); !exit;) |
|
1750 { |
|
1751 exit = !enumer.hasMoreElements(); |
|
1752 if (exit) |
|
1753 { |
|
1754 // for the final samples, modify the step value |
|
1755 // so that they will also be included |
|
1756 // now there are no new samples, so proceed directly to |
|
1757 // adding the final values to the percent list |
|
1758 stepValue = count; |
|
1759 } |
|
1760 else |
|
1761 { |
|
1762 count++; |
|
1763 int compareValue = 0; |
|
1764 boolean match = false; |
|
1765 GppSample sample = (GppSample)enumer.nextElement(); |
|
1766 if (basedOnBinaries) |
|
1767 { |
|
1768 compareValue = getBinaryName(sample).hashCode(); |
|
1769 for (int i = 0; i < selectedBinaryHashCodes.length; i++) |
|
1770 { |
|
1771 if (compareValue == selectedBinaryHashCodes[i]) |
|
1772 { |
|
1773 match = true; |
|
1774 break; |
|
1775 } |
|
1776 } |
|
1777 } |
|
1778 else |
|
1779 { |
|
1780 compareValue = getFunctionName(sample).hashCode(); |
|
1781 for (int i = 0; i < selectedFunctionHashCodes.length; i++) |
|
1782 { |
|
1783 if (compareValue == selectedFunctionHashCodes[i]) |
|
1784 { |
|
1785 match = true; |
|
1786 break; |
|
1787 } |
|
1788 } |
|
1789 } |
|
1790 |
|
1791 if (match) |
|
1792 { |
|
1793 ProfiledThread pt = null; |
|
1794 String name = sample.thread.threadName; |
|
1795 if (profiledThreads.containsKey(name)) |
|
1796 { |
|
1797 pt = (ProfiledThread)profiledThreads.get(name); |
|
1798 } |
|
1799 |
|
1800 if (pt == null) |
|
1801 { |
|
1802 pt = new ProfiledThread(); |
|
1803 |
|
1804 pt.setNameString(name); |
|
1805 pt.setColor(((GppTrace)this.getTrace()).getThreadColorPalette().getColor(name)); |
|
1806 pt.setThreadId(sample.thread.threadId.intValue()); |
|
1807 |
|
1808 pt.setActivityMarkCount((trace.samples.size() + granularityValue) / granularityValue + 1); |
|
1809 for (int i = 0; i < timeStamp + stepValue * samplingInterval; i += stepValue * samplingInterval) |
|
1810 { |
|
1811 pt.zeroActivityMarkValues(i); |
|
1812 } |
|
1813 pt.setEnabled(this.graphIndex, true); |
|
1814 profiledThreads.put(name, pt); |
|
1815 } |
|
1816 |
|
1817 if (percentages.containsKey(pt)) |
|
1818 { |
|
1819 Integer value = (Integer)percentages.get(pt); |
|
1820 value = new Integer(value.intValue()+1); |
|
1821 percentages.remove(pt); |
|
1822 percentages.put(pt,value); |
|
1823 } |
|
1824 else |
|
1825 { |
|
1826 percentages.put(pt,new Integer(1)); |
|
1827 } |
|
1828 } |
|
1829 } |
|
1830 |
|
1831 if (stepValue != 0 && count == stepValue) |
|
1832 { |
|
1833 Vector<ProfiledGeneric> v = new Vector<ProfiledGeneric>(profiledThreads.values()); |
|
1834 Enumeration<ProfiledGeneric> pfEnum = v.elements(); |
|
1835 while (pfEnum.hasMoreElements()) |
|
1836 { |
|
1837 ProfiledThread updatePt = (ProfiledThread)pfEnum.nextElement(); |
|
1838 if (percentages.containsKey(updatePt)) |
|
1839 { |
|
1840 int samples = ((Integer)(percentages.get(updatePt))).intValue(); |
|
1841 int finalPerc = (samples * 100) / stepValue; |
|
1842 updatePt.addActivityMarkValues(timeStamp + stepValue * samplingInterval, finalPerc, samples); |
|
1843 } |
|
1844 else |
|
1845 { |
|
1846 updatePt.zeroActivityMarkValues(timeStamp + stepValue * samplingInterval); |
|
1847 } |
|
1848 } |
|
1849 |
|
1850 percentages.clear(); |
|
1851 count = 0; |
|
1852 timeStamp += stepValue * samplingInterval; |
|
1853 } |
|
1854 } |
|
1855 |
|
1856 this.threadTable.getTable().deselectAll(); |
|
1857 this.threadTable.updateProfiledAndItemData(true); |
|
1858 this.threadTable.getTable().redraw(); |
|
1859 |
|
1860 // if this is not the last table, set the selected names to set up |
|
1861 // the next table |
|
1862 if ( (drawMode == Defines.BINARIES_THREADS_FUNCTIONS) |
|
1863 || (drawMode == Defines.FUNCTIONS_THREADS_BINARIES)) |
|
1864 { |
|
1865 this.threadTable.setSelectedNames(); |
|
1866 } |
|
1867 else |
|
1868 { |
|
1869 // This may not be needed needed |
|
1870 shared.GPP_SelectedThreadNames = new String[0]; |
|
1871 } |
|
1872 } |
|
1873 |
|
1874 /* |
|
1875 * Because a table to the left of a binary table has changed, update |
|
1876 * the binary table. |
|
1877 * If there is no table to the right of this one, redraw the graph based |
|
1878 * on the changed data. |
|
1879 */ |
|
1880 public void refreshProfiledBinaryData(int drawMode) |
|
1881 { |
|
1882 // Must have a table to its left |
|
1883 if ( (drawMode != Defines.THREADS_BINARIES) |
|
1884 && (drawMode != Defines.THREADS_BINARIES_FUNCTIONS) |
|
1885 && (drawMode != Defines.THREADS_FUNCTIONS_BINARIES) |
|
1886 && (drawMode != Defines.FUNCTIONS_BINARIES) |
|
1887 && (drawMode != Defines.FUNCTIONS_BINARIES_THREADS) |
|
1888 && (drawMode != Defines.FUNCTIONS_THREADS_BINARIES) |
|
1889 ) |
|
1890 { |
|
1891 System.out.println(Messages.getString("GppTraceGraph.wrongDrawMode")); //$NON-NLS-1$ |
|
1892 return; |
|
1893 } |
|
1894 |
|
1895 // boolean to use inside loops (never trust a compiler...) |
|
1896 boolean basedOnThreads = (drawMode == Defines.THREADS_BINARIES) |
|
1897 || (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) |
|
1898 || (drawMode == Defines.FUNCTIONS_THREADS_BINARIES); |
|
1899 |
|
1900 Hashtable<String,ProfiledBinary> profiledBinaries = new Hashtable<String,ProfiledBinary>(); |
|
1901 |
|
1902 GenericSampledTrace trace = (GenericSampledTrace)this.getTrace(); |
|
1903 int granularityValue = trace.samples.size() > GppTraceGraph.granularityValue ? GppTraceGraph.granularityValue : trace.samples.size(); |
|
1904 |
|
1905 String[] selectedItems; |
|
1906 int[] selectedThreadIds = null; |
|
1907 int[] selectedFunctionHashCodes = null; |
|
1908 int count = 0; |
|
1909 int timeStamp = 0; |
|
1910 int stepValue = granularityValue; |
|
1911 int samplingInterval = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.samplingInterval"); //$NON-NLS-1$ |
|
1912 boolean exit = false; |
|
1913 |
|
1914 Hashtable<ProfiledBinary,Integer> percentages = new Hashtable<ProfiledBinary,Integer>(); |
|
1915 PIVisualSharedData shared = this.getSharedDataInstance(); |
|
1916 |
|
1917 if (basedOnThreads) |
|
1918 { |
|
1919 selectedItems = shared.GPP_SelectedThreadNames; |
|
1920 if (selectedItems == null) |
|
1921 { |
|
1922 selectedItems = new String[0]; |
|
1923 } |
|
1924 int[] tmpThreadIds = new int[selectedItems.length]; |
|
1925 for (int i = 0; i < selectedItems.length; i++) |
|
1926 { |
|
1927 String tmp = selectedItems[i].substring(selectedItems[i].lastIndexOf('_') + 1, |
|
1928 selectedItems[i].length()); |
|
1929 tmpThreadIds[i] = Integer.parseInt(tmp); |
|
1930 } |
|
1931 selectedThreadIds = tmpThreadIds; |
|
1932 } |
|
1933 else |
|
1934 { |
|
1935 selectedItems = shared.GPP_SelectedFunctionNames; |
|
1936 if (selectedItems == null) |
|
1937 { |
|
1938 selectedItems = new String[0]; |
|
1939 } |
|
1940 int[] tmpHashCodes = new int[selectedItems.length]; |
|
1941 for (int i = 0; i < selectedItems.length; i++) |
|
1942 { |
|
1943 String tmp = selectedItems[i]; |
|
1944 tmpHashCodes[i] = tmp.hashCode(); |
|
1945 } |
|
1946 selectedFunctionHashCodes = tmpHashCodes; |
|
1947 } |
|
1948 |
|
1949 for (Enumeration enumer = trace.getSamples(); !exit;) |
|
1950 { |
|
1951 exit = !enumer.hasMoreElements(); |
|
1952 if (exit) |
|
1953 { |
|
1954 // for the final samples, modify the step value |
|
1955 // so that they will also be included |
|
1956 // now there are no new samples, so proceed directly to |
|
1957 // adding the final values to the percent list |
|
1958 stepValue = count; |
|
1959 } |
|
1960 else |
|
1961 { |
|
1962 count++; |
|
1963 int compareValue = 0; |
|
1964 boolean match = false; |
|
1965 GppSample sample = (GppSample)enumer.nextElement(); |
|
1966 if (basedOnThreads) |
|
1967 { |
|
1968 compareValue = sample.thread.threadId.intValue(); |
|
1969 for (int i = 0; i < selectedThreadIds.length; i++) |
|
1970 { |
|
1971 if (compareValue == selectedThreadIds[i]) |
|
1972 { |
|
1973 match = true; |
|
1974 break; |
|
1975 } |
|
1976 } |
|
1977 } |
|
1978 else |
|
1979 { |
|
1980 compareValue = getFunctionName(sample).hashCode(); |
|
1981 for (int i = 0; i < selectedFunctionHashCodes.length; i++) |
|
1982 { |
|
1983 if (compareValue == selectedFunctionHashCodes[i]) |
|
1984 { |
|
1985 match = true; |
|
1986 break; |
|
1987 } |
|
1988 } |
|
1989 } |
|
1990 |
|
1991 if (match) |
|
1992 { |
|
1993 ProfiledBinary pb = null; |
|
1994 String name = getFunctionName(sample); |
|
1995 if (profiledBinaries.containsKey(name)) |
|
1996 { |
|
1997 pb = (ProfiledBinary)profiledBinaries.get(name); |
|
1998 } |
|
1999 |
|
2000 if (pb == null) |
|
2001 { |
|
2002 pb = new ProfiledBinary(); |
|
2003 |
|
2004 pb.setNameString(name); |
|
2005 pb.setColor(((GppTrace)this.getTrace()).getBinaryColorPalette().getColor(name)); |
|
2006 |
|
2007 pb.setActivityMarkCount((trace.samples.size() + granularityValue) / granularityValue + 1); |
|
2008 for (int i = 0; i < timeStamp + stepValue * samplingInterval; i += stepValue * samplingInterval) |
|
2009 { |
|
2010 pb.zeroActivityMarkValues(i); |
|
2011 } |
|
2012 profiledBinaries.put(name, pb); |
|
2013 } |
|
2014 |
|
2015 if (percentages.containsKey(pb)) |
|
2016 { |
|
2017 Integer value = (Integer)percentages.get(pb); |
|
2018 value = new Integer(value.intValue()+1); |
|
2019 percentages.remove(pb); |
|
2020 percentages.put(pb,value); |
|
2021 } |
|
2022 else |
|
2023 { |
|
2024 percentages.put(pb,new Integer(1)); |
|
2025 } |
|
2026 } |
|
2027 } |
|
2028 |
|
2029 if (stepValue != 0 && count == stepValue) |
|
2030 { |
|
2031 Vector<ProfiledGeneric> v = new Vector<ProfiledGeneric>(profiledBinaries.values()); |
|
2032 Enumeration<ProfiledGeneric> pfEnum = v.elements(); |
|
2033 while (pfEnum.hasMoreElements()) |
|
2034 { |
|
2035 ProfiledFunction updatePf = (ProfiledFunction)pfEnum.nextElement(); |
|
2036 if (percentages.containsKey(updatePf)) |
|
2037 { |
|
2038 int samples = ((Integer)(percentages.get(updatePf))).intValue(); |
|
2039 int finalPerc = (samples * 100) / stepValue; |
|
2040 updatePf.addActivityMarkValues(timeStamp + stepValue * samplingInterval, finalPerc, samples); |
|
2041 } |
|
2042 else |
|
2043 { |
|
2044 updatePf.zeroActivityMarkValues(timeStamp + stepValue * samplingInterval); |
|
2045 } |
|
2046 } |
|
2047 |
|
2048 percentages.clear(); |
|
2049 count = 0; |
|
2050 timeStamp += stepValue * samplingInterval; |
|
2051 } |
|
2052 } |
|
2053 |
|
2054 this.binaryTable.getTable().deselectAll(); |
|
2055 this.binaryTable.updateProfiledAndItemData(true); |
|
2056 this.binaryTable.getTable().redraw(); |
|
2057 |
|
2058 // if this is not the last table, set the selected names to set up |
|
2059 // the next table |
|
2060 if ( (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) |
|
2061 || (drawMode == Defines.FUNCTIONS_BINARIES_THREADS)) |
|
2062 { |
|
2063 this.binaryTable.setSelectedNames(); |
|
2064 } |
|
2065 else |
|
2066 { |
|
2067 // This may not be needed |
|
2068 shared.GPP_SelectedBinaryNames = new String[0]; |
|
2069 } |
|
2070 } |
|
2071 |
|
2072 // sort profiled generics by decreasing total sample count |
|
2073 private static void sortProfiledGenerics(Hashtable<String,ProfiledGeneric> prof, GppTrace gppTrace) |
|
2074 { |
|
2075 // use an insertion sort to create a sorted linked list |
|
2076 // from the hashtable values |
|
2077 Collection<ProfiledGeneric> values = prof.values(); |
|
2078 Vector<ProfiledGeneric> unsorted = new Vector<ProfiledGeneric>(values); |
|
2079 LinkedList<ProfiledGeneric> sorted = new LinkedList<ProfiledGeneric>(); |
|
2080 |
|
2081 Enumeration<ProfiledGeneric> prEnum = unsorted.elements(); |
|
2082 while (prEnum.hasMoreElements()) |
|
2083 { |
|
2084 ProfiledGeneric pg = prEnum.nextElement(); |
|
2085 if (sorted.size() == 0) |
|
2086 { |
|
2087 sorted.addFirst(pg); |
|
2088 } |
|
2089 else |
|
2090 { |
|
2091 Iterator i = sorted.iterator(); |
|
2092 boolean ok = false; |
|
2093 while (i.hasNext()) |
|
2094 { |
|
2095 ProfiledGeneric next = (ProfiledGeneric)i.next(); |
|
2096 if (next.getTotalSampleCount() < pg.getTotalSampleCount()) |
|
2097 { |
|
2098 sorted.add(sorted.indexOf(next), pg); |
|
2099 ok = true; |
|
2100 break; |
|
2101 } |
|
2102 } |
|
2103 if (!ok) |
|
2104 sorted.addLast(pg); |
|
2105 } |
|
2106 } |
|
2107 |
|
2108 // Add the sorted data |
|
2109 Iterator<ProfiledGeneric> iterator = sorted.iterator(); |
|
2110 if (sorted.size() > 0) |
|
2111 { |
|
2112 Vector<ProfiledGeneric> v = null; |
|
2113 if (sorted.get(0) instanceof ProfiledThread) |
|
2114 { |
|
2115 v = gppTrace.getSortedThreads(); |
|
2116 } |
|
2117 else if (sorted.get(0) instanceof ProfiledBinary) |
|
2118 { |
|
2119 v = gppTrace.getSortedBinaries(); |
|
2120 } |
|
2121 else if (sorted.get(0) instanceof ProfiledFunction) |
|
2122 { |
|
2123 v = gppTrace.getSortedFunctions(); |
|
2124 } |
|
2125 if (v != null) |
|
2126 { |
|
2127 v.clear(); |
|
2128 while (iterator.hasNext()) |
|
2129 v.add(0, iterator.next()); |
|
2130 } |
|
2131 } |
|
2132 } |
|
2133 |
|
2134 public void updateGraph() |
|
2135 { |
|
2136 if (drawMode == Defines.BINARIES) |
|
2137 { |
|
2138 vPanel.refreshCumulativeThreadTable(); |
|
2139 } |
|
2140 else if (drawMode == Defines.THREADS) |
|
2141 { |
|
2142 vPanel.refreshCumulativeThreadTable(); |
|
2143 } |
|
2144 |
|
2145 this.repaint(); |
|
2146 } |
|
2147 |
|
2148 public void updateThreadTablePriorities(Hashtable<Integer,String> priorities) |
|
2149 { |
|
2150 this.threadTable.addPriorityColumn(priorities); |
|
2151 } |
|
2152 |
|
2153 static private String stringNotFound = Messages.getString("GppTraceGraph.notFound"); //$NON-NLS-1$ |
|
2154 |
|
2155 static private String stringBinaryAt = Messages.getString("GppTraceGraph.binaryAt"); //$NON-NLS-1$ |
|
2156 static private String stringBinaryForAddress = Messages.getString("GppTraceGraph.binaryForAddress"); //$NON-NLS-1$ |
|
2157 static private String stringBinaryNotFound = Messages.getString("GppTraceGraph.binaryNotFound"); //$NON-NLS-1$ |
|
2158 |
|
2159 static private String stringFunctionAt = Messages.getString("GppTraceGraph.functionAt"); //$NON-NLS-1$ |
|
2160 static private String stringFunctionForAddress = Messages.getString("GppTraceGraph.functionForAddress"); //$NON-NLS-1$ |
|
2161 static private String stringFunctionNotFound = Messages.getString("GppTraceGraph.functionNotFound"); //$NON-NLS-1$ |
|
2162 |
|
2163 public static String getBinaryName(GppSample s) |
|
2164 { |
|
2165 String name = null; |
|
2166 |
|
2167 if (s.currentFunctionSym != null) |
|
2168 name = s.currentFunctionSym.functionBinary.binaryName; |
|
2169 |
|
2170 if ( (s.currentFunctionItt != null) |
|
2171 && ((name == null) || name.endsWith(stringNotFound))) |
|
2172 { |
|
2173 name = s.currentFunctionItt.functionBinary.binaryName; |
|
2174 } |
|
2175 |
|
2176 if ( name == null |
|
2177 || name.startsWith(stringBinaryAt) |
|
2178 || name.startsWith(stringBinaryForAddress)) |
|
2179 { |
|
2180 name = stringBinaryNotFound; |
|
2181 } |
|
2182 return name; |
|
2183 } |
|
2184 |
|
2185 public static String getFunctionName(GppSample s) |
|
2186 { |
|
2187 String name = null; |
|
2188 if (s.currentFunctionSym != null) |
|
2189 name = s.currentFunctionSym.functionName; |
|
2190 |
|
2191 if ( (s.currentFunctionItt != null) |
|
2192 && ((name == null) || name.endsWith(stringNotFound))) |
|
2193 { |
|
2194 name = s.currentFunctionItt.functionName; |
|
2195 } |
|
2196 |
|
2197 if ( (name == null) |
|
2198 || (name.startsWith(stringFunctionAt)) |
|
2199 || (name.startsWith(stringFunctionForAddress))) |
|
2200 { |
|
2201 name = stringFunctionNotFound; |
|
2202 } |
|
2203 |
|
2204 return name; |
|
2205 } |
|
2206 |
|
2207 public static long getFunctionAddress(GppSample s) |
|
2208 { |
|
2209 if (s.currentFunctionSym != null) |
|
2210 { |
|
2211 String name = s.currentFunctionSym.functionName; |
|
2212 if ( (s.currentFunctionItt != null) |
|
2213 && (name == null || name.endsWith(Messages.getString("GppTraceGraph.notFound")))) //$NON-NLS-1$ |
|
2214 { |
|
2215 return s.currentFunctionItt.startAddress.longValue(); |
|
2216 } |
|
2217 else |
|
2218 { |
|
2219 return s.currentFunctionSym.startAddress.longValue(); |
|
2220 } |
|
2221 } |
|
2222 else if (s.currentFunctionItt != null) |
|
2223 { |
|
2224 if (s.currentFunctionItt.functionName == null) |
|
2225 { |
|
2226 if (s.currentFunctionSym != null) |
|
2227 return s.currentFunctionSym.startAddress.longValue(); |
|
2228 } |
|
2229 else |
|
2230 { |
|
2231 return s.currentFunctionItt.startAddress.longValue(); |
|
2232 } |
|
2233 } |
|
2234 |
|
2235 return 0; |
|
2236 } |
|
2237 |
|
2238 public int getDrawMode() |
|
2239 { |
|
2240 return drawMode; |
|
2241 } |
|
2242 |
|
2243 public void setDrawMode(int drawMode) |
|
2244 { |
|
2245 if ( |
|
2246 (drawMode == Defines.THREADS) |
|
2247 || (drawMode == Defines.THREADS_FUNCTIONS) |
|
2248 || (drawMode == Defines.THREADS_FUNCTIONS_BINARIES) |
|
2249 || (drawMode == Defines.THREADS_BINARIES) |
|
2250 || (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) |
|
2251 || (drawMode == Defines.BINARIES) |
|
2252 || (drawMode == Defines.BINARIES_THREADS) |
|
2253 || (drawMode == Defines.BINARIES_THREADS_FUNCTIONS) |
|
2254 || (drawMode == Defines.BINARIES_FUNCTIONS) |
|
2255 || (drawMode == Defines.BINARIES_FUNCTIONS_THREADS) |
|
2256 || (drawMode == Defines.FUNCTIONS) |
|
2257 || (drawMode == Defines.FUNCTIONS_THREADS) |
|
2258 || (drawMode == Defines.FUNCTIONS_THREADS_BINARIES) |
|
2259 || (drawMode == Defines.FUNCTIONS_BINARIES) |
|
2260 || (drawMode == Defines.FUNCTIONS_BINARIES_THREADS)) |
|
2261 { |
|
2262 if (this.drawMode != drawMode) { |
|
2263 this.setGraphImageChanged(true); |
|
2264 } |
|
2265 this.drawMode = drawMode; |
|
2266 refreshMode(); |
|
2267 } |
|
2268 else |
|
2269 { |
|
2270 System.out.println(Messages.getString("GppTraceGraph.unknownDrawMode")); //$NON-NLS-1$ |
|
2271 this.drawMode = Defines.THREADS; |
|
2272 refreshMode(); |
|
2273 } |
|
2274 } |
|
2275 |
|
2276 private void refreshMode() |
|
2277 { |
|
2278 this.vPanel.refreshCumulativeThreadTable(); |
|
2279 } |
|
2280 |
2118 |
2281 public int getUid() { |
2119 public int getUid() { |
2282 return this.uid; |
2120 return this.uid; |
2283 } |
2121 } |
2284 |
2122 |
2285 public GppTraceGraph getTraceGraph() { |
|
2286 return this.thisTraceGraph; |
|
2287 } |
|
2288 |
|
2289 public void setLeftSash(Sash leftSash) { |
2123 public void setLeftSash(Sash leftSash) { |
2290 this.leftSash = leftSash; |
2124 this.leftSash = leftSash; |
2291 } |
2125 } |
2292 |
2126 |
2293 public Sash getLeftSash() { |
2127 public Sash getLeftSash() { |
2294 return this.leftSash; |
2128 return this.leftSash; |
2295 } |
2129 } |
2296 |
2130 |
2297 public void setRightSash(Sash rightSash) { |
2131 public void setRightSash(Sash rightSash) { |
2298 this.rightSash = rightSash; |
2132 this.rightSash = rightSash; |
2299 } |
2133 } |
2300 |
2134 |
2301 public Sash getRightSash() { |
2135 public Sash getRightSash() { |
2302 return this.rightSash; |
2136 return this.rightSash; |
2303 } |
2137 } |
2304 |
2138 |
2305 public void setProfiledThreads(Vector<ProfiledGeneric> profiledThreads) { |
2139 public void setProfiledThreads(Vector<ProfiledGeneric> profiledThreads) { |
2306 this.profiledThreads = profiledThreads; |
2140 this.profiledThreads = profiledThreads; |
2307 } |
2141 } |
2308 |
2142 |
2309 public Vector<ProfiledGeneric> getProfiledThreads() { |
2143 public Vector<ProfiledGeneric> getProfiledThreads() { |
2310 return this.profiledThreads; |
2144 return this.profiledThreads; |
2311 } |
2145 } |
2312 |
2146 |
2313 public Vector<ProfiledGeneric> getSortedThreads() { |
2147 public Vector<ProfiledGeneric> getSortedThreads() { |
2314 return this.sortedProfiledThreads; |
2148 return this.sortedProfiledThreads; |
2315 } |
2149 } |
2316 |
2150 |
2317 public void setProfiledBinaries(Vector<ProfiledGeneric> profiledBinaries) { |
2151 public void setProfiledBinaries(Vector<ProfiledGeneric> profiledBinaries) { |
2318 this.profiledBinaries = profiledBinaries; |
2152 this.profiledBinaries = profiledBinaries; |
2319 } |
2153 } |
2320 |
2154 |
2321 public Vector<ProfiledGeneric> getProfiledBinaries() { |
2155 public Vector<ProfiledGeneric> getProfiledBinaries() { |
2322 return this.profiledBinaries; |
2156 return this.profiledBinaries; |
2323 } |
2157 } |
2324 |
2158 |
2325 public Vector<ProfiledGeneric> getSortedBinaries() { |
2159 public Vector<ProfiledGeneric> getSortedBinaries() { |
2326 return this.sortedProfiledBinaries; |
2160 return this.sortedProfiledBinaries; |
2327 } |
2161 } |
2328 |
2162 |
2329 public void setProfiledFunctions(Vector<ProfiledGeneric> profiledFunctions) { |
2163 public void setProfiledFunctions(Vector<ProfiledGeneric> profiledFunctions) { |
2330 this.profiledFunctions = profiledFunctions; |
2164 this.profiledFunctions = profiledFunctions; |
2331 } |
2165 } |
2332 |
2166 |
2333 public Vector<ProfiledGeneric> getProfiledFunctions() { |
2167 public Vector<ProfiledGeneric> getProfiledFunctions() { |
2334 return this.profiledFunctions; |
2168 return this.profiledFunctions; |
2335 } |
2169 } |
2336 |
2170 |
2337 public Vector<ProfiledGeneric> getSortedFunctions() { |
2171 public Vector<ProfiledGeneric> getSortedFunctions() { |
2338 return this.sortedProfiledFunctions; |
2172 return this.sortedProfiledFunctions; |
2339 } |
2173 } |
2340 |
2174 |
2341 public ProfiledThreshold getThresholdThread() { |
2175 public ProfiledThreshold getThresholdThread() { |
2342 return thresholdThread; |
2176 return thresholdThread; |
2343 } |
2177 } |
2344 |
2178 |
2345 public ProfiledThreshold getThresholdBinary() { |
2179 public ProfiledThreshold getThresholdBinary() { |
2346 return thresholdBinary; |
2180 return thresholdBinary; |
2347 } |
2181 } |
2348 |
2182 |
2349 public ProfiledThreshold getThresholdFunction() { |
2183 public ProfiledThreshold getThresholdFunction() { |
2350 return thresholdFunction; |
2184 return thresholdFunction; |
2351 } |
2185 } |
2352 |
2186 |
|
2187 /* |
|
2188 * (non-Javadoc) |
|
2189 * |
|
2190 * @see |
|
2191 * org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events |
|
2192 * .MouseEvent) |
|
2193 */ |
2353 public void mouseMove(org.eclipse.swt.events.MouseEvent e) { |
2194 public void mouseMove(org.eclipse.swt.events.MouseEvent e) { |
2354 } |
2195 } |
|
2196 |
|
2197 /* (non-Javadoc) |
|
2198 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#graphVisibilityChanged(boolean) |
|
2199 */ |
|
2200 @Override |
|
2201 public void graphVisibilityChanged(boolean visible){ |
|
2202 getGppTrace().setLegendVisible(graphIndex, visible, holdTablesComposite); |
|
2203 } |
|
2204 |
|
2205 /* (non-Javadoc) |
|
2206 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#graphMaximized(boolean) |
|
2207 */ |
|
2208 @Override |
|
2209 public void graphMaximized(boolean value){ |
|
2210 //TODO this needs to be re-implemented probably using setVisible() on all graphs (rather than calling max on one graph) |
|
2211 getGppTrace().setLegendMaximised(graphIndex, value, holdTablesComposite); |
|
2212 } |
|
2213 |
|
2214 /* |
|
2215 * (non-Javadoc) |
|
2216 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#graphMaximized(boolean) |
|
2217 */ |
|
2218 public void refreshColoursFromTrace() { |
|
2219 if (graphIndex == PIPageEditor.THREADS_PAGE) { |
|
2220 getThreadTable().addColor(Defines.THREADS); |
|
2221 } else if (graphIndex == PIPageEditor.BINARIES_PAGE) { |
|
2222 getBinaryTable().addColor(Defines.BINARIES); |
|
2223 } else if (graphIndex == PIPageEditor.FUNCTIONS_PAGE) { |
|
2224 getFunctionTable().addColor(Defines.FUNCTIONS); |
|
2225 } |
|
2226 } |
|
2227 |
|
2228 /* (non-Javadoc) |
|
2229 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#doGetActivityList(com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric) |
|
2230 */ |
|
2231 @Override |
|
2232 protected float[] doGetActivityList(ProfiledGeneric pg) { |
|
2233 return adapter.getActivityList(pg); |
|
2234 } |
|
2235 |
|
2236 /* (non-Javadoc) |
|
2237 * @see com.nokia.carbide.cpp.pi.visual.IGenericTraceGraph#getTitle() |
|
2238 */ |
|
2239 @Override |
|
2240 public String getTitle() { |
|
2241 return String.format(Messages.getString("GppTraceGraph.2"), title, getTranslatedDrawMode()); //$NON-NLS-1$ |
|
2242 } |
|
2243 |
|
2244 private String getTranslatedDrawMode() { |
|
2245 String s = EMPTY_STRING; |
|
2246 |
|
2247 switch (this.drawMode) { |
|
2248 case Defines.THREADS: { |
|
2249 s = Messages.getString("GppTraceGraph.3"); //$NON-NLS-1$ |
|
2250 break; |
|
2251 } |
|
2252 case Defines.THREADS_FUNCTIONS: { |
|
2253 s = Messages.getString("GppTraceGraph.4"); //$NON-NLS-1$ |
|
2254 break; |
|
2255 } |
|
2256 case Defines.THREADS_FUNCTIONS_BINARIES: { |
|
2257 s = Messages.getString("GppTraceGraph.5"); //$NON-NLS-1$ |
|
2258 break; |
|
2259 } |
|
2260 case Defines.THREADS_BINARIES: { |
|
2261 s = Messages.getString("GppTraceGraph.6"); //$NON-NLS-1$ |
|
2262 break; |
|
2263 } |
|
2264 case Defines.THREADS_BINARIES_FUNCTIONS: { |
|
2265 s = Messages.getString("GppTraceGraph.7"); //$NON-NLS-1$ |
|
2266 break; |
|
2267 } |
|
2268 case Defines.BINARIES: { |
|
2269 s = Messages.getString("GppTraceGraph.8"); //$NON-NLS-1$ |
|
2270 break; |
|
2271 } |
|
2272 case Defines.BINARIES_THREADS: { |
|
2273 s = Messages.getString("GppTraceGraph.9"); //$NON-NLS-1$ |
|
2274 break; |
|
2275 } |
|
2276 case Defines.BINARIES_THREADS_FUNCTIONS: { |
|
2277 s = Messages.getString("GppTraceGraph.10"); //$NON-NLS-1$ |
|
2278 break; |
|
2279 } |
|
2280 case Defines.BINARIES_FUNCTIONS: { |
|
2281 s = Messages.getString("GppTraceGraph.11"); //$NON-NLS-1$ |
|
2282 break; |
|
2283 } |
|
2284 case Defines.BINARIES_FUNCTIONS_THREADS: { |
|
2285 s = Messages.getString("GppTraceGraph.12"); //$NON-NLS-1$ |
|
2286 break; |
|
2287 } |
|
2288 case Defines.FUNCTIONS: { |
|
2289 s = Messages.getString("GppTraceGraph.13"); //$NON-NLS-1$ |
|
2290 break; |
|
2291 } |
|
2292 case Defines.FUNCTIONS_THREADS: { |
|
2293 s = Messages.getString("GppTraceGraph.14"); //$NON-NLS-1$ |
|
2294 break; |
|
2295 } |
|
2296 case Defines.FUNCTIONS_THREADS_BINARIES: { |
|
2297 s = Messages.getString("GppTraceGraph.15"); //$NON-NLS-1$ |
|
2298 break; |
|
2299 } |
|
2300 case Defines.FUNCTIONS_BINARIES: { |
|
2301 s = Messages.getString("GppTraceGraph.16"); //$NON-NLS-1$ |
|
2302 break; |
|
2303 } |
|
2304 case Defines.FUNCTIONS_BINARIES_THREADS: { |
|
2305 s = Messages.getString("GppTraceGraph.17"); //$NON-NLS-1$ |
|
2306 break; |
|
2307 } |
|
2308 default: |
|
2309 break; |
|
2310 } |
|
2311 return s; |
|
2312 } |
|
2313 |
|
2314 /* (non-Javadoc) |
|
2315 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#getShortTitle() |
|
2316 */ |
|
2317 @Override |
|
2318 public String getShortTitle() { |
|
2319 return shortTitle; |
|
2320 } |
|
2321 |
|
2322 public Action[] addTitleBarMenuItems() { |
|
2323 return null; |
|
2324 } |
|
2325 |
|
2326 /* (non-Javadoc) |
|
2327 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.ITitleBarMenu#getContextHelpId() |
|
2328 */ |
|
2329 public String getContextHelpId() { |
|
2330 return AddressPlugin.getPageHelpContextId(GppTraceUtil.getPageIndex(graphIndex)); |
|
2331 } |
|
2332 |
|
2333 /* (non-Javadoc) |
|
2334 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#setVisible(boolean) |
|
2335 */ |
|
2336 @Override |
|
2337 public void setVisible(boolean show) { |
|
2338 super.setVisible(show); //this sets visibility of the graph component |
|
2339 } |
|
2340 |
|
2341 /* (non-Javadoc) |
|
2342 * @see com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph#isGraphMinimizedWhenOpened() |
|
2343 */ |
|
2344 @Override |
|
2345 public boolean isGraphMinimizedWhenOpened(){ |
|
2346 // CPU load graph is shown when view is opened |
|
2347 return false; |
|
2348 } |
|
2349 |
|
2350 public void addContextMenuItems(Menu menu, |
|
2351 org.eclipse.swt.events.MouseEvent me) { |
|
2352 if (getGppTrace() != null && getGppTrace().getCPUCount() > 1){ |
|
2353 new MenuItem(menu, SWT.SEPARATOR); |
|
2354 |
|
2355 final boolean isSeparate = this instanceof GppTraceGraphSMP; |
|
2356 |
|
2357 MenuItem changeViewAction = new MenuItem(menu, SWT.PUSH); |
|
2358 changeViewAction.setText(isSeparate ? Messages.getString("GppTraceGraph.18") : Messages.getString("GppTraceGraph.19")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
2359 changeViewAction.addSelectionListener(new SelectionAdapter() { |
|
2360 public void widgetSelected(SelectionEvent e) { |
|
2361 AddressPlugin.getDefault().receiveSelectionEvent(isSeparate ? AddressPlugin.ACTION_COMBINED_CPU_VIEW : AddressPlugin.ACTION_SEPARATE_CPU_VIEW); |
|
2362 } |
|
2363 }); |
|
2364 } |
|
2365 |
|
2366 } |
|
2367 |
2355 } |
2368 } |