summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCamilo Bernal2012-05-30 09:50:57 (EDT)
committer Roland Grunberg2012-05-30 11:31:41 (EDT)
commit6593e16b8c5ef4774a6327fea867ac9fd0af1fc0 (patch)
tree460c7cb5cbb04c2fbd5c9a9e158fca3bf3093e8e
parentac4b8afc97ae388362c7af0daab791f6c55c506b (diff)
downloadorg.eclipse.linuxtools-6593e16b8c5ef4774a6327fea867ac9fd0af1fc0.zip
org.eclipse.linuxtools-6593e16b8c5ef4774a6327fea867ac9fd0af1fc0.tar.gz
org.eclipse.linuxtools-6593e16b8c5ef4774a6327fea867ac9fd0af1fc0.tar.bz2
Added ability to open perf data files in the Perf Viewer.
In the plug-in.xml file, an editor extension point is included in order to add a launcher (PerfOpenData.java) for perf data files. In order to properly report on the the perf file a configuration is needed. This is done in the createDefaultConfiguration (PerfOpenData.java), which creates a new default configuration based on the project's name. In PerfCore.java, it is not necesssary to differentiate between default events and multiple events, so now events are collected without having to check this. Changes were made to the current tests (ModelTest.java) to reflect the new change, which specifies what the "Default Event" is, namely "cycles".
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java4
-rw-r--r--perf/org.eclipse.linuxtools.perf/plugin.xml10
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java21
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java72
4 files changed, 85 insertions, 22 deletions
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
index 1cbef86..2c89964 100644
--- a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
+++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
@@ -167,7 +167,7 @@ public class ModelTest extends AbstractTest {
assertTrue(invisibleRoot.getChildren()[0] instanceof PMEvent);
PMEvent ev = (PMEvent)invisibleRoot.getChildren()[0];
- assertEquals("Default Event", ev.getName());
+ assertEquals("cycles", ev.getName());
assertTrue(ev.hasChildren());
assertEquals(1, ev.getChildren().length);
assertTrue(ev.getChildren()[0] instanceof PMCommand);
@@ -206,7 +206,7 @@ public class ModelTest extends AbstractTest {
assertTrue(invisibleRoot.getChildren()[0] instanceof PMEvent);
PMEvent ev = (PMEvent)invisibleRoot.getChildren()[0];
- assertEquals("Default Event", ev.getName());
+ assertEquals("cycles", ev.getName());
assertTrue(ev.hasChildren());
assertEquals(1, ev.getChildren().length);
assertTrue(ev.getChildren()[0] instanceof PMCommand);
diff --git a/perf/org.eclipse.linuxtools.perf/plugin.xml b/perf/org.eclipse.linuxtools.perf/plugin.xml
index dbdde71..c7013c0 100644
--- a/perf/org.eclipse.linuxtools.perf/plugin.xml
+++ b/perf/org.eclipse.linuxtools.perf/plugin.xml
@@ -94,5 +94,15 @@
id="org.eclipse.linuxtools.perf.launch.perfImage">
</launchConfigurationTypeImage>
</extension>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ default="true"
+ filenames="perf.data, perf.data.old"
+ id="org.eclipse.linuxtools.perf.editor"
+ launcher="org.eclipse.linuxtools.internal.perf.launch.PerfOpenData"
+ name="Perf Viewer">
+ </editor>
+ </extension>
</plugin>
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
index 1e691ce..87007a5 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
@@ -322,29 +322,13 @@ public class PerfCore {
PMFile currentFile = null;
PMSymbol currentSym = null;
try {
- //Set up the event parent depending on whats selected.
- if (config.getAttribute(PerfPlugin.ATTR_DefaultEvent, PerfPlugin.ATTR_DefaultEvent_default)) {
- currentEvent = new PMEvent("Default Event");
- invisibleRoot.addChild(currentEvent);
- } else if (!config.getAttribute(PerfPlugin.ATTR_MultipleEvents, PerfPlugin.ATTR_MultipleEvents_default)) {
- ArrayList<String> selE = (ArrayList<String>) config.getAttribute(PerfPlugin.ATTR_SelectedEvents, PerfPlugin.ATTR_SelectedEvents_default);
- if (selE != null) {
- currentEvent = new PMEvent(selE.get(0));
- } else {
- // this should never happen.
- currentEvent = new PMEvent("Error please fix profiling events chosen in launch config");
- }
- }
-
while (( line = input.readLine()) != null){
if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
//System.out.println("Reading line: " + line);
if ((line.startsWith("#"))) {
//if (PerfPlugin.DEBUG_ON) System.out.println("Reading line: " + line);
// # is comment line, but if we're in multi-event mode then we need to scan for event name.
- if (line.contains("Events:")
- && config.getAttribute(PerfPlugin.ATTR_MultipleEvents, PerfPlugin.ATTR_MultipleEvents_default)
- && !config.getAttribute(PerfPlugin.ATTR_DefaultEvent, PerfPlugin.ATTR_DefaultEvent_default)) {
+ if (line.contains("Events:")) {
String[] tmp = line.trim().split(" ");
currentEvent = new PMEvent(tmp[tmp.length - 1]);
//if (PerfPlugin.DEBUG_ON) System.out.println("Event is " + tmp[tmp.length - 1]);
@@ -387,9 +371,6 @@ public class PerfCore {
}
} catch (IOException e) {
e.printStackTrace();
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
spitStream(error,"Perf Report STDERR", print);
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java
new file mode 100644
index 0000000..f4a2794
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Camilo Bernal <cabernal@redhat.com> - Initial Implementation.
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.perf.launch;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.linuxtools.internal.perf.PerfCore;
+import org.eclipse.linuxtools.internal.perf.PerfPlugin;
+import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut;
+import org.eclipse.ui.IEditorLauncher;
+
+public class PerfOpenData extends ProfileLaunchShortcut implements
+ IEditorLauncher {
+
+ @Override
+ public void open(IPath file) {
+
+ // get project name of where the file resides.
+ String projectName = ResourcesPlugin.getWorkspace().getRoot()
+ .getFileForLocation(file).getProject().getName();
+ ILaunchConfiguration config = createDefaultConfiguration(projectName);
+ PerfCore.Report(config, null, null, null, file.toOSString(), null);
+ }
+
+ @Override
+ protected ILaunchConfigurationType getLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(
+ PerfPlugin.LAUNCHCONF_ID);
+ }
+
+ @Override
+ protected void setDefaultProfileAttributes(
+ ILaunchConfigurationWorkingCopy wc) throws CoreException {
+ wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
+ wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true);
+ }
+
+ /**
+ * Create an ILaunchConfiguration instance given the project's name.
+ *
+ * @param projectName
+ * @return ILaunchConfiguration based on String projectName
+ */
+ protected ILaunchConfiguration createDefaultConfiguration(String projectName) {
+ ILaunchConfiguration config = null;
+ try {
+ ILaunchConfigurationType configType = getLaunchConfigType();
+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(
+ null,
+ getLaunchManager().generateLaunchConfigurationName(
+ projectName));
+ config = (ILaunchConfiguration) wc;
+
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return config;
+ }
+} \ No newline at end of file