use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.
the class SystemTapScriptLaunchConfigurationDelegate method preLaunchCheck.
@Override
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
// Force the configuration to use the proper Process Factory.
if (!configuration.getAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, "").equals(SystemTapRuntimeProcessFactory.PROCESS_FACTORY_ID)) {
// $NON-NLS-1$
ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
wc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, SystemTapRuntimeProcessFactory.PROCESS_FACTORY_ID);
wc.doSave();
}
// Find the parent project of the target script.
IPath path = Path.fromOSString(configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.SCRIPT_PATH_ATTR, (String) null));
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
scriptProject = file == null ? null : new IProject[] { file.getProject() };
// Only save the target script's project if a project is found.
if (scriptProject != null) {
return super.preLaunchCheck(configuration, mode, monitor);
}
return true;
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.
the class SystemTapScriptLaunchShortcut method findLaunchConfiguration.
private ILaunchConfiguration findLaunchConfiguration(String scriptPath, String scriptProject) {
ILaunchConfiguration configuration = null;
ArrayList<ILaunchConfiguration> candidateConfigurations = new ArrayList<>();
try {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfiguration[] configs = launchManager.getLaunchConfigurations(getLaunchConfigType());
for (ILaunchConfiguration config : configs) {
if (config.getAttribute(SystemTapScriptLaunchConfigurationTab.SCRIPT_PATH_ATTR, "").equals(scriptPath)) {
// $NON-NLS-1$
candidateConfigurations.add(config);
}
}
int candidateCount = candidateConfigurations.size();
if (candidateCount == 0) {
LinkedList<String> configNames = new LinkedList<>();
configs = launchManager.getLaunchConfigurations();
for (ILaunchConfiguration config : configs) {
configNames.add(config.getName());
}
String configName = // $NON-NLS-1$ //$NON-NLS-2$
(scriptProject == null ? "" : scriptProject + " ") + Path.fromOSString(scriptPath).lastSegment();
String wcName = configName;
int conflict_index, conflict_count = 0;
while ((conflict_index = configNames.indexOf(wcName)) != -1) {
// $NON-NLS-1$
wcName = configName.concat(String.format(" (%d)", ++conflict_count));
configNames.remove(conflict_index);
}
ILaunchConfigurationType type = getLaunchConfigType();
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, wcName);
wc.setAttribute(SystemTapScriptLaunchConfigurationTab.SCRIPT_PATH_ATTR, scriptPath);
configuration = wc.doSave();
} else if (candidateCount == 1) {
configuration = candidateConfigurations.get(0);
} else {
configuration = chooseConfiguration(candidateConfigurations, ILaunchManager.RUN_MODE);
}
} catch (CoreException e) {
ExceptionErrorDialog.openError(Messages.SystemTapScriptLaunchShortcut_couldNotFindConfig, e);
}
return configuration;
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.
the class VagrantConnection method rtCall.
private static void rtCall(String[] args, File vagrantDir, Map<String, String> environment) {
// org.eclipse.core.externaltools.internal.IExternalToolConstants
// $NON-NLS-1$
final String EXTERNAL_TOOLS = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType";
// $NON-NLS-1$
final String UI_PLUGIN_ID = "org.eclipse.ui.externaltools";
// $NON-NLS-1$
final String ATTR_LOCATION = UI_PLUGIN_ID + ".ATTR_LOCATION";
// $NON-NLS-1$
final String ATTR_TOOL_ARGUMENTS = UI_PLUGIN_ID + ".ATTR_TOOL_ARGUMENTS";
// $NON-NLS-1$
final String ATTR_WORKING_DIRECTORY = UI_PLUGIN_ID + ".ATTR_WORKING_DIRECTORY";
String arguments = Arrays.asList(args).stream().map(u -> u.toString()).collect(// $NON-NLS-1$
Collectors.joining(" "));
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType(EXTERNAL_TOOLS);
try {
// TODO: worth handling 'vagrant' (not on PATH) as an alias ?
String vagrantPath = findVagrantPath();
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, VG);
wc.setAttribute(ATTR_LOCATION, vagrantPath);
wc.setAttribute(ATTR_TOOL_ARGUMENTS, arguments);
wc.setAttribute(ATTR_WORKING_DIRECTORY, vagrantDir != null ? vagrantDir.getAbsolutePath() : null);
wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, environment);
wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
} catch (CoreException e1) {
Activator.log(e1);
}
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.
the class ConfigurationTest method testConfig.
/**
* This test checks if the commands sent by SystemTap match exactly the options
* that are set. Uses the delegate.launch() function.
*
* Activates all options!
* @throws CoreException
*/
@Test
public void testConfig() throws CoreException {
LaunchStapGraph shortcut = new LaunchStapGraph();
String testCDirectives = "-DRandomjunk -DMoreJunk";
String testOutputPath = "/tmp/ThisFileDoesNothingDeleteIt";
String testBinaryPath = "/path/to/binary";
String testScriptPath = "/tmp/NotAScriptFile.stp";
String testArguments = "/path/to/binary";
int testPid = 413;
int testBuffer = 100;
int testPass = 10;
ILaunchConfiguration config = shortcut.outsideGetLaunchConfigType().newInstance(null, "Temp name");
ILaunchConfigurationWorkingCopy wc = config.copy("Testing configuration");
wc.setAttribute(LaunchConfigurationConstants.COMMAND_VERBOSE, 1);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_KEEP_TEMPORARY, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_GURU, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_PROLOGUE_SEARCH, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_NO_CODE_ELISION, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_DISABLE_WARNINGS, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_BULK_MODE, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_TIMING_INFO, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_SKIP_BADVARS, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_IGNORE_DWARF, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_TAPSET_COVERAGE, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_LEAVE_RUNNING, true);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_PASS, testPass);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_BUFFER_BYTES, testBuffer);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_TARGET_PID, testPid);
wc.setAttribute(LaunchConfigurationConstants.COMMAND_C_DIRECTIVES, testCDirectives);
wc.setAttribute(LaunchConfigurationConstants.BINARY_PATH, testBinaryPath);
wc.setAttribute(LaunchConfigurationConstants.SCRIPT_PATH, testScriptPath);
wc.setAttribute(LaunchConfigurationConstants.ARGUMENTS, testArguments);
wc.setAttribute(LaunchConfigurationConstants.OUTPUT_PATH, testOutputPath);
config = wc.doSave();
SystemTapLaunchConfigurationDelegate del = new SystemTapLaunchConfigurationDelegate();
del.launch(config, "profile", null, null);
assertEquals("stap -v -p" + testPass + " -k -g -P -u -w -b -t -s" + testBuffer + " -x" + testPid + " " + testCDirectives + " -F --skip-badvars --ignore-dwarf -q " + " -c '" + testBinaryPath + "' " + testScriptPath + " --runtime=dyninst " + testArguments + " >& " + testOutputPath, del.generateCommand());
killStap();
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.
the class SystemTapTabTest method testTabs.
@Test
public void testTabs() throws CoreException {
Shell sh = new Shell();
Composite cmp = new Composite(sh, SWT.NONE);
LaunchStapGraph shortCut = new LaunchStapGraph();
SystemTapOptionsTab stp = new SystemTapOptionsTab();
stp.createControl(cmp);
ILaunchConfiguration configuration;
configuration = shortCut.outsideGetLaunchConfigType().newInstance(null, (DebugPlugin.getDefault().getLaunchManager()).generateLaunchConfigurationName("invalid"));
ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
stp.setDefaults(wc);
stp.performApply(wc);
wc.doSave();
stp.initializeFrom(configuration);
sh.open();
}
Aggregations