diff options
author | Alexander Kurtakov | 2014-04-14 19:56:55 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2014-04-15 08:17:32 +0000 |
commit | 4b08b3758ba927c7f248eb74c403d2a6508d6f89 (patch) | |
tree | 07291630e38d52a53bd63cbf6b243ee1970e2a81 /oprofile | |
parent | 55ae03bf1bc6822481c5514906803645fd41a78f (diff) | |
download | org.eclipse.linuxtools-4b08b3758ba927c7f248eb74c403d2a6508d6f89.tar.gz org.eclipse.linuxtools-4b08b3758ba927c7f248eb74c403d2a6508d6f89.tar.xz org.eclipse.linuxtools-4b08b3758ba927c7f248eb74c403d2a6508d6f89.zip |
oprofile/perf: Remove dead code.
And other small changes wherever spotted.
Change-Id: I19616bd1a052d8ec2cf873553bb36a7c45057beb
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Reviewed-on: https://git.eclipse.org/r/24996
Tested-by: Hudson CI
Diffstat (limited to 'oprofile')
35 files changed, 285 insertions, 474 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java index b71d53b24c..0b6803b72e 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java @@ -24,25 +24,25 @@ public interface IOpcontrolProvider { * Initialize the Oprofile kernel module * @throws OpcontrolException */ - public void initModule() throws OpcontrolException; + void initModule() throws OpcontrolException; /** * De-initialize (unload) the kernel module * @throws OpcontrolException */ - public void deinitModule() throws OpcontrolException; + void deinitModule() throws OpcontrolException; /** * Clears out data from the current session * @throws OpcontrolException */ - public void reset() throws OpcontrolException; + void reset() throws OpcontrolException; /** * Flush the current oprofiled sample buffers to disk * @throws OpcontrolException */ - public void dumpSamples() throws OpcontrolException; + void dumpSamples() throws OpcontrolException; /** * Setup oprofiled collection parameters @@ -50,37 +50,37 @@ public interface IOpcontrolProvider { * @param events list of events to collect * @throws OpcontrolException */ - public void setupDaemon(OprofileDaemonOptions options, OprofileDaemonEvent[] events) throws OpcontrolException; + void setupDaemon(OprofileDaemonOptions options, OprofileDaemonEvent[] events) throws OpcontrolException; /** * Start data collection by oprofiled (will start oprofiled if necessary) * @throws OpcontrolException */ - public void startCollection() throws OpcontrolException; + void startCollection() throws OpcontrolException; /** * Stop data collection (does NOT stop daemon) * @throws OpcontrolException */ - public void stopCollection() throws OpcontrolException; + void stopCollection() throws OpcontrolException; /** * Stop data collection and shutdown oprofiled * @throws OpcontrolException */ - public void shutdownDaemon() throws OpcontrolException; + void shutdownDaemon() throws OpcontrolException; /** * Start oprofiled (does NOT start data collection) * @throws OpcontrolException */ - public void startDaemon() throws OpcontrolException; + void startDaemon() throws OpcontrolException; /** * Save the current session * @throws OpcontrolException */ - public void saveSession(String name) throws OpcontrolException; + void saveSession(String name) throws OpcontrolException; /** * Delete the session with the specified name for the specified event @@ -88,7 +88,7 @@ public interface IOpcontrolProvider { * @param sessionEvent The name of the event containing the session * @throws OpcontrolException */ - public void deleteSession (String sessionName, String sessionEvent) throws OpcontrolException; + void deleteSession (String sessionName, String sessionEvent) throws OpcontrolException; /** * Check if the user has permission to run opcontrol @@ -97,12 +97,12 @@ public interface IOpcontrolProvider { * @throws OpcontrolException * @since 2.0 */ - public boolean hasPermissions(IProject project) throws OpcontrolException; + boolean hasPermissions(IProject project) throws OpcontrolException; /** * Check status and return true if any status was returned * @return true if any status was returned, otherwise false * @throws OpcontrolException */ - public boolean status() throws OpcontrolException; + boolean status() throws OpcontrolException; } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java index b5aab4d05e..1ea3c7d6e7 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpxmlProvider.java @@ -29,7 +29,7 @@ public interface IOpxmlProvider { * @param info <code>OpInfo</code> object for results * @return <code>IRunnableWithProgress</code> that may be run by the caller */ - public IRunnableWithProgress info(OpInfo info); + IRunnableWithProgress info(OpInfo info); /** * Returns an <code>IRunnableWithProgress</code> that fetches samples for the @@ -39,7 +39,7 @@ public interface IOpxmlProvider { * @param image the image being profiled to be returned to the caller * @return <code>IRunnableWithProgress</code> that may be run by the caller */ - public IRunnableWithProgress modelData(String eventName, String sessionName, OpModelImage image); + IRunnableWithProgress modelData(String eventName, String sessionName, OpModelImage image); /** * Returns an <code>IRunnableWithProgress</code> that checks the validity of the given @@ -50,7 +50,7 @@ public interface IOpxmlProvider { * @param eventValid a size one array to hold the return result (see <code>CheckEventsProcessor</code>) * @return <code>IRunnableWithProgress</code> that may be run by the caller */ - public IRunnableWithProgress checkEvents(int ctr, String event, int um, int[] eventValid); + IRunnableWithProgress checkEvents(int ctr, String event, int um, int[] eventValid); /** * Returns an <code>IRunnableWithProgress</code> that fetches the list of sessions @@ -58,5 +58,5 @@ public interface IOpxmlProvider { * @param sessionList an <code>ArrayList</code> in which to return the list of sessions * @return <code>IRunnableWithProgress</code> that may be run by the caller */ - public IRunnableWithProgress sessions(ArrayList<OpModelSession> sessionList); + IRunnableWithProgress sessions(ArrayList<OpModelSession> sessionList); } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java index a62f274913..72388aa2c4 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/Oprofile.java @@ -33,8 +33,7 @@ import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory; /** * Common class wrapper for all things Oprofile. */ -public class Oprofile -{ +public class Oprofile { // Ugh. Need to know whether the module is loaded without running oprofile commands... private static final String[] OPROFILE_CPU_TYPE_FILES = { "/dev/oprofile/cpu_type", //$NON-NLS-1$ @@ -158,15 +157,6 @@ public class Oprofile } /** - * Finds the event with the given name - * @param name the event's name (i.e., CPU_CLK_UNHALTED) - * @return the event or <code>null</code> if not found - */ - public static OpEvent findEvent(String name) { - return info.findEvent(name); - } - - /** * Get all the events that may be collected on the given counter. * @param num the counter number * @return an array of all valid events -- NEVER RETURNS NULL! diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java index 5df4cc978e..af73a453fa 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OprofileCorePlugin.java @@ -7,8 +7,8 @@ * * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation - * Kent Sebastian <ksebasti@redhat.com> - - *******************************************************************************/ + * Kent Sebastian <ksebasti@redhat.com> - + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.core; @@ -40,24 +40,15 @@ public class OprofileCorePlugin extends Plugin { //The shared instance. private static OprofileCorePlugin plugin; - private IOpxmlProvider opxmlProvider; public static final String DEBUG_PRINT_PREFIX = "DEBUG: "; //$NON-NLS-1$ - + /** * The constructor. */ public OprofileCorePlugin() { plugin = this; } - - /** - * This method is called upon plug-in activation - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - } /** * This method is called when the plug-in is stopped @@ -67,7 +58,7 @@ public class OprofileCorePlugin extends Plugin { super.stop(context); plugin = null; } - + /** * Returns the shared instance. */ @@ -81,49 +72,21 @@ public class OprofileCorePlugin extends Plugin { public static String getId() { return PLUGIN_ID; } - + /** * Returns the OpxmlProvider registered with the plugin or throws an exception * @return the OpxmlProvider */ public IOpxmlProvider getOpxmlProvider() { - opxmlProvider = new LinuxOpxmlProvider(); - return opxmlProvider; + return new LinuxOpxmlProvider(); } - + /** * Returns the registered opcontrol provider or throws an exception * @return the OpcontrolProvider registered with the plugin * @throws OpcontrolException */ public IOpcontrolProvider getOpcontrolProvider() throws OpcontrolException { -// Exception except = null; -// -// if (_opcontrol == null) { -// IExtensionRegistry registry = Platform.getExtensionRegistry(); -// IExtensionPoint extension = registry.getExtensionPoint(PLUGIN_ID, "OpcontrolProvider"); //$NON-NLS-1$ -// if (extension != null) { -// IExtension[] extensions = extension.getExtensions(); -// IConfigurationElement[] configElements = extensions[0].getConfigurationElements(); -// if (configElements.length != 0) { -// try { -// _opcontrol = (IOpcontrolProvider) configElements[0].createExecutableExtension("class"); //$NON-NLS-1$ -// } catch (CoreException ce) { -// except = ce; -// } -// } -// } -// } -// -// // If there was a problem finding opcontrol, throw an exception -// if (_opcontrol == null) { -// String msg = getResourceString("opcontrolProvider.error.missing"); //$NON-NLS-1$ -// Status status = new Status(IStatus.ERROR, getId(), IStatus.OK, msg, except); -// throw new OpcontrolException(status); -// } -// -// return _opcontrol; - IOpcontrolProvider opcontrolProvider = null; IExtensionRegistry registry = Platform.getExtensionRegistry(); @@ -158,7 +121,7 @@ public class OprofileCorePlugin extends Plugin { return opcontrolProvider; } - + /** * Creates an error status object * @param errorClassString A string of the error class @@ -174,7 +137,7 @@ public class OprofileCorePlugin extends Plugin { return new Status(IStatus.ERROR, getId(), IStatus.OK, statusMessage, e); } } - + /** * Shows an error Dialog * @param errorClassString A string of the error class @@ -184,14 +147,14 @@ public class OprofileCorePlugin extends Plugin { final IStatus status; final String dialogTitle = OprofileProperties.getString(errorClassString + ".error.dialog.title"); //$NON-NLS-1$ final String errorMessage = OprofileProperties.getString(errorClassString + ".error.dialog.message"); //$NON-NLS-1$ - + if (ex == null) { status = createErrorStatus(errorClassString, null); } else { status = ex.getStatus(); } - //needs to be run in the ui thread otherwise swt throws invalid thread access + //needs to be run in the ui thread otherwise swt throws invalid thread access Display.getDefault().syncExec(new Runnable() { @Override public void run() { @@ -200,9 +163,9 @@ public class OprofileCorePlugin extends Plugin { }); } - + /** - * + * * @return {@code true} when platform was started in debug mode ({@code -debug} switch) * and {@code org.eclipse.linuxtools.internal.oprofile.core/debug} is set in some .options file * either in $HOME/.options or $(pwd)/.options. @@ -215,29 +178,18 @@ public class OprofileCorePlugin extends Plugin { /** * Log a string message with the given severity in the error log. - * + * * @param severity the severity of this exception * @param msg the string message to be logged */ public static void log(int severity, String msg) { plugin.getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, msg, null)); } - - /** - * Log an exception in the error log. - * - * @param severity the severity of this exception - * @param msg The message to be logged - * @param cause object representing the cause of this exception - */ - public static void log(int severity, String msg, Throwable cause) { - plugin.getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, msg, cause)); - } - + /** - * Returns the location of the plugin by checking the path of the bundle's + * Returns the location of the plugin by checking the path of the bundle's * locationURL. - * + * * @return An absolute path representing the location of this plugin */ public String getPluginLocation() { diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OpxmlException.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OpxmlException.java deleted file mode 100644 index 63aba0be64..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/OpxmlException.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 Red Hat, Inc. - * 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 - *******************************************************************************/ -package org.eclipse.linuxtools.internal.oprofile.core; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - -/** - * An exception thrown by any of the IOpxmlProvider functions - */ -public class OpxmlException extends CoreException { - - /** - * - */ - private static final long serialVersionUID = 2788304536155025911L; - - /** - * Constructor - * @param status <code>IStatus</code> for the exception - */ - public OpxmlException(IStatus status) { - super(status); - } -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpInfo.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpInfo.java index e62f08d907..39e37f86fc 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpInfo.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpInfo.java @@ -8,7 +8,7 @@ * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation * Kent Sebastian <ksebasti@redhat.com> - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.core.daemon; @@ -31,7 +31,7 @@ public class OpInfo { public static final String DEFAULT_LOCK_FILE = DefaultsProcessor.LOCK_FILE; public static final String DEFAULT_LOG_FILE = DefaultsProcessor.LOG_FILE; public static final String DEFAULT_DUMP_STATUS = DefaultsProcessor.DUMP_STATUS; - + /** * A comparator class used when sorting events * (sorting by event name) @@ -61,49 +61,49 @@ public class OpInfo { return astr.compareTo(bstr); } } - + /** * The number of counters supported by this configuration */ private int nrCounters; - + /** * A HashMap of Oprofile defaults */ private HashMap<String,String> defaults; - + /** * The permanent list of events indexed by counter */ private OpEvent[][] eventList; - + /** * The CPU frequency of this CPU in MHz */ private double cpuSpeed; - + /** * Whether or not oprofile is running in timer mode */ private boolean timerMode; - + /** * Return all of Oprofile's generic information. * @return a class containing the information */ - public static OpInfo getInfo() { + public static OpInfo getInfo() { // Run opmxl and get the static information OpInfo info = new OpInfo(); try { OpInfoRunner opxml = (OpInfoRunner) OprofileCorePlugin.getDefault().getOpxmlProvider().info(info); boolean ret = opxml.run0(null); - if (ret == false) + if (ret == false) { info = null; - } catch (InvocationTargetException e) { - } catch (InterruptedException e) { + } + } catch (InvocationTargetException|InterruptedException e) { } - + return info; } @@ -116,7 +116,7 @@ public class OpInfo { */ public void setNrCounters(int ctrs) { nrCounters = ctrs; - + // Allocate room for event lists for the counters eventList = new OpEvent[nrCounters][]; } @@ -152,7 +152,7 @@ public class OpInfo { Arrays.sort(eventList[counterNum], new SortEventComparator()); } } - + /** * Sets whether or not oprofile is operating in timer mode. * Only called from XML parsers. @@ -169,7 +169,7 @@ public class OpInfo { public int getNrCounters() { return nrCounters; } - + /** * Returns the CPU's speed in MHz * @return the speed @@ -177,7 +177,7 @@ public class OpInfo { public double getCPUSpeed() { return cpuSpeed; } - + /** * Returns the requested default. Valid defaults are <code>DEFAULT_DUMP_STATUS</code>, * <code>DEFAULT_LOCK_FILE</code>, <code>DEFAULT_LOG_FILE</code>, and @@ -193,14 +193,15 @@ public class OpInfo { * Returns an array of events valid for the given counter number. * @param num the counter number * @return an array of valid events - */ + */ public OpEvent[] getEvents(int num) { - if (num >= 0 && num < eventList.length) + if (num >= 0 && num < eventList.length) { return eventList[num]; - + } + return new OpEvent[0]; } - + /** * Returns whether or not oprofile is operating in timer mode. * @return a boolean, true if in timer mode, false if not @@ -208,7 +209,7 @@ public class OpInfo { public boolean getTimerMode() { return timerMode; } - + /** * Searches the for the event with the given name * @param name the name of the event (e.g., CPU_CLK_UNHALTED) @@ -218,10 +219,11 @@ public class OpInfo { // Search through all counters for (int counter = 0; counter < getNrCounters(); ++counter) { int idx = Arrays.binarySearch(getEvents(counter), name, new SearchEventComparator()); - if (idx >= 0) + if (idx >= 0) { return eventList[counter][idx]; + } } - + return null; } } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpUnitMask.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpUnitMask.java index 89c068ec00..2857283e2c 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpUnitMask.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OpUnitMask.java @@ -7,7 +7,7 @@ * * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation - * Kent Sebastian <ksebasti@redhat.com> + * Kent Sebastian <ksebasti@redhat.com> *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.core.daemon; @@ -16,8 +16,8 @@ package org.eclipse.linuxtools.internal.oprofile.core.daemon; * A class representing the unit mask that may be associated with oprofile * events. Note that since this class was originally written, oprofile unit * masks have changed -- a single unit mask may affect several bits at once. - * Hence, instead of a certain bit being flipped, the specific bits to be changed - * are determined by the particular mask's index + * Hence, instead of a certain bit being flipped, the specific bits to be changed + * are determined by the particular mask's index */ public class OpUnitMask { /** @@ -34,7 +34,7 @@ public class OpUnitMask { */ public String description; } - + public static final int SET_DEFAULT_MASK = -1; /** @@ -107,9 +107,9 @@ public class OpUnitMask { */ public void setDefault(int theDefault) { defaultMask = theDefault; - setDefaultMaskValue(); + setDefaultMaskValue(); } - + /** * Sets the unitmask type. * Only used from the XML parsers. @@ -118,7 +118,7 @@ public class OpUnitMask { public void setType(int type) { maskType = type; } - + /** * Returns the integer value of this unitmask, suitable for passing to oprofile. * @return the integer value @@ -130,7 +130,7 @@ public class OpUnitMask { /** * Tests whether a particular mask is set in the unitmask value, based on the * value of the mask option at the given index. - * + * * @param index the index of the mask option to check * @return whether the given mask option's value is set */ @@ -156,8 +156,8 @@ public class OpUnitMask { } /** - * Sets the absolute unitmask value. - * + * Sets the absolute unitmask value. + * * @param newValue the new value of this unitmask */ public void setMaskValue(int newValue) { @@ -167,7 +167,7 @@ public class OpUnitMask { mask = newValue; } } - + /** * Sets the bits of the given mask option's value in the unitmask value. * @param index the index of the mask option to set @@ -205,7 +205,7 @@ public class OpUnitMask { //type invalid or unknown, or out of bounds return -1; } - + /** * Unset the bits of the given mask option's value in the unitmask value. * @param index the index of the mask option to set @@ -229,12 +229,13 @@ public class OpUnitMask { * @return the description */ public String getText(int num) { - if (num >= 0 && num < maskOptionDescriptions.length) + if (num >= 0 && num < maskOptionDescriptions.length) { return maskOptionDescriptions[num]; + } return null; } - + /** * Returns the number of mask options in this unitmask. * @return the number of mask options diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OprofileDaemonOptions.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OprofileDaemonOptions.java index a693012c82..1a0cb364e0 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OprofileDaemonOptions.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OprofileDaemonOptions.java @@ -8,7 +8,7 @@ * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation * Kent Sebastian <ksebasti@redhat.com> - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.core.daemon; @@ -21,36 +21,31 @@ public class OprofileDaemonOptions { * Kernel image file */ private String kernelImageFile; - - /** - * Enable verbose logging - */ - private boolean verboseLogging; - + /** * How to separate profiles (mask) */ private int separateProfiles; - + /** * The image to profile */ private String binaryImage; - + /** * How many calls down to profile */ private int callgraphDepth; - + /** * Sample separation options. Determines how oprofiled will group * samples for binaries which isn't the main binary being profiled. - * + * * Currently only properly support: * -none: ignore all other binaries * -library: include shared library samples * -kernel: include kernel module samples (which implicitly includes library) - * + * * the others probably wouldn't show nicely in the view */ public static final int SEPARATE_NONE = 0; @@ -58,19 +53,18 @@ public class OprofileDaemonOptions { public static final int SEPARATE_KERNEL = 2; public static final int SEPARATE_THREAD = 4; public static final int SEPARATE_CPU = 8; - + /** * Constructor */ public OprofileDaemonOptions() { //defaults kernelImageFile = ""; //$NON-NLS-1$ - verboseLogging = false; - separateProfiles = SEPARATE_NONE; + separateProfiles = SEPARATE_NONE; binaryImage = ""; //$NON-NLS-1$ callgraphDepth = 0; } - + /** * Get the kernel image file * @return the kernel image file @@ -78,7 +72,7 @@ public class OprofileDaemonOptions { public String getKernelImageFile() { return kernelImageFile; } - + /** * Set the kernel image file * @param image the kernel image @@ -88,29 +82,13 @@ public class OprofileDaemonOptions { } /** - * Get daemon verbose logging - * @return whether verbose logging is enabled - */ - public boolean getVerboseLogging() { - return verboseLogging; - } - - /** - * Set daemon verbose logging - * @param logging whether to enable verbose logging - */ - public void setVerboseLogging(boolean logging) { - verboseLogging = logging; - } - - /** * Get daemon profile separation mask * @return mask of options */ public int getSeparateProfilesMask() { return separateProfiles; } - + /** * Set daemon profile separation mask * @param mask the new separation mask @@ -142,12 +120,4 @@ public class OprofileDaemonOptions { public int getCallgraphDepth() { return callgraphDepth; } - - /** - * Sets the call depth value. - * @param depth integer amount of calls down to profile - */ - public void setCallgraphDepth(int depth) { - this.callgraphDepth = depth; - } } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java index 1992f082a7..4e5cbddf25 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java @@ -335,7 +335,7 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider { * @throws OpcontrolException * @since 1.1 */ - protected boolean checkOpcontrolProcess(Process p) throws OpcontrolException { + private boolean checkOpcontrolProcess(Process p) throws OpcontrolException { if (p != null) { String errOutput = ""; //$NON-NLS-1$ String output = "", s; //$NON-NLS-1$ @@ -396,7 +396,7 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider { * @return a string path to opcontrol executable * @since 1.1 */ - protected String findOpcontrolExecutable() { + private String findOpcontrolExecutable() { IProject project = Oprofile.OprofileProject.getProject(); if (!LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){ return OPCONTROL_EXECUTABLE; diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpxmlRunner.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpxmlRunner.java index 28c07771bf..6de5dfa313 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpxmlRunner.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/OpxmlRunner.java @@ -7,8 +7,8 @@ * * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation - * Kent Sebastian <ksebasti@redhat.com> - - *******************************************************************************/ + * Kent Sebastian <ksebasti@redhat.com> - + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.core.linux; import java.io.BufferedReader; @@ -37,7 +37,6 @@ import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin; import org.eclipse.linuxtools.internal.oprofile.core.OprofileProperties; import org.eclipse.linuxtools.internal.oprofile.core.opxml.AbstractDataAdapter; import org.eclipse.linuxtools.internal.oprofile.core.opxml.OprofileSAXHandler; -import org.eclipse.linuxtools.internal.oprofile.core.opxml.XMLProcessor; import org.eclipse.linuxtools.internal.oprofile.core.opxml.checkevent.CheckEventAdapter; import org.eclipse.linuxtools.internal.oprofile.core.opxml.info.InfoAdapter; import org.eclipse.linuxtools.internal.oprofile.core.opxml.modeldata.ModelDataAdapter; @@ -53,23 +52,14 @@ import org.xml.sax.XMLReader; /** * This class will run opxml. - * + * * opxml is a small program which acts as a textual interface between Oprofile and - * BFD and the oprofile plugins. + * BFD and the oprofile plugins. */ public class OpxmlRunner { private OprofileSAXHandler handler; - /** - * Returns the current XMLProcessor handling parsing of opxml output. - * @return the processor - */ - public XMLProcessor getProcessor() { - return handler.getProcessor(); - } - - /** * Runs opxml with the given arguments. * @param args the arguments to pass to opxml * @param callData any callData to pass to the processor @@ -78,7 +68,7 @@ public class OpxmlRunner { public boolean run(String[] args, Object callData) { XMLReader reader = null; handler = OprofileSAXHandler.getInstance(callData); - + // Create XMLReader SAXParserFactory factory = SAXParserFactory.newInstance(); try { @@ -87,18 +77,18 @@ public class OpxmlRunner { e.printStackTrace(); return false; } - + // Set content/error handlers reader.setContentHandler(handler); reader.setErrorHandler(handler); - + // Check for timer support InfoAdapter.checkTimerSupport(); // Run opxml try { File file = constructFile(args); - + //handle the opxml_session file if (args[0].equals(SessionManager.SESSIONS)){ SessionManager sessManNew = new SessionManager(SessionManager.SESSION_LOCATION); @@ -142,7 +132,7 @@ public class OpxmlRunner { FileReader fr = new FileReader(file); reader.parse(new InputSource(fr)); } - + return true; } catch (SAXException e) { e.printStackTrace(); @@ -174,7 +164,7 @@ public class OpxmlRunner { } return file; } - + private File constructFile(String [] args){ String fileName = ""; for (int i = 0; i < args.length; i++){ @@ -182,7 +172,7 @@ public class OpxmlRunner { } return new File (SessionManager.OPXML_PREFIX + fileName); } - + private boolean handleModelData (String [] args){ ArrayList<String> cmd = new ArrayList<>(); cmd.add("-Xdg"); //$NON-NLS-1$ @@ -204,7 +194,7 @@ public class OpxmlRunner { saveOpxmlToFile(bi, args); return true; } - + /** * Add the current session to the session manager for each event * that it was profiled under. @@ -225,7 +215,7 @@ public class OpxmlRunner { try { String cmd[] = {"-X", "-d"}; InputStream is = runOpReport(cmd); - + if (is != null){ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java index 4e4a9348a4..0e60c715eb 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/model/OpModelEvent.java @@ -7,8 +7,8 @@ * * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation - * Kent Sebastian <ksebasti@redhat.com> - - *******************************************************************************/ + * Kent Sebastian <ksebasti@redhat.com> - + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.core.model; @@ -33,15 +33,10 @@ public class OpModelEvent { return eventName; } - public OpModelSession getSession() - { + public OpModelSession getSession() { return parentSession; } - public void setSession(OpModelSession session) - { - this.parentSession = session; - } //populate all images & dependent images public void refreshModel() { image = getNewImage(); diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/AbstractDataAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/AbstractDataAdapter.java index 432fba024c..2b8cca3730 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/AbstractDataAdapter.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/AbstractDataAdapter.java @@ -18,7 +18,6 @@ import java.io.UnsupportedEncodingException; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; @@ -27,18 +26,18 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public abstract class AbstractDataAdapter { - + /** * @return a Document representing the newly created XML data. */ public abstract Document getDocument (); - + /** * parse the XML data modifying it as necessary to produce the necessary * XML output. */ public abstract void process (); - + /** * @return an InputStream to the newly created XML data. */ @@ -53,17 +52,13 @@ public abstract class AbstractDataAdapter { xformer = factory.newTransformer(); xformer.setOutputProperty("indent", "yes"); xformer.transform(source, result); - inp = new ByteArrayInputStream(stw.toString().getBytes("UTF-8")); - } catch (TransformerConfigurationException e) { - e.printStackTrace(); - } catch (TransformerException e) { - e.printStackTrace(); - } catch (UnsupportedEncodingException e) { + inp = new ByteArrayInputStream(stw.toString().getBytes("UTF-8")); + } catch (TransformerException|UnsupportedEncodingException e) { e.printStackTrace(); } return inp; } - + @Override public String toString (){ String ret = null; @@ -77,8 +72,6 @@ public abstract class AbstractDataAdapter { xformer.setOutputProperty("indent", "yes"); xformer.transform(source, result); ret = stw.toString(); - } catch (TransformerConfigurationException e) { - e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java index 1e8fdb22fb..9457f43c6c 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/EventIdCache.java @@ -35,7 +35,7 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -/** +/** * Caches the event data used by the CheckEventAdapter. The performance * improvement is targeted at the first time a call with the given arguments is * made. The first given call to check-event will take roughly O(n), and all @@ -44,7 +44,7 @@ import org.xml.sax.SAXException; * simply parses the XML from ophelp -X and stores it. */ public class EventIdCache { - + private static final String HELP_EVENTS = "help_events"; //$NON-NLS-1$ private static final String HEADER = "header"; //$NON-NLS-1$ private static final String SCHEMA = "schemaversion"; //$NON-NLS-1$ @@ -63,7 +63,7 @@ public class EventIdCache { // Map containing the caches for remote machines private static HashMap<String, EventIdCache> cacheMap; - + public static EventIdCache getInstance(){ if (cacheMap == null) { @@ -91,7 +91,7 @@ public class EventIdCache { return newCache; } - + /** * @param id the id corresponding to an event * @return the DOM Element corresponding to the event tag @@ -145,18 +145,17 @@ public class EventIdCache { eventId.eventDoc = builder.parse(p.getInputStream()); Element elem = (Element) eventId.eventDoc.getElementsByTagName(HELP_EVENTS).item(0); eventId.eventRoot = elem; - } catch (IOException e) { - } catch (SAXException e) { + } catch (IOException|SAXException e) { } } catch (ParserConfigurationException e1) { e1.printStackTrace(); } - + } catch (IOException e) { e.printStackTrace(); } } - + /** * Get the unit mask type. Schema Version 1.1 and newer of ophelp XML * will list the unit mask type as an attribute. Older version will not @@ -243,8 +242,7 @@ public class EventIdCache { } } eventReader.close(); - } catch (IOException e) { - } catch (CoreException e) { + } catch (IOException|CoreException e) { } finally { if (bi != null) { try { diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/OprofileSAXHandler.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/OprofileSAXHandler.java index 3dd058ba58..6aa2ec2bd2 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/OprofileSAXHandler.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/OprofileSAXHandler.java @@ -7,7 +7,7 @@ * * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.core.opxml; import java.util.HashMap; @@ -27,25 +27,25 @@ import org.xml.sax.helpers.DefaultHandler; public class OprofileSAXHandler extends DefaultHandler { // The only allowed instance of this class private static OprofileSAXHandler instance = null; - + // A Map of all the XML processors for opxml private static HashMap<String,Class<?>> processors = new HashMap<>(); - + // The current processor being used to parse the document private XMLProcessor processor = null; private Object callData; - + /* A stack of XML processors. This allows processors to invoke sub-processors for handling nested tags more efficiently. */ private Stack<XMLProcessor> processorStack = new Stack<>(); - + // Introduced for fix of Eclipse BZ#343025 // As per SAX spec, SAX parsers are allowed to split character data into as many chunks as - // they please, and they can split the text at whichever boundaries they want. In order to + // they please, and they can split the text at whichever boundaries they want. In order to // handle this properly, it is needed to accumulate the text returned in each call // until it recieves a callback that isn't characters. private StringBuffer charactersBuffer; - + // A convenience class for specifying XMLProcessors private static class ProcessorItem { public String tagName; @@ -55,15 +55,15 @@ public class OprofileSAXHandler extends DefaultHandler { handlerClass = cls; } } - - // The list of all "root" XML tags and their handler classes + + // The list of all "root" XML tags and their handler classes private static final ProcessorItem[] handlerList = { new ProcessorItem(OpxmlConstants.INFO_TAG, OpInfoProcessor.class), new ProcessorItem(OpxmlConstants.CHECKEVENTS_TAG, CheckEventsProcessor.class), new ProcessorItem(OpxmlConstants.MODELDATA_TAG, ModelDataProcessor.class), new ProcessorItem(OpxmlConstants.SESSIONS_TAG, SessionsProcessor.class) }; - + /** * Returns an instance of the handler. This must be used to access the parser! * @return a handler instance @@ -71,47 +71,45 @@ public class OprofileSAXHandler extends DefaultHandler { public static OprofileSAXHandler getInstance(Object callData) { if (instance == null) { instance = new OprofileSAXHandler(); - + // Initialize processor map for (int i = 0; i < handlerList.length; ++i) { processors.put(handlerList[i].tagName, handlerList[i].handlerClass); } } - + // Set calldata into handler instance.setCallData (callData); return instance; } - + /** * Sets the calldata for the processor. * @param callData the calldata to pass to the processor */ - public void setCallData(Object callData) - { + private void setCallData(Object callData) { this.callData = callData; } - + /** * Returns the processor for a given request type. * @param type the name of the processor * @return the requested processor or null */ - public static XMLProcessor getProcessor(String type) { + private static XMLProcessor getProcessor(String type) { XMLProcessor processor = null; - + Class<?> handlerClass = processors.get(type); if (handlerClass != null) { try { processor = (XMLProcessor) handlerClass.newInstance(); - } catch (InstantiationException e) { - } catch (IllegalAccessException e) { + } catch (InstantiationException|IllegalAccessException e) { } } - + return processor; } - + /** * @see org.xml.sax.ContentHandler#startDocument() */ @@ -120,14 +118,14 @@ public class OprofileSAXHandler extends DefaultHandler { // Reset processor processor = null; } - + /** * @see org.xml.sax.ContentHandler#endDocument() */ @Override public void endDocument() { } - + /** * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes) */ @@ -138,16 +136,16 @@ public class OprofileSAXHandler extends DefaultHandler { processor = getProcessor(qName); processor.reset(callData); } - + // If we already have a processor, so let it deal with this new element. // Allow the processor to deal with it's own tag as well: this way it can // grab attributes from it. processor.startElement(qName, attrs, callData); - - // Clean up the characters buffer + + // Clean up the characters buffer charactersBuffer = new StringBuffer(); } - + /** * @see org.xml.sax.ContentHandler#endElement(String, String, String) */ @@ -157,7 +155,7 @@ public class OprofileSAXHandler extends DefaultHandler { processor.characters(charactersBuffer.toString(), callData); processor.endElement(qName, callData); } - + /** * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ @@ -169,15 +167,7 @@ public class OprofileSAXHandler extends DefaultHandler { // Append the character to the buffer. charactersBuffer.append(str); } - - /** - * Returns the processor used to parse the document. - * @return the XMLProcessor - */ - public XMLProcessor getProcessor() { - return processor; - } - + /** * Pushes the current XMLProcessor onto the stack and installs the given * processor as the document's parser/handler. @@ -188,7 +178,7 @@ public class OprofileSAXHandler extends DefaultHandler { processor = proc; processor.reset(callData); } - + /** * Removes the current XMLProcessor and installs the previous processor. * NOTE: This assumes that endElement caused the pop, so it calls endElement in diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/XMLProcessor.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/XMLProcessor.java index 6bc5b941fc..7e5be3b4b6 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/XMLProcessor.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/XMLProcessor.java @@ -68,7 +68,7 @@ public class XMLProcessor { * @param source source attribute string * @return the source string with escaped characters translated back to their single character counterpart */ - public String valid_string(String source) { + public String validString(String source) { final String chars_long[] = {"&", """, "'", "<", ">"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ final String chars[] = {"&", "\"", "'", "<", ">"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ for (int i = 0; i < chars_long.length; i++) { diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java index af080cd040..b775f7843b 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java @@ -43,19 +43,19 @@ import org.xml.sax.SAXException; * data to modify it into the format expected by the SAX parser. */ public class InfoAdapter extends AbstractDataAdapter{ - + public static final String HELP_EVENTS = "help_events"; //$NON-NLS-1$ public static final String INFO = "info"; //$NON-NLS-1$ - + public static final String DEFAULTS = "defaults"; //$NON-NLS-1$ public static final String NUM_COUNTERS = "num-counters"; //$NON-NLS-1$ public static final String CPU_FREQUENCY = "cpu-frequency"; //$NON-NLS-1$ public static final String TIMER_MODE = "timer-mode"; //$NON-NLS-1$ public static final String TIMER = "timer"; //$NON-NLS-1$ - + public static final String EVENT_LIST = "event-list"; //$NON-NLS-1$ public static final String COUNTER = "counter"; //$NON-NLS-1$ - + public static final String EVENT = "event"; //$NON-NLS-1$ public static final String EVENT_NAME = "event_name"; //$NON-NLS-1$ public static final String NAME = "name"; //$NON-NLS-1$ @@ -64,26 +64,26 @@ public class InfoAdapter extends AbstractDataAdapter{ public static final String MIN_COUNT = "min_count"; //$NON-NLS-1$ public static final String MINIMUM = "minimum"; //$NON-NLS-1$ public static final String VALUE = "value"; //$NON-NLS-1$ - + public static final String UNIT_MASKS = "unit_masks"; //$NON-NLS-1$ public static final String UNITMASK = "unit-mask"; //$NON-NLS-1$ public static final String DEFAULT = "default"; //$NON-NLS-1$ public static final String TYPE = "type"; //$NON-NLS-1$ - + public static final String UNIT_MASK = "unit_mask"; //$NON-NLS-1$ public static final String MASK = "mask"; //$NON-NLS-1$ - + public static final String SAMPLE_DIR = "sample-dir"; //$NON-NLS-1$ public static final String LOCK_FILE = "lock-file"; //$NON-NLS-1$ public static final String LOG_FILE = "log-file"; //$NON-NLS-1$ public static final String DUMP_STATUS = "dump-status"; //$NON-NLS-1$ - + public static final String CPUINFO = "/proc/cpuinfo"; //$NON-NLS-1$ public static String DEV_OPROFILE = "/dev/oprofile/"; //$NON-NLS-1$ public static String CPUTYPE = DEV_OPROFILE + "cpu_type"; //$NON-NLS-1$ public static final String OP_SHARE = "/usr/share/oprofile/"; //$NON-NLS-1$ public static final String EVENTS = "events"; //$NON-NLS-1$ - + public static final String SAMPLE_DIR_VAL = "/var/lib/oprofile/samples/"; //$NON-NLS-1$ public static final String LOCK_FILE_VAL = "/var/lib/oprofile/lock"; //$NON-NLS-1$ public static final String LOG_FILE_VAL = "/var/lib/oprofile/samples/oprofiled.log"; //$NON-NLS-1$ @@ -93,7 +93,7 @@ public class InfoAdapter extends AbstractDataAdapter{ private Element oldRoot; // the root of the document with data from ophelp private Element newRoot; // the root of the document we intent to build private static IRemoteFileProxy proxy; - + private static boolean hasTimerSupport; public InfoAdapter (){ @@ -183,34 +183,34 @@ public class InfoAdapter extends AbstractDataAdapter{ Element numCountersTag = newDoc.createElement(NUM_COUNTERS); numCountersTag.setTextContent(String.valueOf(numCounters)); newRoot.appendChild(numCountersTag); - + // cpu frequency int cpuFreq = getCPUFrequency(); Element cpuFreqTag = newDoc.createElement(CPU_FREQUENCY); cpuFreqTag.setTextContent(String.valueOf(cpuFreq)); newRoot.appendChild(cpuFreqTag); - + // file defaults Element defaultsTag = newDoc.createElement(DEFAULTS); - + Element sampleDirTag = newDoc.createElement(SAMPLE_DIR); sampleDirTag.setTextContent(SAMPLE_DIR_VAL); defaultsTag.appendChild(sampleDirTag); - + Element lockFileTag = newDoc.createElement(LOCK_FILE); lockFileTag.setTextContent(LOCK_FILE_VAL); defaultsTag.appendChild(lockFileTag); - + Element logFileTag = newDoc.createElement(LOG_FILE); logFileTag.setTextContent(LOG_FILE_VAL); defaultsTag.appendChild(logFileTag); - + Element dumpStatusTag = newDoc.createElement(DUMP_STATUS); dumpStatusTag.setTextContent(DUMP_STATUS_VAL); defaultsTag.appendChild(dumpStatusTag); - + newRoot.appendChild(defaultsTag); - + // timer mode Element timerModeTag = newDoc.createElement(TIMER_MODE); timerModeTag.setTextContent(String.valueOf(hasTimerSupport())); @@ -354,17 +354,17 @@ public class InfoAdapter extends AbstractDataAdapter{ } private void createXML() { - + NodeList eventList = oldRoot.getElementsByTagName(EVENT); Element newEventList = newDoc.createElement(EVENT_LIST); - + for (int i = 0; i < eventList.getLength(); i++){ // get the event data Element event = (Element) eventList.item(i); - String name = event.getAttribute(EVENT_NAME); + String name = event.getAttribute(EVENT_NAME); String desc = event.getAttribute(DESC); String min_count = event.getAttribute(MIN_COUNT); - + // create the data for the new event Element newEventTag = newDoc.createElement(EVENT); Element nameTag = newDoc.createElement(NAME); @@ -373,42 +373,42 @@ public class InfoAdapter extends AbstractDataAdapter{ descTag.setTextContent(desc); Element minimumTag = newDoc.createElement(MINIMUM); minimumTag.setTextContent(min_count); - + newEventTag.appendChild(nameTag); newEventTag.appendChild(descTag); newEventTag.appendChild(minimumTag); - + Element unitMaskTag = (Element) event.getElementsByTagName(UNIT_MASKS).item(0); - + // check if there are any unit masks for this event if (unitMaskTag != null){ String defaultVal = unitMaskTag.getAttribute(DEFAULT); // Get the unit mask type (compatible with 1.0 and 1.1 ophelp xml schemas) String type = EventIdCache.getInstance().getUnitMaskType(name); - + Element newUnitMaskTag = newDoc.createElement(UNITMASK); Element typeTag = newDoc.createElement(TYPE); typeTag.setTextContent(type); Element defaultValTag = newDoc.createElement(DEFAULT); defaultValTag.setTextContent(defaultVal); - + newUnitMaskTag.appendChild(typeTag); newUnitMaskTag.appendChild(defaultValTag); newEventTag.appendChild(newUnitMaskTag); - + NodeList unitMaskList = unitMaskTag.getElementsByTagName(UNIT_MASK); for (int j = 0; j < unitMaskList.getLength(); j++){ Element unitMask = (Element) unitMaskList.item(j); String maskVal = unitMask.getAttribute(MASK); String maskDesc = unitMask.getAttribute(DESC); - + Element newMask = newDoc.createElement(MASK); Element newVal = newDoc.createElement(VALUE); newVal.setTextContent(maskVal); Element newDesc = newDoc.createElement(DESCRIPTION); newDesc.setTextContent(maskDesc); - + newMask.appendChild(newVal); newMask.appendChild(newDesc); newUnitMaskTag.appendChild(newMask); @@ -417,31 +417,31 @@ public class InfoAdapter extends AbstractDataAdapter{ }else{ String defaultVal = "0"; //$NON-NLS-1$ String type = "mandatory"; //$NON-NLS-1$ - + Element newUnitMaskTag = newDoc.createElement(UNITMASK); Element typeTag = newDoc.createElement(TYPE); typeTag.setTextContent(type); Element defaultValTag = newDoc.createElement(DEFAULT); defaultValTag.setTextContent(defaultVal); - + newUnitMaskTag.appendChild(typeTag); newUnitMaskTag.appendChild(defaultValTag); newEventTag.appendChild(newUnitMaskTag); - + Element newMask = newDoc.createElement(MASK); Element newVal = newDoc.createElement(VALUE); newVal.setTextContent("0"); //$NON-NLS-1$ Element newDesc = newDoc.createElement(DESCRIPTION); newDesc.setTextContent("No unit mask"); //$NON-NLS-1$ - + newMask.appendChild(newVal); newMask.appendChild(newDesc); newUnitMaskTag.appendChild(newMask); } - + newEventList.appendChild(newEventTag); } - + for (int i = 0; i < getNrCounters(); i++){ Element eventListTag = (Element) newEventList.cloneNode(true); eventListTag.setAttribute(COUNTER, String.valueOf(i)); @@ -457,7 +457,7 @@ public class InfoAdapter extends AbstractDataAdapter{ /** * @since 3.0 */ - public void setEventIdCacheDoc (Element elem) { + private void setEventIdCacheDoc (Element elem) { EventIdCache.getInstance().setCacheDoc(elem); } } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/DependentProcessor.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/DependentProcessor.java index ef24c03657..746b50c3d5 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/DependentProcessor.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/DependentProcessor.java @@ -55,7 +55,7 @@ public class DependentProcessor extends XMLProcessor { @Override public void startElement(String name, Attributes attrs, Object callData) { if (name.equals(IMAGE_TAG)) { - image.setName(valid_string(attrs.getValue(ATTR_IMAGENAME))); + image.setName(validString(attrs.getValue(ATTR_IMAGENAME))); image.setCount(Integer.parseInt(attrs.getValue(ATTR_COUNT))); } else if (name.equals(SYMBOLS_TAG)) { OprofileSAXHandler.getInstance(callData).push(_symbolsProcessor); diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataAdapter.java index 357a3f48df..7282bbceb9 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataAdapter.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataAdapter.java @@ -34,47 +34,47 @@ import org.xml.sax.SAXException; * expected by the SAX parser. */ public class ModelDataAdapter extends AbstractDataAdapter { - + public final static String ID = "id"; //$NON-NLS-1$ public final static String IDREF = "idref"; //$NON-NLS-1$ public final static String NAME = "name"; //$NON-NLS-1$ public final static String COUNT = "count"; //$NON-NLS-1$ public final static String SAMPLE = "sample"; //$NON-NLS-1$ public final static String LINE = "line"; //$NON-NLS-1$ - + public final static String SYMBOL_DATA = "symboldata"; //$NON-NLS-1$ public final static String SYMBOL_DETAILS = "symboldetails"; //$NON-NLS-1$ public final static String SYMBOL = "symbol"; //$NON-NLS-1$ - + public final static String FILE = "file"; //$NON-NLS-1$ - + public final static String SETUP = "setup"; //$NON-NLS-1$ public final static String EVENT_SETUP = "eventsetup"; //$NON-NLS-1$ public final static String TIMER_SETUP = "timersetup"; //$NON-NLS-1$ public final static String SETUP_COUNT = "setupcount"; //$NON-NLS-1$ public final static String EVENT_NAME = "eventname"; //$NON-NLS-1$ public final static String RTC_INTERRUPTS = "rtcinterrupts"; //$NON-NLS-1$ - + public final static String PROFILE = "profile"; //$NON-NLS-1$ public final static String MODEL_DATA = "model-data"; //$NON-NLS-1$ - + public final static String MODULE = "module"; //$NON-NLS-1$ public final static String DEPENDENT = "dependent"; //$NON-NLS-1$ - + public final static String BINARY = "binary"; //$NON-NLS-1$ public final static String IMAGE = "image"; //$NON-NLS-1$ - + public final static String SYMBOLS = "symbols"; //$NON-NLS-1$ public final static String SYMBOL_TABLE = "symboltable"; //$NON-NLS-1$ public final static String DETAIL_TABLE = "detailtable"; //$NON-NLS-1$ - + public final static String DETAIL_DATA = "detaildata"; //$NON-NLS-1$ - + private boolean isParseable; private Document newDoc; // the document we intend to build private Element oldRoot; // the root of the document with data from opreport private Element newRoot; // the root of the document we intent to build - + /** * Constructor to the ModelAdapter class * @param is The input stream to be parsed @@ -89,7 +89,7 @@ public class ModelDataAdapter extends AbstractDataAdapter { Document oldDoc = builder.parse(is); Element elem = (Element) oldDoc.getElementsByTagName(PROFILE).item(0); oldRoot = elem; - + newDoc = builder.newDocument(); newRoot = newDoc.createElement(MODEL_DATA); newDoc.appendChild(newRoot); @@ -102,25 +102,25 @@ public class ModelDataAdapter extends AbstractDataAdapter { e1.printStackTrace(); } } - + @Override public void process (){ createXML(); } private void createXML() { - + // get the binary name and the image count Element oldImage = (Element) oldRoot.getElementsByTagName(BINARY).item(0); Element newImage = newDoc.createElement(IMAGE); - + String binName = oldImage.getAttribute(NAME); newImage.setAttribute(NAME, binName); - + Element countTag = (Element) oldImage.getElementsByTagName(COUNT).item(0); String imageCount = countTag.getTextContent().trim(); newImage.setAttribute(COUNT, imageCount); - + // There is no setup count in timer mode if (!InfoAdapter.hasTimerSupport()){ // get the count that was used to profile @@ -129,34 +129,34 @@ public class ModelDataAdapter extends AbstractDataAdapter { String setupcount = eventSetupTag.getAttribute(SETUP_COUNT); newImage.setAttribute(SETUP_COUNT, setupcount); } - + // these elements contain the data needed to populate the new symbol table Element oldSymbolTableTag = (Element) oldRoot.getElementsByTagName(SYMBOL_TABLE).item(0); NodeList oldSymbolDataList = oldSymbolTableTag.getElementsByTagName(SYMBOL_DATA); - + Element oldDetailTableTag = (Element) oldRoot.getElementsByTagName(DETAIL_TABLE).item(0); NodeList oldDetailTableList = oldDetailTableTag.getElementsByTagName(SYMBOL_DETAILS); - + // parse the data into HashMaps for O(1) lookup time, as opposed to O(n). HashMap<String, HashMap<String, String>> oldSymbolDataListMap = parseDataList (oldSymbolDataList); HashMap<String, NodeList> oldDetailTableListMap = parseDetailTable (oldDetailTableList); - + // An ArrayList to hold the binary and other modules ArrayList<Element> oldImageList = new ArrayList<>(); // The first element is the original binary! - oldImageList.add(oldImage); - + oldImageList.add(oldImage); + NodeList oldModuleList = oldImage.getElementsByTagName(MODULE); // Set up the dependent tag for any modules run by this binary Element dependentTag = newDoc.createElement(DEPENDENT); if (oldModuleList.getLength() > 0){ dependentTag.setAttribute(COUNT, "0"); //$NON-NLS-1$ - + for (int t = 0; t < oldModuleList.getLength(); t++){ oldImageList.add((Element)oldModuleList.item(t)); } } - + // iterate through all (binary/modules) for (Element oldImg : oldImageList) { Element newImg; @@ -164,10 +164,10 @@ public class ModelDataAdapter extends AbstractDataAdapter { newImg = newImage; }else{ newImg = newDoc.createElement(IMAGE); - + String imgName = oldImg.getAttribute(NAME); newImg.setAttribute(NAME, imgName); - + Element modCountTag = (Element) oldImg.getElementsByTagName(COUNT).item(0); String imgCount = modCountTag.getTextContent().trim(); newImg.setAttribute(COUNT, imgCount); @@ -181,7 +181,7 @@ public class ModelDataAdapter extends AbstractDataAdapter { // iterate through all symbols for (int i = 0; i < oldSymbolList.getLength(); i++) { Element oldSymbol = (Element) oldSymbolList.item(i); - + /** * The original binary is a parent for all symbols * We only want library function calls under their respective @@ -190,7 +190,7 @@ public class ModelDataAdapter extends AbstractDataAdapter { if (!oldSymbol.getParentNode().isSameNode(oldImg)){ continue; } - + Element newSymbol = newDoc.createElement(SYMBOL); String idref = oldSymbol.getAttribute(IDREF); String symbolCount = ((Element) oldSymbol.getElementsByTagName(COUNT).item(0)).getTextContent().trim(); @@ -267,7 +267,7 @@ public class ModelDataAdapter extends AbstractDataAdapter { newSymbolsTag.appendChild(newSymbol); } - + newImg.appendChild(newSymbolsTag); // If this is a module, attach it to the dependent tag if (oldImg.getTagName().equals(MODULE)){ @@ -279,15 +279,15 @@ public class ModelDataAdapter extends AbstractDataAdapter { newRoot.appendChild(newImg); } } - + if (oldModuleList.getLength() > 0){ newImage.appendChild(dependentTag); } - + } /** - * + * * @param oldDetailTableList the list of 'symboldetails' tags within detailtable * @return a HashMap where the key is a function id and the value is a NodeList * containing a list of the 'detaildata' tags that contain sample information. @@ -304,7 +304,7 @@ public class ModelDataAdapter extends AbstractDataAdapter { } /** - * + * * @param oldSymbolDataList the list of 'symboldata' tags within symboltable * @return a Hashmap where the key is a function id and the value is a HashMap * with various parameters of data @@ -336,12 +336,12 @@ public class ModelDataAdapter extends AbstractDataAdapter { public Document getDocument() { return newDoc; } - + /** * Helper class to sort the samples of a given symbol in descending order from largest * to smallest */ - public static final Comparator<Element> SAMPLE_COUNT_ORDER = new Comparator<Element>() + private static final Comparator<Element> SAMPLE_COUNT_ORDER = new Comparator<Element>() { @Override public int compare(Element a, Element b) { @@ -352,12 +352,12 @@ public class ModelDataAdapter extends AbstractDataAdapter { Element b_countTag = (Element) b.getElementsByTagName(COUNT).item(0); Element a_LineTag = (Element) a.getElementsByTagName(LINE).item(0); Element b_LineTag = (Element) b.getElementsByTagName(LINE).item(0); - + Integer a_count = Integer.parseInt(a_countTag.getTextContent().trim()); Integer b_count = Integer.parseInt(b_countTag.getTextContent().trim()); Integer a_line = Integer.parseInt(a_LineTag.getTextContent().trim()); Integer b_line = Integer.parseInt(b_LineTag.getTextContent().trim()); - + if (a_count.compareTo(b_count) == 0){ return a_line.compareTo(b_line); } @@ -372,5 +372,5 @@ public class ModelDataAdapter extends AbstractDataAdapter { public boolean isParseable() { return isParseable; } - + } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataProcessor.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataProcessor.java index 607ccbd318..4441e76d24 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataProcessor.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/ModelDataProcessor.java @@ -59,7 +59,7 @@ public class ModelDataProcessor extends XMLProcessor { public void startElement(String name, Attributes attrs, Object callData) { if (name.equals(IMAGE_TAG)) { if (imgSeen == 0) { - image.setName(valid_string(attrs.getValue(ATTR_IMAGENAME))); + image.setName(validString(attrs.getValue(ATTR_IMAGENAME))); image.setCount(Integer.parseInt(attrs.getValue(ATTR_COUNT))); } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/SymbolsProcessor.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/SymbolsProcessor.java index 11ba53cd07..50288f4c14 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/SymbolsProcessor.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/modeldata/SymbolsProcessor.java @@ -57,9 +57,9 @@ public class SymbolsProcessor extends XMLProcessor { @Override public void startElement(String name, Attributes attrs, Object callData) { if (name.equals(SYMBOL_TAG)) { - symbol.setName(valid_string(attrs.getValue(ATTR_NAME))); + symbol.setName(validString(attrs.getValue(ATTR_NAME))); symbol.setCount(Integer.parseInt(attrs.getValue(ATTR_COUNT))); - symbol.setFilePath(valid_string(attrs.getValue(ATTR_FILE))); + symbol.setFilePath(validString(attrs.getValue(ATTR_FILE))); symbol.setLine(Integer.parseInt(attrs.getValue(ATTR_LINE))); } else if (name.equals(SAMPLE_TAG)) { OprofileSAXHandler.getInstance(callData).push(samplesProcessor); diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java index 72ea33f49b..151e4dc6d5 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionManager.java @@ -22,7 +22,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; @@ -61,7 +60,7 @@ public class SessionManager { /** * Session manager class constructor to manipulate the XML data - * + * * @param file * the xml file */ @@ -89,7 +88,7 @@ public class SessionManager { /** * Add a session to the specified event element if it does not exist. - * + * * @param sessionName * the name of the session * @param eventName @@ -115,7 +114,7 @@ public class SessionManager { /** * Check if a session exists - * + * * @param sessionName * the name of the session * @return true if the session exists, otherwise false @@ -126,7 +125,7 @@ public class SessionManager { /** * Find an element in the XML - * + * * @param elem * the element to look under * @param tagName @@ -179,7 +178,7 @@ public class SessionManager { /** * Remove a session named sessionName that is under eventName if it exists. - * + * * @param sessionName * @param eventName */ @@ -203,7 +202,7 @@ public class SessionManager { /** * remove event elem for given session sessionName , also remove session if * there is no event under it. - * + * * @param sessionName * @param elem * @@ -232,7 +231,7 @@ public class SessionManager { /** * Return a list of the events run with the given session - * + * * @param sessionName * the name of the session * @return A String ArrayList of event names that were run with the given @@ -270,7 +269,7 @@ public class SessionManager { /** * Write the contents of the given Document to a file. */ - public void writeToFile(String filePath) { + private void writeToFile(String filePath) { Source source = new DOMSource(doc); Result result = new StreamResult(new File(filePath)); TransformerFactory factory = TransformerFactory.newInstance(); @@ -278,8 +277,6 @@ public class SessionManager { try { xformer = factory.newTransformer(); xformer.transform(source, result); - } catch (TransformerConfigurationException e) { - e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java index f7f5bda1fe..a3a42553d8 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/sessions/SessionsProcessor.java @@ -62,7 +62,7 @@ public class SessionsProcessor extends XMLProcessor { @Override public void startElement(String name, Attributes attrs, Object callData) { if (name.equals(SESSION_TAG)) { - String sessionName = valid_string(attrs.getValue(SESSION_NAME_ATTR)); + String sessionName = validString(attrs.getValue(SESSION_NAME_ATTR)); currentSession = new OpModelSession(sessionName); eventList = new ArrayList<>(); } else if (name.equals(EVENT_TAG)) { diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java index bddd6efe34..0316113a67 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java @@ -223,7 +223,7 @@ AbstractLaunchConfigurationTab { * @param config * @return */ - public boolean validateEvents(ILaunchConfiguration config) { + private boolean validateEvents(ILaunchConfiguration config) { int numEnabledEvents = 0; boolean valid = true; @@ -379,7 +379,7 @@ AbstractLaunchConfigurationTab { * @return * @since 1.1 */ - protected IProject getProject(ILaunchConfiguration config){ + private IProject getProject(ILaunchConfiguration config){ String name = null; try { name = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ @@ -1253,8 +1253,7 @@ AbstractLaunchConfigurationTab { * @since 3.0 * */ - protected class HandleButtonClick implements Listener - { + protected class HandleButtonClick implements Listener { @Override public void handleEvent(Event event) { diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java index f8db7ed5c8..90e77cd96f 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java @@ -298,7 +298,7 @@ public abstract class AbstractOprofileLaunchConfigurationDelegate extends Profil } return null; } - + /** * * @param config diff --git a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java index 34af0762e5..27595d2ef1 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.remote.launch/src/org/eclipse/linuxtools/internal/oprofile/remote/core/linux/RemoteLinuxOpcontrolProvider.java @@ -37,14 +37,6 @@ public class RemoteLinuxOpcontrolProvider extends LinuxOpcontrolProvider { return p; } - protected String findOpcontrol(){ - return OPCONTROL_EXECUTABLE; - } - - public static boolean isInstalled(){ - return true; - } - /** * Checks if the user has permissions to execute opcontrol as root without providing password * and if opcontrol exists in the indicated path diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiMessages.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiMessages.java index 5ab697a218..bcf84ce48e 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiMessages.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiMessages.java @@ -7,32 +7,26 @@ * * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.ui; import java.util.MissingResourceException; import java.util.ResourceBundle; -public class OprofileUiMessages -{ +public class OprofileUiMessages { private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.oprofile.ui.oprofileui"; //$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - private OprofileUiMessages() - { + private OprofileUiMessages() { } - public static String getString(String key) - { - try - { + public static String getString(String key) { + try { return RESOURCE_BUNDLE.getString(key); - } - catch (MissingResourceException e) - { + } catch (MissingResourceException e) { return '!' + key + '!'; } } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiPlugin.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiPlugin.java index 5d68485572..7cb0d52da2 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiPlugin.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/OprofileUiPlugin.java @@ -7,16 +7,14 @@ * * Contributors: * Keith Seitz <keiths@redhat.com> - initial API and implementation - * Kent Sebastian <ksebasti@redhat.com> - - *******************************************************************************/ + * Kent Sebastian <ksebasti@redhat.com> - + *******************************************************************************/ package org.eclipse.linuxtools.internal.oprofile.ui; import java.text.DecimalFormat; import java.text.NumberFormat; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.linuxtools.internal.oprofile.ui.view.OprofileView; import org.eclipse.swt.widgets.Shell; @@ -33,7 +31,7 @@ public class OprofileUiPlugin extends AbstractUIPlugin { private static OprofileUiPlugin plugin; private OprofileView oprofileview = null; - + public static final String PLUGIN_ID = "org.eclipse.linuxtools.oprofile.ui"; //$NON-NLS-1$ public static final String ID_OPROFILE_VIEW = PLUGIN_ID + ".OProfileView"; //$NON-NLS-1$ @@ -45,9 +43,9 @@ public class OprofileUiPlugin extends AbstractUIPlugin { public static final String SYMBOL_ICON = ICON_PATH + "symbol.gif"; //$NON-NLS-1$ public static final String SAMPLE_ICON = ICON_PATH + "sample.gif"; //$NON-NLS-1$ public static final String ERROR_ICON = ICON_PATH + "error.png"; //$NON-NLS-1$ - + public static final double MINIMUM_SAMPLE_PERCENTAGE = 0.0001; - + public static final String ANNOTATION_TYPE_LT_MIN_PERCENTAGE = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.min.pct"; //$NON-NLS-1$ public static final String ANNOTATION_TYPE_LT_05 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.05.pct"; //$NON-NLS-1$ public static final String ANNOTATION_TYPE_LT_10 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.10.pct"; //$NON-NLS-1$ @@ -56,7 +54,7 @@ public class OprofileUiPlugin extends AbstractUIPlugin { public static final String ANNOTATION_TYPE_LT_40 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.40.pct"; //$NON-NLS-1$ public static final String ANNOTATION_TYPE_LT_50 = "org.eclipse.linuxtools.oprofile.ui.annotation.lt.50.pct"; //$NON-NLS-1$ public static final String ANNOTATION_TYPE_GT_50 = "org.eclipse.linuxtools.oprofile.ui.annotation.gt.50.pct"; //$NON-NLS-1$ - + /** * The constructor. */ @@ -80,8 +78,8 @@ public class OprofileUiPlugin extends AbstractUIPlugin { super.stop(context); plugin = null; } - - + + /** * Returns the shared instance. */ @@ -90,13 +88,6 @@ public class OprofileUiPlugin extends AbstractUIPlugin { } /** - * Returns the workspace instance. - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - /** * Returns an image descriptor for the image file at the given * plug-in relative path * @@ -106,8 +97,7 @@ public class OprofileUiPlugin extends AbstractUIPlugin { public static ImageDescriptor getImageDescriptor(String path) { return imageDescriptorFromPlugin(PLUGIN_ID, path); } - - + public OprofileView getOprofileView() { return oprofileview; } @@ -119,7 +109,7 @@ public class OprofileUiPlugin extends AbstractUIPlugin { public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } - + public static Shell getActiveWorkbenchShell() { IWorkbenchWindow window = getActiveWorkbenchWindow(); if (window != null) { @@ -127,14 +117,14 @@ public class OprofileUiPlugin extends AbstractUIPlugin { } return null; } - + public static String getPercentageString(double percentage) { NumberFormat nf = NumberFormat.getPercentInstance(); if (nf instanceof DecimalFormat) { nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); } - + if (percentage < OprofileUiPlugin.MINIMUM_SAMPLE_PERCENTAGE) { return "<" + nf.format(OprofileUiPlugin.MINIMUM_SAMPLE_PERCENTAGE); //$NON-NLS-1$ } else { diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileView.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileView.java index cb37a4fd9b..b4040e26c7 100755 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileView.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileView.java @@ -95,7 +95,7 @@ public class OprofileView extends ViewPart implements ISelectionChangedListener MenuManager sortMenu = new MenuManager( OprofileUiMessages.getString("view.menu.sortby.label")); //$NON-NLS-1$ - for (UiModelRoot.SORT_TYPE s : UiModelRoot.SORT_TYPE.values()) { + for (UiModelRoot.SortType s : UiModelRoot.SortType.values()) { sortMenu.add(new OprofileViewSortAction(s, OprofileViewSortAction.sortTypeMap.get(s))); } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java index 706ad01b82..a9aae5a2ac 100755 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewDeleteSessionAction.java @@ -74,8 +74,7 @@ public class OprofileViewDeleteSessionAction extends Action { } } - public static void deleteOperfDataFolder(IFolder operfData) - { + public static void deleteOperfDataFolder(IFolder operfData) { if(operfData.exists()) { try { operfData.delete(true,null); diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSortAction.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSortAction.java index 8d6f3443da..13f5aed309 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSortAction.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/internal/oprofile/ui/view/OprofileViewSortAction.java @@ -17,18 +17,18 @@ import org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot; */ public class OprofileViewSortAction extends Action { - public static Map<UiModelRoot.SORT_TYPE, String> sortTypeMap = new HashMap<>(); + public static Map<UiModelRoot.SortType, String> sortTypeMap = new HashMap<>(); static{ - sortTypeMap.put(UiModelRoot.SORT_TYPE.DEFAULT, OprofileUiMessages.getString("view.actions.default.label")); //$NON-NLS-1$ - sortTypeMap.put(UiModelRoot.SORT_TYPE.SESSION, OprofileUiMessages.getString("view.actions.session.label")); //$NON-NLS-1$ - sortTypeMap.put(UiModelRoot.SORT_TYPE.EVENT, OprofileUiMessages.getString("view.actions.event.label")); //$NON-NLS-1$ - sortTypeMap.put(UiModelRoot.SORT_TYPE.LIB, OprofileUiMessages.getString("view.actions.lib.label")); //$NON-NLS-1$ - sortTypeMap.put(UiModelRoot.SORT_TYPE.FUNCTION, OprofileUiMessages.getString("view.actions.function.label")); //$NON-NLS-1$ - sortTypeMap.put(UiModelRoot.SORT_TYPE.LINE_NO, OprofileUiMessages.getString("view.actions.line.label")); //$NON-NLS-1$ + sortTypeMap.put(UiModelRoot.SortType.DEFAULT, OprofileUiMessages.getString("view.actions.default.label")); //$NON-NLS-1$ + sortTypeMap.put(UiModelRoot.SortType.SESSION, OprofileUiMessages.getString("view.actions.session.label")); //$NON-NLS-1$ + sortTypeMap.put(UiModelRoot.SortType.EVENT, OprofileUiMessages.getString("view.actions.event.label")); //$NON-NLS-1$ + sortTypeMap.put(UiModelRoot.SortType.LIB, OprofileUiMessages.getString("view.actions.lib.label")); //$NON-NLS-1$ + sortTypeMap.put(UiModelRoot.SortType.FUNCTION, OprofileUiMessages.getString("view.actions.function.label")); //$NON-NLS-1$ + sortTypeMap.put(UiModelRoot.SortType.LINE_NO, OprofileUiMessages.getString("view.actions.line.label")); //$NON-NLS-1$ } - private UiModelRoot.SORT_TYPE sortType; + private UiModelRoot.SortType sortType; - public OprofileViewSortAction(UiModelRoot.SORT_TYPE sortType, String text) { + public OprofileViewSortAction(UiModelRoot.SortType sortType, String text) { super(text); this.sortType = sortType; } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelDependent.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelDependent.java index 291c809fa7..d61f046cc3 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelDependent.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelDependent.java @@ -72,7 +72,7 @@ public class UiModelDependent implements IUiModelElement { @Override public IUiModelElement[] getChildren() { - if (UiModelRoot.SORT_TYPE.LIB == UiModelRoot.getSortingType()) { + if (UiModelRoot.SortType.LIB == UiModelRoot.getSortingType()) { Arrays.sort(dependents, UiModelSorting.getInstance()); return dependents; } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelImage.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelImage.java index 2030fde444..e132474b1d 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelImage.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelImage.java @@ -94,7 +94,7 @@ public class UiModelImage implements IUiModelElement { children[i] = symbols[i]; } } - if (UiModelRoot.SORT_TYPE.FUNCTION == UiModelRoot.getSortingType()) { + if (UiModelRoot.SortType.FUNCTION == UiModelRoot.getSortingType()) { Arrays.sort(children, UiModelSorting.getInstance()); return children; } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java index 0bf961b625..68c3df1bdc 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelRoot.java @@ -81,7 +81,7 @@ public class UiModelRoot implements IUiModelElement { @Override public IUiModelElement[] getChildren() { if (session != null && session.length != 0) { - if (UiModelRoot.SORT_TYPE.SESSION == UiModelRoot.getSortingType()) { + if (UiModelRoot.SortType.SESSION == UiModelRoot.getSortingType()) { Arrays.sort(session, UiModelSorting.getInstance()); return session; } @@ -122,15 +122,13 @@ public class UiModelRoot implements IUiModelElement { * @since 3.0 * */ - public static enum SORT_TYPE{DEFAULT,SESSION,EVENT,LIB,FUNCTION,LINE_NO} - private static SORT_TYPE sortType; - public static void setSortingType(SORT_TYPE sortType) - { + public static enum SortType{DEFAULT,SESSION,EVENT,LIB,FUNCTION,LINE_NO} + private static SortType sortType; + public static void setSortingType(SortType sortType) { UiModelRoot.sortType = sortType; } - public static SORT_TYPE getSortingType() - { + public static SortType getSortingType() { return UiModelRoot.sortType; } } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java index 2d3b62d9bf..6a19f481d4 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSession.java @@ -13,7 +13,6 @@ package org.eclipse.linuxtools.oprofile.ui.model; import java.util.Arrays; import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelEvent; -import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot; import org.eclipse.linuxtools.internal.oprofile.core.model.OpModelSession; import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiMessages; import org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin; @@ -40,10 +39,10 @@ public class UiModelSession implements IUiModelElement { * @param session Oprofile session node in the data model */ public UiModelSession(OpModelSession session) { - if(session != null){ - this.session = session; - refreshModel(); - } + if (session != null) { + this.session = session; + refreshModel(); + } } private void refreshModel() { @@ -56,11 +55,6 @@ public class UiModelSession implements IUiModelElement { } - protected OpModelSession[] getModelDataSessions() { - OpModelRoot modelRoot = OpModelRoot.getDefault(); - return modelRoot.getSessions(); - } - @Override public String toString() { return session.getName(); @@ -92,7 +86,7 @@ public class UiModelSession implements IUiModelElement { */ @Override public IUiModelElement[] getChildren() { - if (UiModelRoot.SORT_TYPE.EVENT == UiModelRoot.getSortingType()) { + if (UiModelRoot.SortType.EVENT == UiModelRoot.getSortingType()) { Arrays.sort(events, UiModelSorting.getInstance()); return events; } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java index befb11c894..99d4a6c1fb 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.ui/src/org/eclipse/linuxtools/oprofile/ui/model/UiModelSymbol.java @@ -131,7 +131,7 @@ public class UiModelSymbol implements IUiModelElement { */ @Override public IUiModelElement[] getChildren() { - if (UiModelRoot.SORT_TYPE.LINE_NO == UiModelRoot.getSortingType()) { + if (UiModelRoot.SortType.LINE_NO == UiModelRoot.getSortingType()) { Arrays.sort(samples, UiModelSorting.getInstance()); return samples; } |