From f4291aac256622546a5a51dce109599007f5b3cb Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Fri, 30 Jan 2009 20:04:15 -0500 Subject: [PATCH] Errors: Print a URL with a hash of the format string to find more information about an error. --- configs/common/Simulation.py | 20 ++++++++++---------- configs/example/fs.py | 4 ++-- configs/example/se.py | 2 +- src/base/misc.cc | 14 ++++++++++++++ src/python/m5/SimObject.py | 4 ++-- src/python/m5/__init__.py | 20 ++++++++++++++++---- src/python/m5/params.py | 4 ++-- 7 files changed, 47 insertions(+), 21 deletions(-) diff --git a/configs/common/Simulation.py b/configs/common/Simulation.py index e604dd0d9..3e4b8ec93 100644 --- a/configs/common/Simulation.py +++ b/configs/common/Simulation.py @@ -78,10 +78,10 @@ def run(options, root, testsys, cpu_class): cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: - m5.panic("Error: Can't specify both --fast-forward and --checkpoint-restore") + m5.fatal("Error: Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: - m5.panic("Error: Must specify --caches when using --standard-switch") + m5.fatal("Error: Must specify --caches when using --standard-switch") np = options.num_cpus max_checkpoints = options.max_checkpoints @@ -129,7 +129,7 @@ def run(options, root, testsys, cpu_class): # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: - m5.panic('simpoint not found') + m5.fatal('simpoint not found') testsys.cpu[i].max_insts_any_thread = \ testsys.cpu[i].workload[0].simpoint # No distance specified, just switch @@ -163,7 +163,7 @@ def run(options, root, testsys, cpu_class): if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: - m5.panic('no simpoint for testsys.cpu[%d].workload[0]' % i) + m5.fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below @@ -183,13 +183,13 @@ def run(options, root, testsys, cpu_class): import re if not isdir(cptdir): - m5.panic("checkpoint dir %s does not exist!" % cptdir) + m5.fatal("checkpoint dir %s does not exist!", cptdir) if options.at_instruction: checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % \ (options.bench, options.checkpoint_restore)) if not exists(checkpoint_dir): - m5.panic("Unable to find checkpoint directory %s" % \ + m5.fatal("Unable to find checkpoint directory %s", checkpoint_dir) print "Restoring checkpoint ..." @@ -198,7 +198,7 @@ def run(options, root, testsys, cpu_class): elif options.simpoint: # assume workload 0 has the simpoint if testsys.cpu[0].workload[0].simpoint == 0: - m5.panic('Unable to find simpoint') + m5.fatal('Unable to find simpoint') options.checkpoint_restore += \ int(testsys.cpu[0].workload[0].simpoint) @@ -206,8 +206,8 @@ def run(options, root, testsys, cpu_class): checkpoint_dir = joinpath(cptdir, "cpt.%s.%d" % \ (options.bench, options.checkpoint_restore)) if not exists(checkpoint_dir): - m5.panic("Unable to find checkpoint directory %s.%s" % \ - (options.bench, options.checkpoint_restore)) + m5.fatal("Unable to find checkpoint directory %s.%s", + options.bench, options.checkpoint_restore) print "Restoring checkpoint ..." m5.restoreCheckpoint(root,checkpoint_dir) @@ -226,7 +226,7 @@ def run(options, root, testsys, cpu_class): cpt_num = options.checkpoint_restore if cpt_num > len(cpts): - m5.panic('Checkpoint %d not found' % cpt_num) + m5.fatal('Checkpoint %d not found', cpt_num) ## Adjust max tick based on our starting tick maxtick = maxtick - int(cpts[cpt_num - 1]) diff --git a/configs/example/fs.py b/configs/example/fs.py index 5b5d26c90..c155d0222 100644 --- a/configs/example/fs.py +++ b/configs/example/fs.py @@ -31,7 +31,7 @@ import optparse, os, sys import m5 if not m5.build_env['FULL_SYSTEM']: - m5.panic("This script requires full-system mode (*_FS).") + m5.fatal("This script requires full-system mode (*_FS).") from m5.objects import * m5.AddToPath('../common') @@ -105,7 +105,7 @@ elif m5.build_env['TARGET_ISA'] == "sparc": elif m5.build_env['TARGET_ISA'] == "x86": test_sys = makeLinuxX86System(test_mem_mode, bm[0]) else: - m5.panic("incapable of building non-alpha or non-sparc full system!") + m5.fatal("incapable of building non-alpha or non-sparc full system!") if options.kernel is not None: test_sys.kernel = binary(options.kernel) diff --git a/configs/example/se.py b/configs/example/se.py index a2172aeb5..1193da004 100644 --- a/configs/example/se.py +++ b/configs/example/se.py @@ -33,7 +33,7 @@ import m5 if m5.build_env['FULL_SYSTEM']: - m5.panic("This script requires syscall emulation mode (*_SE).") + m5.fatal("This script requires syscall emulation mode (*_SE).") from m5.objects import * import os, optparse, sys diff --git a/src/base/misc.cc b/src/base/misc.cc index b0c769ac6..035282baf 100644 --- a/src/base/misc.cc +++ b/src/base/misc.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include "base/cprintf.hh" #include "base/hostinfo.hh" @@ -68,15 +69,20 @@ __exit_message(const char *prefix, int code, default: format += "\n"; } + + uint32_t crc = crc32(0, (const Bytef*)fmt, strlen(fmt)); format += " @ cycle %d\n[%s:%s, line %d]\n"; format += "Memory Usage: %ld KBytes\n"; + format += "For more information see: http://www.m5sim.org/%s/%x\n"; args.push_back(curTick); args.push_back(func); args.push_back(file); args.push_back(line); args.push_back(memUsage()); + args.push_back(prefix); + args.push_back(crc); ccprintf(cerr, format.c_str(), args); @@ -103,6 +109,8 @@ __base_message(std::ostream &stream, const char *prefix, bool verbose, default: format += "\n"; } + + uint32_t crc = crc32(0, (const Bytef*)fmt, strlen(fmt)); if (verbose) { format += " @ cycle %d\n[%s:%s, line %d]\n"; @@ -112,5 +120,11 @@ __base_message(std::ostream &stream, const char *prefix, bool verbose, args.push_back(line); } + if (strcmp(prefix, "warn") == 0) { + format += "For more information see: http://www.m5sim.org/%s/%x\n"; + args.push_back(prefix); + args.push_back(crc); + } + ccprintf(stream, format.c_str(), args); } diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index 2b5dd1bc2..1db9c7495 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -748,8 +748,8 @@ class SimObject(object): for param in param_names: value = self._values.get(param) if value is None: - m5.fatal("%s.%s without default or user set value" \ - % (self.path(), param)) + m5.fatal("%s.%s without default or user set value", + self.path(), param) value = value.getValue() if isinstance(self._params[param], VectorParamDesc): diff --git a/src/python/m5/__init__.py b/src/python/m5/__init__.py index 97b22ef2a..733258acf 100644 --- a/src/python/m5/__init__.py +++ b/src/python/m5/__init__.py @@ -37,18 +37,30 @@ MaxTick = 2**63 - 1 # define this here so we can use it right away if necessary +def errorURL(prefix, s): + try: + import zlib + hashstr = "%x" % zlib.crc32(s) + except: + hashstr = "UnableToHash" + return "For more information see: http://www.m5sim.org/%s/%s" % \ + (prefix, hashstr) + + # panic() should be called when something happens that should never # ever happen regardless of what the user does (i.e., an acutal m5 # bug). -def panic(string): - print >>sys.stderr, 'panic:', string +def panic(fmt, *args): + print >>sys.stderr, 'panic:', fmt % args + print >>sys.stderr, errorURL('panic',fmt) sys.exit(1) # fatal() should be called when the simulation cannot continue due to # some condition that is the user's fault (bad configuration, invalid # arguments, etc.) and not a simulator bug. -def fatal(string): - print >>sys.stderr, 'fatal:', string +def fatal(fmt, *args): + print >>sys.stderr, 'fatal:', fmt % args + print >>sys.stderr, errorURL('fatal',fmt) sys.exit(1) # force scalars to one-element lists for uniformity diff --git a/src/python/m5/params.py b/src/python/m5/params.py index 081bd342e..18eeac0d1 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -327,8 +327,8 @@ class CheckedIntType(MetaParamValue): if not (hasattr(cls, 'min') and hasattr(cls, 'max')): if not (hasattr(cls, 'size') and hasattr(cls, 'unsigned')): panic("CheckedInt subclass %s must define either\n" \ - " 'min' and 'max' or 'size' and 'unsigned'\n" \ - % name); + " 'min' and 'max' or 'size' and 'unsigned'\n", + name); if cls.unsigned: cls.min = 0 cls.max = 2 ** cls.size - 1