Support for FP Paired Single Operations
[gem5.git] / base / misc.cc
index 0ce9f7be9ed03962efd7dc3d2ce2139c96f96e30..f3c86827b9a1ef6efd840ff38b6aa8f9794fbcac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2002-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <iostream>
 #include <string>
 
-#include "host.hh"
-#include "cprintf.hh"
-#include "misc.hh"
-#include "universe.hh"
-#include "trace.hh"
+#include "base/cprintf.hh"
+#include "base/hostinfo.hh"
+#include "base/misc.hh"
+#include "base/output.hh"
+#include "base/trace.hh"
+#include "sim/host.hh"
+#include "sim/root.hh"
 
 using namespace std;
 
@@ -41,7 +43,18 @@ void
 __panic(const string &format, cp::ArgList &args, const char *func,
         const char *file, int line)
 {
-    string fmt = "panic: " + format + " [%s:%s, line %d]\n";
+    string fmt = "panic: " + format;
+    switch (fmt[fmt.size() - 1]) {
+      case '\n':
+      case '\r':
+        break;
+      default:
+        fmt += "\n";
+    }
+
+    fmt += " @ cycle %d\n[%s:%s, line %d]\n";
+
+    args.append(curTick);
     args.append(func);
     args.append(file);
     args.append(line);
@@ -49,11 +62,6 @@ __panic(const string &format, cp::ArgList &args, const char *func,
 
     delete &args;
 
-#if TRACING_ON
-    // dump trace buffer, if there is one
-    Trace::theLog.dump(cerr);
-#endif
-
     abort();
 }
 
@@ -61,16 +69,24 @@ void
 __fatal(const string &format, cp::ArgList &args, const char *func,
         const char *file, int line)
 {
-    long mem_usage();
+    string fmt = "fatal: " + format;
+
+    switch (fmt[fmt.size() - 1]) {
+      case '\n':
+      case '\r':
+        break;
+      default:
+        fmt += "\n";
+    }
 
-    string fmt = "fatal: " + format + " [%s:%s, line %d]\n"
-        "\n%d\nMemory Usage: %ld KBytes\n";
+    fmt += " @ cycle %d\n[%s:%s, line %d]\n";
+    fmt += "Memory Usage: %ld KBytes\n";
 
+    args.append(curTick);
     args.append(func);
     args.append(file);
     args.append(line);
-    args.append(curTick);
-    args.append(mem_usage());
+    args.append(memUsage());
     args.dump(cerr, fmt);
 
     delete &args;
@@ -83,15 +99,26 @@ __warn(const string &format, cp::ArgList &args, const char *func,
        const char *file, int line)
 {
     string fmt = "warn: " + format;
+
+    switch (fmt[fmt.size() - 1]) {
+      case '\n':
+      case '\r':
+        break;
+      default:
+        fmt += "\n";
+    }
+
 #ifdef VERBOSE_WARN
-    fmt += " [%s:%s, line %d]\n";
+    fmt += " @ cycle %d\n[%s:%s, line %d]\n";
+    args.append(curTick);
     args.append(func);
     args.append(file);
     args.append(line);
-#else
-    fmt += "\n";
 #endif
+
     args.dump(cerr, fmt);
+    if (simout.isFile(*outputStream))
+        args.dump(*outputStream, fmt);
 
     delete &args;
 }