Home » Language IDEs » C / C++ IDE (CDT) » Hacking error messages
Hacking error messages [message #150073] |
Tue, 26 July 2005 20:24  |
Eclipse User |
|
|
|
We're using Green Hills compilers to compile C code. Eclipse doesn't
understand Green Hills error messages, so I have to read the console
output to find my errors and I can't just click on a "Problem" entry to
jump to the error.
I *could* write an error parser for the Green Hills compiler, but that
would require me getting elbow-deep in Eclipse development and I'm a
total n00b (not a Java n00b, just an Eclipse n00b).
Or, I could write a filter using sed scripts or awk or something to put
Green Hills error messages in a format that Eclipse knows about...
Or so I thought... I tried writing a test program and looking at gcc's
output. I'm pretty sure this is a hopeless idea.
Does anyone have anything heartening to tell me? Or is this line of
inquiry as doomed as it appears to be?
Has anyone actually written a Green Hills error parser that is (so far)
invisible to Google?
|
|
|
Re: Hacking error messages [message #150180 is a reply to message #150073] |
Wed, 27 July 2005 17:33   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------050009000303020407060301
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Actually - I was wrong. It's not too bad. For those of you who happen to
use Green Hills and Eclipse, the script is attached.
My understanding is that Green Hills is actually a bit hostile to
Eclipse. I'd be curious to know if there actually *is* anyone who uses
them together (besides me).
--------------050009000303020407060301
Content-Type: text/plain;
name="MyBuilder"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="MyBuilder"
#=========================================================== ====================
#
# This script builds Green Hills projects and converts the messages to a form
# the Eclipse GCC error parser can recognize.
#
# The following excerpt comes from GCCErrorParser.java:
#
#
# // Known patterns.
# // (a)
# // filename:lineno: description
# //
# // (b)
# // filename:lineno:column: description
# //
# // (c)
# // In file included from b.h:2,
# // from a.h:3,
# // from hello.c:3:
# // c.h:2:15: missing ')' in macro parameter list
# //
# // (d)
# // In file included from hello.c:3:
# // c.h:2:15: missing ')' in macro parameter list
# //
# // (e)
# // h.c: In function `main':
# // h.c:41: `foo' undeclared (first use in this function)
# // h.c:41: (Each undeclared identifier is reported only once
# // h.c:41: for each function it appears in.)
# // h.c:41: parse error before `char'
# // h.c:75: `p' undeclared (first use in this function)
#
#
# From what little experience I've had with the Green Hills C compiler, it
# introduces messages with a line of the following format:
#
# <file>, line <line>: <type> #<ID>: <message>
#
# Where:
#
# <type> is "error" or "warning" or something.
# <ID> is an identifier for the given message.
#
# Example:
#
# "main.c", line 42: error #69-D: stupid mistake
#
# The Green Hills programs seem to wrap long error messages to following lines.
# For example:
#
# "main.c", line 42: error #69-D: This is a long explanation
# of the stupid mistake you made.
# stupid ?= mistake;
# ^
# It appears that the only way you can find the end of the message is to look
# for the line that contains nothing but white space and the caret (^). That
# line, and the previous line are not actually part of the message.
#
#=========================================================== ====================
#=========================================================== ====================
#----------------------------------------------------------- --------------------
# Global Variables
#----------------------------------------------------------- --------------------
#
# Usage.
#
Usage="$0 [<GHArgs> ... ]"
#
# The path to the GHS gbuild command.
#
GHSBuilder='C:/GHS/arm407/gbuild.exe'
#
# This is the master pattern output lines that introduce a message.
#
# \1: File
# \2: Line number
# \3: Message type
# \4: Message ID
# \5: Message
#
MasterPattern='^"\([^"][^"]*\)", line \([0-9][0-9]*\): \([a-z][a-z]*\) #\([^:][^:]*\): \(.*\)$'
#=========================================================== ====================
#----------------------------------------------------------- --------------------
# Build, and pipe the output to sed.
#----------------------------------------------------------- --------------------
${GHSBuilder} $@ 2>&1 |\
sed -n -e "
#----------------------------------------------------------- ----------------
# Check if this line introduces a message. If not, print this line and move
# on to the next.
#----------------------------------------------------------- ----------------
/${MasterPattern}/!{
p
b
}
#----------------------------------------------------------- ----------------
# If control arrives here, this line is a message. Copy this line to the
# hold space.
#----------------------------------------------------------- ----------------
h
#----------------------------------------------------------- ----------------
# The current line is safely tucked away in the hold space. We now want to
# accumulate lines until we find one that contains nothing but white space
# and a caret.
#----------------------------------------------------------- ----------------
:Accumulate
#----------------------------------------------------------- ------------
# Get the next line and append it to the hold space. Note that this
# inserts a newline character, which will be handy later.
#----------------------------------------------------------- ------------
n
H
#----------------------------------------------------------- ------------
# If the current line contains nothing but white space and a caret,
# we're done accumulating.
#----------------------------------------------------------- ------------
/^[ ]*^[ ]*/b FinishedAccumulating
#----------------------------------------------------------- ------------
# Go back for more.
#----------------------------------------------------------- ------------
b Accumulate
:FinishedAccumulating
#----------------------------------------------------------- ----------------
# When control arrives here, we've finished accumulating everything in the
# hold space. We can now start pulling stuff back out. Copy the hold space
# to the pattern space.
#----------------------------------------------------------- ----------------
g
#----------------------------------------------------------- ----------------
# Remove the source code and caret lines from the pattern space.
#----------------------------------------------------------- ----------------
s/\(.*\)\n.*\n.*/\1/
#----------------------------------------------------------- ----------------
# Remove all newlines.
#----------------------------------------------------------- ----------------
s/\n//g
#----------------------------------------------------------- ----------------
# Remove redundant spaces.
#----------------------------------------------------------- ----------------
s/ */ /g
#----------------------------------------------------------- ----------------
# Reformat this message to GCC pattern (a).
#----------------------------------------------------------- ----------------
s/${MasterPattern}/\1:\2: \5/g
#----------------------------------------------------------- ----------------
# Print the re-formatted message. Eclipse should be able to recognize this.
#----------------------------------------------------------- ----------------
p
#----------------------------------------------------------- ----------------
# We don't want to throw away the source code and caret lines. Retrieve the
# hold space again.
#----------------------------------------------------------- ----------------
g
#----------------------------------------------------------- ----------------
# Remove all but the source code and caret lines from the pattern space.
#----------------------------------------------------------- ----------------
s/.*\n\(.*\n.*\)/\1/
#----------------------------------------------------------- ----------------
# Print the source code and caret lines.
#----------------------------------------------------------- ----------------
p
"
--------------050009000303020407060301--
|
|
|
Re: Hacking error messages [message #150249 is a reply to message #150180] |
Thu, 28 July 2005 18:01   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------020203040002080902000401
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
A greatly improved version.
--------------020203040002080902000401
Content-Type: text/plain;
name="MyBuilder"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="MyBuilder"
#=========================================================== ====================
#
# This script builds Green Hills projects and converts the messages to a form
# the Eclipse GCC error parser can recognize.
#
# The following excerpt comes from GCCErrorParser.java:
#
#
# // Known patterns.
# // (a)
# // filename:lineno: description
# //
# // (b)
# // filename:lineno:column: description
# //
# // (c)
# // In file included from b.h:2,
# // from a.h:3,
# // from hello.c:3:
# // c.h:2:15: missing ')' in macro parameter list
# //
# // (d)
# // In file included from hello.c:3:
# // c.h:2:15: missing ')' in macro parameter list
# //
# // (e)
# // h.c: In function `main':
# // h.c:41: `foo' undeclared (first use in this function)
# // h.c:41: (Each undeclared identifier is reported only once
# // h.c:41: for each function it appears in.)
# // h.c:41: parse error before `char'
# // h.c:75: `p' undeclared (first use in this function)
#
#
# Also, if the GCC parser sees a message description that begins with the word
# "Warning" or "warning", it will remove that word from the message and create a
# warning marker. Otherwise, it will create an error marker.
#
#
# From what little experience I've had with the Green Hills C compiler, it
# introduces messages with a line of the following format:
#
# <file>, line <line>: <type> #<ID>: <message>
#
# Where:
#
# <type> is "error" or "warning" or something.
# <ID> is an identifier for the given message.
#
# Example:
#
# "main.c", line 42: error #69-D: stupid mistake
#
# The Green Hills programs seem to wrap long error messages to following lines.
# For example:
#
# "main.c", line 42: error #69-D: This is a long explanation
# of the stupid mistake you made.
# stupid ?= mistake;
# ^
# It appears that the only way you can find the end of the message is to look
# for the line that contains nothing but white space and the caret (^). That
# line and the previous line are not actually part of the message.
#
#
# From what little experience I've had with the Green Hills linker, it
# introduces messages with a line of the following format:
#
# [elxr] (<type>) <description>
#
# Where:
#
# <type> is "error" or "warning" or something.
#
# Example:
#
# [elxr] (error) symbol frob.borz.bix multiply defined in
# plen.o
# garsh.o
#
#=========================================================== ====================
#=========================================================== ====================
#----------------------------------------------------------- --------------------
# Global Variables
#----------------------------------------------------------- --------------------
#
# Usage.
#
Usage="$0 [<GHArgs> ... ]"
#
# The path to the GHS gbuild command.
#
GHSBuilder='C:/GHS/arm407/gbuild.exe -noreasons'
#
# This is the pattern for output lines that introduce compiler messages.
#
# \1: File
# \2: Line number
# \3: Message type
# \4: Message ID
# \5: Message
#
CompilerMasterPattern='^"\([^"][^"]*\)", line \([0-9][0-9]*\): \([a-z ][a-z ]*\) #\([^:][^:]*\): \(.*\)$'
CompilerWarningPattern='^"\([^"][^"]*\)", line \([0-9][0-9]*\): warning #\([^:][^:]*\): \(.*\)$'
#
# This is the pattern for output lines that introduce linker messages.
#
# \1: Message type
# \2: Message
#
LinkerPattern='^\[elxr\] (\([a-z ][a-z ]*\)) \(.*\)$'
#
# Banners.
#
CompilerWarningBanner='i\
\
==== Compiler Warning ================================================\
'
CompilerErrorBanner='i\
\
==== Compiler Error ==================================================\
'
LinkerErrorBanner='i\
\
==== Linker Error ====================================================\
'
#=========================================================== ====================
#----------------------------------------------------------- --------------------
# Build and pipe the result to sed.
#----------------------------------------------------------- --------------------
${GHSBuilder} $@ 2>&1 |\
tr -d '\r' |\
sed -n -e "
#----------------------------------------------------------- ----------------
# Check if this line introduces a compiler message.
#----------------------------------------------------------- ----------------
/${CompilerMasterPattern}/{
#----------------------------------------------------------- ------------
# If control arrives here, this line is a message. Copy this line to the
# hold space.
#----------------------------------------------------------- ------------
h
#----------------------------------------------------------- ------------
# The current line is safely tucked away in the hold space. We now want
# to accumulate lines until we find one that contains nothing but white
# space and a caret.
#----------------------------------------------------------- ------------
:CompilerAccumulate
#----------------------------------------------------------- --------
# Get the next line and append it to the hold space. Note that this
# inserts a newline character, which will be handy later.
#----------------------------------------------------------- --------
n
H
#----------------------------------------------------------- --------
# If the current line contains nothing but white space and a caret,
# we're done accumulating.
#----------------------------------------------------------- --------
/^[ ]*^[ ]*\$/b CompilerDone
#----------------------------------------------------------- --------
# Go back for more.
#----------------------------------------------------------- --------
b CompilerAccumulate
:CompilerDone
#----------------------------------------------------------- ------------
# When control arrives here, we've finished accumulating everything in
# the hold space. We can now start pulling stuff back out. Copy the hold
# space to the pattern space.
#----------------------------------------------------------- ------------
g
#----------------------------------------------------------- ------------
# Remove the source code and caret lines from the pattern space.
#----------------------------------------------------------- ------------
s/\(.*\)\n.*\n.*/\1/
#----------------------------------------------------------- ------------
# Remove all newlines.
#----------------------------------------------------------- ------------
s/\n//g
#----------------------------------------------------------- ------------
# Remove redundant spaces.
#----------------------------------------------------------- ------------
s/ */ /g
#----------------------------------------------------------- ------------
# Figure out what kind of message this is.
#----------------------------------------------------------- ------------
/${CompilerWarningPattern}/{
#----------------------------------------------------------- --------
# If control arrives here, this is a warning message. Print the
# corresponding banner.
#----------------------------------------------------------- --------
${CompilerWarningBanner}
#----------------------------------------------------------- --------
# Reformat this message and insert "warning" at the beginning of the
# description. The GCC error parser will remove the string and
# create a warning marker.
#----------------------------------------------------------- --------
s/${CompilerMasterPattern}/\1:\2: warning \5/
#----------------------------------------------------------- --------
# Branch off and print the message.
#----------------------------------------------------------- --------
b PrintCompilerMessage
}
#----------------------------------------------------------- ------------
# Reformat the message.
#----------------------------------------------------------- ------------
${CompilerErrorBanner}
s/${CompilerMasterPattern}/\1:\2: \5/
#----------------------------------------------------------- ------------
# Control arrives here when we're ready to print the compiler message.
#----------------------------------------------------------- ------------
:PrintCompilerMessage
#----------------------------------------------------------- ------------
# Print the re-formatted message. Eclipse should be able to recognize
# this.
#----------------------------------------------------------- ------------
p
#----------------------------------------------------------- ------------
# We don't want to throw away the source code and caret lines. Retrieve
# the hold space again.
#----------------------------------------------------------- ------------
g
#----------------------------------------------------------- ------------
# Remove all but the source code and caret lines from the pattern space.
#----------------------------------------------------------- ------------
s/.*\n\(.*\n.*\)/\1/
#----------------------------------------------------------- ------------
# Print the source code and caret lines.
#----------------------------------------------------------- ------------
p
#----------------------------------------------------------- ------------
# Go back for more.
#----------------------------------------------------------- ------------
b
}
#----------------------------------------------------------- ----------------
# Check if this line introduces a linker message.
#----------------------------------------------------------- ----------------
/${LinkerPattern}/{
#----------------------------------------------------------- ------------
# Control arrives here if another linker message terminated the previous
# one.
#----------------------------------------------------------- ------------
: AnotherLinkerMessage
#----------------------------------------------------------- ------------
# If control arrives here, this line is a message. Copy this line to the
# hold space.
#----------------------------------------------------------- ------------
h
#----------------------------------------------------------- ------------
# The current line is safely tucked away in the hold space. We now want
# to accumulate lines until we find something that terminates this
# message.
#----------------------------------------------------------- ------------
:LinkerAccumulate
#----------------------------------------------------------- --------
# Get the next line.
#----------------------------------------------------------- --------
n
#----------------------------------------------------------- --------
# Two things will terminate a linker message:
#
# 1) Another linker message.
# 2) A blank line.
#----------------------------------------------------------- --------
/${LinkerPattern}/b LinkerDone
/^[ ]*\$/b LinkerDone
#----------------------------------------------------------- --------
# If control arrives here, this line belongs to the message we've
# already started. Append it to the hold space. Note that this
# inserts a newline character, which will be handy later.
#----------------------------------------------------------- --------
H
#----------------------------------------------------------- --------
# Go back for more.
#----------------------------------------------------------- --------
b LinkerAccumulate
:LinkerDone
#----------------------------------------------------------- ------------
# When control arrives here, we've finished accumulating everything in
# the hold space. We can now start pulling stuff back out. Swap the hold
# and pattern space. We swap, instead of just copying the hold space to
# the pattern space, because the pattern space may now actually hold the
# first part of the next linker message.
#----------------------------------------------------------- ------------
x
#----------------------------------------------------------- ------------
# Print the message.
#----------------------------------------------------------- ------------
${LinkerErrorBanner}
p
#----------------------------------------------------------- ------------
# Swap the hold and pattern space again.
#----------------------------------------------------------- ------------
x
#----------------------------------------------------------- ------------
# Now, the pattern space contains the line that terminated the current
# message. If it's a blank line, then go back to scanning messages.
#----------------------------------------------------------- ------------
/^[ ]*/b
#----------------------------------------------------------- ------------
# If control arrives here, we have the first line of another linker
# message in the pattern space. Go back to process it.
#----------------------------------------------------------- ------------
b AnotherLinkerMessage
}
#----------------------------------------------------------- ----------------
# If control arrives here, this line is not part of a message. Print it and
# go back for more.
#----------------------------------------------------------- ----------------
p
"
--------------020203040002080902000401--
|
|
|
Re: Hacking error messages [message #150282 is a reply to message #150073] |
Fri, 29 July 2005 04:00  |
Eclipse User |
|
|
|
In article <dc6k85$hpp$1@news.eclipse.org>, pturley@pturley.com says...
> We're using Green Hills compilers to compile C code. Eclipse doesn't
> understand Green Hills error messages, so I have to read the console
> output to find my errors and I can't just click on a "Problem" entry to
> jump to the error.
>
> I *could* write an error parser for the Green Hills compiler, but that
> would require me getting elbow-deep in Eclipse development and I'm a
> total n00b (not a Java n00b, just an Eclipse n00b).
>
> Or, I could write a filter using sed scripts or awk or something to put
> Green Hills error messages in a format that Eclipse knows about...
>
> Or so I thought... I tried writing a test program and looking at gcc's
> output. I'm pretty sure this is a hopeless idea.
>
> Does anyone have anything heartening to tell me? Or is this line of
> inquiry as doomed as it appears to be?
>
> Has anyone actually written a Green Hills error parser that is (so far)
> invisible to Google?
>
It is really not too complicated to write an error parser for Eclipse.
I've done it and I'm new to Eclipse and to Java.
You have to write a plugin which requires the
org.eclipse.cdt.core and extends the "ErrorParser" extention point.
Copy the VCErrorParser.jave file and modify it to your needs.
Hope this helps
Klaus
|
|
|
Goto Forum:
Current Time: Thu May 08 19:55:47 EDT 2025
Powered by FUDForum. Page generated in 0.03835 seconds
|