* Authors: Nathan Binkert
*/
+#include <cstdlib>
#include <iostream>
#include <string>
#include "base/misc.hh"
#include "base/output.hh"
#include "base/trace.hh"
-#include "sim/host.hh"
-#include "sim/root.hh"
+#include "base/types.hh"
+#include "base/varargs.hh"
+#include "sim/core.hh"
using namespace std;
-void
-__panic(const string &format, cp::ArgList &args, const char *func,
- const char *file, int line)
-{
- string fmt = "panic: " + format;
- switch (fmt[fmt.size() - 1]) {
- case '\n':
- case '\r':
- break;
- default:
- fmt += "\n";
- }
+bool want_warn = true;
+bool want_info = true;
+bool want_hack = true;
- fmt += " @ cycle %d\n[%s:%s, line %d]\n";
-
- args.append(curTick);
- args.append(func);
- args.append(file);
- args.append(line);
- args.dump(cerr, fmt);
-
- delete &args;
-
- abort();
-}
+bool warn_verbose = false;
+bool info_verbose = false;
+bool hack_verbose = false;
void
-__fatal(const string &format, cp::ArgList &args, const char *func,
- const char *file, int line)
+__exit_message(const char *prefix, int code,
+ const char *func, const char *file, int line,
+ const char *fmt, CPRINTF_DEFINITION)
{
- string fmt = "fatal: " + format;
+ CPrintfArgsList args(VARARGS_ALLARGS);
- switch (fmt[fmt.size() - 1]) {
+ string format = prefix;
+ format += ": ";
+ format += fmt;
+ switch (format[format.size() - 1]) {
case '\n':
case '\r':
break;
default:
- fmt += "\n";
+ format += "\n";
}
- fmt += " @ cycle %d\n[%s:%s, line %d]\n";
- fmt += "Memory Usage: %ld KBytes\n";
+ format += " @ cycle %d\n[%s:%s, line %d]\n";
+ format += "Memory Usage: %ld KBytes\n";
- args.append(curTick);
- args.append(func);
- args.append(file);
- args.append(line);
- args.append(memUsage());
- args.dump(cerr, fmt);
+ args.push_back(curTick());
+ args.push_back(func);
+ args.push_back(file);
+ args.push_back(line);
+ args.push_back(memUsage());
- delete &args;
+ ccprintf(cerr, format.c_str(), args);
- exit(1);
+ if (code < 0)
+ abort();
+ else
+ exit(code);
}
void
-__warn(const string &format, cp::ArgList &args, const char *func,
- const char *file, int line)
+__base_message(std::ostream &stream, const char *prefix, bool verbose,
+ const char *func, const char *file, int line,
+ const char *fmt, CPRINTF_DEFINITION)
{
- string fmt = "warn: " + format;
+ CPrintfArgsList args(VARARGS_ALLARGS);
- switch (fmt[fmt.size() - 1]) {
+ string format = prefix;
+ format += ": ";
+ format += fmt;
+ switch (format[format.size() - 1]) {
case '\n':
case '\r':
break;
default:
- fmt += "\n";
+ format += "\n";
}
-#ifdef VERBOSE_WARN
- fmt += " @ cycle %d\n[%s:%s, line %d]\n";
- args.append(curTick);
- args.append(func);
- args.append(file);
- args.append(line);
-#endif
-
- args.dump(cerr, fmt);
- if (simout.isFile(*outputStream))
- args.dump(*outputStream, 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);
+ }
- delete &args;
+ ccprintf(stream, format.c_str(), args);
}