Search in sources :

Example 1 with ValgrindViewPart

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);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Test(org.junit.Test)

Example 2 with ValgrindViewPart

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));
}
Also used : ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ValgrindStackFrame(org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) CoreMessagesViewer(org.eclipse.linuxtools.internal.valgrind.ui.CoreMessagesViewer)

Example 3 with ValgrindViewPart

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"));
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) Test(org.junit.Test)

Example 4 with ValgrindViewPart

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"));
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) Test(org.junit.Test)

Example 5 with ValgrindViewPart

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();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IPath(org.eclipse.core.runtime.IPath) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) SubMonitor(org.eclipse.core.runtime.SubMonitor) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IValgrindOutputDirectoryProvider(org.eclipse.linuxtools.valgrind.launch.IValgrindOutputDirectoryProvider) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

ValgrindViewPart (org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart)14 IValgrindMessage (org.eclipse.linuxtools.valgrind.core.IValgrindMessage)10 Test (org.junit.Test)7 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)5 ArrayList (java.util.ArrayList)4 TreePath (org.eclipse.jface.viewers.TreePath)3 TreeSelection (org.eclipse.jface.viewers.TreeSelection)3 IOException (java.io.IOException)2 IMarker (org.eclipse.core.resources.IMarker)2 IProject (org.eclipse.core.resources.IProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 SubMonitor (org.eclipse.core.runtime.SubMonitor)2 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)2 IContributionItem (org.eclipse.jface.action.IContributionItem)2 IToolBarManager (org.eclipse.jface.action.IToolBarManager)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2