Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9b843d179d0d5f5ec4dd2e25df0748f2511781a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*******************************************************************************
 * Copyright (c) 2004, 2008, 2009 Red Hat, Inc.
 * (C) Copyright 2010 IBM Corp. 2010
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Keith Seitz <keiths@redhat.com> - initial API and implementation
 *    Kent Sebastian <ksebasti@redhat.com>
 *    Thavidu Ranatunga (IBM) - Derived and modified code from
 *        org.eclipse.linuxtools.oprofile.core.OprofileCorePlugin
 *******************************************************************************/ 
package org.eclipse.linuxtools.internal.perf;

import java.util.List;

import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.linuxtools.internal.perf.model.TreeParent;
import org.eclipse.linuxtools.internal.perf.ui.PerfProfileView;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * The activator class controls the plug-in life cycle
 */
public class PerfPlugin extends AbstractUIPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "org.eclipse.linuxtools.perf";

	// View ID
	public static final String VIEW_ID = "org.eclipse.linuxtools.perf.ui.ProfileView";
	public static final String SOURCE_DISASSEMBLY_VIEW_ID = "org.eclipse.linuxtools.perf.ui.SourceDisassemblyView";

	// Launch Config ID
	public static final String LAUNCHCONF_ID = "org.eclipse.linuxtools.perf.launch.profile";
	
	//Perf Options tab attribs.
	public static final String ATTR_Kernel_Location = "org.eclipse.linuxtools.internal.perf.attr.Kernel.Location";
	public static final String ATTR_Kernel_Location_default = "";
	public static final String ATTR_Record_Realtime = "org.eclipse.linuxtools.internal.perf.attr.Record.Realtime";
	public static final boolean ATTR_Record_Realtime_default = false;
	public static final String ATTR_Record_Verbose = "org.eclipse.linuxtools.internal.perf.attr.Record.Verbose";
	public static final boolean ATTR_Record_Verbose_default = false;
	public static final String ATTR_SourceLineNumbers = "org.eclipse.linuxtools.internal.perf.attr.SourceLineNumbers";
	public static final boolean ATTR_SourceLineNumbers_default = true;
	public static final String ATTR_Kernel_SourceLineNumbers = "org.eclipse.linuxtools.internal.perf.attr.Kernel.SourceLineNumbers";
	public static final boolean ATTR_Kernel_SourceLineNumbers_default = false;
	public static final String ATTR_Multiplex = "org.eclipse.linuxtools.internal.perf.attr.Multiplex";
	public static final boolean ATTR_Multiplex_default = false;
	public static final String ATTR_ModuleSymbols = "org.eclipse.linuxtools.internal.perf.attr.ModuleSymbols";
	public static final boolean ATTR_ModuleSymbols_default = false;
	public static final String ATTR_HideUnresolvedSymbols = "org.eclipse.linuxtools.internal.perf.attr.HideUnresolvedSymbols";
	public static final boolean ATTR_HideUnresolvedSymbols_default = true;
	public static final String ATTR_ShowSourceDisassembly = "org.eclipse.linuxtools.internal.perf.attr.ShowSourceDisassembly";
	public static final boolean ATTR_ShowSourceDisassembly_default = false;
	
	//Perf Events tab attribs.
	public static final String ATTR_DefaultEvent = "org.eclipse.linuxtools.internal.perf.attr.DefaultEvent";
	public static final boolean ATTR_DefaultEvent_default = true;
	public static final String ATTR_MultipleEvents = "org.eclipse.linuxtools.internal.perf.attr.MultipleEvents";
	public static final boolean ATTR_MultipleEvents_default = false;
	public static final String ATTR_SelectedEvents = "org.eclipse.linuxtools.internal.perf.attr.SelectedEvents";
	public static final List<String> ATTR_SelectedEvents_default = null;
	public static final String ATTR_RawHwEvents = "org.eclipse.linuxtools.internal.perf.attr.RawHwEvents";
	public static final List<String> ATTR_RawHwEvents_default = null;
	public static final String ATTR_HwBreakpointEvents = "org.eclipse.linuxtools.internal.perf.attr.HwBreakpointEvents";
	public static final List<String> ATTR_HwBreakpointEvents_default = null;
	
	//Strings
	public static final String STRINGS_Kernel_Location = "Location of kernel image file (optional): ";
	public static final String STRINGS_Record_Realtime = "Record with realtime priority (RT SCHED_FIFO)";
	public static final String STRINGS_Record_Verbose = "Record with verbose output";
	public static final String STRINGS_ModuleSymbols = "Load Module Symbols";
	public static final String STRINGS_HideUnresolvedSymbols = "Hide Unresolved Symbols";
	public static final String STRINGS_SourceLineNumbers = "Obtain source line numbers from profile data";
	public static final String STRINGS_Kernel_SourceLineNumbers = "Obtain kernel source line numbers from profile data (Warning: May be very slow)";
	public static final String STRINGS_Multiplex = "Multiplex counter output in a single channel";
	public static final String STRINGS_RAWHWEvents = "Raw hardware event descriptor";
	public static final String STRINGS_HWBREAKPOINTS = "Hardware breakpoint";
	public static final String STRINGS_UnfiledSymbols = "Unfiled Symbols";
	public static final String STRINGS_MultipleFilesForSymbol = "Symbols conflicting in multiple files";
	public static final String STRINGS_ShowSourceDisassembly = "Show Source Disassembly View";
	
	public static final String PERF_COMMAND = "perf";
	public static final String PERF_DEFAULT_DATA = "perf.data";
	public static final boolean DEBUG_ON = false; //Spew debug messages or not.


	
	  
	
	// The shared instance
	private static PerfPlugin plugin;
	
	// Model Root
	private TreeParent _modelRoot;

	// Source Disassembly Data
	private SourceDisassemblyData sourceDisassemblyData;

	// Profile view
	private PerfProfileView _ProfileView = null;

	// Current profile data
	private IPath curProfileData;

	// Current working directory
	private IPath curWorkingDir;

	public TreeParent getModelRoot() {
		return _modelRoot;
	}

	public SourceDisassemblyData getSourceDisassemblyData () {
		return sourceDisassemblyData;
	}

	public IPath getPerfProfileData() {
		return curProfileData;
	}

	public IPath getWorkingDir(){
		return curWorkingDir;
	}

	/**
	 * Return cleared model root.
	 * @return TreeParent cleared model root.
	 */
	public TreeParent clearModelRoot(){
		if (_modelRoot == null) {
			_modelRoot = new TreeParent("");
		} else {
			_modelRoot.clear();
		}
		return _modelRoot;
	}

	public void setModelRoot(TreeParent rootnode) {
		this._modelRoot = rootnode;
	}

	public void setSourceDisassemblyData (SourceDisassemblyData sourceDisassemblyData) {
		this.sourceDisassemblyData = sourceDisassemblyData;
	}

	public void setPerfProfileData(IPath perfProfileData) {
		this.curProfileData = perfProfileData;
	}

	public void setWorkingDir(IPath workingDir){
		curWorkingDir = workingDir;
	}

	public PerfProfileView getProfileView() {
		if (_ProfileView == null) {
			try {
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
			} catch (PartInitException e2) {
				e2.printStackTrace();
			}
		}
		return _ProfileView;
	}

	public void setProfileView(PerfProfileView profileView) {
		this._ProfileView = profileView;
	}
	
	/**
	 * The constructor
	 */
	public PerfPlugin() {
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
	@Override
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
	 */
	@Override
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static PerfPlugin getDefault() {
		return plugin;
	}

	/**
	 * Returns an image descriptor for the image file at the given
	 * plug-in relative path
	 *
	 * @param path the path
	 * @return the image descriptor
	 */
	public static ImageDescriptor getImageDescriptor(String path) {
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
	}
}

Back to the top