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();
}
}
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);
}
}
}
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();
}
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);
}
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);
}
Aggregations