Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Overholt2011-02-28 04:04:59 +0000
committerAndrew Overholt2011-02-28 04:32:33 +0000
commit5c6a832e0b912442934b29fdb3ddf1e96c00fd4e (patch)
tree4559d4b10d838fc786c7ccb0756f96985d53574d
parentff15e0d153ab41fe1d00d581dacda71d3ae378cd (diff)
parent08d8f64b6203df90c9bb6cb1fc10576e0feb58e9 (diff)
downloadorg.eclipse.linuxtools-0.6.2.tar.gz
org.eclipse.linuxtools-0.6.2.tar.xz
org.eclipse.linuxtools-0.6.2.zip
Merge valgrind 0.6.2v0.6.2
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.core/ChangeLog5
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCoreParser.java111
2 files changed, 116 insertions, 0 deletions
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.core/ChangeLog b/valgrind/org.eclipse.linuxtools.valgrind.core/ChangeLog
index 35777382d4..2cc1d653df 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.core/ChangeLog
+++ b/valgrind/org.eclipse.linuxtools.valgrind.core/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-13 Elliott Baron <ebaron@fedoraproject.org>
+
+ * src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCoreParser.java (ValgrindCoreParser): Handle warning
+ messages.
+
2010-08-25 Elliott Baron <ebaron@fedoraproject.org>
* META-INF/MANIFEST.MF: Bump version to 0.6.1.
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCoreParser.java b/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCoreParser.java
new file mode 100644
index 0000000000..403bbf7cbb
--- /dev/null
+++ b/valgrind/org.eclipse.linuxtools.valgrind.core/src/org/eclipse/linuxtools/internal/valgrind/core/ValgrindCoreParser.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.valgrind.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.linuxtools.valgrind.core.IValgrindMessage;
+
+public class ValgrindCoreParser extends AbstractValgrindTextParser {
+ private static final String AT = "at"; //$NON-NLS-1$
+ private static final String BY = "by"; //$NON-NLS-1$
+
+ protected List<IValgrindMessage> messages;
+ protected int pid;
+ protected ILaunch launch;
+
+ public ValgrindCoreParser(File inputFile, ILaunch launch) throws IOException {
+ this.launch = launch;
+ BufferedReader br = new BufferedReader(new FileReader(inputFile));
+ // keep track of nested messages and their corresponding indents
+ Stack<IValgrindMessage> messageStack = new Stack<IValgrindMessage>();
+ Stack<Integer> indentStack = new Stack<Integer>();
+ messages = new ArrayList<IValgrindMessage>();
+
+ try {
+ pid = parsePID(inputFile.getName(), CommandLineConstants.LOG_PREFIX);
+ String line;
+ while ((line = br.readLine()) != null) {
+ // remove PID string
+ // might encounter warnings also #325130
+ line = line.replaceFirst("==\\d+==|\\*\\*\\d+\\*\\*", EMPTY_STRING); //$NON-NLS-1$
+
+ int indent;
+ for (indent = 0; indent < line.length()
+ && line.charAt(indent) == ' '; indent++)
+ ;
+
+ line = line.trim();
+ if (!line.equals(EMPTY_STRING)) {
+ /*
+ * indent == 1 -> top level message
+ * indent > 1 -> child message
+ * indent == 0 -> should not occur
+ */
+ if (indent == 1) {
+ // top-level message, clear stacks
+ IValgrindMessage message = getMessage(null, line);
+ messages.add(message);
+ messageStack.clear();
+ messageStack.push(message);
+ indentStack.clear();
+ indentStack.push(indent);
+ }
+ else if (indent > 1) {
+ // find this message's parent
+ while (indent <= indentStack.peek()) {
+ messageStack.pop();
+ indentStack.pop();
+ }
+
+ messageStack.push(getMessage(messageStack.peek(), line));
+ indentStack.push(indent);
+ }
+ }
+ }
+ } finally {
+ if (br != null) {
+ br.close();
+ }
+ }
+ }
+
+ protected IValgrindMessage getMessage(IValgrindMessage message, String line) throws IOException {
+ if (line.startsWith(AT) || line.startsWith(BY)) {
+ Object[] parsed = parseFilename(line);
+ String filename = (String) parsed[0];
+ int lineNo = (Integer) parsed[1];
+ return new ValgrindStackFrame(message, line, launch, filename, lineNo);
+ }
+ return new ValgrindError(message, line, launch, pid);
+ }
+
+ public IValgrindMessage[] getMessages() {
+ return messages.toArray(new IValgrindMessage[messages.size()]);
+ }
+
+ public void printMessages(IValgrindMessage m, int indent) {
+ for (int i = 0; i < indent; i++) {
+ System.out.print(SPACE);
+ }
+ System.out.println(m.getText());
+ for (IValgrindMessage child : m.getChildren()) {
+ printMessages(child, indent + 1);
+ }
+ }
+}

Back to the top