use of org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart in project linuxtools by eclipse.
the class ExpandCollapseTest method testExpand.
@Test
public void testExpand() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testDefaults");
ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
viewer = view.getMessagesViewer();
contextMenu = viewer.getTreeViewer().getTree().getMenu();
// Select first error and expand it
IValgrindMessage[] messages = (IValgrindMessage[]) viewer.getTreeViewer().getInput();
IValgrindMessage element = messages[0];
TreeSelection selection = new TreeSelection(new TreePath(new Object[] { element }));
viewer.getTreeViewer().setSelection(selection);
contextMenu.notifyListeners(SWT.Show, null);
contextMenu.getItem(0).notifyListeners(SWT.Selection, null);
checkExpanded(element, true);
}
use of org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart in project linuxtools by eclipse.
the class LinkedResourceDoubleClickTest method doDoubleClick.
private void doDoubleClick() {
ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
CoreMessagesViewer viewer = view.getMessagesViewer();
// get first leaf
IValgrindMessage[] elements = (IValgrindMessage[]) viewer.getTreeViewer().getInput();
IValgrindMessage element = elements[0];
TreePath path = new TreePath(new Object[] { element });
frame = null;
while (element.getChildren().length > 0) {
element = element.getChildren()[0];
path = path.createChildPath(element);
if (element instanceof ValgrindStackFrame) {
frame = (ValgrindStackFrame) element;
}
}
assertNotNull(frame);
viewer.getTreeViewer().expandToLevel(frame, AbstractTreeViewer.ALL_LEVELS);
TreeSelection selection = new TreeSelection(path);
// do double click
IDoubleClickListener listener = viewer.getDoubleClickListener();
listener.doubleClick(new DoubleClickEvent(viewer.getTreeViewer(), selection));
}
use of org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart in project linuxtools by eclipse.
the class SignalTest method testSegfaultHandle.
@Test
public void testSegfaultHandle() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testSegfault");
ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
IValgrindMessage[] messages = view.getMessages();
assertTrue(messages.length > 0);
// $NON-NLS-1$
assertTrue(messages[0].getText().contains("SIGSEGV"));
}
use of org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart in project linuxtools by eclipse.
the class BasicHelgrindTest method testNumErrors.
@Test
public void testNumErrors() throws CoreException, URISyntaxException, IOException {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testHelgrindGeneric");
ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
assertEquals(1, view.getMessages().length);
// $NON-NLS-1$
assertEquals(view.getMessages()[0].getText(), Messages.getString("ValgrindOutputView.No_output"));
}
use of org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart in project linuxtools by eclipse.
the class ValgrindLaunchConfigurationDelegate method launch.
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor m) throws CoreException {
if (m == null) {
m = new NullProgressMonitor();
}
// $NON-NLS-1$
SubMonitor monitor = SubMonitor.convert(m, Messages.getString("ValgrindLaunchConfigurationDelegate.Profiling_Local_CCPP_Application"), 10);
// check for cancellation
if (monitor.isCanceled()) {
return;
}
this.config = config;
this.launch = launch;
try {
IProject project = CDebugUtils.verifyCProject(config).getProject();
ValgrindUIPlugin.getDefault().setProfiledProject(project);
command = getValgrindCommand();
// remove any output from previous run
ValgrindUIPlugin.getDefault().resetView();
// reset stored launch data
getPlugin().setCurrentLaunchConfiguration(null);
getPlugin().setCurrentLaunch(null);
String valgrindCommand = getValgrindCommand().getValgrindCommand();
// also ensure Valgrind version is usable
try {
valgrindVersion = getPlugin().getValgrindVersion(project);
} catch (CoreException e) {
// if versioning failed, issue an error dialog and return
errorDialog(// $NON-NLS-1$
Messages.getString("ValgrindLaunchConfigurationDelegate.Valgrind_version_failed_msg"), e.getMessage());
return;
}
monitor.worked(1);
IPath exePath = CDebugUtils.verifyProgramPath(config);
String[] arguments = getProgramArgumentsArray(config);
File workDir = getWorkingDirectory(config);
if (workDir == null) {
// $NON-NLS-1$ //$NON-NLS-2$
workDir = new File(System.getProperty("user.home", "."));
}
// set output directory in config
IValgrindOutputDirectoryProvider provider = getPlugin().getOutputDirectoryProvider();
setOutputPath(config, provider.getOutputPath());
outputPath = verifyOutputPath(config);
// create/empty output directory
createDirectory(outputPath);
// tool that was launched
toolID = getTool(config);
// ask tool extension for arguments
dynamicDelegate = getDynamicDelegate(toolID);
String[] opts = getValgrindArgumentsArray(config);
// set the default source locator if required
setDefaultSourceLocator(launch, config);
ArrayList<String> cmdLine = new ArrayList<>(1 + arguments.length);
cmdLine.add(valgrindCommand);
cmdLine.addAll(Arrays.asList(opts));
cmdLine.add(exePath.toPortableString());
cmdLine.addAll(Arrays.asList(arguments));
String[] commandArray = cmdLine.toArray(new String[cmdLine.size()]);
boolean usePty = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
monitor.worked(1);
// check for cancellation
if (monitor.isCanceled()) {
return;
}
// call Valgrind
command.execute(commandArray, getEnvironment(config), workDir, usePty, project);
monitor.worked(3);
process = createNewProcess(launch, command.getProcess(), commandArray[0]);
// set the command line used
process.setAttribute(IProcess.ATTR_CMDLINE, command.getCommandLine());
while (!process.isTerminated()) {
Thread.sleep(100);
}
// store these for use by other classes
getPlugin().setCurrentLaunchConfiguration(config);
getPlugin().setCurrentLaunch(launch);
// parse Valgrind logs
IValgrindMessage[] messages = parseLogs(outputPath);
// create launch summary string to distinguish this launch
launchStr = createLaunchStr();
// create view
ValgrindUIPlugin.getDefault().createView(launchStr, toolID);
// set log messages
ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
view.setMessages(messages);
monitor.worked(1);
// pass off control to extender
dynamicDelegate.handleLaunch(config, launch, outputPath, monitor.newChild(2));
// initialize tool-specific part of view
dynamicDelegate.initializeView(view.getDynamicView(), launchStr, monitor.newChild(1));
// refresh view
ValgrindUIPlugin.getDefault().refreshView();
// show view
ValgrindUIPlugin.getDefault().showView();
// set up resource listener for post-build events.
ResourcesPlugin.getWorkspace().addResourceChangeListener(new ProjectBuildListener(project), IResourceChangeEvent.POST_BUILD);
monitor.worked(1);
} catch (IOException e) {
// $NON-NLS-1$
abort(Messages.getString("ValgrindLaunchConfigurationDelegate.Error_starting_process"), e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
m.done();
}
}
Aggregations