diff options
12 files changed, 288 insertions, 115 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java index cbe81b8b6d..d9fd8eb0aa 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java @@ -20,9 +20,9 @@ import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.Launch; import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions; import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin; -import org.eclipse.linuxtools.internal.oprofile.launch.configuration.LaunchOptions; -import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileEventConfigTab; import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileSetupTab; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.LaunchTestingOptions; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.OprofileTestingEventConfigTab; import org.eclipse.linuxtools.oprofile.launch.tests.utils.TestingOprofileLaunchConfigurationDelegate; import org.eclipse.linuxtools.profiling.tests.AbstractTest; import org.eclipse.swt.layout.GridLayout; @@ -59,8 +59,9 @@ public class TestLaunching extends AbstractTest { @Override protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) { - OprofileEventConfigTab configTab = new OprofileEventConfigTab(); + OprofileTestingEventConfigTab configTab = new OprofileTestingEventConfigTab(); OprofileSetupTab setupTab = new OprofileSetupTab(); + configTab.setOprofileProject(proj.getProject()); configTab.setDefaults(wc); setupTab.setDefaults(wc); } @@ -69,13 +70,14 @@ public class TestLaunching extends AbstractTest { TestingOprofileLaunchConfigurationDelegate delegate = new TestingOprofileLaunchConfigurationDelegate(); ILaunch launch = new Launch(config, ILaunchManager.PROFILE_MODE, null); - LaunchOptions options = new LaunchOptions(); + LaunchTestingOptions options = new LaunchTestingOptions(); + options.setOprofileProject(proj.getProject()); options.loadConfiguration(config); assertTrue(options.isValid()); assertEquals("", options.getBinaryImage()); //$NON-NLS-1$ assertEquals("", options.getKernelImageFile()); //$NON-NLS-1$ assertEquals(OprofileDaemonOptions.SEPARATE_NONE, options.getSeparateSamples()); - + delegate.launch(config, ILaunchManager.PROFILE_MODE, launch, null); assertTrue(delegate.eventsIsNull); assertNotNull(delegate._options); @@ -99,7 +101,8 @@ public class TestLaunching extends AbstractTest { wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(0), true); wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(0), 0); wc.doSave(); - LaunchOptions options = new LaunchOptions(); + LaunchTestingOptions options = new LaunchTestingOptions(); + options.setOprofileProject(proj.getProject()); options.loadConfiguration(config); assertTrue(options.isValid()); assertEquals("", options.getBinaryImage()); //$NON-NLS-1$ diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunchingExternalProject.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunchingExternalProject.java index 6931333170..b31351c6b7 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunchingExternalProject.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunchingExternalProject.java @@ -25,9 +25,9 @@ import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.Launch; import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions; import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin; -import org.eclipse.linuxtools.internal.oprofile.launch.configuration.LaunchOptions; -import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileEventConfigTab; import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileSetupTab; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.LaunchTestingOptions; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.OprofileTestingEventConfigTab; import org.eclipse.linuxtools.oprofile.launch.tests.utils.TestingOprofileLaunchConfigurationDelegate; import org.eclipse.linuxtools.profiling.tests.AbstractTest; import org.eclipse.swt.layout.GridLayout; @@ -80,7 +80,8 @@ public class TestLaunchingExternalProject extends AbstractTest { // Implemented abstract method of AbstractTest @Override protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) { - OprofileEventConfigTab configTab = new OprofileEventConfigTab(); + OprofileTestingEventConfigTab configTab = new OprofileTestingEventConfigTab(); + configTab.setOprofileProject(externalProject); OprofileSetupTab setupTab = new OprofileSetupTab(); configTab.setDefaults(wc); setupTab.setDefaults(wc); @@ -92,7 +93,8 @@ public class TestLaunchingExternalProject extends AbstractTest { * @throws CoreException */ public void testLaunchExternalProject() throws CoreException { - LaunchOptions options = new LaunchOptions(); + LaunchTestingOptions options = new LaunchTestingOptions(); + options.setOprofileProject(externalProject); options.loadConfiguration(config); TestingOprofileLaunchConfigurationDelegate delegate = new TestingOprofileLaunchConfigurationDelegate(); @@ -102,7 +104,7 @@ public class TestLaunchingExternalProject extends AbstractTest { assertEquals("", options.getBinaryImage()); //$NON-NLS-1$ assertEquals("", options.getKernelImageFile()); //$NON-NLS-1$ assertEquals(OprofileDaemonOptions.SEPARATE_NONE, options.getSeparateSamples()); - + delegate.launch(config, ILaunchManager.PROFILE_MODE, launch, null); assertTrue(delegate.eventsIsNull); assertNotNull(delegate._options); diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java index 2083510694..4ef3522a3f 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java @@ -18,13 +18,12 @@ import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.Launch; -import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonEvent; import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions; import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin; -import org.eclipse.linuxtools.internal.oprofile.launch.configuration.LaunchOptions; -import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileEventConfigTab; import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileSetupTab; -import org.eclipse.linuxtools.internal.oprofile.launch.launching.OprofileManualLaunchConfigurationDelegate; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.LaunchTestingOptions; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.OprofileTestingEventConfigTab; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.TestingOprofileLaunchConfigurationDelegate; import org.eclipse.linuxtools.profiling.tests.AbstractTest; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; @@ -32,36 +31,6 @@ import org.eclipse.swt.widgets.Shell; import org.osgi.framework.FrameworkUtil; public class TestManualLaunching extends AbstractTest { - private static class testingOprofileLaunchConfigurationDelegate extends OprofileManualLaunchConfigurationDelegate { - public boolean eventsIsNull; - public OprofileDaemonOptions _options; - @Override - protected void oprofileDumpSamples() { return; } - @Override - protected void oprofileReset() { return; } - @Override - protected void oprofileShutdown() { return; } - @Override - protected void oprofileStartCollection() { return; } - @Override - protected boolean oprofileStatus() { return true; } - @Override - protected void oprofileSetupDaemon(OprofileDaemonOptions options, OprofileDaemonEvent[] events) { - _options = options; - eventsIsNull = events == null ? true : false; - return; - } - @Override - protected void postExec(LaunchOptions options, OprofileDaemonEvent[] daemonEvents, Process process) { - super.postExec(options, daemonEvents, process); - - try { - process.waitFor(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } protected ILaunchConfiguration config; protected Shell testShell; @@ -89,23 +58,25 @@ public class TestManualLaunching extends AbstractTest { @Override protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) { - OprofileEventConfigTab configTab = new OprofileEventConfigTab(); + OprofileTestingEventConfigTab configTab = new OprofileTestingEventConfigTab(); OprofileSetupTab setupTab = new OprofileSetupTab(); + configTab.setOprofileProject(proj.getProject()); configTab.setDefaults(wc); setupTab.setDefaults(wc); } public void testDefaultLaunch() throws CoreException { - testingOprofileLaunchConfigurationDelegate delegate = new testingOprofileLaunchConfigurationDelegate(); + TestingOprofileLaunchConfigurationDelegate delegate = new TestingOprofileLaunchConfigurationDelegate(); ILaunch launch = new Launch(config, ILaunchManager.PROFILE_MODE, null); - LaunchOptions options = new LaunchOptions(); + LaunchTestingOptions options = new LaunchTestingOptions(); + options.setOprofileProject(proj.getProject()); options.loadConfiguration(config); assertTrue(options.isValid()); assertEquals("", options.getBinaryImage()); //$NON-NLS-1$ assertEquals("", options.getKernelImageFile()); //$NON-NLS-1$ assertEquals(OprofileDaemonOptions.SEPARATE_NONE, options.getSeparateSamples()); - + delegate.launch(config, ILaunchManager.PROFILE_MODE, launch, null); assertTrue(delegate.eventsIsNull); assertNotNull(delegate._options); @@ -117,7 +88,7 @@ public class TestManualLaunching extends AbstractTest { } public void testEventLaunch() throws CoreException { - testingOprofileLaunchConfigurationDelegate delegate = new testingOprofileLaunchConfigurationDelegate(); + TestingOprofileLaunchConfigurationDelegate delegate = new TestingOprofileLaunchConfigurationDelegate(); ILaunch launch = new Launch(config, ILaunchManager.PROFILE_MODE, null); ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); @@ -129,7 +100,8 @@ public class TestManualLaunching extends AbstractTest { wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(0), true); wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(0), 0); wc.doSave(); - LaunchOptions options = new LaunchOptions(); + LaunchTestingOptions options = new LaunchTestingOptions(); + options.setOprofileProject(proj.getProject()); options.loadConfiguration(config); assertTrue(options.isValid()); assertEquals("", options.getBinaryImage()); //$NON-NLS-1$ diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestSetup.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestSetup.java index 505cf4e6d4..57a96366ff 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestSetup.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestSetup.java @@ -19,8 +19,9 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions; import org.eclipse.linuxtools.internal.oprofile.launch.OprofileLaunchPlugin; -import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileEventConfigTab; import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileSetupTab; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.LaunchTestingOptions; +import org.eclipse.linuxtools.oprofile.launch.tests.utils.OprofileTestingEventConfigTab; import org.eclipse.linuxtools.profiling.tests.AbstractTest; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; @@ -33,11 +34,13 @@ import org.osgi.framework.FrameworkUtil; public class TestSetup extends AbstractTest { protected ILaunchConfiguration config; protected Shell testShell; + protected IProject project; @Override protected void setUp() throws Exception { super.setUp(); proj = createProjectAndBuild(FrameworkUtil.getBundle(this.getClass()), "primeTest"); //$NON-NLS-1$ + project = proj.getProject(); config = createConfiguration(proj.getProject()); testShell = new Shell(Display.getDefault()); testShell.setLayout(new GridLayout()); @@ -57,14 +60,22 @@ public class TestSetup extends AbstractTest { @Override protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) { - OprofileEventConfigTab configTab = new OprofileEventConfigTab(); + OprofileTestingEventConfigTab configTab = new OprofileTestingEventConfigTab(); OprofileSetupTab setupTab = new OprofileSetupTab(); + configTab.setOprofileProject(proj.getProject()); configTab.setDefaults(wc); setupTab.setDefaults(wc); } //getter functions for otherwise unaccessible member variables - private static class OprofileTestingSetupTab extends OprofileSetupTab { + private class OprofileTestingSetupTab extends OprofileSetupTab { + @Override + protected IProject getOprofileProject() { return proj.getProject(); } + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy config) { + options = new LaunchTestingOptions(); + options.saveConfiguration(config); + } protected Button getKernelCheck() { return checkSeparateKernel; } protected Button getLibraryCheck() { return checkSeparateLibrary; } protected Text getTextKernelImage() { return kernelImageFileText; } @@ -122,19 +133,7 @@ public class TestSetup extends AbstractTest { testPerformApply(tab, wc); assertTrue(tab.isValid(config)); } - - private static class OprofileTestingEventConfigTab extends OprofileEventConfigTab { - @Override - protected boolean getOprofileTimerMode() { return false; } - @Override - protected int getNumberOfOprofileCounters() { return 1; } - @Override - protected boolean checkEventSetupValidity(int counter, String name, int maskValue) { return true; } - @Override - protected boolean hasPermissions(IProject project) { return true; } - public Button getDefaultCheck() { return defaultEventCheck; } - } - + public void testEventConfigTab() throws CoreException { OprofileTestingEventConfigTab tab = new OprofileTestingEventConfigTab(); tab.createControl(new Shell()); diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/LaunchTestingOptions.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/LaunchTestingOptions.java new file mode 100644 index 0000000000..65f6550a43 --- /dev/null +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/LaunchTestingOptions.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Red Hat - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.oprofile.launch.tests.utils; + +import org.eclipse.core.resources.IProject; +import org.eclipse.linuxtools.internal.oprofile.launch.configuration.LaunchOptions; + +public class LaunchTestingOptions extends LaunchOptions { + private IProject project; + + public void setOprofileProject(IProject proj) { + project = proj; + } + + @Override + protected IProject getOprofileProject() { + return project; + } +} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/OprofileTestingEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/OprofileTestingEventConfigTab.java new file mode 100644 index 0000000000..d442147f4e --- /dev/null +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/OprofileTestingEventConfigTab.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Red Hat - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.oprofile.launch.tests.utils; + +import org.eclipse.core.resources.IProject; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent; +import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask; +import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask.MaskInfo; +import org.eclipse.linuxtools.internal.oprofile.launch.configuration.AbstractEventConfigTab; +import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter; +import org.eclipse.swt.widgets.Button; + +// mock event configuration tab +public class OprofileTestingEventConfigTab extends AbstractEventConfigTab { + private IProject project; + + @Override + protected boolean getOprofileTimerMode() { + return false; + } + + @Override + protected int getNumberOfOprofileCounters() { + return 1; + } + + @Override + protected boolean checkEventSetupValidity(int counter, String name, + int maskValue) { + return true; + } + + @Override + protected boolean hasPermissions(IProject project) { + return true; + } + + @Override + protected IProject getOprofileProject() { + return project; + } + + @Override + public void setOprofileProject(IProject proj) { + project = proj; + } + + @Override + protected void updateOprofileInfo() { + } + + public Button getDefaultCheck() { + return defaultEventCheck; + } + + @Override + protected OprofileCounter[] getOprofileCounters(ILaunchConfiguration config) { + // setup and return mock counters + OprofileCounter[] ctrs = new OprofileCounter[] { getOprofileCounter(1) }; + if (config != null) { + ctrs[0].loadConfiguration(config); + } + return ctrs; + } + + @Override + public OprofileCounter getOprofileCounter(int i) { + // mock mask info + MaskInfo maskInfo = new MaskInfo(); + maskInfo.description = "mock mask info"; //$NON-NLS-1$ + maskInfo.value = 0; + + MaskInfo[] maskInfoDescriptions = { maskInfo }; + + // mock mask + OpUnitMask mask = new OpUnitMask(); + mask.setDefault(0); + mask.setMaskDescriptions(maskInfoDescriptions); + mask.setType(0); + mask.setMaskFromIndex(0); + mask.setMaskValue(0); + + // mock events + OpEvent event = new OpEvent(); + event.setMinCount(1); + event.setText("mock-event"); //$NON-NLS-1$ + event.setTextDescription("Mock Event"); //$NON-NLS-1$ + event.setUnitMask(mask); + + OpEvent[] events = { event }; + + // mock counter + OprofileCounter ctr = new OprofileCounter(i, events); + ctr.setCount(1); + ctr.setEvent(event); + + return ctr; + } + +} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/TestingOprofileLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/TestingOprofileLaunchConfigurationDelegate.java index 96ef7b9c22..97a45642dc 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/TestingOprofileLaunchConfigurationDelegate.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/TestingOprofileLaunchConfigurationDelegate.java @@ -12,44 +12,79 @@ package org.eclipse.linuxtools.oprofile.launch.tests.utils; +import java.net.URI; + +import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonEvent; import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions; import org.eclipse.linuxtools.internal.oprofile.launch.configuration.LaunchOptions; +import org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter; import org.eclipse.linuxtools.internal.oprofile.launch.launching.OprofileLaunchConfigurationDelegate; /** * Helper delegate class - * + * * @author Red Hat Inc. * */ -public final class TestingOprofileLaunchConfigurationDelegate extends OprofileLaunchConfigurationDelegate { +public final class TestingOprofileLaunchConfigurationDelegate extends + OprofileLaunchConfigurationDelegate { public boolean eventsIsNull; - public OprofileDaemonOptions _options; + public OprofileDaemonOptions _options; + @Override - protected void oprofileDumpSamples() { return; } + protected void oprofileDumpSamples() { + return; + } + @Override - protected void oprofileReset() { return; } + protected void oprofileReset() { + return; + } + @Override - protected void oprofileShutdown() { return; } + protected void oprofileShutdown() { + return; + } + @Override - protected boolean oprofileStatus() { return true; } + protected boolean oprofileStatus() { + return true; + } + @Override - protected void oprofileStartCollection() { return; } + protected void oprofileStartCollection() { + return; + } + @Override - protected void oprofileSetupDaemon(OprofileDaemonOptions options, OprofileDaemonEvent[] events) { - _options = options; - eventsIsNull = events == null ? true : false; - return; + protected void oprofileSetupDaemon(OprofileDaemonOptions options, + OprofileDaemonEvent[] events) { + _options = options; + eventsIsNull = events == null ? true : false; + return; } + @Override - protected void postExec(LaunchOptions options, OprofileDaemonEvent[] daemonEvents, Process process) { + protected void postExec(LaunchOptions options, + OprofileDaemonEvent[] daemonEvents, Process process) { super.postExec(options, daemonEvents, process); - + try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); - } + } + } + + @Override + protected OprofileCounter[] oprofileCounters(ILaunchConfiguration config) { + return new OprofileCounter[0]; + + } + + @Override + protected URI oprofileWorkingDirURI(){ + return oprofileProject().getLocationURI(); } } 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 8e605aa228..79e8e1ff8f 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 @@ -1027,7 +1027,9 @@ public abstract class AbstractEventConfigTab extends public void setEnabled(boolean enabled) { if (unitMaskButtons != null) { for (Button b : unitMaskButtons) { - b.setEnabled(enabled); + if (!b.isDisposed()) { + b.setEnabled(enabled); + } } } } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java index c44f0b3117..b357b41e42 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/LaunchOptions.java @@ -13,6 +13,7 @@ package org.eclipse.linuxtools.internal.oprofile.launch.configuration; import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -42,7 +43,7 @@ public class LaunchOptions { public boolean isValid() { IRemoteFileProxy proxy = null; try { - proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject()); + proxy = RemoteProxyManager.getInstance().getFileProxy(getOprofileProject()); } catch (CoreException e) { e.printStackTrace(); } @@ -55,7 +56,15 @@ public class LaunchOptions { return true; } - + + /** + * Get project to profile + * @return IProject project to profile + */ + protected IProject getOprofileProject(){ + return Oprofile.OprofileProject.getProject(); + } + /** * Saves the global options of this object into the specified launch * configuration diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java index fe2f029d72..a8d25fc99c 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java @@ -49,9 +49,18 @@ public class OprofileCounter { * @param nr the counter number */ public OprofileCounter(int nr) { + this(nr, Oprofile.getEvents(nr)); + } + + /** + * Constructor for OprofileCounter. + * @param nr the counter number + * @param events the given events for counter number <code>nr</code> + */ + public OprofileCounter(int nr, OpEvent[] events) { number = nr; _enabled = false; - eventList = Oprofile.getEvents(number); + eventList = events; daemonEvent = new OprofileDaemonEvent(); } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java index c153534f7f..bf1392a3d2 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileSetupTab.java @@ -14,6 +14,7 @@ package org.eclipse.linuxtools.internal.oprofile.launch.configuration; import java.text.MessageFormat; import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -48,9 +49,6 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { protected Button checkSeparateLibrary; protected Button checkSeparateKernel; - //maybe these later -// protected Button _checkSeparateThread; -// protected Button _checkSeparateCpu; protected LaunchOptions options = null; @@ -63,7 +61,6 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { @Override public boolean isValid(ILaunchConfiguration config) { boolean b = options.isValid(); - // System.out.println("SetupTab isValid = " + b); return b; } @@ -87,10 +84,6 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { checkSeparateLibrary.setSelection(true); if ((separate & OprofileDaemonOptions.SEPARATE_KERNEL) != 0) checkSeparateKernel.setSelection(true); -// if ((separate & OprofileDaemonOptions.SEPARATE_THREAD) != 0) -// _checkSeparateThread.setSelection(true); -// if ((separate & OprofileDaemonOptions.SEPARATE_CPU) != 0) -// _checkSeparateCpu.setSelection(true); } } @@ -164,8 +157,6 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { checkSeparateLibrary = myCreateCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateLibrary.text")); //$NON-NLS-1$ checkSeparateKernel = myCreateCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateKernel.text")); //$NON-NLS-1$ -// _checkSeparateThread = _createCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateThread.text")); //$NON-NLS-1$ -// _checkSeparateCpu = _createCheckButton(p, OprofileLaunchMessages.getString("tab.global.check.separateCpu.text")); //$NON-NLS-1$ } // convenience method to create radio buttons with the given label @@ -199,18 +190,6 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { } else { newSeparate = oldSeparate & ~OprofileDaemonOptions.SEPARATE_KERNEL; } -// } else if (button == _checkSeparateThread) { -// if (button.getSelection()) { -// newSeparate = oldSeparate | OprofileDaemonOptions.SEPARATE_THREAD; -// } else { -// newSeparate = oldSeparate & ~OprofileDaemonOptions.SEPARATE_THREAD; -// } -// } else if (button == _checkSeparateCpu) { -// if (button.getSelection()) { -// newSeparate = oldSeparate | OprofileDaemonOptions.SEPARATE_CPU; -// } else { -// newSeparate = oldSeparate & ~OprofileDaemonOptions.SEPARATE_CPU; -// } } options.setSeparateSamples(newSeparate); @@ -225,7 +204,7 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { if (filename.length() > 0) { try { - proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject()); + proxy = RemoteProxyManager.getInstance().getFileProxy(getOprofileProject()); } catch (CoreException e) { e.printStackTrace(); } @@ -252,7 +231,7 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { // Displays a file dialog to allow the user to select the kernel image file private void showFileDialog(Shell shell) { try { - proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject()); + proxy = RemoteProxyManager.getInstance().getFileProxy(getOprofileProject()); } catch (CoreException e) { e.printStackTrace(); } @@ -287,4 +266,12 @@ public class OprofileSetupTab extends AbstractLaunchConfigurationTab { } } } + + /** + * Get project to profile + * @return IProject project to profile + */ + protected IProject getOprofileProject(){ + return Oprofile.OprofileProject.getProject(); + } } 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 35e4cc47c5..b9cd069c22 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 @@ -59,7 +59,7 @@ public abstract class AbstractOprofileLaunchConfigurationDelegate extends Profil OprofileDaemonEvent[] daemonEvents = null; if (!config.getAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false)) { //get the events to profile from the counters - OprofileCounter[] counters = OprofileCounter.getCounters(config); + OprofileCounter[] counters = oprofileCounters(config); ArrayList<OprofileDaemonEvent> events = new ArrayList<OprofileDaemonEvent>(); for (int i = 0; i < counters.length; ++i) { @@ -78,10 +78,8 @@ public abstract class AbstractOprofileLaunchConfigurationDelegate extends Profil * originally in the CDT under LocalCDILaunchDelegate::RunLocalApplication */ //set up and launch the local c/c++ program - IRemoteCommandLauncher launcher = RemoteProxyManager.getInstance().getLauncher(Oprofile.OprofileProject.getProject()); - IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(Oprofile.OprofileProject.getProject()); - URI workingDirURI = proxy.getWorkingDir(); - IPath workingDirPath = new Path(workingDirURI.getPath()); + IRemoteCommandLauncher launcher = RemoteProxyManager.getInstance().getLauncher(oprofileProject()); + IPath workingDirPath = new Path(oprofileWorkingDirURI().getPath()); String arguments[] = getProgramArgumentsArray( config ); Process process = launcher.execute(exePath, arguments, getEnvironment(config), workingDirPath, monitor); @@ -138,6 +136,27 @@ public abstract class AbstractOprofileLaunchConfigurationDelegate extends Profil OprofileCorePlugin.getDefault().getOpcontrolProvider().dumpSamples(); } + protected IProject oprofileProject(){ + return Oprofile.OprofileProject.getProject(); + } + + + /** + * Return the URI of the current working directory from the current + * project's file proxy. + * + * @return URI URI of the working directory. + * @throws CoreException + */ + protected URI oprofileWorkingDirURI() throws CoreException{ + IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(oprofileProject()); + return proxy.getWorkingDir(); + } + + protected OprofileCounter[] oprofileCounters(ILaunchConfiguration config){ + return OprofileCounter.getCounters(config); + } + /** * Runs opcontrol --help. Returns true if there was any output, false * otherwise. Return value can be used to tell if the user successfully |