changeset 31ba8b062d08 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=31ba8b062d08
description:
isa_parser: add a debug variable that changes how errors are reported.
This allows us to get tracebacks in certain cases where they're more
useful than our error message.
diffstat:
1 file changed, 14 insertions(+), 2 deletions(-)
src/arch/isa_parser.py | 16 ++++++++++++++--
diffs (75 lines):
diff -r f4895857bb48 -r 31ba8b062d08 src/arch/isa_parser.py
--- a/src/arch/isa_parser.py Fri Feb 26 18:14:48 2010 -0800
+++ b/src/arch/isa_parser.py Fri Feb 26 18:14:48 2010 -0800
@@ -36,6 +36,8 @@
from m5.util.grammar import Grammar
+debug=False
+
###################
# Utility functions
@@ -83,7 +85,7 @@
self.lineno = first
self.string = second
- def display(self, filename_stack, print_traceback=False):
+ def display(self, filename_stack, print_traceback=debug):
# Output formatted to work under Emacs compile-mode. Optional
# 'print_traceback' arg, if set to True, prints a Python stack
# backtrace too (can be handy when trying to debug the parser
@@ -104,7 +106,7 @@
return "%s%s %s" % (spaces, line_str, self.string)
- def exit(self, filename_stack, print_traceback=False):
+ def exit(self, filename_stack, print_traceback=debug):
# Just call exit.
sys.exit(self.display(filename_stack, print_traceback))
@@ -247,6 +249,8 @@
try:
vars = self.func(self.user_code, context, *args[0], **args[1])
except Exception, exc:
+ if debug:
+ raise
error(lineno, 'error defining "%s": %s.' % (name, exc))
for k in vars.keys():
if k not in ('header_output', 'decoder_output',
@@ -882,6 +886,8 @@
try:
base_cls = eval(base_cls_name + 'Operand')
except NameError:
+ if debug:
+ raise
error(lineno,
'error: unknown operand base class "%s"' % base_cls_name)
# The following statement creates a new class called
@@ -1518,6 +1524,8 @@
try:
exec fixPythonIndentation(t[2]) in exportContext
except Exception, exc:
+ if debug:
+ raise
error(t, 'error: %s in global let block "%s".' % (exc, t[2]))
t[0] = GenCode(header_output = exportContext["header_output"],
decoder_output = exportContext["decoder_output"],
@@ -1531,6 +1539,8 @@
try:
user_dict = eval('{' + t[3] + '}')
except Exception, exc:
+ if debug:
+ raise
error(t,
'error: %s in def operand_types block "%s".' % (exc, t[3]))
buildOperandTypeMap(user_dict, t.lexer.lineno)
@@ -1545,6 +1555,8 @@
try:
user_dict = eval('{' + t[3] + '}', exportContext)
except Exception, exc:
+ if debug:
+ raise
error(t, 'error: %s in def operands block "%s".' % (exc, t[3]))
buildOperandNameMap(user_dict, t.lexer.lineno)
t[0] = GenCode() # contributes nothing to the output C++ file
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev