Home » Language IDEs » C / C++ IDE (CDT) » Hacking error messages
|
Re: Hacking error messages [message #150180 is a reply to message #150073] |
Wed, 27 July 2005 21:33 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Patrick Turley![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=pturley%40pturley.com) Messages: 43 Registered: July 2009 |
Member |
|
|
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 22:01 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Patrick Turley![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=pturley%40pturley.com) Messages: 43 Registered: July 2009 |
Member |
|
|
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--
|
|
| |
Goto Forum:
Current Time: Sun Sep 01 03:20:38 GMT 2024
Powered by FUDForum. Page generated in 0.03379 seconds
|