Search in sources :

Example 1 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class ValgrindLaunchConfigurationDelegate method parseLogs.

protected IValgrindMessage[] parseLogs(IPath outputPath) throws IOException, CoreException {
    List<IValgrindMessage> messages = new ArrayList<>();
    for (File log : outputPath.toFile().listFiles(LOG_FILTER)) {
        ValgrindCoreParser parser = new ValgrindCoreParser(log, launch);
        IValgrindMessage[] results = parser.getMessages();
        if (results.length == 0) {
            results = new IValgrindMessage[1];
            // $NON-NLS-1$
            results[0] = new ValgrindInfo(null, Messages.getString("ValgrindOutputView.No_output"), launch);
        }
        messages.addAll(Arrays.asList(results));
        createMarkers(results);
    }
    return messages.toArray(new IValgrindMessage[messages.size()]);
}
Also used : IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ValgrindInfo(org.eclipse.linuxtools.internal.valgrind.core.ValgrindInfo) ArrayList(java.util.ArrayList) ValgrindCoreParser(org.eclipse.linuxtools.internal.valgrind.core.ValgrindCoreParser) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 2 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class BasicMemcheckTest method testNumErrors.

@Test
public void testNumErrors() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testNumErrors");
    IValgrindMessage[] messages = ValgrindUIPlugin.getDefault().getView().getMessages();
    assertEquals(3, messages.length);
    // $NON-NLS-1$
    checkTestMessages(messages, "testNumErrors");
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) Test(org.junit.Test)

Example 3 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage 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 4 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage 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 5 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class LinkedResourceMarkerTest method findMarker.

private void findMarker(ArrayList<IMarker> markers, IValgrindMessage error) throws Exception, CoreException {
    ValgrindStackFrame frame = null;
    IValgrindMessage[] children = error.getChildren();
    for (int i = 0; i < children.length; i++) {
        if (frame == null && children[i] instanceof ValgrindStackFrame && isWorkspaceFrame((ValgrindStackFrame) children[i])) {
            frame = (ValgrindStackFrame) children[i];
        } else if (children[i] instanceof ValgrindError) {
            findMarker(markers, children[i]);
        }
    }
    int ix = -1;
    for (int i = 0; i < markers.size(); i++) {
        IMarker marker = markers.get(i);
        if (marker.getAttribute(IMarker.MESSAGE).equals(error.getText()) && marker.getResource().getName().equals(frame.getFile()) && marker.getAttribute(IMarker.LINE_NUMBER).equals(frame.getLine())) {
            ix = i;
        }
    }
    assertFalse(ix < 0);
    markers.remove(ix);
}
Also used : ValgrindError(org.eclipse.linuxtools.internal.valgrind.core.ValgrindError) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ValgrindStackFrame(org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame) IMarker(org.eclipse.core.resources.IMarker)

Aggregations

IValgrindMessage (org.eclipse.linuxtools.valgrind.core.IValgrindMessage)24 ValgrindStackFrame (org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame)10 ValgrindViewPart (org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart)10 Test (org.junit.Test)9 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)6 ArrayList (java.util.ArrayList)5 IMarker (org.eclipse.core.resources.IMarker)5 TreePath (org.eclipse.jface.viewers.TreePath)4 TreeSelection (org.eclipse.jface.viewers.TreeSelection)4 ValgrindError (org.eclipse.linuxtools.internal.valgrind.core.ValgrindError)4 IFile (org.eclipse.core.resources.IFile)3 CoreException (org.eclipse.core.runtime.CoreException)3 IPath (org.eclipse.core.runtime.IPath)3 File (java.io.File)2 IOException (java.io.IOException)2 URI (java.net.URI)2 IProject (org.eclipse.core.resources.IProject)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Status (org.eclipse.core.runtime.Status)2