use of org.eclipse.cdt.core.model.IBinary in project linuxtools by eclipse.
the class SystemTapOptionsTab method setDefaults.
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_VERBOSE, LaunchConfigurationConstants.DEFAULT_COMMAND_VERBOSE);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_KEEP_TEMPORARY, LaunchConfigurationConstants.DEFAULT_COMMAND_KEEP_TEMPORARY);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_GURU, LaunchConfigurationConstants.DEFAULT_COMMAND_GURU);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_PROLOGUE_SEARCH, LaunchConfigurationConstants.DEFAULT_COMMAND_PROLOGUE_SEARCH);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_NO_CODE_ELISION, LaunchConfigurationConstants.DEFAULT_COMMAND_NO_CODE_ELISION);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_DISABLE_WARNINGS, LaunchConfigurationConstants.DEFAULT_COMMAND_DISABLE_WARNINGS);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_BULK_MODE, LaunchConfigurationConstants.DEFAULT_COMMAND_BULK_MODE);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_TIMING_INFO, LaunchConfigurationConstants.DEFAULT_COMMAND_TIMING_INFO);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_SKIP_BADVARS, LaunchConfigurationConstants.DEFAULT_COMMAND_SKIP_BADVARS);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_IGNORE_DWARF, LaunchConfigurationConstants.DEFAULT_COMMAND_IGNORE_DWARF);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_TAPSET_COVERAGE, LaunchConfigurationConstants.DEFAULT_COMMAND_TAPSET_COVERAGE);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_LEAVE_RUNNING, LaunchConfigurationConstants.DEFAULT_COMMAND_LEAVE_RUNNING);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_PASS, LaunchConfigurationConstants.DEFAULT_COMMAND_PASS);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_BUFFER_BYTES, LaunchConfigurationConstants.DEFAULT_COMMAND_BUFFER_BYTES);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_TARGET_PID, LaunchConfigurationConstants.DEFAULT_COMMAND_TARGET_PID);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_C_DIRECTIVES, LaunchConfigurationConstants.DEFAULT_COMMAND_C_DIRECTIVES);
configuration.setAttribute(LaunchConfigurationConstants.BINARY_PATH, LaunchConfigurationConstants.DEFAULT_BINARY_PATH);
configuration.setAttribute(LaunchConfigurationConstants.SCRIPT_PATH, LaunchConfigurationConstants.DEFAULT_SCRIPT_PATH);
configuration.setAttribute(LaunchConfigurationConstants.OUTPUT_PATH, LaunchConfigurationConstants.DEFAULT_OUTPUT_PATH);
configuration.setAttribute(LaunchConfigurationConstants.ARGUMENTS, LaunchConfigurationConstants.DEFAULT_ARGUMENTS);
configuration.setAttribute(LaunchConfigurationConstants.BINARY_ARGUMENTS, LaunchConfigurationConstants.DEFAULT_BINARY_ARGUMENTS);
configuration.setAttribute(LaunchConfigurationConstants.GENERATED_SCRIPT, LaunchConfigurationConstants.DEFAULT_GENERATED_SCRIPT);
configuration.setAttribute(LaunchConfigurationConstants.NEED_TO_GENERATE, LaunchConfigurationConstants.DEFAULT_NEED_TO_GENERATE);
configuration.setAttribute(LaunchConfigurationConstants.PARSER_CLASS, LaunchConfigurationConstants.DEFAULT_PARSER_CLASS);
configuration.setAttribute(LaunchConfigurationConstants.VIEW_CLASS, LaunchConfigurationConstants.DEFAULT_VIEW_CLASS);
configuration.setAttribute(LaunchConfigurationConstants.USE_COLOUR, LaunchConfigurationConstants.DEFAULT_USE_COLOUR);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_LIST, ConfigurationOptionsSetter.setOptions(configuration));
ICElement cElement = null;
cElement = getContext(configuration, getPlatform(configuration));
if (cElement != null) {
initializeCProject(cElement, configuration);
} else {
// don't want to remember the interim value from before
configuration.setMappedResources(null);
}
IBinary bin = getBinary(configuration);
if (bin != null) {
String programName = bin.getResource().getProjectRelativePath().toString();
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programName);
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
LaunchStapGraph launch = new LaunchStapGraph();
// Do not run callgraph
launch.setTestMode(true);
// $NON-NLS-1$
launch.launch(bin, "", configuration);
}
}
use of org.eclipse.cdt.core.model.IBinary in project linuxtools by eclipse.
the class OpenGmonAction method getDefaultBinary.
private String getDefaultBinary(IPath file) {
IProject project = null;
IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file);
if (c != null) {
project = c.getProject();
if (project != null && project.exists()) {
ICProject cproject = CoreModel.getDefault().create(project);
if (cproject != null) {
try {
IBinary[] b = cproject.getBinaryContainer().getBinaries();
if (b != null && b.length > 0 && b[0] != null) {
IResource r = b[0].getResource();
return r.getLocation().toOSString();
}
} catch (CModelException e) {
}
}
}
}
// $NON-NLS-1$
return "";
}
use of org.eclipse.cdt.core.model.IBinary in project linuxtools by eclipse.
the class ProfileLaunchShortcut method searchAndLaunch.
/**
* Search and launch binary.
*
* @param elements Binaries to search.
* @param mode Launch mode.
*/
private void searchAndLaunch(final Object[] elements, String mode) {
if (elements != null && elements.length > 0) {
IBinary bin = null;
if (elements.length == 1 && elements[0] instanceof IBinary) {
bin = (IBinary) elements[0];
} else {
final List<IBinary> results = new ArrayList<>();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getActiveWorkbenchShell());
IRunnableWithProgress runnable = pm -> {
int nElements = elements.length;
pm.beginTask(Messages.ProfileLaunchShortcut_Looking_for_executables, nElements);
try {
IProgressMonitor sub = SubMonitor.convert(pm, 1);
for (int i = 0; i < nElements; i++) {
if (elements[i] instanceof IAdaptable) {
IResource r = ((IAdaptable) elements[i]).getAdapter(IResource.class);
if (r != null) {
ICProject cproject = CoreModel.getDefault().create(r.getProject());
if (cproject != null) {
try {
IBinary[] bins = cproject.getBinaryContainer().getBinaries();
for (IBinary bin1 : bins) {
if (bin1.isExecutable()) {
results.add(bin1);
}
}
} catch (CModelException e) {
// TODO should this be simply ignored ?
}
}
}
}
if (pm.isCanceled()) {
throw new InterruptedException();
}
sub.done();
}
} finally {
pm.done();
}
};
try {
dialog.run(true, true, runnable);
} catch (InterruptedException e) {
return;
} catch (InvocationTargetException e) {
handleFail(e.getMessage());
return;
}
int count = results.size();
if (count == 0) {
handleFail(Messages.ProfileLaunchShortcut_Binary_not_found);
} else if (count > 1) {
bin = chooseBinary(results, mode);
} else {
bin = results.get(0);
}
}
if (bin != null) {
launch(bin, mode);
}
} else {
handleFail(Messages.ProfileLaunchShortcut_no_project_selected);
}
}
use of org.eclipse.cdt.core.model.IBinary in project linuxtools by eclipse.
the class ProfileLaunchShortcut method chooseBinary.
/**
* Prompts the user to select a binary
* @param binList The list of binaries.
* @param mode Old and not used parameter.
*
* @return the selected binary or <code>null</code> if none.
*/
// TODO remove unused mode parameter for 4.0
protected IBinary chooseBinary(List<IBinary> binList, String mode) {
ILabelProvider programLabelProvider = new CElementLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IBinary) {
return ((IBinary) element).getPath().lastSegment();
}
return super.getText(element);
}
};
ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IBinary) {
IBinary bin = (IBinary) element;
StringBuilder name = new StringBuilder();
// $NON-NLS-1$ //$NON-NLS-2$
name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be"));
// $NON-NLS-1$
name.append(" - ");
name.append(bin.getPath().toString());
return name.toString();
}
return super.getText(element);
}
};
TwoPaneElementSelector dialog = new TwoPaneElementSelector(getActiveWorkbenchShell(), programLabelProvider, qualifierLabelProvider);
dialog.setElements(binList.toArray());
dialog.setTitle(Messages.ProfileLaunchShortcut_Profile);
dialog.setMessage(Messages.ProfileLaunchShortcut_Choose_a_local_application);
dialog.setUpperListLabel(Messages.ProfileLaunchShortcut_Binaries);
dialog.setLowerListLabel(Messages.ProfileLaunchShortcut_Qualifier);
dialog.setMultipleSelection(false);
if (dialog.open() == Window.OK) {
return (IBinary) dialog.getFirstResult();
}
return null;
}
use of org.eclipse.cdt.core.model.IBinary in project linuxtools by eclipse.
the class RemoteProxyCMainTab method initializeProgramName.
/**
* Set the program name attributes on the working copy based on the
* ICElement.
* @param cElement The element to get data from.
* @param config The configuration to initialize
*/
protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
boolean renamed = false;
if (!(cElement instanceof IBinary)) {
cElement = cElement.getCProject();
}
if (cElement instanceof ICProject) {
IProject project = cElement.getCProject().getProject();
String name = project.getName();
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
if (projDes != null) {
String buildConfigName = projDes.getActiveConfiguration().getName();
// Bug 234951
name = NLS.bind(LaunchMessages.CMainTab_Configuration_name, name, buildConfigName);
}
name = getLaunchConfigurationDialog().generateName(name);
config.rename(name);
renamed = true;
}
IBinary binary = null;
if (cElement instanceof ICProject) {
IBinary[] bins = getBinaryFiles((ICProject) cElement);
if (bins != null && bins.length == 1) {
binary = bins[0];
}
} else if (cElement instanceof IBinary) {
binary = (IBinary) cElement;
}
String projectDir = EMPTY_STRING;
IProject project = null;
try {
project = ConfigUtils.getProject(ConfigUtils.getProjectName(config));
} catch (CoreException e) {
setErrorMessage(fPreviouslyCheckedWorkingDirErrorMsg = ProxyLaunchMessages.error_accessing_working_directory);
}
if (project != null) {
try {
projectDir = RemoteProxyManager.getInstance().getRemoteProjectLocation(project);
} catch (CoreException e) {
setErrorMessage(fPreviouslyCheckedWorkingDirErrorMsg = ProxyLaunchMessages.error_accessing_working_directory);
}
}
String path = EMPTY_STRING;
if (binary != null) {
path = binary.getResource().getProjectRelativePath().toOSString();
if (!renamed) {
String name = binary.getElementName();
int index = name.lastIndexOf('.');
if (index > 0) {
name = name.substring(0, index);
}
name = getLaunchConfigurationDialog().generateName(name);
config.rename(name);
renamed = true;
}
}
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectDir + IPath.SEPARATOR + path);
if (!renamed) {
String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName());
config.rename(name);
}
}
Aggregations