Search in sources :

Example 81 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class AbstractProfilingOptionsTab method setProvider.

/**
 * Set the provider attribute in the specified configuration.
 * @param providerId The new provider id.
 */
private void setProvider(String providerId) {
    try {
        ILaunchConfigurationWorkingCopy wc = initial.getWorkingCopy();
        wc.setAttribute(ProviderProfileConstants.PROVIDER_CONFIG_ATT, providerId);
        initial = wc.doSave();
    } catch (CoreException e1) {
        e1.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 82 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class ProviderLaunchConfigurationDelegate method launch.

@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    if (config != null) {
        // get provider id from configuration.
        String providerId = config.getAttribute(ProviderProfileConstants.PROVIDER_CONFIG_ATT, // $NON-NLS-1$
        "");
        String providerToolName = config.getAttribute(ProviderProfileConstants.PROVIDER_CONFIG_TOOLNAME_ATT, // $NON-NLS-1$
        "");
        if (providerId == null || providerId.isEmpty()) {
            // $NON-NLS-1$
            String cProjectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
            if (cProjectName != null && !cProjectName.isEmpty()) {
                // We have a previously created C/C++ run/debug configuration and now Linux Tools
                // profiling framework has been added.  Find a suitable default provider id to use
                // and perform initialization prior to profiling.
                String defaultType = null;
                String[] categories = ProviderFramework.getProviderCategories();
                if (categories.length == 0) {
                    infoDialog(Messages.ProviderNoProfilers_title_0, Messages.ProviderNoProfilers_msg_0);
                    return;
                }
                for (String category : categories) {
                    // Give precedence to timing category if present
                    if (category.equals("timing")) {
                        // $NON-NLS-1$
                        // $NON-NLS-1$
                        defaultType = "timing";
                    }
                }
                // if default category still not set, take first one found
                if (defaultType == null)
                    defaultType = categories[0];
                providerId = ProviderFramework.getProviderIdToRun(null, defaultType);
                ProfileLaunchConfigurationTabGroup tabGroupConfig = ProviderFramework.getTabGroupProviderFromId(providerId);
                if (tabGroupConfig == null) {
                    infoDialog(Messages.ProviderNoProfilers_title_0, Messages.ProviderNoProfilers_msg_0);
                    return;
                }
                AbstractLaunchConfigurationTab[] tabs = tabGroupConfig.getProfileTabs();
                // Set up defaults according to profiling tabs.  We must use a working copy
                // to do this which we save at the end to the original copy.
                ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
                for (ILaunchConfigurationTab tab : tabs) {
                    tab.setDefaults(wc);
                }
                config = wc.doSave();
            }
        }
        // get delegate associated with provider id.
        AbstractCLaunchDelegate delegate = ProviderFramework.getConfigurationDelegateFromId(providerId);
        // launch delegate
        if (delegate != null) {
            try {
                delegate.launch(config, mode, launch, monitor);
            } catch (CoreException e) {
                errorDialog(Messages.ProviderLaunchError_msg_0, e.getMessage());
            }
        } else {
            String message = providerToolName.isEmpty() ? NLS.bind(Messages.ProviderProfilerMissing_msg_0, providerId) : NLS.bind(Messages.ProviderProfilerMissing_msg_1, providerToolName);
            infoDialog(Messages.ProviderProfilerMissing_title_0, message);
        }
    }
}
Also used : AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) CoreException(org.eclipse.core.runtime.CoreException) ProfileLaunchConfigurationTabGroup(org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) AbstractCLaunchDelegate(org.eclipse.cdt.launch.AbstractCLaunchDelegate) ILaunchConfigurationTab(org.eclipse.debug.ui.ILaunchConfigurationTab)

Example 83 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class AbstractTest method createConfiguration.

protected ILaunchConfiguration createConfiguration(IProject proj) throws CoreException {
    String projectName = proj.getName();
    String binPath = "";
    ILaunchConfigurationType configType = getLaunchConfigType();
    ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(projectName));
    if (proj.getLocation() == null) {
        IFileStore fileStore = null;
        try {
            fileStore = EFS.getStore(new URI(proj.getLocationURI() + BIN_DIR + IPath.SEPARATOR + projectName));
        } catch (URISyntaxException e) {
            fail(NLS.bind(Messages.getString("AbstractTest.No_binary"), // $NON-NLS-1$
            projectName));
        }
        if ((fileStore instanceof LocalFile)) {
            fail(NLS.bind(Messages.getString("AbstractTest.No_binary"), // $NON-NLS-1$
            projectName));
        }
        binPath = EFSExtensionManager.getDefault().getPathFromURI(proj.getLocationURI()) + BIN_DIR + IPath.SEPARATOR + proj.getName();
    } else {
        IResource bin = proj.findMember(new Path(BIN_DIR).append(projectName));
        if (bin == null) {
            fail(NLS.bind(Messages.getString("AbstractTest.No_binary"), // $NON-NLS-1$
            projectName));
        }
        binPath = bin.getProjectRelativePath().toString();
        wc.setMappedResources(new IResource[] { bin, proj });
    }
    wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, binPath);
    wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
    wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
    // Make launch run in foreground
    wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
    setProfileAttributes(wc);
    return wc.doSave();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) LocalFile(org.eclipse.core.internal.filesystem.local.LocalFile) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) IFileStore(org.eclipse.core.filesystem.IFileStore) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) IResource(org.eclipse.core.resources.IResource)

Example 84 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class ModelTest method testReportString.

@Test
public void testReportString() throws CoreException {
    ILaunchConfigurationWorkingCopy tempConfig = null;
    tempConfig = config.copy("test-config");
    tempConfig.setAttribute(PerfPlugin.ATTR_Kernel_Location, "/boot/kernel");
    tempConfig.setAttribute(PerfPlugin.ATTR_ModuleSymbols, true);
    String[] reportString = PerfCore.getReportString(tempConfig, "resources/defaultevent-data/perf.data");
    assertNotNull(reportString);
    String[] expectedString = { PerfPlugin.PERF_COMMAND, "report", "--sort", "comm,dso,sym", "-n", "-t", "" + (char) 1, "--vmlinux", "/boot/kernel", "-m", "-i", "resources/defaultevent-data/perf.data" };
    assertArrayEquals(expectedString, reportString);
}
Also used : ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 85 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class TestLaunching method testEventLaunch.

@Test
public void testEventLaunch() throws CoreException {
    TestingOprofileLaunchConfigurationDelegate delegate = new TestingOprofileLaunchConfigurationDelegate();
    ILaunch launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    wc.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false);
    wc.setAttribute(OprofileLaunchPlugin.attrConterEnabled(0), true);
    wc.setAttribute(OprofileLaunchPlugin.attrCounterCount(0), 100000);
    // $NON-NLS-1$
    wc.setAttribute(OprofileLaunchPlugin.attrConterEvent(0, 0), "FAKE_EVENT");
    wc.setAttribute(OprofileLaunchPlugin.attrCounterProfileKernel(0), true);
    wc.setAttribute(OprofileLaunchPlugin.attrCounterProfileUser(0), true);
    wc.setAttribute(OprofileLaunchPlugin.attrCounterUnitMask(0), 0);
    wc.doSave();
    LaunchTestingOptions options = new LaunchTestingOptions();
    options.setOprofileProject(proj.getProject());
    options.loadConfiguration(config);
    assertTrue(options.isValid());
    assertTrue(options.getBinaryImage().isEmpty());
    assertTrue(options.getKernelImageFile().isEmpty());
    assertEquals(OprofileDaemonOptions.SEPARATE_NONE, options.getSeparateSamples());
    Oprofile.OprofileProject.setProfilingBinary(Oprofile.OprofileProject.OPERF_BINARY);
    delegate.launch(config, ILaunchManager.PROFILE_MODE, launch, null);
}
Also used : LaunchTestingOptions(org.eclipse.linuxtools.oprofile.launch.tests.utils.LaunchTestingOptions) TestingOprofileLaunchConfigurationDelegate(org.eclipse.linuxtools.oprofile.launch.tests.utils.TestingOprofileLaunchConfigurationDelegate) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Launch(org.eclipse.debug.core.Launch) ILaunch(org.eclipse.debug.core.ILaunch) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Aggregations

ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)119 Test (org.junit.Test)75 ILaunch (org.eclipse.debug.core.ILaunch)52 IProcess (org.eclipse.debug.core.model.IProcess)49 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)29 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)18 CoreException (org.eclipse.core.runtime.CoreException)16 IPath (org.eclipse.core.runtime.IPath)12 ILaunchManager (org.eclipse.debug.core.ILaunchManager)10 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)8 IProject (org.eclipse.core.resources.IProject)7 Shell (org.eclipse.swt.widgets.Shell)7 ArrayList (java.util.ArrayList)6 Path (org.eclipse.core.runtime.Path)6 ILaunchConfigurationTab (org.eclipse.debug.ui.ILaunchConfigurationTab)5 Version (org.osgi.framework.Version)5 IResource (org.eclipse.core.resources.IResource)4 Launch (org.eclipse.debug.core.Launch)3 MassifViewPart (org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart)3 Button (org.eclipse.swt.widgets.Button)3