use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.
the class MultiProcessTest method testExec.
@Test
public void testExec() throws Exception {
ILaunchConfigurationWorkingCopy config = createConfiguration(proj.getProject()).getWorkingCopy();
config.setAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, true);
config.doSave();
// $NON-NLS-1$
doLaunch(config, "testExec");
IValgrindMessage[] messages = ValgrindUIPlugin.getDefault().getView().getMessages();
assertEquals(4, messages.length);
// $NON-NLS-1$
checkTestMessages(messages, "testExec");
}
use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage 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.valgrind.core.IValgrindMessage in project linuxtools by eclipse.
the class WrongDeallocationResolution method getAllocFunction.
/**
* Returns the allocation function that relates to the given marker
* @param marker {@link IMarker} object that points to where the wrong de-allocation function is
* @return {@link String} object containing the allocation function
* @throws BadLocationException
*/
private String getAllocFunction(IMarker marker, IDocument document) throws BadLocationException {
IValgrindMessage allocMessage = 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)) {
allocMessage = getStackBottom(getNestedStack(wrongDeallocMessage));
}
}
if (allocMessage instanceof ValgrindStackFrame) {
int allocLine = ((ValgrindStackFrame) allocMessage).getLine() - 1;
int allocOffset = document.getLineOffset(allocLine);
int allocLength = document.getLineLength(allocLine);
return document.get(allocOffset, allocLength);
}
return null;
}
use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.
the class WrongDeallocationResolution method apply.
@Override
public void apply(IMarker marker, IDocument document) {
try {
IASTNode astNode = getIASTNode(marker, document);
if (astNode != null) {
int nodeLength = astNode.getFileLocation().getNodeLength();
int nodeOffset = astNode.getFileLocation().getNodeOffset();
String content = document.get(nodeOffset, nodeLength);
if (content.contains(DELETE)) {
String allocFunction = getAllocFunction(marker, document);
if (allocFunction.contains(NEW)) {
// $NON-NLS-1$
content = document.get(nodeOffset, nodeLength).replace(DELETE, DELETE + "[]");
document.replace(nodeOffset, nodeLength, content);
} else {
addParentheses(astNode, document);
if (content.contains("[")) {
// $NON-NLS-1$
removeBrackets(astNode, document);
}
content = document.get(nodeOffset, nodeLength).replace(DELETE, FREE);
document.replace(nodeOffset, nodeLength, content);
}
} else if (content.contains(FREE)) {
if (getAllocFunction(marker, document).contains("[")) {
// $NON-NLS-1$
// $NON-NLS-1$
content = content.concat("[]");
}
content = content.replace(FREE, DELETE);
document.replace(nodeOffset, nodeLength, content);
}
IValgrindMessage message = getMessage(marker);
removeMessage(message.getParent());
ValgrindStackFrame nestedStackFrame = getStackBottom(getNestedStack(message.getParent()));
int nestedLine = nestedStackFrame.getLine();
String nestedFile = nestedStackFrame.getFile();
removeMarker(nestedFile, nestedLine, marker.getType());
marker.delete();
}
} catch (BadLocationException | CoreException e) {
Status status = new Status(IStatus.ERROR, ValgrindUIPlugin.PLUGIN_ID, null, e);
// $NON-NLS-1$
String title = Messages.getString("ValgrindMemcheckQuickFixes.Valgrind_error_title");
// $NON-NLS-1$
String message = Messages.getString("ValgrindMemcheckQuickFixes.Error_applying_quickfix");
showErrorMessage(title, message, status);
}
}
use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.
the class WrongDeallocationResolution method getStackBottom.
/**
* Return the last nested element from a given {@link IValgrindMessage}, or null if there are
* no nested messages.
* @param message
* @return The {@link ValgrindStackFrame} in the bottom of the nested stack
*/
private ValgrindStackFrame getStackBottom(IValgrindMessage message) {
ValgrindStackFrame stackBottom = null;
IValgrindMessage[] children = message.getChildren();
for (IValgrindMessage child : children) {
if (child instanceof ValgrindStackFrame) {
stackBottom = (ValgrindStackFrame) child;
}
}
return stackBottom;
}
Aggregations