Search in sources :

Example 21 with IValgrindMessage

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

the class MultiProcessTest method testNoExec.

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

Example 22 with IValgrindMessage

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

the class WrongDeallocationResolution method getMessagesByText.

/**
 * Returns all of the messages from the currently active Valgrind view that
 * contains a given {@link String} in their description.
 * @param text the {@link String} to match the Valgrind messages' descriptions
 * @return All messages containing the given text.
 */
private IValgrindMessage[] getMessagesByText(String text) {
    ValgrindViewPart valgrindView = ValgrindUIPlugin.getDefault().getView();
    ArrayList<IValgrindMessage> foundMessages = new ArrayList<>();
    if (valgrindView != null) {
        IValgrindMessage[] messages = valgrindView.getMessages();
        if (messages != null && messages.length != 0) {
            for (IValgrindMessage message : messages) {
                if (message.getText().contains(text)) {
                    foundMessages.add(message);
                }
            }
        }
    }
    IValgrindMessage[] foundMessagesArray = new IValgrindMessage[foundMessages.size()];
    foundMessages.toArray(foundMessagesArray);
    return foundMessagesArray;
}
Also used : ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ArrayList(java.util.ArrayList)

Example 23 with IValgrindMessage

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

the class WrongDeallocationResolution method getMessage.

/**
 * Returns the {@link IValgrindMessage} element from the Valgrind View that represents
 * a given Marker
 * @param marker the marker to which the ValgrindMessage relates
 * @return {@link IValgrindMessage} that represents the {@link IMarker}
 */
private IValgrindMessage getMessage(IMarker marker) {
    IValgrindMessage message = null;
    String file = marker.getResource().getName();
    int line = marker.getAttribute(IMarker.LINE_NUMBER, 0);
    // $NON-NLS-1$
    IValgrindMessage[] wrongDeallocMessages = getMessagesByText(Messages.getString("ValgrindMemcheckQuickFixes.Wrong_dealloc_message"));
    for (IValgrindMessage wrongDeallocMessage : wrongDeallocMessages) {
        ValgrindStackFrame stackBottom = getStackBottom(wrongDeallocMessage);
        int stackBottomLine = stackBottom.getLine();
        String stackBottomFile = stackBottom.getFile();
        if (stackBottomLine == line && file != null && stackBottomFile.endsWith(file)) {
            message = stackBottom;
        }
    }
    return message;
}
Also used : IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ValgrindStackFrame(org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame)

Example 24 with IValgrindMessage

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

the class WrongDeallocationResolution method getNestedStack.

/**
 * Returns the nested stack from a given ValgrindMessage in the Valgrind View
 * @param message The message from which the stack will be acquired
 * @return {@link ValgrindError} object containing the nested stack
 */
private ValgrindError getNestedStack(IValgrindMessage message) {
    ValgrindError nestedError = null;
    IValgrindMessage[] children = message.getChildren();
    for (IValgrindMessage child : children) {
        if (child instanceof ValgrindError) {
            nestedError = (ValgrindError) child;
        }
    }
    return nestedError;
}
Also used : ValgrindError(org.eclipse.linuxtools.internal.valgrind.core.ValgrindError) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage)

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