Compiler warnings from Keil toolchain incorrectly formatted

Sysprogs forums Forums VisualGDB Compiler warnings from Keil toolchain incorrectly formatted

This topic contains 9 replies, has 2 voices, and was last updated by  mmoore 3 months, 1 week ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #10612

    mmoore
    Participant

    I encountered this issue after upgrading from VS 2015 to VS 2017 (VGDB 5.2).  Under 2015, I followed the tutorial at https://visualgdb.com/tutorials/arm/keil/ to configure a VS/VGDB project based on an existing uVision project.  In the tutorial, there is a section on compiler error formatting that indicates the need to download BuildMessageTemplates.xml and put it in the VGDB directory.  I never had to follow this step under VS 2015 and never had any error message formatting issues.  After upgrading to 2017, I started getting error message formatting problems.  I followed the steps in the tutorial without success.  I also attempted to modify the RegularExpressions.xml file in the VGDB directory.  I gather that the way formatting messages is handled has changed between the version the tutorial was written against and version 5.2.  Nothing that I did had any effect on the output.  The problem stems from the fact that VS 2017 adds a “n>” prefix to all build output log entries.  This is due to the parallel build support, where n is the build number.  This throws off the whatever RegEx VGDB is using, but it doesn’t appear to be using any that I modified.

    Is there any RegEx that I can modify under version 5.2 to remedy this issue?

    #10616

    support
    Keymaster

    Hi,

    Sorry, looks like we forgot to update the tutorial. Starting from VisualGDB 5.2, the build message templates have been moved to the <VisualGDB directory>\RegularExpressions.xml file along with other regular expressions used by VisualGDB so that you can tweak them more easily.

    You can now also override the message templates for each project individually. Please see the updated Keil tutorial for details.

    #10626

    mmoore
    Participant

    Thanks for the update!  I downloaded the file and added the changes to the .vgdgsettings file.  It appears that VS now formats and displays compiler errors correctly, but it won’t build.  I get this error when attempting to build:

    1>Inline build failed – ReadFile failed, win32 error code 109. Doing a normal build…

    1>Build/launch failed: Object reference not set to an instance of an object.

    The source of the error is the Microsoft.MakeFile.Targets file, in this section:

      <Target Name=”Build” DependsOnTargets=”PrepareForNMakeBuild;ResolveReferences;GetTargetPath;$(PreNMakeBuildTarget)” Returns=”$(NMakeManagedOutput)”>

    <VCMessage Code=”MSB8005″ Type=”Warning” Arguments=”NMakeBuildCommandLine” Condition=”‘$(NMakeBuildCommandLine)’==””/>

    <Exec Command=”$(NMakeBuildCommandLine)”  Condition=”‘$(NMakeBuildCommandLine)’!=””/>

    </Target>

    Specifically, the Exec Command line fails.  This occurs when this line exists in the .vgdbsettings file (added per the updated tutorial):

      <BuildMessageTemplateFile>BuildMessageRegexes.xml</BuildMessageTemplateFile>

    I have tried moving this line within the .vgdbsettings file, but it has the same effect regardless of location within the file.

    #10627

    mmoore
    Participant

    It would seem I spoke to soon about the messages formatting correctly.  The message I saw that was correctly formatted was generated by VS, not the Keil toolchain.  I tinkered with the BuildMessageRegexes.xml file a bit.  If I remove the <GCCDetailedMessage> line, it will build successfully.  However, it still does not format the compiler messages correctly.  It does not seem to matter how the RegEx is written, it always formats the same.  It appears to be ignoring the RegEx defined in the BuildMessageRegexes.xml file.  I validated the modified RegEx against the build output in RegExBuddy and it matches.  What am I missing?

    • This reply was modified 3 months, 2 weeks ago by  mmoore.
    #10648

    support
    Keymaster

    Hi,

    Thanks for reporting this, looks like the updated BuildMessageRegexes.xml file contained a small error. We have updated the version linked from our tutorial. Let us know if it works.

    #10652

    mmoore
    Participant

    Thanks for the update.  This has resolved the issue where the project won’t build with   <BuildMessageTemplateFile>BuildMessageRegexes.xml</BuildMessageTemplateFile> defined in the .vgdbsettings file.  However, I am still getting incorrectly formatted compiler errors and the changes I make to the RegEx in BuildMessageRegexes.xml appear to make no difference.  I have tested my RegEx against the build output in RegexBuddy and it matches as expected.  Here is the RegEx for compiler messages:

    <GCCMessage>^1>”(.*)”, line ([0-9]+) : (error|warning) : (.*)$</GCCMessage>

    I thought perhaps XML did not like the angle bracket, so I have also tried:

    <GCCMessage>^1<![CDATA[>]]>”(.*)”, line ([0-9]+) : (error|warning) : (.*)$</GCCMessage>

    and

    <GCCMessage>”(.*)”, line ([0-9]+) : (error|warning) : (.*)$</GCCMessage>

    as well as several other permutations.  I am attempting to match compiler messages in build output like this:

    1>”../application/some_file.c”, line 424 : warning : #177-D: function “naughty_function”  was declared but never referenced

    The error list is always formatted as “#177-D: function “naughty_function”  was declared but never referenced” with blank file and line 1.  Please let me know what I need to do differently to make this work.

    #10661

    support
    Keymaster

    Hi,

    OK, we’ve tried reproducing this with the following extra line in Makefile:

    The vgdbsettings file contains the following element:

    The BuildMessageRegexes.xml defines GCCMessage as follows:

    This does actually produce the expected results (the message is converted to VS format in the Build Output window and VS recognizes it):

    Please try checking your code against the examples shown here (note that this forum engine converts the ” character to a slightly different one and it won’t work if you simply copy-paste it). If it does not work, please try reducing the problem to a GCC project with an ‘echo’ line injected into the Makefile and send us the entire repro project so that we could help you troubleshoot this.

    #10665

    mmoore
    Participant

    Thanks for your response.  I have ensured that the .vgdbsettings and BuildMessageRegexes.xml files are configured as you indicated.  I modified the Makefile like so:

    I added three echo lines to the Makefile.  The first is per your listing above.  The second is a verbatim copy of the build output.  The third is a copy of the build output with ‘warn’ instead of ‘warning’ to test the RegEx match.  These all format in the build output as expected.  However, the compiler output is still not formatted.  Here is a relevant section of the build output:

    I also tried removing the end-of-line anchor from the RegEx, but the results were the same.  Have you tested this with your demo project from the Keil toolchain tutorial under VS 2017?  Is the Keil toolchain output somehow bypassing the RegEx filtering? Please let me know what I can do or if there is anything I can provide to get this resolved.  Thanks!

    • This reply was modified 3 months, 1 week ago by  mmoore.
    • This reply was modified 3 months, 1 week ago by  mmoore.
    #10690

    support
    Keymaster

    Hi,

    The Keil toolchain output should not bypass the regex filters, but it could use some special unicode characters that could interfere with the regexes.

    Please try running “make > build.log” from the command line and then double-check using a hex editor that the lines generated by Keil look exactly the same as the lines printed from the Makefile. You can also send the log file to our support email so that we could check it for you (please attach it instead of pasting to avoid automatic character transformation).

    We have not tested it with Keil as we don’t officially support it out-of-the-box yet, sorry.

    #10702

    mmoore
    Participant

    I finally got it figured out. Apparently the output was already being re-written by the time that it showed up incorrectly formatted in the build output. So the line that I have been trying to match (per the previous post):

    "../application/source_file.c", line 71 : warning : #177-D: variable "_naughty_variable" was declared but never referenced

    actually comes out of the compiler looking like this:

    "../application/source_file.c", line 71: Warning: #177-D: variable "_naughty_variable" was declared but never referenced

    So apparently the capitalization of warning/error was different, as well as the spacing before the colon. I modified the RegEx and the compiler messages are now formatted correctly. Thanks for all your help.

    • This reply was modified 3 months, 1 week ago by  mmoore.
Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.