Fixes for GNU ld error parsing. Reported in <https://bugs.eclipse.org/bugs/show_bug.cgi?id=296966>
authorEd Swartz <ed.swartz@nokia.com>
Fri, 04 Dec 2009 14:31:59 -0600
changeset 123 71e3840b8eca
parent 118 f0e9dc42b68e
child 124 e120fb809ed2
Fixes for GNU ld error parsing. Reported in <https://bugs.eclipse.org/bugs/show_bug.cgi?id=296966>
cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java
cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GLDErrorParserTests.java
cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java
cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/messages.properties
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java	Tue Nov 24 19:18:36 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java	Fri Dec 04 14:31:59 2009 -0600
@@ -22,6 +22,7 @@
         // Just add more test cases here as you create them for
         // each class being tested
 		suite.addTest(GCCErrorParserTests.suite());
+		suite.addTest(GLDErrorParserTests.suite());
         suite.addTest(FileBasedErrorParserTests.suite());
         suite.addTest(ErrorParserManagerTest.suite());
         suite.addTest(ErrorParserFileMatchingTest.suite());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GLDErrorParserTests.java	Fri Dec 04 14:31:59 2009 -0600
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Nokia and others.
+ * 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:
+ *     Nokia - initial API and implementation, based on GCCErrorParserTests
+ *******************************************************************************/
+package org.eclipse.cdt.core.internal.errorparsers.tests;
+
+
+import java.io.IOException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * This test is designed to exercise the error parser capabilities for GNU ld.
+ */
+public class GLDErrorParserTests extends GenericErrorParserTests {
+
+	// old style: no colons before sections
+	public static final String[] GLD_ERROR_STREAM0 = {
+		"make -k all",
+		"gcc -o hallo.o main.c libfoo.a",
+		"main.c(.text+0x14): undefined reference to `foo()'",
+		"main.o(.rodata+0x14): undefined reference to `something'",
+		"make: Target `all' not remade because of errors." };
+	public static final int GLD_ERROR_STREAM0_WARNINGS = 0;
+	public static final int GLD_ERROR_STREAM0_ERRORS = 2;
+	public static final String[] GLD_ERROR_STREAM0_FILENAMES = {"main.c","main.o"};
+	
+	// new style: colons before sections
+	public static final String[] GLD_ERROR_STREAM1 = {
+		"make -k all",
+		"gcc -o hallo.o main.c libfoo.a",
+		"main.c:(.text+0x14): undefined reference to `foo()'",
+		"main.o:(.rodata+0x14): undefined reference to `something'",
+		"make: Target `all' not remade because of errors." };
+	public static final int GLD_ERROR_STREAM1_WARNINGS = 0;
+	public static final int GLD_ERROR_STREAM1_ERRORS = 2;
+	public static final String[] GLD_ERROR_STREAM1_FILENAMES = {"main.c","main.o"};
+
+	public static final String[] GLD_ERROR_STREAM2 = {
+		"make -k all",
+		"gcc -o hallo.o main.c libfoo.a",
+		"libfoo.a(foo.o): In function `foo':",
+		"foo.c:(.text+0x7): undefined reference to `bar'",
+		"make: Target `all' not remade because of errors." };
+	public static final int GLD_ERROR_STREAM2_WARNINGS = 0;
+	public static final int GLD_ERROR_STREAM2_ERRORS = 1;
+	public static final String[] GLD_ERROR_STREAM2_FILENAMES = {"foo.c"};
+
+
+	public GLDErrorParserTests() {
+		super();
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(GLDErrorParserTests.class);
+		return suite;
+	}
+
+	public void testLinkerMessages0() throws IOException {
+		runParserTest(GLD_ERROR_STREAM0, GLD_ERROR_STREAM0_ERRORS, GLD_ERROR_STREAM0_WARNINGS, GLD_ERROR_STREAM0_FILENAMES,
+				null, new String[]{GLD_ERROR_PARSER_ID});
+	}
+	public void testLinkerMessages1() throws IOException {
+		runParserTest(GLD_ERROR_STREAM1, GLD_ERROR_STREAM1_ERRORS, GLD_ERROR_STREAM1_WARNINGS, GLD_ERROR_STREAM1_FILENAMES,
+				null, new String[]{GLD_ERROR_PARSER_ID});
+	}
+	public void testLinkerMessages2() throws IOException {
+		runParserTest(GLD_ERROR_STREAM2, GLD_ERROR_STREAM2_ERRORS, GLD_ERROR_STREAM2_WARNINGS, GLD_ERROR_STREAM2_FILENAMES,
+				null, new String[]{GLD_ERROR_PARSER_ID});
+	}
+}
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java	Tue Nov 24 19:18:36 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java	Fri Dec 04 14:31:59 2009 -0600
@@ -35,6 +35,7 @@
  */
 public class GenericErrorParserTests extends TestCase {
 	public static final String GCC_ERROR_PARSER_ID = "org.eclipse.cdt.core.GCCErrorParser";
+	public static final String GLD_ERROR_PARSER_ID = "org.eclipse.cdt.core.GLDErrorParser";
 
 	protected IProject fTempProject;
 
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/messages.properties	Tue Nov 24 19:18:36 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/messages.properties	Fri Dec 04 14:31:59 2009 -0600
@@ -18,6 +18,6 @@
 GCCErrorParser_sikp_instantiatedFromHere=instantiated from 
 #GCCErrorParser_Warnings=(.*?):([0-9]+):([0-9]+:)?( (.*[Ww]arning:|WARNING:|[Ee]rror:))? (.*)
 GCCErrorParser_Warnings=(.*?):([0-9]+):([0-9]+:)?(.*?[([Ww]arning)(WARNING)([Ee]rror)]:)? (.*)
-GLDErrorParser_error_text=(.*)\\(\\.text\\+.*\\): (.*)
+GLDErrorParser_error_text=(.*?):?\\(\\.\\w+\\+.*\\): (.*)
 GLDErrorParser_warning_general=ld(\\.exe)?: [Ww]arning:? (.*)
 GLDErrorParser_error_general=ld(\\.exe)?: (.*)