summaryrefslogtreecommitdiff
path: root/src/base/misc.cc
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2009-04-06 10:19:36 -0700
committerGabe Black <gblack@eecs.umich.edu>2009-04-06 10:19:36 -0700
commitd080581db1f9ee4e1e6d07d2b01c13c67908a391 (patch)
treecc484b289fa5a30c4631f9faa1d8b456bffeebfc /src/base/misc.cc
parent7a7c4c5fca83a8d47c7e71c9c080a882ebe204a9 (diff)
parent639cb0a42d953ee32bc7e96b0cdfa96cd40e9fc1 (diff)
downloadgem5-d080581db1f9ee4e1e6d07d2b01c13c67908a391.tar.xz
Merge ARM into the head. ARM will compile but may not actually work.
Diffstat (limited to 'src/base/misc.cc')
-rw-r--r--src/base/misc.cc96
1 files changed, 46 insertions, 50 deletions
diff --git a/src/base/misc.cc b/src/base/misc.cc
index afb48ca80..035282baf 100644
--- a/src/base/misc.cc
+++ b/src/base/misc.cc
@@ -28,8 +28,10 @@
* Authors: Nathan Binkert
*/
+#include <cstdlib>
#include <iostream>
#include <string>
+#include <zlib.h>
#include "base/cprintf.hh"
#include "base/hostinfo.hh"
@@ -42,42 +44,24 @@
using namespace std;
-void
-__panic(const char *func, const char *file, int line, const char *fmt,
- CPRINTF_DEFINITION)
-{
- string format = "panic: ";
- format += fmt;
- switch (format[format.size() - 1]) {
- case '\n':
- case '\r':
- break;
- default:
- format += "\n";
- }
-
- format += " @ cycle %d\n[%s:%s, line %d]\n";
-
- CPrintfArgsList args(VARARGS_ALLARGS);
-
- args.push_back(curTick);
- args.push_back(func);
- args.push_back(file);
- args.push_back(line);
+bool want_warn = true;
+bool want_info = true;
+bool want_hack = true;
- ccprintf(cerr, format.c_str(), args);
-
- abort();
-}
+bool warn_verbose = false;
+bool info_verbose = false;
+bool hack_verbose = false;
void
-__fatal(const char *func, const char *file, int line, const char *fmt,
- CPRINTF_DEFINITION)
+__exit_message(const char *prefix, int code,
+ const char *func, const char *file, int line,
+ const char *fmt, CPRINTF_DEFINITION)
{
CPrintfArgsList args(VARARGS_ALLARGS);
- string format = "fatal: ";
- format += fmt;
+ string format = prefix;
+ format += ": ";
+ format += fmt;
switch (format[format.size() - 1]) {
case '\n':
case '\r':
@@ -85,28 +69,39 @@ __fatal(const char *func, const char *file, int line, const char *fmt,
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);
- exit(1);
+ if (code < 0)
+ abort();
+ else
+ exit(code);
}
void
-__warn(const char *func, const char *file, int line, const char *fmt,
- CPRINTF_DEFINITION)
+__base_message(std::ostream &stream, const char *prefix, bool verbose,
+ const char *func, const char *file, int line,
+ const char *fmt, CPRINTF_DEFINITION)
{
- string format = "warn: ";
- format += fmt;
+ CPrintfArgsList args(VARARGS_ALLARGS);
+ string format = prefix;
+ format += ": ";
+ format += fmt;
switch (format[format.size() - 1]) {
case '\n':
case '\r':
@@ -114,21 +109,22 @@ __warn(const char *func, const char *file, int line, const char *fmt,
default:
format += "\n";
}
+
+ uint32_t crc = crc32(0, (const Bytef*)fmt, strlen(fmt));
+
+ if (verbose) {
+ format += " @ cycle %d\n[%s:%s, line %d]\n";
+ args.push_back(curTick);
+ args.push_back(func);
+ args.push_back(file);
+ args.push_back(line);
+ }
-#ifdef VERBOSE_WARN
- format += " @ cycle %d\n[%s:%s, line %d]\n";
-#endif
-
- CPrintfArgsList args(VARARGS_ALLARGS);
-
-#ifdef VERBOSE_WARN
- args.push_back(curTick);
- args.push_back(func);
- args.push_back(file);
- args.push_back(line);
-#endif
+ 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(cerr, format.c_str(), args);
- if (simout.isFile(*outputStream))
- ccprintf(*outputStream, format.c_str(), args);
+ ccprintf(stream, format.c_str(), args);
}