Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 167995 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/trace/jvmti/internal/client/context/TIContextProvider.java (-13 / +12 lines)
Lines 19-25 Link Here
19
import java.util.Map;
19
import java.util.Map;
20
20
21
import org.eclipse.hyades.trace.views.internal.context.java.BasicContextProvider;
21
import org.eclipse.hyades.trace.views.internal.context.java.BasicContextProvider;
22
import org.eclipse.hyades.ui.provisional.context.IContextAttributes;
23
import org.eclipse.hyades.ui.provisional.context.IContextLabelFormatProvider;
22
import org.eclipse.hyades.ui.provisional.context.IContextLabelFormatProvider;
24
23
25
public class TIContextProvider extends BasicContextProvider implements TIContextAttributes {
24
public class TIContextProvider extends BasicContextProvider implements TIContextAttributes {
Lines 75-103 Link Here
75
				result = new AverageAgeLP();
74
				result = new AverageAgeLP();
76
			else if (key.equals(PACKAGE_GENERATIONS) || key.equals(CLASS_GENERATIONS) || key.equals(CALL_SITE_GENERATIONS))
75
			else if (key.equals(PACKAGE_GENERATIONS) || key.equals(CLASS_GENERATIONS) || key.equals(CALL_SITE_GENERATIONS))
77
				result = new GenerationsLP();
76
				result = new GenerationsLP();
78
			else if (key.equals(IContextAttributes.THREAD_NAME))
77
			else if (key.equals(THREAD_NAME))
79
				result = new ThreadNameLP();
78
				result = new ThreadNameLP();
80
			else if (key.equals(IContextAttributes.THREAD_CLASS_NAME))
79
			else if (key.equals(THREAD_CLASS_NAME))
81
				result = new ThreadClassNameLP();
80
				result = new ThreadClassNameLP();
82
			else if (key.equals(IContextAttributes.THREAD_START_TIME))
81
			else if (key.equals(THREAD_START_TIME))
83
				result = new ThreadStartTimeLP();
82
				result = new ThreadStartTimeLP();
84
			else if (key.equals(IContextAttributes.THREAD_STOP_TIME))
83
			else if (key.equals(THREAD_STOP_TIME))
85
				result = new ThreadStopTimeLP();
84
				result = new ThreadStopTimeLP();
86
			else if (key.equals(IContextAttributes.THREAD_STATE))
85
			else if (key.equals(THREAD_STATE))
87
				result = new ThreadStateLP();
86
				result = new ThreadStateLP();
88
			else if (key.equals(IContextAttributes.THREAD_RUNNING_TIME))
87
			else if (key.equals(THREAD_RUNNING_TIME))
89
				result = new ThreadRunningTimeLP();
88
				result = new ThreadRunningTimeLP();
90
			else if (key.equals(IContextAttributes.THREAD_SLEEPING_TIME))
89
			else if (key.equals(THREAD_SLEEPING_TIME))
91
				result = new ThreadSleepingTimeLP();
90
				result = new ThreadSleepingTimeLP();
92
			else if (key.equals(IContextAttributes.THREAD_WAITING_TIME))
91
			else if (key.equals(THREAD_WAITING_TIME))
93
				result = new ThreadWaitingTimeLP();
92
				result = new ThreadWaitingTimeLP();
94
			else if (key.equals(IContextAttributes.THREAD_BLOCKED_TIME))
93
			else if (key.equals(THREAD_BLOCKED_TIME))
95
				result = new ThreadBlockedTimeLP();
94
				result = new ThreadBlockedTimeLP();
96
			else if (key.equals(IContextAttributes.THREAD_DEADLOCKED_TIME))
95
			else if (key.equals(THREAD_DEADLOCKED_TIME))
97
				result = new ThreadDeadlockedTimeLP();
96
				result = new ThreadDeadlockedTimeLP();
98
			else if (key.equals(IContextAttributes.THREAD_BLOCK_COUNT))
97
			else if (key.equals(THREAD_BLOCK_COUNT))
99
				result = new ThreadBlockCountLP();
98
				result = new ThreadBlockCountLP();
100
			else if (key.equals(IContextAttributes.THREAD_DEADLOCK_COUNT))
99
			else if (key.equals(THREAD_DEADLOCK_COUNT))
101
				result = new ThreadDeadlockCountLP();
100
				result = new ThreadDeadlockCountLP();
102
		} else {
101
		} else {
103
			result = super.getContextLabelFormatProvider(key);
102
			result = super.getContextLabelFormatProvider(key);
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/MemoryAnalysisPage.java (-2 / +21 lines)
Lines 16-23 Link Here
16
16
17
import org.eclipse.emf.ecore.EObject;
17
import org.eclipse.emf.ecore.EObject;
18
import org.eclipse.hyades.models.hierarchy.extensions.SimpleSearchQuery;
18
import org.eclipse.hyades.models.hierarchy.extensions.SimpleSearchQuery;
19
import org.eclipse.hyades.trace.ui.ITraceSelection;
19
import org.eclipse.hyades.trace.ui.TraceViewer;
20
import org.eclipse.hyades.trace.ui.TraceViewer;
20
import org.eclipse.hyades.trace.ui.TraceViewerPage;
21
import org.eclipse.hyades.trace.ui.TraceViewerPage;
22
import org.eclipse.hyades.trace.ui.UIPlugin;
21
import org.eclipse.hyades.trace.views.internal.StatisticView;
23
import org.eclipse.hyades.trace.views.internal.StatisticView;
22
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.custom.CTabFolder;
25
import org.eclipse.swt.custom.CTabFolder;
Lines 71-76 Link Here
71
				;
73
				;
72
			}
74
			}
73
			public void widgetSelected(SelectionEvent e) {
75
			public void widgetSelected(SelectionEvent e) {
76
				updateAllocDetails();
74
				StatisticView view = _views[_tabFolder.getSelectionIndex()];
77
				StatisticView view = _views[_tabFolder.getSelectionIndex()];
75
				view.updateUI(view.getColumnDataList());
78
				view.updateUI(view.getColumnDataList());
76
				updateButtons();
79
				updateButtons();
Lines 88-99 Link Here
88
91
89
		tabItem = new CTabItem(_tabFolder, SWT.NONE);
92
		tabItem = new CTabItem(_tabFolder, SWT.NONE);
90
		tabItem.setText("Allocation Details");
93
		tabItem.setText("Allocation Details");
91
		AllocationDetailsView allocView = new AllocationDetailsView(_tabFolder, this, memView);
94
		AllocationDetailsView allocView = new AllocationDetailsView(_tabFolder, this);
92
		_views[1] = allocView;
95
		_views[1] = allocView;
93
		tabItem.setControl(_views[1].getControl());
96
		tabItem.setControl(_views[1].getControl());
94
97
95
		memView._viewDetails = allocView;
98
		memView._viewDetails = allocView;
96
97
		_tabFolder.setSelection(0);
99
		_tabFolder.setSelection(0);
98
	}
100
	}
99
101
Lines 159-162 Link Here
159
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
161
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
160
		return view.isShowPercent();
162
		return view.isShowPercent();
161
	}
163
	}
164
165
	void showAllocDetails() {
166
		setViewMode(TAB_ALLOC_DETAILS, 0);
167
		updateAllocDetails();
168
	}
169
170
	void updateAllocDetails() {
171
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
172
		if (view instanceof AllocationDetailsView) {
173
			ITraceSelection model = UIPlugin.getDefault().getSelectionModel(getMOFObject());
174
			if (model.size() > 0) {
175
				Object obj = model.getFirstElement();
176
				((AllocationDetailsView) view).showAllocDetails(obj);
177
			} else
178
				((AllocationDetailsView) view).showAllocDetails(null);
179
		}
180
	}
162
}
181
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/MemoryAnalysisViewer.java (-3 / +3 lines)
Lines 25-35 Link Here
25
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ContextUpdaterHelper;
25
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ContextUpdaterHelper;
26
import org.eclipse.hyades.trace.views.util.internal.OpenSource;
26
import org.eclipse.hyades.trace.views.util.internal.OpenSource;
27
import org.eclipse.hyades.ui.filters.IFilterScopes;
27
import org.eclipse.hyades.ui.filters.IFilterScopes;
28
import org.eclipse.hyades.ui.provisional.context.IContextAttributes;
29
import org.eclipse.jface.action.Action;
28
import org.eclipse.jface.action.Action;
30
import org.eclipse.jface.action.IMenuManager;
29
import org.eclipse.jface.action.IMenuManager;
31
import org.eclipse.jface.action.IToolBarManager;
30
import org.eclipse.jface.action.IToolBarManager;
32
import org.eclipse.swt.widgets.Menu;
31
import org.eclipse.swt.widgets.Menu;
32
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
33
import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils;
33
import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils;
34
import org.eclipse.ui.IActionBars;
34
import org.eclipse.ui.IActionBars;
35
35
Lines 156-163 Link Here
156
				page.setViewMode(0, BaseMemoryStatisticView.PACKAGE_MODE);
156
				page.setViewMode(0, BaseMemoryStatisticView.PACKAGE_MODE);
157
			}
157
			}
158
		};
158
		};
159
		Utils.setActionProperties(_viewPackage, _context, IContextAttributes.SHOW_PACKAGE_LEVEL);
159
		Utils.setActionProperties(_viewPackage, _context, TIContextAttributes.SHOW_PACKAGE_LEVEL);
160
		Utils.setActionProperties(_viewClass, _context, IContextAttributes.SHOW_CLASS_LEVEL);
160
		Utils.setActionProperties(_viewClass, _context, TIContextAttributes.SHOW_CLASS_LEVEL);
161
161
162
		String openSourceStr = TraceUIMessages._74;
162
		String openSourceStr = TraceUIMessages._74;
163
		_openSource = new Action(openSourceStr) {
163
		_openSource = new Action(openSourceStr) {
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/BaseMemoryStatisticView.java (-41 / +29 lines)
Lines 21-27 Link Here
21
import org.eclipse.hyades.models.hierarchy.extensions.SimpleSearchQuery;
21
import org.eclipse.hyades.models.hierarchy.extensions.SimpleSearchQuery;
22
import org.eclipse.hyades.models.trace.TRCClass;
22
import org.eclipse.hyades.models.trace.TRCClass;
23
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
23
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
24
import org.eclipse.hyades.models.trace.TRCGCEvent;
25
import org.eclipse.hyades.models.trace.TRCPackage;
24
import org.eclipse.hyades.models.trace.TRCPackage;
26
import org.eclipse.hyades.models.trace.impl.TRCClassImpl;
25
import org.eclipse.hyades.models.trace.impl.TRCClassImpl;
27
import org.eclipse.hyades.models.trace.impl.TRCPackageImpl;
26
import org.eclipse.hyades.models.trace.impl.TRCPackageImpl;
Lines 35-44 Link Here
35
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnLabelAdapter;
34
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnLabelAdapter;
36
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
35
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
37
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
36
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
38
import org.eclipse.hyades.ui.provisional.context.IContextAttributes;
37
import org.eclipse.jface.viewers.StructuredViewer;
38
import org.eclipse.jface.viewers.TreeViewer;
39
import org.eclipse.jface.viewers.Viewer;
39
import org.eclipse.jface.viewers.Viewer;
40
import org.eclipse.swt.events.SelectionEvent;
40
import org.eclipse.swt.graphics.Image;
41
import org.eclipse.swt.graphics.Image;
41
import org.eclipse.swt.widgets.Composite;
42
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Tree;
42
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
44
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
43
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextUpdaterHelper;
45
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextUpdaterHelper;
44
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.LiveSizeLabelAdapter;
46
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.LiveSizeLabelAdapter;
Lines 48-53 Link Here
48
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.PackageNameLabelAdapter;
50
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.PackageNameLabelAdapter;
49
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.TotalInstancesLabelAdapter;
51
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.TotalInstancesLabelAdapter;
50
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.TotalSizeLabelAdapter;
52
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.TotalSizeLabelAdapter;
53
import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils;
51
54
52
public class BaseMemoryStatisticView extends BaseStatisticView {
55
public class BaseMemoryStatisticView extends BaseStatisticView {
53
56
Lines 231-255 Link Here
231
	}
234
	}
232
235
233
	protected String getClassModeColumnsTemplate() {
236
	protected String getClassModeColumnsTemplate() {
234
		return
237
		return ""
235
			IContextAttributes.THREAD_CLASS_NAME + ":" + CM_COL_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | V | ColumnData.NONMOVABLE) + ":left:150,"
238
			+ TIContextAttributes.THREAD_CLASS_NAME + ":" + CM_COL_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | V | ColumnData.NONMOVABLE) + ":left:150,"
236
			+ IContextAttributes.PACKAGE_NAME + ":" + CM_COL_PACKAGE_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | V | ColumnData.NONMOVABLE) + ":left:120,"
239
			+ TIContextAttributes.PACKAGE_NAME + ":" + CM_COL_PACKAGE_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | V | ColumnData.NONMOVABLE) + ":left:120,"
237
			+ IContextAttributes.CLASS_LIVE_INST + ":" + CM_COL_LIVE_INST + ":" + String.valueOf(V | D) + ":right:80,"
240
			+ TIContextAttributes.CLASS_LIVE_INST + ":" + CM_COL_LIVE_INST + ":" + String.valueOf(V | D) + ":right:80,"
238
			+ IContextAttributes.CLASS_ACTIVE_SIZE + ":" + CM_COL_LIVE_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
241
			+ TIContextAttributes.CLASS_ACTIVE_SIZE + ":" + CM_COL_LIVE_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
239
			+ IContextAttributes.CLASS_TOTAL_INST + ":" + CM_COL_TOTAL_INST + ":" + String.valueOf(V | D) + ":right:80,"
242
			+ TIContextAttributes.CLASS_TOTAL_INST + ":" + CM_COL_TOTAL_INST + ":" + String.valueOf(V | D) + ":right:80,"
240
			+ IContextAttributes.CLASS_TOTAL_SIZE + ":" + CM_COL_TOTAL_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
243
			+ TIContextAttributes.CLASS_TOTAL_SIZE + ":" + CM_COL_TOTAL_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
241
			+ TIContextAttributes.CLASS_AVG_AGE + ":" + CM_COL_AVG_AGE + ":" + String.valueOf(V) + ":right:80"
244
			+ TIContextAttributes.CLASS_AVG_AGE + ":" + CM_COL_AVG_AGE + ":" + String.valueOf(V) + ":right:80"
242
			//+ TIContextAttributes.CLASS_GENERATIONS + ":" + CM_COL_GENERATIONS + ":" + String.valueOf(V | D) + ":right:80"
245
			//+ TIContextAttributes.CLASS_GENERATIONS + ":" + CM_COL_GENERATIONS + ":" + String.valueOf(V | D) + ":right:80"
243
			;
246
			;
244
	}
247
	}
245
248
246
	protected String getPackageModeColumnsTemplate() {
249
	protected String getPackageModeColumnsTemplate() {
247
		return
250
		return ""
248
			IContextAttributes.PACKAGE_NAME + ":" + PM_COL_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | V | ColumnData.NONMOVABLE) + ":left:120,"
251
			+ TIContextAttributes.PACKAGE_NAME + ":" + PM_COL_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | V | ColumnData.NONMOVABLE) + ":left:120,"
249
			+ IContextAttributes.PACKAGE_LIVE_INST + ":" + PM_COL_LIVE_INST + ":" + String.valueOf(V | D) + ":right:80,"
252
			+ TIContextAttributes.PACKAGE_LIVE_INST + ":" + PM_COL_LIVE_INST + ":" + String.valueOf(V | D) + ":right:80,"
250
			+ IContextAttributes.PACKAGE_ACTIVE_SIZE + ":" + PM_COL_LIVE_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
253
			+ TIContextAttributes.PACKAGE_ACTIVE_SIZE + ":" + PM_COL_LIVE_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
251
			+ IContextAttributes.PACKAGE_TOTAL_INST + ":" + PM_COL_TOTAL_INST + ":" + String.valueOf(V | D) + ":right:80,"
254
			+ TIContextAttributes.PACKAGE_TOTAL_INST + ":" + PM_COL_TOTAL_INST + ":" + String.valueOf(V | D) + ":right:80,"
252
			+ IContextAttributes.PACKAGE_TOTAL_SIZE + ":" + PM_COL_TOTAL_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
255
			+ TIContextAttributes.PACKAGE_TOTAL_SIZE + ":" + PM_COL_TOTAL_SIZE + ":" + String.valueOf(V | D) + ":right:80,"
253
			+ TIContextAttributes.PACKAGE_AVG_AGE + ":" + PM_COL_AVG_AGE + ":" + String.valueOf(V) + ":right:80"
256
			+ TIContextAttributes.PACKAGE_AVG_AGE + ":" + PM_COL_AVG_AGE + ":" + String.valueOf(V) + ":right:80"
254
			//+ TIContextAttributes.PACKAGE_GENERATIONS + ":" + PM_COL_GENERATIONS + ":" + String.valueOf(V | D) + ":right:80"
257
			//+ TIContextAttributes.PACKAGE_GENERATIONS + ":" + PM_COL_GENERATIONS + ":" + String.valueOf(V | D) + ":right:80"
255
			;
258
			;
Lines 288-312 Link Here
288
		return ret;
291
		return ret;
289
	}
292
	}
290
293
291
	int getObjAge(TRCFullTraceObject obj, EList listGC) {
292
		int age = 0;
293
		double t0 = obj.getCreateTime();
294
		double t1 = obj.getCollectTime();
295
		int len = listGC.size();
296
		for (int j = 0; j < len; j++) {
297
			TRCGCEvent gcEvent = (TRCGCEvent) listGC.get(j);
298
			if (gcEvent.getType().equals("finish")) {
299
				double time = gcEvent.getTime();
300
				if (time <= t0)
301
					continue;
302
				if (t1 > 0 && time >= t1)
303
					break;
304
				age++;
305
			}
306
		}
307
		return age;
308
	}
309
310
	void updateAgeInfo(Object arr[]) {
294
	void updateAgeInfo(Object arr[]) {
311
		_ageMap.clear();
295
		_ageMap.clear();
312
		for (int i = 0; i < arr.length; i++) {
296
		for (int i = 0; i < arr.length; i++) {
Lines 320-327 Link Here
320
				int len = list.size();
304
				int len = list.size();
321
				for (int j = 0; j < len; j++) {
305
				for (int j = 0; j < len; j++) {
322
					Object obj = list.get(j);
306
					Object obj = list.get(j);
323
					if (obj instanceof TRCFullTraceObject ) {
307
					if (obj instanceof TRCFullTraceObject) {
324
						int age = getObjAge((TRCFullTraceObject)obj, listGC);
308
						int age = Utils.getObjAge((TRCFullTraceObject)obj, listGC);
325
						ageInfo.sumAges += age;
309
						ageInfo.sumAges += age;
326
						ageInfo.objCount++;
310
						ageInfo.objCount++;
327
					}
311
					}
Lines 335-344 Link Here
335
		public int sumAges;
319
		public int sumAges;
336
		public int objCount;
320
		public int objCount;
337
	}
321
	}
338
	
322
339
	protected void select(Object obj) {
323
	protected StructuredViewer createTreeViewer(Composite tree) {
340
		if (null == _viewDetails || _viewDetails.getControl().isDisposed())
324
		TreeViewer tv = getTreeViewer((Tree) tree);
341
			return;
325
		return tv;
342
		_viewDetails.populateData(obj);
326
	}
327
328
	public void widgetDefaultSelected(SelectionEvent event) {
329
		if (_page instanceof MemoryAnalysisPage)
330
			((MemoryAnalysisPage)_page).showAllocDetails();
343
	}
331
	}
344
}
332
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/ThreadStatisticView.java (-12 / +12 lines)
Lines 30-36 Link Here
30
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
30
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
31
import org.eclipse.hyades.trace.views.util.internal.ThreadDetails;
31
import org.eclipse.hyades.trace.views.util.internal.ThreadDetails;
32
import org.eclipse.hyades.ui.provisional.context.ContextManager;
32
import org.eclipse.hyades.ui.provisional.context.ContextManager;
33
import org.eclipse.hyades.ui.provisional.context.IContextAttributes;
34
import org.eclipse.hyades.ui.provisional.context.IContextLanguage;
33
import org.eclipse.hyades.ui.provisional.context.IContextLanguage;
35
import org.eclipse.jface.action.IMenuManager;
34
import org.eclipse.jface.action.IMenuManager;
36
import org.eclipse.jface.viewers.IContentProvider;
35
import org.eclipse.jface.viewers.IContentProvider;
Lines 56-61 Link Here
56
import org.eclipse.swt.widgets.TableColumn;
55
import org.eclipse.swt.widgets.TableColumn;
57
import org.eclipse.swt.widgets.Tree;
56
import org.eclipse.swt.widgets.Tree;
58
import org.eclipse.swt.widgets.TreeItem;
57
import org.eclipse.swt.widgets.TreeItem;
58
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
59
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.ThreadBlockCountColumnLabel;
59
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.ThreadBlockCountColumnLabel;
60
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.ThreadBlockedTimeColumnLabel;
60
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.ThreadBlockedTimeColumnLabel;
61
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.ThreadClassNameColumnLabel;
61
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.ThreadClassNameColumnLabel;
Lines 280-297 Link Here
280
280
281
	public String getDefaultColumnsTemplate() {
281
	public String getDefaultColumnsTemplate() {
282
		return ""
282
		return ""
283
				+ IContextAttributes.THREAD_NAME + ":" + COL_THREAD_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:120,"
283
				+ TIContextAttributes.THREAD_NAME + ":" + COL_THREAD_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:120,"
284
				+ IContextAttributes.THREAD_CLASS_NAME + ":" + COL_CLASS_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150,"
284
				+ TIContextAttributes.THREAD_CLASS_NAME + ":" + COL_CLASS_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150,"
285
				//+ IContextAttributes.THREAD_START_TIME + ":2:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
285
				//+ TIContextAttributes.THREAD_START_TIME + ":2:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
286
				//+ IContextAttributes.THREAD_STOP_TIME + ":3:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
286
				//+ TIContextAttributes.THREAD_STOP_TIME + ":3:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
287
				+ IContextAttributes.THREAD_STATE + ":" + COL_STATE + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
287
				+ TIContextAttributes.THREAD_STATE + ":" + COL_STATE + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
288
				+ IContextAttributes.THREAD_RUNNING_TIME + ":" + COL_RUN_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," 
288
				+ TIContextAttributes.THREAD_RUNNING_TIME + ":" + COL_RUN_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," 
289
				//+ IContextAttributes.THREAD_SLEEPING_TIME + ":6:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120,"
289
				//+ IContextAttributes.THREAD_SLEEPING_TIME + ":6:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120,"
290
				+ IContextAttributes.THREAD_WAITING_TIME + ":" + COL_WAIT_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120,"
290
				+ TIContextAttributes.THREAD_WAITING_TIME + ":" + COL_WAIT_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120,"
291
				+ IContextAttributes.THREAD_BLOCKED_TIME + ":" + COL_BLOCK_TIME+ ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120,"
291
				+ TIContextAttributes.THREAD_BLOCKED_TIME + ":" + COL_BLOCK_TIME+ ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120,"
292
				+ IContextAttributes.THREAD_BLOCK_COUNT + ":" + COL_BLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
292
				+ TIContextAttributes.THREAD_BLOCK_COUNT + ":" + COL_BLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
293
				+ IContextAttributes.THREAD_DEADLOCKED_TIME + ":" + COL_DEADLOCK_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
293
				+ TIContextAttributes.THREAD_DEADLOCKED_TIME + ":" + COL_DEADLOCK_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
294
				+ IContextAttributes.THREAD_DEADLOCK_COUNT + ":" + COL_DEADLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80"
294
				+ TIContextAttributes.THREAD_DEADLOCK_COUNT + ":" + COL_DEADLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80"
295
				;
295
				;
296
	}
296
	}
297
297
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/AllocationDetailsView.java (-66 / +250 lines)
Lines 14-116 Link Here
14
14
15
package org.eclipse.tptp.trace.jvmti.internal.client.views;
15
package org.eclipse.tptp.trace.jvmti.internal.client.views;
16
16
17
import java.util.ArrayList;
18
import java.util.HashMap;
19
import java.util.Map;
20
17
import org.eclipse.emf.common.util.EList;
21
import org.eclipse.emf.common.util.EList;
18
import org.eclipse.emf.ecore.EObject;
19
import org.eclipse.hyades.models.trace.TRCClass;
22
import org.eclipse.hyades.models.trace.TRCClass;
23
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
24
import org.eclipse.hyades.models.trace.TRCMethod;
20
import org.eclipse.hyades.models.trace.TRCObjectAllocationAnnotation;
25
import org.eclipse.hyades.models.trace.TRCObjectAllocationAnnotation;
21
import org.eclipse.hyades.trace.ui.ITraceSelection;
26
import org.eclipse.hyades.models.trace.TRCPackage;
22
import org.eclipse.hyades.trace.ui.TraceViewerPage;
27
import org.eclipse.hyades.trace.ui.TraceViewerPage;
23
import org.eclipse.hyades.trace.ui.UIPlugin;
24
import org.eclipse.hyades.trace.ui.ViewSelectionChangedEvent;
25
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ContextUpdaterHelper;
26
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
28
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
27
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
29
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
28
import org.eclipse.hyades.ui.provisional.context.ContextManager;
30
import org.eclipse.hyades.ui.provisional.context.IContextLabelFormatProvider;
31
import org.eclipse.hyades.ui.util.GridUtil;
29
import org.eclipse.jface.viewers.Viewer;
32
import org.eclipse.jface.viewers.Viewer;
33
import org.eclipse.swt.events.SelectionEvent;
34
import org.eclipse.swt.graphics.Color;
35
import org.eclipse.swt.graphics.Font;
36
import org.eclipse.swt.graphics.FontData;
30
import org.eclipse.swt.graphics.Image;
37
import org.eclipse.swt.graphics.Image;
31
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Composite;
39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.tptp.trace.jvmti.internal.client.AllocationSite;
32
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
41
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
42
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextProvider;
43
import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils;
33
44
34
public class AllocationDetailsView extends BaseStatisticView {
45
public class AllocationDetailsView extends BaseStatisticView {
35
46
36
	TRCClass _class;
47
	static public final int AD_COL_METHOD_NAME = 0;
37
	BaseMemoryStatisticView _memView;
48
	static public final int AD_COL_LINE_NO = 1;
49
	static public final int AD_COL_CLASS_NAME = 2;
50
	static public final int AD_COL_PACKAGE_NAME = 3;
51
	static public final int AD_COL_LIVE_INST = 4;
52
	static public final int AD_COL_LIVE_SIZE = 5;
53
	static public final int AD_COL_TOTAL_INST = 6;
54
	static public final int AD_COL_TOTAL_SIZE = 7;
55
	static public final int AD_COL_AVG_AGE = 8;
56
57
	private Map _allocSites = new HashMap();
58
	private TRCClass _class;
59
	private int _nextIndex;
60
	private Label _label;
38
	static final Object _emptyArr[] = new Object[0];
61
	static final Object _emptyArr[] = new Object[0];
39
	
62
40
	protected AllocationDetailsView(Composite parent, TraceViewerPage page,
63
	protected AllocationDetailsView(Composite parent, TraceViewerPage page) {
41
			BaseMemoryStatisticView memView) {
42
		super(parent, page);
64
		super(parent, page);
43
		_memView = memView;
44
	}
65
	}
45
66
46
	protected String getColumnsPreferencesKey() {
67
	protected String getColumnsPreferencesKey() {
47
		return "org.eclipse.hyades.trace.views.statistic.allocdetails03";
68
		return "org.eclipse.hyades.trace.views.statistic.allocdetails04";
48
	}
69
	}
49
70
50
	protected String getViewTypeStr() {
71
	protected String getViewTypeStr() {
51
		return "viewoption.allocdetails";
72
		return "viewoption.allocdetails";
52
	}
73
	}
74
	
75
	protected Composite createControl(Composite parent, ArrayList cols) {
76
		Composite comp = super.createControl(parent, cols);
77
		_label = _toolkit.createLabel(comp, null);
78
		Font font = _label.getFont();
79
		FontData fd = font.getFontData()[0];
80
		font = new Font(null, new FontData(fd.getName(), fd.getHeight() * 3 / 2, fd.getStyle()));
81
		_label.setFont(font);
82
		_label.setBackground(comp.getBackground());
83
		_label.setForeground(new Color(null, 0, 0, 200));
84
		_label.setLayoutData(GridUtil.createHorizontalFill());
85
		return comp;
86
	}
53
87
54
	protected String getDefaultColumnsTemplate() {
88
	protected String getDefaultColumnsTemplate() {
55
		return ""
89
		return ""
56
			+ TIContextAttributes.METHOD_NAME + ":" + 0 + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150,"
90
			+ TIContextAttributes.METHOD_NAME + ":" + AD_COL_METHOD_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150,"
57
			+ TIContextAttributes.METHOD_LINE_NUMBER + ":" + 1 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":left:120,"
91
			+ TIContextAttributes.METHOD_LINE_NUMBER + ":" + AD_COL_LINE_NO + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
58
			+ TIContextAttributes.CLASS_NAME + ":" + 2 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":left:150,"
92
			+ TIContextAttributes.CLASS_NAME + ":" + AD_COL_CLASS_NAME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":left:150,"
59
			+ TIContextAttributes.PACKAGE_NAME + ":" + 3 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":left:120,"
93
			+ TIContextAttributes.PACKAGE_NAME + ":" + AD_COL_PACKAGE_NAME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":left:120,"
60
			+ TIContextAttributes.CLASS_LIVE_INST + ":" + 4 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
94
			+ TIContextAttributes.CLASS_LIVE_INST + ":" + AD_COL_LIVE_INST + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
61
			+ TIContextAttributes.CLASS_ACTIVE_SIZE + ":" + 5 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
95
			+ TIContextAttributes.CLASS_ACTIVE_SIZE + ":" + AD_COL_LIVE_SIZE + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
62
			+ TIContextAttributes.CLASS_TOTAL_INST + ":" + 6 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
96
			+ TIContextAttributes.CLASS_TOTAL_INST + ":" + AD_COL_TOTAL_INST + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
63
			+ TIContextAttributes.CLASS_TOTAL_SIZE + ":" + 7 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
97
			+ TIContextAttributes.CLASS_TOTAL_SIZE + ":" + AD_COL_TOTAL_SIZE + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80,"
64
			+ TIContextAttributes.CLASS_AVG_AGE + ":" + 8 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80"
98
			+ TIContextAttributes.CLASS_AVG_AGE + ":" + AD_COL_AVG_AGE + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80"
65
			//+ TIContextAttributes.CLASS_GENERATIONS + ":" + 9 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80"
99
			//+ TIContextAttributes.CLASS_GENERATIONS + ":" + 9 + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80"
66
			;
100
			;
67
	}
101
	}
68
	
102
69
	public String getColumnText(Object element, int columnIndex) {
103
	public String getColumnText(Object element, int columnIndex) {
70
		StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
104
		StatisticTableColumnInfo info = StatisticTableColumnInfo
105
				.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
71
		int pos = info.getColumnData().getInitalPos();
106
		int pos = info.getColumnData().getInitalPos();
72
		String label = "";
107
		String label = "";
73
		if (!(element instanceof TRCObjectAllocationAnnotation))
108
		if (!(element instanceof AllocationSite))
74
			return label;
109
			return label;
110
		AllocationSite allocSite = (AllocationSite) element;
75
		switch (pos) {
111
		switch (pos) {
76
		case 0: label = "method name"; break;
112
		case AD_COL_METHOD_NAME:
77
		case 1: label = "line number"; break;
113
			if (allocSite._method != null)
78
		case 2: break;
114
				label = allocSite._method.getName();
79
		case 3: break;
115
			break;
80
		case 4: break;
116
		case AD_COL_CLASS_NAME:
117
			if (allocSite._method != null &&
118
					allocSite._method.getDefiningClass() != null)
119
				label = allocSite._method.getDefiningClass().getName();
120
			break;
121
		case AD_COL_PACKAGE_NAME:
122
			if (allocSite._method != null &&
123
					allocSite._method.getDefiningClass() != null &&
124
					allocSite._method.getDefiningClass().getPackage() != null)
125
				label = allocSite._method.getDefiningClass().getPackage().getName();
126
			break;
127
		case AD_COL_LINE_NO:
128
			label = "" + allocSite._lineNo;
129
			break;
130
		case AD_COL_TOTAL_INST:
131
			label = "" + allocSite._total;
132
			break;
133
		case AD_COL_TOTAL_SIZE:
134
			label = "" + allocSite._totalSize;
135
			break;
136
		case AD_COL_LIVE_INST:
137
			label = "" + (allocSite._total - allocSite._collected);
138
			break;
139
		case AD_COL_LIVE_SIZE:
140
			label = "" + (allocSite._totalSize - allocSite._collectedSize);
141
			break;
142
		case AD_COL_AVG_AGE:
143
			double age = 0;
144
			if (allocSite._total > 0) {
145
				age = (double) allocSite._sumAges / allocSite._total;
146
				label = "" + age;
147
			}
148
			IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.CALL_SITE_AVG_AGE);
149
			label = formatter.getDisplayStringFromElement(new Double(age), null, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
150
			break;
81
		}
151
		}
82
		return label;
152
		return label;
83
	}
153
	}
84
154
85
	public Image getColumnImage(Object element, int columnIndex) {
155
	public Image getColumnImage(Object element, int columnIndex) {
86
		return null;
156
		StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
157
		int pos = info.getColumnData().getInitalPos();
158
		Image image = null;
159
		if (!(element instanceof AllocationSite))
160
			return image;
161
		AllocationSite allocSite = (AllocationSite) element;
162
		switch (pos) {
163
		case AD_COL_METHOD_NAME:
164
			if (allocSite._method != null) {
165
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.METHOD_NAME);
166
				image = formatter.getDisplayImageByElement(allocSite._method.getName(), allocSite._method, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
167
			}
168
			break;
169
		case AD_COL_CLASS_NAME:
170
			if (allocSite._method != null &&
171
					allocSite._method.getDefiningClass() != null) {
172
				TRCClass cls = allocSite._method.getDefiningClass();
173
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.CLASS_NAME);
174
				image = formatter.getDisplayImageByElement(cls.getName(), cls, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
175
			}
176
			break;
177
		case AD_COL_PACKAGE_NAME:
178
			if (allocSite._method != null &&
179
					allocSite._method.getDefiningClass() != null &&
180
					allocSite._method.getDefiningClass().getPackage() != null) {
181
				TRCPackage pkg = allocSite._method.getDefiningClass().getPackage();
182
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.PACKAGE_NAME);
183
				image = formatter.getDisplayImageByElement(pkg.getName(), pkg, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
184
			}
185
			break;
186
		}
187
		return image;
87
	}
188
	}
88
189
	
89
	TRCClass getSelectedClass() {
190
	public int compareElements(Object e1, Object e2, int pos, boolean isDelta) {
90
		return _class;
191
		int ret = 0;
91
		/*if (null == _memView || _memView.getControl().isDisposed())
192
		if (!(e1 instanceof AllocationSite && e2 instanceof AllocationSite))
92
			return null;
193
			return ret;
93
		IStructuredSelection selection = (IStructuredSelection) _memView.getTreeViewer().getSelection();
194
		AllocationSite a1 = (AllocationSite) e1;
94
		if (null == selection || selection.isEmpty())
195
		AllocationSite a2 = (AllocationSite) e2;
95
			return null;
196
		switch (pos) {
96
		Object element = selection.getFirstElement();
197
		case AD_COL_METHOD_NAME:
97
		if (!(element instanceof TRCClass))
198
			ret = Utils.compare(a1._method != null ? a1._method.getName() : null
98
			return null;
199
					, a2._method != null ? a2._method.getName() : null);
99
		return (TRCClass) element;*/
200
			break;
201
		case AD_COL_CLASS_NAME:
202
			ret = Utils.compare(a1._method != null &&
203
					a1._method.getDefiningClass() != null ?
204
							a1._method.getDefiningClass().getName() : null
205
					, a2._method != null &&
206
					a2._method.getDefiningClass() != null ?
207
							a2._method.getDefiningClass().getName() : null);
208
			break;
209
		case AD_COL_PACKAGE_NAME:
210
			ret = Utils.compare(a1._method != null &&
211
					a1._method.getDefiningClass() != null &&
212
					a1._method.getDefiningClass().getPackage() != null ?
213
							a1._method.getDefiningClass().getPackage().getName() : null
214
					, a2._method != null &&
215
					a2._method.getDefiningClass() != null &&
216
					a2._method.getDefiningClass().getPackage() != null ?
217
							a2._method.getDefiningClass().getPackage().getName() : null);
218
			break;
219
		case AD_COL_LINE_NO:
220
			ret = a1._lineNo - a2._lineNo;
221
			break;
222
		case AD_COL_TOTAL_INST:
223
			ret = a1._total - a2._total;
224
			break;
225
		case AD_COL_TOTAL_SIZE:
226
			ret = a1._totalSize - a2._totalSize;
227
			break;
228
		case AD_COL_LIVE_INST:
229
			ret = (a1._total - a1._collected) - (a2._total - a2._collected);
230
			break;
231
		case AD_COL_LIVE_SIZE:
232
			ret = (a1._totalSize - a1._collectedSize) - (a2._totalSize - a2._collectedSize);
233
			break;
234
		case AD_COL_AVG_AGE:
235
			double age1 = a1._total > 0 ? a1._sumAges / a1._total : 0;
236
			double age2 = a2._total > 0 ? a2._sumAges / a2._total : 0;
237
			ret = Utils.compare(age1, age2);
238
			break;
239
		}
240
		return ret;
100
	}
241
	}
101
242
102
	public Object[] getElements(Object inputElement) {
243
	public Object[] getElements(Object inputElement) {
103
		TRCClass cls = getSelectedClass();
244
		updateData();
104
		if (null == cls)
245
		return _allocSites.values().toArray();
105
			return _emptyArr;
106
		EList list = cls.getAnnotations();
107
		if (null == list)
108
			return _emptyArr;
109
		return list.toArray();
110
	}
111
112
	public int compare(Viewer viewer, Object e1, Object e2, int pos) {
113
		return 0;
114
	}
246
	}
115
247
116
	public Object[] getChildren(Object parentElement) {
248
	public Object[] getChildren(Object parentElement) {
Lines 123-148 Link Here
123
255
124
	protected StatisticSorter getViewerSorterInstance() {
256
	protected StatisticSorter getViewerSorterInstance() {
125
		return new StatisticSorter() {
257
		return new StatisticSorter() {
258
			public int compare(Viewer viewer, Object e1, Object e2) {
259
				return _sortSequence * compareElements(e1, e2, _pos, _info.isDeltaColumn());
260
			}
126
		};
261
		};
127
	}
262
	}
128
263
129
	protected void populateData(Object obj) {
264
	protected void showAllocDetails(Object obj) {
130
		if (obj instanceof TRCClass) {
265
		if (obj == null || obj instanceof TRCClass) {
131
			_class = (TRCClass) obj;
266
			_class = (TRCClass) obj;
132
			refresh();
267
			_nextIndex = 0;
268
			_allocSites.clear();
269
			String text = Utils.getPackageClassName(_class);
270
			if (text.length() > 0)
271
				text = "Allocation details for '" + text + "'";
272
			_label.setText(text);
273
			//_label.getParent().layout();
133
		}
274
		}
275
		refresh();
134
	}
276
	}
135
	
277
136
	public void handleViewSelectionChangedEvent(ViewSelectionChangedEvent event) {
278
	void updateData() {
137
		Object source = event.getSource();
279
		if (null == _class)
138
		if (source != this) {
280
			return;
139
			ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject());
281
		TRCObjectAllocationAnnotation aa = Utils.getAllocationAnnotation(_class);
140
			if (model.size() > 0) {
282
		if (null == aa)
141
				Object sel = model.getFirstElement();
283
			return;
142
				if (sel != null) {
284
		EList listGC = _class.getPackage().getProcess().getGcEvents();
143
					populateData(sel);
285
		EList lineNumbers = aa.getLineNumbers();
286
		EList methods = aa.getMethods();
287
		EList objects = _class.getObjects();
288
		int lineNoLen = lineNumbers.size();
289
		int methodsLen = methods.size();
290
		int objectsLen = objects.size();
291
		// gather alloc sites by line No
292
		for (int i = _nextIndex; i < lineNoLen; i++) {
293
			Integer lineNo = (Integer) lineNumbers.get(i);
294
			AllocationSite allocSite = (AllocationSite) _allocSites.get(lineNo);
295
			if (null == allocSite) {
296
				TRCMethod method = null;
297
				int line = lineNo.intValue();
298
				// find corresponding method
299
				for (int j = 0; j < methodsLen; j++) {
300
					TRCMethod method0 = (TRCMethod) methods.get(j);
301
					if (line >= method0.getLineNo() && line <= method0.getLineNo() + method0.getLineCount()) {
302
						method = method0;
303
						break;
304
					}
305
				}
306
				allocSite = new AllocationSite(line, method);
307
				_allocSites.put(lineNo, allocSite);
308
			}
309
			int j = i + i + 1;
310
			if (j < objectsLen && objects.get(j) instanceof TRCFullTraceObject) {
311
				TRCFullTraceObject trObj = (TRCFullTraceObject) objects.get(j);
312
				if (trObj.getCollectTime() > 0) {
313
					allocSite._collected++;
314
					allocSite._collectedSize += trObj.getSize();
144
				}
315
				}
316
				allocSite._totalSize += trObj.getSize();
317
				int age = Utils.getObjAge(trObj, listGC);
318
				allocSite._sumAges += age;
319
				allocSite._total++;
145
			}
320
			}
146
		}
321
		}
322
		_nextIndex = lineNoLen;
323
	}
324
325
	public void widgetDefaultSelected(SelectionEvent event) {
326
		if (event.item.getData() instanceof AllocationSite) {
327
			AllocationSite allocSite = (AllocationSite) event.item.getData();
328
			String pattern = Utils.composeMethodName(allocSite);
329
			Utils.openSource(pattern);
330
		}
147
	}
331
	}
148
}
332
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/ThreadsTipHandler.java (-1 / +1 lines)
Lines 9-15 Link Here
9
 *    Intel Corporation - Initial API and implementation
9
 *    Intel Corporation - Initial API and implementation
10
 *    Vitaly A. Provodin, Intel - Initial API and implementation
10
 *    Vitaly A. Provodin, Intel - Initial API and implementation
11
 *
11
 *
12
 * $Id:
12
 * $Id: $
13
 *****************************************************************************/
13
 *****************************************************************************/
14
package org.eclipse.tptp.trace.jvmti.internal.client.widgets;
14
package org.eclipse.tptp.trace.jvmti.internal.client.widgets;
15
15
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/Utils.java (-28 / +107 lines)
Lines 20-27 Link Here
20
import org.eclipse.emf.ecore.EObject;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.hyades.models.hierarchy.TRCAnnotation;
21
import org.eclipse.hyades.models.hierarchy.TRCAnnotation;
22
import org.eclipse.hyades.models.trace.TRCClass;
22
import org.eclipse.hyades.models.trace.TRCClass;
23
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
24
import org.eclipse.hyades.models.trace.TRCGCEvent;
23
import org.eclipse.hyades.models.trace.TRCMethod;
25
import org.eclipse.hyades.models.trace.TRCMethod;
24
import org.eclipse.hyades.models.trace.TRCMethodInvocation;
26
import org.eclipse.hyades.models.trace.TRCMethodInvocation;
27
import org.eclipse.hyades.models.trace.TRCObjectAllocationAnnotation;
25
import org.eclipse.hyades.models.trace.TRCPackage;
28
import org.eclipse.hyades.models.trace.TRCPackage;
26
import org.eclipse.hyades.models.trace.TRCThread;
29
import org.eclipse.hyades.models.trace.TRCThread;
27
import org.eclipse.hyades.models.trace.TRCThreadDeadEvent;
30
import org.eclipse.hyades.models.trace.TRCThreadDeadEvent;
Lines 55-60 Link Here
55
import org.eclipse.swt.graphics.Point;
58
import org.eclipse.swt.graphics.Point;
56
import org.eclipse.swt.graphics.Rectangle;
59
import org.eclipse.swt.graphics.Rectangle;
57
import org.eclipse.swt.widgets.Display;
60
import org.eclipse.swt.widgets.Display;
61
import org.eclipse.tptp.trace.jvmti.internal.client.AllocationSite;
58
import org.eclipse.tptp.trace.jvmti.internal.client.MethodDetails;
62
import org.eclipse.tptp.trace.jvmti.internal.client.MethodDetails;
59
import org.eclipse.tptp.trace.jvmti.internal.client.TITracePlugin;
63
import org.eclipse.tptp.trace.jvmti.internal.client.TITracePlugin;
60
import org.eclipse.tptp.trace.jvmti.internal.client.views.UIMessages;
64
import org.eclipse.tptp.trace.jvmti.internal.client.views.UIMessages;
Lines 238-282 Link Here
238
		return size.x;
242
		return size.x;
239
	}
243
	}
240
244
241
	static public String composeThreadName(TRCThread thread, boolean inclState) {
245
	static public TRCClass getThreadClass(TRCThread thread) {
242
		String name = thread.getName();
243
		String threadClass = getThreadClassName(thread);
244
		if (threadClass != null && threadClass.length() > 0) {
245
			name += " [" + threadClass + "]";
246
		}
247
		if (inclState) {
248
			EList list = thread.getThreadEvents();
249
			if (null != list && list.size() > 0)
250
				name+= " (" + getEventName2((TRCThreadEvent)list.get(list.size() - 1)) + ")";
251
		}
252
		return name;
253
	}
254
255
	static public String getThreadClassName(TRCThread thread) {
256
		String name = "";
257
		TRCClass cls = null;
246
		TRCClass cls = null;
258
		TRCPackage pkg = null;
259
		if (thread.getThreadObject() != null) {
247
		if (thread.getThreadObject() != null) {
260
			cls = thread.getThreadObject().getIsA();
248
			cls = thread.getThreadObject().getIsA();
261
		} else if (thread.getInitialInvocations().size() > 0) {
249
		} else if (thread.getInitialInvocations().size() > 0) {
262
			cls = ((TRCMethodInvocation) thread.getInitialInvocations().get(0)).getMethod().getDefiningClass();
250
			cls = ((TRCMethodInvocation) thread.getInitialInvocations().get(0)).getMethod().getDefiningClass();
263
		}
251
		}
252
		return cls;
253
	}
254
255
	static public String getThreadClassName(TRCThread thread) {
256
		String name = "";
257
		TRCClass cls = getThreadClass(thread);
264
		if (cls != null)
258
		if (cls != null)
265
			pkg = cls.getPackage();
259
			name = getPackageClassName(cls);
266
		if (cls != null && pkg != null) {
260
		return name;
267
			name = "".equals(pkg.getName()) ? cls.getName() : (pkg.getName() + "." + cls.getName());
261
	}
262
263
	static public String getPackageClassName(TRCClass cls) {
264
		String name = "";
265
		if (cls != null) {
266
			TRCPackage pkg = cls.getPackage();
267
			if (pkg != null && pkg.getName().length() > 0)
268
				name = pkg.getName() + "." + cls.getName();
269
			else
270
				name = cls.getName();
268
		}
271
		}
269
		return name;
272
		return name;
270
	}
273
	}
271
274
272
	static public String composeMethodName(TRCMethodInvocation method) {
275
	static public String getFullMethodName(TRCMethod m, boolean sig) {
273
		TRCMethod m = method.getMethod();
274
		String name = "";
276
		String name = "";
275
		name += m.getDefiningClass().getName();
277
		name += getPackageClassName(m.getDefiningClass());
276
		name += ".";
278
		name += ".";
277
		name += m.getName();
279
		name += m.getName();
278
		name += m.getSignature();
280
		if (sig)
279
		name += " [" + m.getCalls() + "]";
281
			name += m.getSignature();
280
		return name;
282
		return name;
281
	}
283
	}
282
284
Lines 314-319 Link Here
314
		return UIMessages._unknown;
316
		return UIMessages._unknown;
315
	}
317
	}
316
318
319
	static public String composeThreadName(TRCThread thread, boolean inclState) {
320
		String name = thread.getName();
321
		String threadClass = getThreadClassName(thread);
322
		if (threadClass != null && threadClass.length() > 0) {
323
			name += " [" + threadClass + "]";
324
		}
325
		if (inclState) {
326
			EList list = thread.getThreadEvents();
327
			if (null != list && list.size() > 0)
328
				name+= " (" + getEventName2((TRCThreadEvent)list.get(list.size() - 1)) + ")";
329
		}
330
		return name;
331
	}
332
333
	static public String composeMethodName(TRCMethodInvocation method) {
334
		return getFullMethodName(method.getMethod(), true);
335
	}
336
317
	static public String composeEventName(TRCThreadEvent event) {
337
	static public String composeEventName(TRCThreadEvent event) {
318
		String name = event.getThread().getName();
338
		String name = event.getThread().getName();
319
		name += " [" + event.getThread().getGroupName() + "] (" + getEventName2(event);
339
		name += " [" + event.getThread().getGroupName() + "] (" + getEventName2(event);
Lines 342-347 Link Here
342
		return name;
362
		return name;
343
	}
363
	}
344
364
365
	static public String composeMethodName(AllocationSite allocSite) {
366
		String name = "";
367
		if (allocSite._method != null)
368
			name += getFullMethodName(allocSite._method, true);
369
		if (allocSite._lineNo >= 0)
370
			name += " line:" + allocSite._lineNo;
371
		return name;
372
	}
373
345
	static public Image getItemImage(Object obj) {
374
	static public Image getItemImage(Object obj) {
346
		if (obj instanceof MethodDetails) {
375
		if (obj instanceof MethodDetails) {
347
			if (((MethodDetails)obj).running)
376
			if (((MethodDetails)obj).running)
Lines 540-546 Link Here
540
		return null;
569
		return null;
541
	}
570
	}
542
571
543
	public static String fixMethodSignature(String sig) {
572
	static public TRCObjectAllocationAnnotation getAllocationAnnotation(TRCClass cls) {
573
		TRCObjectAllocationAnnotation aa = null;
574
		EList list = cls.getAnnotations();
575
		int len = list.size();
576
		for (int i = 0; i < len; i++) {
577
			TRCAnnotation annotation = (TRCAnnotation) list.get(i);
578
			if (annotation instanceof TRCObjectAllocationAnnotation)
579
				aa = (TRCObjectAllocationAnnotation) annotation;
580
		}
581
		return aa;
582
	}
583
584
	static public String fixMethodSignature(String sig) {
544
		int pos = sig.indexOf('(');
585
		int pos = sig.indexOf('(');
545
		if (pos >= 0) {
586
		if (pos >= 0) {
546
			String ret = sig.substring(0, pos);
587
			String ret = sig.substring(0, pos);
Lines 550-556 Link Here
550
		return sig;
591
		return sig;
551
	}
592
	}
552
593
553
	public static String restoreMethodSignature(String sig) {
594
	static public String restoreMethodSignature(String sig) {
554
		String ret = "";
595
		String ret = "";
555
		int pos = sig.indexOf('(');
596
		int pos = sig.indexOf('(');
556
		if (pos >= 0) {
597
		if (pos >= 0) {
Lines 608-615 Link Here
608
		return sig;
649
		return sig;
609
	}
650
	}
610
651
611
	public static boolean openSource(Object element) {
652
	static public boolean openSource(Object element) {
612
		if (element instanceof String) {
653
		if (element instanceof String) {
654
			System.out.println("openSource: " + element);
613
			final String pattern = (String) element;
655
			final String pattern = (String) element;
614
			final int javaType = IJavaSearchConstants.METHOD;
656
			final int javaType = IJavaSearchConstants.METHOD;
615
			BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
657
			BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
Lines 627-630 Link Here
627
		OpenSource.openSource(element);
669
		OpenSource.openSource(element);
628
		return true;
670
		return true;
629
	}
671
	}
672
673
	static public int getObjAge(TRCFullTraceObject obj, EList listGC) {
674
		int age = 0;
675
		double t0 = obj.getCreateTime();
676
		double t1 = obj.getCollectTime();
677
		int len = listGC.size();
678
		for (int j = 0; j < len; j++) {
679
			TRCGCEvent gcEvent = (TRCGCEvent) listGC.get(j);
680
			if (gcEvent.getType().equals("finish")) {
681
				double time = gcEvent.getTime();
682
				if (time <= t0)
683
					continue;
684
				if (t1 > 0 && time >= t1)
685
					break;
686
				age++;
687
			}
688
		}
689
		return age;
690
	}
691
692
	public static int compare(double d1, double d2) {
693
		if (d1 > d2)
694
			return 1;
695
		if (d1 < d2)
696
			return 1;
697
		return 0;
698
	}
699
700
	public static int compare(String s1, String s2) {
701
		if (s1 != null && s2 != null)
702
			return s1.compareToIgnoreCase(s2);
703
		if (s1 != null)
704
			return 1;
705
		if (s2 != null)
706
			return -1;
707
		return 0;
708
	}
630
}
709
}
(-)plugin.xml (+7 lines)
Lines 98-103 Link Here
98
             name="%JVMTI_ANALYSIS_TYPE_VIEW_THRD_STATES"
98
             name="%JVMTI_ANALYSIS_TYPE_VIEW_THRD_STATES"
99
             type="org.eclipse.tptp.analysisType.jvmti.thread">
99
             type="org.eclipse.tptp.analysisType.jvmti.thread">
100
       </analyzerExtension>
100
       </analyzerExtension>
101
       <analyzerExtension
102
             class="org.eclipse.tptp.trace.jvmti.internal.client.views.MemoryAnalysisViewer"
103
             extension="org.eclipse.tptp.trace.jvmti.client.analyzerExtension2"
104
             icon="icons/full/obj16/memleakantype_obj.gif"
105
             id="org.eclipse.tptp.trace.jvmti.internal.client.views.MemoryAnalysisViewer"
106
             name="%JVMTI_ANALYSIS_TYPE_VIEW_HEAP_ANALYSIS">
107
       </analyzerExtension>
101
	</extension>
108
	</extension>
102
109
103
   	<extension
110
   	<extension
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/AllocationSite.java (+22 lines)
Added Link Here
1
package org.eclipse.tptp.trace.jvmti.internal.client;
2
3
import org.eclipse.hyades.models.trace.TRCMethod;
4
5
public class AllocationSite {
6
7
	public int _lineNo;
8
	public int _total;
9
	public int _sumAges;
10
	public int _collected;
11
	public int _totalSize;
12
	public int _collectedSize;
13
	public TRCMethod _method;
14
15
	public AllocationSite() {
16
	}
17
18
	public AllocationSite(int lineNo, TRCMethod method) {
19
		_method = method;
20
		_lineNo = lineNo;
21
	}
22
}

Return to bug 167995