1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 495661 - Period is a valid symbol in a section name

When using -ffunction-section, each function is placed in it's own
section name. For example the main() function would be placed in
.text.main, so the pattern looking for undefined references needs to
allow the extra dot there.
Since C++ will use other symbols than what's included in \w, lets allow
everything except a + sign and whitespace.

Change-Id: I66d9ee7d8cbc0a405e60d7cdeb43c38b30107245
Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
Torbjörn Svensson 2020-03-12 19:20:06 +01:00 committed by Jonah Graham
parent 0c464f651e
commit 36de92cc77
3 changed files with 46 additions and 12 deletions

View file

@ -38,12 +38,13 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
new String[] { "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'",
"(.text.myfunc+0x42): undefined reference to `bar'",
"make: Target `all' not remade because of errors.", },
2, // errors
3, // errors
0, // warnings
0, // Infos
new String[] { "main.c", "main.o" },
new String[] { "undefined reference to `foo()'", "undefined reference to `something'" },
new String[] { "main.c", "main.o", "project" }, new String[] { "undefined reference to `foo()'",
"undefined reference to `something'", "undefined reference to `bar'" },
new String[] { GLD_ERROR_PARSER_ID });
}
@ -53,12 +54,13 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
new String[] { "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'",
"(.text.myfunc+0x42): undefined reference to `bar'",
"make: Target `all' not remade because of errors.", },
2, // errors
3, // errors
0, // warnings
0, // Infos
new String[] { "main.c", "main.o" },
new String[] { "undefined reference to `foo()'", "undefined reference to `something'" },
new String[] { "main.c", "main.o", "project" }, new String[] { "undefined reference to `foo()'",
"undefined reference to `something'", "undefined reference to `bar'" },
new String[] { GLD_ERROR_PARSER_ID });
}
@ -104,4 +106,32 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
"cannot find -ljpeg", },
new String[] { GLD_ERROR_PARSER_ID });
}
public void testLinkerMessages_bug495661() throws IOException {
runParserTest(
// new style: colons before sections
new String[] { "make all ",
// @formatter:off
"Building file: ../src/a.cpp",
"Invoking: GCC C++ Compiler",
"g++ -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF\"src/a.d\" -MT\"src/a.o\" -o \"src/a.o\" \"../src/a.cpp\"",
"Finished building: ../src/a.cpp",
" ",
"Building target: parser",
"Invoking: GCC C++ Linker",
"g++ -o \"a\" ./src/a.o ",
"/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: ./src/a.o: in function `TLS wrapper function for A::max_compatdb_time':",
"a.cpp:(.text._ZTWN1A17max_compatdb_timeE[_ZTWN1A17max_compatdb_timeE]+0x21): undefined reference to `A::max_compatdb_time'",
"collect2: error: ld returned 1 exit status",
"make: *** [makefile:47: parser] Error 1",
"\"make all\" terminated with exit code 2. Build might be incomplete.", },
// @formatter:on
2, // errors
0, // warnings
0, // Infos
new String[] { "a.cpp", "project" },
new String[] { "./src/a.o: in function `TLS wrapper function for A::max_compatdb_time':",
"undefined reference to `A::max_compatdb_time'" },
new String[] { GLD_ERROR_PARSER_ID });
}
}

View file

@ -140,9 +140,13 @@ public abstract class GenericErrorParserTests extends TestCase {
if (expectedFileNames != null) {
assertEquals(expectedFileNames.length, markerGenerator.uniqFiles.size());
for (int i = 0; i < expectedFileNames.length; i++) {
// Keep in mind that uniqFiles get alphabetically sorted
IPath path = ((IFile) markerGenerator.uniqFiles.get(i)).getLocation();
assertEquals(expectedFileNames[i], path.lastSegment());
IResource resource = markerGenerator.uniqFiles.get(i);
// Markers for errors without source file has resource of type IProject
if (!(resource instanceof IProject)) {
assertTrue(resource instanceof IFile);
// Keep in mind that uniqFiles get alphabetically sorted
assertEquals(expectedFileNames[i], resource.getLocation().lastSegment());
}
}
}

View file

@ -68,10 +68,10 @@ CDTGNUCErrorParser.regex.GenericWarning=(.*?):(\\d+):(\\d+:)?\\s*(([Ww]arning)|(
CDTGNUCErrorParser.regex.OtherError=(.*?):(\\d+):(\\d+:)? (.*)
CDTGNULinkerErrorParser.name=GNU Linker Error Parser
CDTGNULinkerErrorParser.regex.InFunction=(.*?):?(\\(\\.\\w+\\+.*\\))?:\\s*(In function [`'"](.*)['"]:)
CDTGNULinkerErrorParser.regex.InFunction=(.*?):?(\\(\\.[^\\s+]+\\+.*\\))?:\\s*(In function [`'"](.*)['"]:)
CDTGNULinkerErrorParser.regex.WarningDangerousFunction=(.*?):(\\d+):(\\d+:)? ([Ww]arning:)?\\s*(the use of [`'"](.*)['"] is dangerous, better use [`'"](.*)['"].*)
CDTGNULinkerErrorParser.regex.TextWarning=(.*?):?\\(\\.\\w+\\+.*\\): [Ww]arning:? (.*)
CDTGNULinkerErrorParser.regex.TextError=(.*?):?\\(\\.\\w+\\+.*\\): (.*)
CDTGNULinkerErrorParser.regex.TextWarning=(.*?):?\\(\\.[^\\s+]+\\+.*\\): [Ww]arning:? (.*)
CDTGNULinkerErrorParser.regex.TextError=(.*?):?\\(\\.[^\\s+]+\\+.*\\): (.*)
CDTGNULinkerErrorParser.regex.ldWarning=(.*[/\\\\])?ld(\\.exe)?: [Ww]arning:? (.*)
CDTGNULinkerErrorParser.regex.ldError=(.*[/\\\\])?ld(\\.exe)?: (.*)