Clean up tracing stuff more, get rid of the trace log since
authorNathan Binkert <binkertn@umich.edu>
Sat, 10 Feb 2007 23:14:50 +0000 (15:14 -0800)
committerNathan Binkert <binkertn@umich.edu>
Sat, 10 Feb 2007 23:14:50 +0000 (15:14 -0800)
its not all that useful. Fix a few bugs with python/C++
integration.

--HG--
extra : convert_revision : a706512f7dc8b0c88f1ff96fe35ab8fbf9548b78

14 files changed:
src/SConscript
src/base/trace.cc
src/base/trace.hh
src/cpu/exetrace.cc
src/cpu/exetrace.hh
src/cpu/o3/commit_impl.hh
src/cpu/simple/base.cc
src/kern/linux/printk.cc
src/kern/tru64/dump_mbuf.cc
src/kern/tru64/printf.cc
src/kern/tru64/tru64_events.cc
src/python/m5/main.py
src/python/swig/trace.i
src/sim/main.cc

index 9037f96340a8c6c817ec8332ffb8c324e06bd9e6..d6b4c6c8d036035787456767e48c77a6d90871f9 100644 (file)
@@ -151,7 +151,6 @@ base_sources = Split('''
        sim/stat_context.cc
        sim/stat_control.cc
        sim/system.cc
-        sim/trace_control.cc
         ''')
 
 trace_reader_sources = Split('''
index efa76b0443ad276581f38d3c4dc6aed117a27281..7afb038be540cee0834952f2fe47a951a2da8057 100644 (file)
@@ -37,8 +37,9 @@
 #include <vector>
 
 #include "base/misc.hh"
-#include "base/trace.hh"
+#include "base/output.hh"
 #include "base/str.hh"
+#include "base/trace.hh"
 #include "base/varargs.hh"
 
 using namespace std;
@@ -55,149 +56,74 @@ bool enabled = true;
 // output.
 //
 ostream *dprintf_stream = &cerr;
-
-ObjectMatch ignore;
-
-Log theLog;
-
-Log::Log()
+ostream &
+output()
 {
-    size = 0;
-    buffer = NULL;
+    return *dprintf_stream;
 }
 
-
 void
-Log::init(int _size)
+setOutput(const string &filename)
 {
-    if (buffer != NULL) {
-        fatal("Trace::Log::init called twice!");
-    }
-
-    size = _size;
-
-    buffer = new Record *[size];
-
-    for (int i = 0; i < size; ++i) {
-        buffer[i] = NULL;
-    }
-
-    nextRecPtr = &buffer[0];
-    wrapRecPtr = &buffer[size];
+    dprintf_stream = simout.find(filename);
 }
 
+ObjectMatch ignore;
 
-Log::~Log()
+void
+dprintf(Tick when, const std::string &name, const char *format,
+        CPRINTF_DEFINITION)
 {
-    for (int i = 0; i < size; ++i) {
-        delete buffer[i];
-    }
-
-    delete [] buffer;
-}
+    if (!name.empty() && ignore.match(name))
+        return;
 
+    std::ostream &os = *dprintf_stream;
 
-void
-Log::append(Record *rec)
-{
-    // dump record to output stream if there's one open
-    if (dprintf_stream != NULL) {
-        rec->dump(*dprintf_stream);
-    } else {
-        rec->dump(cout);
-    }
+    string fmt = "";
+    CPrintfArgsList args(VARARGS_ALLARGS);
 
-    // no buffering: justget rid of it now
-    if (buffer == NULL) {
-        delete rec;
-        return;
+    if (!name.empty()) {
+        fmt = "%s: " + fmt;
+        args.push_front(name);
     }
 
-    Record *oldRec = *nextRecPtr;
-
-    if (oldRec != NULL) {
-        // log has wrapped: overwrite
-        delete oldRec;
+    if (when != (Tick)-1) {
+        fmt = "%7d: " + fmt;
+        args.push_front(when);
     }
 
-    *nextRecPtr = rec;
+    fmt += format;
 
-    if (++nextRecPtr == wrapRecPtr) {
-        nextRecPtr = &buffer[0];
-    }
+    ccprintf(os, fmt.c_str(), args);
+    os.flush();
 }
 
-
 void
-Log::dump(ostream &os)
+dump(Tick when, const std::string &name, const void *d, int len)
 {
-    if (buffer == NULL) {
+    if (!name.empty() && ignore.match(name))
         return;
-    }
-
-    Record **bufPtr = nextRecPtr;
-
-    if (*bufPtr == NULL) {
-        // next record slot is empty: log must not be full yet.
-        // start dumping from beginning of buffer
-        bufPtr = buffer;
-    }
-
-    do {
-        Record *rec = *bufPtr;
-
-        rec->dump(os);
 
-        if (++bufPtr == wrapRecPtr) {
-            bufPtr = &buffer[0];
-        }
-    } while (bufPtr != nextRecPtr);
-}
-
-PrintfRecord::~PrintfRecord()
-{}
+    std::ostream &os = *dprintf_stream;
 
-void
-PrintfRecord::dump(ostream &os)
-{
     string fmt = "";
+    CPrintfArgsList args;
 
     if (!name.empty()) {
         fmt = "%s: " + fmt;
         args.push_front(name);
     }
 
-    if (cycle != (Tick)-1) {
+    if (when != (Tick)-1) {
         fmt = "%7d: " + fmt;
-        args.push_front(cycle);
+        args.push_front(when);
     }
 
-    fmt += format;
-
-    ccprintf(os, fmt.c_str(), args);
-    os.flush();
-}
-
-DataRecord::DataRecord(Tick _cycle, const string &_name,
-                       const void *_data, int _len)
-    : Record(_cycle), name(_name), len(_len)
-{
-    data = new uint8_t[len];
-    memcpy(data, _data, len);
-}
-
-DataRecord::~DataRecord()
-{
-    delete [] data;
-}
-
-void
-DataRecord::dump(ostream &os)
-{
+    const char *data = static_cast<const char *>(d);
     int c, i, j;
-
     for (i = 0; i < len; i += 16) {
-        ccprintf(os, "%d: %s: %08x  ", cycle, name, i);
+        ccprintf(os, fmt, args);
+        ccprintf(os, "%08x  ", i);
         c = len - i;
         if (c > 16) c = 16;
 
@@ -213,8 +139,7 @@ DataRecord::dump(ostream &os)
 
         for (j = 0; j < c; j++) {
             int ch = data[i + j] & 0x7f;
-            ccprintf(os,
-                     "%c", (char)(isprint(ch) ? ch : ' '));
+            ccprintf(os, "%c", (char)(isprint(ch) ? ch : ' '));
         }
 
         ccprintf(os, "\n");
@@ -223,4 +148,66 @@ DataRecord::dump(ostream &os)
             break;
     }
 }
-} // namespace Trace
+
+bool
+changeFlag(const char *s, bool value)
+{
+    using namespace Trace;
+    std::string str(s);
+
+    for (int i = 0; i < numFlagStrings; ++i) {
+        if (str != flagStrings[i])
+            continue;
+
+        if (i < NumFlags) {
+            flags[i] = value;
+        } else {
+            i -= NumFlags;
+
+            const Flags *flagVec = compoundFlags[i];
+            for (int j = 0; flagVec[j] != -1; ++j) {
+                if (flagVec[j] < NumFlags)
+                    flags[flagVec[j]] = value;
+            }
+        }
+
+        return true;
+    }
+
+    // the flag was not found.
+    return false;
+}
+
+void
+dumpStatus()
+{
+    using namespace Trace;
+    for (int i = 0; i < numFlagStrings; ++i) {
+        if (flags[i])
+            cprintf("%s\n", flagStrings[i]);
+    }
+}
+
+/* namespace Trace */ }
+
+
+// add a set of functions that can easily be invoked from gdb
+extern "C" {
+    void
+    setTraceFlag(const char *string)
+    {
+        Trace::changeFlag(string, true);
+    }
+
+    void
+    clearTraceFlag(const char *string)
+    {
+        Trace::changeFlag(string, false);
+    }
+
+    void
+    dumpTraceStatus()
+    {
+        Trace::dumpStatus();
+    }
+/* extern "C" */ }
index dbe98a11bf2521797c64823728ec54147a9a13fe..8e380d8e13866ff4ab499b2aece20a1e787c1567 100644 (file)
 #ifndef __BASE_TRACE_HH__
 #define __BASE_TRACE_HH__
 
+#include <string>
 #include <vector>
 
 #include "base/cprintf.hh"
 #include "base/match.hh"
+#include "base/traceflags.hh"
 #include "sim/host.hh"
 #include "sim/root.hh"
 
-#include "base/traceflags.hh"
-
 namespace Trace {
 
-    typedef std::vector<bool> FlagVec;
-
-    extern FlagVec flags;
-
-    extern std::ostream *dprintf_stream;
-
-    inline bool
-    IsOn(int t)
-    {
-        return flags[t];
-    }
-
-    extern bool enabled;
-
-    void dump(const uint8_t *data, int count);
-
-    class Record
-    {
-      protected:
-        Tick cycle;
-
-        Record(Tick _cycle)
-            : cycle(_cycle)
-        {
-        }
-
-      public:
-        virtual ~Record() {}
-
-        virtual void dump(std::ostream &) = 0;
-    };
-
-    class PrintfRecord : public Record
-    {
-      private:
-        const std::string &name;
-        const char *format;
-        CPrintfArgsList args;
-
-      public:
-        PrintfRecord(Tick cycle, const std::string &_name, const char *_format,
-                     CPRINTF_DECLARATION)
-            : Record(cycle), name(_name), format(_format),
-              args(VARARGS_ALLARGS)
-        {
-        }
-
-        virtual ~PrintfRecord();
-
-        virtual void dump(std::ostream &);
-    };
-
-    class DataRecord : public Record
-    {
-      private:
-        const std::string &name;
-        uint8_t *data;
-        int len;
+std::ostream &output();
+void setOutput(const std::string &filename);
 
-      public:
-        DataRecord(Tick cycle, const std::string &name,
-                   const void *_data, int _len);
-        virtual ~DataRecord();
+extern bool enabled;
+typedef std::vector<bool> FlagVec;
+extern FlagVec flags;
+inline bool IsOn(int t) { return flags[t]; }
+bool changeFlag(const char *str, bool value);
+void dumpStatus();
 
-        virtual void dump(std::ostream &);
-    };
+extern ObjectMatch ignore;
+extern const std::string DefaultName;
 
-    class Log
-    {
-      private:
-        int     size;          // number of records in log
-        Record **buffer;       // array of 'size' Record ptrs (circular buf)
-        Record **nextRecPtr;   // next slot to use in buffer
-        Record **wrapRecPtr;   // &buffer[size], for quick wrap check
+void dprintf(Tick when, const std::string &name, const char *format,
+             CPRINTF_DECLARATION);
+void dump(Tick when, const std::string &name, const void *data, int len);
 
-      public:
-        Log();
-        ~Log();
-
-        void init(int _size);
-
-        void append(Record *); // append trace record to log
-        void dump(std::ostream &);     // dump contents to stream
-    };
-
-    extern Log theLog;
-
-    extern ObjectMatch ignore;
-
-    inline void
-    dprintf(Tick when, const std::string &name, const char *format,
-            CPRINTF_DECLARATION)
-    {
-        if (!name.empty() && ignore.match(name))
-            return;
-
-        theLog.append(new Trace::PrintfRecord(when, name, format,
-                                              VARARGS_ALLARGS));
-    }
-
-    inline void
-    dataDump(Tick when, const std::string &name, const void *data, int len)
-    {
-        theLog.append(new Trace::DataRecord(when, name, data, len));
-    }
-
-    extern const std::string DefaultName;
-
-};
-
-inline std::ostream &
-DebugOut()
-{
-    return *Trace::dprintf_stream;
-}
+/* namespace Trace */ }
 
 // This silly little class allows us to wrap a string in a functor
 // object so that we can give a name() that DPRINTF will like
@@ -186,7 +89,7 @@ inline const std::string &name() { return Trace::DefaultName; }
 
 #define DDUMP(x, data, count) do {                              \
     if (DTRACE(x))                                              \
-        Trace::dataDump(curTick, name(), data, count);          \
+        Trace::dump(curTick, name(), data, count);              \
 } while (0)
 
 #define DPRINTF(x, ...) do {                                    \
@@ -199,6 +102,10 @@ inline const std::string &name() { return Trace::DefaultName; }
         Trace::dprintf((Tick)-1, std::string(), __VA_ARGS__);   \
 } while (0)
 
+#define DDUMPN(data, count) do {                                \
+    Trace::dump(curTick, name(), data, count);                  \
+} while (0)
+
 #define DPRINTFN(...) do {                                      \
     Trace::dprintf(curTick, name(), __VA_ARGS__);               \
 } while (0)
@@ -210,11 +117,12 @@ inline const std::string &name() { return Trace::DefaultName; }
 #else // !TRACING_ON
 
 #define DTRACE(x) (false)
+#define DDUMP(x, data, count) do {} while (0)
 #define DPRINTF(x, ...) do {} while (0)
 #define DPRINTFR(...) do {} while (0)
+#define DDUMPN(data, count) do {} while (0)
 #define DPRINTFN(...) do {} while (0)
 #define DPRINTFNR(...) do {} while (0)
-#define DDUMP(x, data, count) do {} while (0)
 
 #endif // TRACING_ON
 
index 5108d7338b293c4496297740e87d6546aaf29672..683cb138e947ba2da4407a1f81b4e4f07f8bcbf0 100644 (file)
@@ -123,8 +123,10 @@ inline void printLevelHeader(ostream & os, int level)
 #endif
 
 void
-Trace::InstRecord::dump(ostream &outs)
+Trace::InstRecord::dump()
 {
+    ostream &outs = Trace::output();
+
     DPRINTF(Sparc, "Instruction: %#X\n", staticInst->machInst);
     if (flags[PRINT_REG_DELTA])
     {
@@ -194,7 +196,7 @@ Trace::InstRecord::dump(ostream &outs)
         bool is_trace_system = true;
 #endif
         if (is_trace_system) {
-            ccprintf(outs, "%7d ) ", cycle);
+            ccprintf(outs, "%7d ) ", when);
             outs << "0x" << hex << PC << ":\t";
             if (staticInst->isLoad()) {
                 outs << "<RD 0x" << hex << addr;
@@ -206,8 +208,8 @@ Trace::InstRecord::dump(ostream &outs)
             outs << endl;
         }
     } else {
-        if (flags[PRINT_CYCLE])
-            ccprintf(outs, "%7d: ", cycle);
+        if (flags[PRINT_TICKS])
+            ccprintf(outs, "%7d: ", when);
 
         outs << thread->getCpuPtr()->name() << " ";
 
@@ -324,7 +326,7 @@ Trace::InstRecord::dump(ostream &outs)
         // We took a trap on a micro-op...
         if (wasMicro && !staticInst->isMicroOp())
         {
-            // let's skip comparing this cycle
+            // let's skip comparing this tick
             while (!compared)
                 if (shared_data->flags == OWN_M5) {
                     shared_data->flags = OWN_LEGION;
@@ -748,7 +750,7 @@ Trace::InstRecord::setParams()
 {
     flags[TRACE_MISSPEC]     = exe_trace_spec;
 
-    flags[PRINT_CYCLE]       = exe_trace_print_cycle;
+    flags[PRINT_TICKS]       = exe_trace_print_cycle;
     flags[PRINT_OP_CLASS]    = exe_trace_print_opclass;
     flags[PRINT_THREAD_NUM]  = exe_trace_print_thread;
     flags[PRINT_RESULT_DATA] = exe_trace_print_effaddr;
index a825f6a82fb497031b4b4e34baae10949da0b07b..95a142f3ca9ea274b6bf2aa60af8812576306c5d 100644 (file)
 #include <fstream>
 #include <vector>
 
-#include "sim/host.hh"
-#include "cpu/inst_seq.hh"     // for InstSeqNum
 #include "base/trace.hh"
-#include "cpu/thread_context.hh"
+#include "cpu/inst_seq.hh"     // for InstSeqNum
 #include "cpu/static_inst.hh"
+#include "cpu/thread_context.hh"
+#include "sim/host.hh"
 
 class ThreadContext;
 
 
 namespace Trace {
 
-class InstRecord : public Record
+class InstRecord
 {
   protected:
     typedef TheISA::IntRegFile IntRegFile;
 
+    Tick when;
+
     // The following fields are initialized by the constructor and
     // thus guaranteed to be valid.
     ThreadContext *thread;
@@ -95,10 +97,10 @@ class InstRecord : public Record
     bool regs_valid;
 
   public:
-    InstRecord(Tick _cycle, ThreadContext *_thread,
+    InstRecord(Tick _when, ThreadContext *_thread,
                const StaticInstPtr &_staticInst,
                Addr _pc, bool spec)
-        : Record(_cycle), thread(_thread),
+        : when(_when), thread(_thread),
           staticInst(_staticInst), PC(_pc),
           misspeculating(spec)
     {
@@ -110,9 +112,7 @@ class InstRecord : public Record
         cp_seq_valid = false;
     }
 
-    virtual ~InstRecord() { }
-
-    virtual void dump(std::ostream &outs);
+    ~InstRecord() { }
 
     void setAddr(Addr a) { addr = a; addr_valid = true; }
 
@@ -136,11 +136,11 @@ class InstRecord : public Record
 
     void setRegs(const IntRegFile &regs);
 
-    void finalize() { theLog.append(this); }
+    void dump();
 
     enum InstExecFlagBits {
         TRACE_MISSPEC = 0,
-        PRINT_CYCLE,
+        PRINT_TICKS,
         PRINT_OP_CLASS,
         PRINT_THREAD_NUM,
         PRINT_RESULT_DATA,
@@ -176,13 +176,13 @@ InstRecord::setRegs(const IntRegFile &regs)
 
 inline
 InstRecord *
-getInstRecord(Tick cycle, ThreadContext *tc,
+getInstRecord(Tick when, ThreadContext *tc,
               const StaticInstPtr staticInst,
               Addr pc)
 {
     if (DTRACE(InstExec) &&
         (InstRecord::traceMisspec() || !tc->misspeculating())) {
-        return new InstRecord(cycle, tc, staticInst, pc,
+        return new InstRecord(when, tc, staticInst, pc,
                               tc->misspeculating());
     }
 
index f1457922c0269615f7778da90180e7c12e9ffcc2..18fb2aaa369ab2dbc04257507610ce5d504be92b 100644 (file)
@@ -1106,7 +1106,8 @@ DefaultCommit<Impl>::commitHead(DynInstPtr &head_inst, unsigned inst_num)
     if (head_inst->traceData) {
         head_inst->traceData->setFetchSeq(head_inst->seqNum);
         head_inst->traceData->setCPSeq(thread[tid]->numInst);
-        head_inst->traceData->finalize();
+        head_inst->traceData->dump();
+        delete head_inst->traceData;
         head_inst->traceData = NULL;
     }
 
index b8d1f3bede10a0d4c180026071e10484305c1cf0..80b137909734dd703eeddf054edf3d62f191f338 100644 (file)
@@ -427,7 +427,9 @@ BaseSimpleCPU::postExecute()
     traceFunctions(thread->readPC());
 
     if (traceData) {
-        traceData->finalize();
+        traceData->dump();
+        delete traceData;
+        traceData = NULL;
     }
 }
 
index ea3d59f19bb77431638858f74613fc059b740941..0e9fd6620b79698b6f8eda187c04d2b16e36f41f 100644 (file)
@@ -41,11 +41,12 @@ using namespace std;
 void
 Printk(TheISA::Arguments args)
 {
+    std::ostream &out = Trace::output();
     char *p = (char *)args++;
 
-    ios::fmtflags saved_flags = DebugOut().flags();
-    char old_fill = DebugOut().fill();
-    int old_precision = DebugOut().precision();
+    ios::fmtflags saved_flags = out.flags();
+    char old_fill = out.fill();
+    int old_precision = out.precision();
 
     while (*p) {
         switch (*p) {
@@ -118,53 +119,53 @@ Printk(TheISA::Arguments args)
                 case 'P':
                 case 'p': {
                   if (hexnum)
-                      DebugOut() << hex;
+                      out << hex;
 
                   if (octal)
-                      DebugOut() << oct;
+                      out << oct;
 
                   if (format) {
                       if (!zero)
-                          DebugOut().setf(ios::showbase);
+                          out.setf(ios::showbase);
                       else {
                           if (hexnum) {
-                              DebugOut() << "0x";
+                              out << "0x";
                               width -= 2;
                           } else if (octal) {
-                              DebugOut() << "0";
+                              out << "0";
                               width -= 1;
                           }
                       }
                   }
 
                   if (zero)
-                      DebugOut().fill('0');
+                      out.fill('0');
 
                   if (width > 0)
-                      DebugOut().width(width);
+                      out.width(width);
 
                   if (leftjustify && !zero)
-                      DebugOut().setf(ios::left);
+                      out.setf(ios::left);
 
                   if (sign) {
                       if (islong)
-                          DebugOut() << (int64_t)args;
+                          out << (int64_t)args;
                       else
-                          DebugOut() << (int32_t)args;
+                          out << (int32_t)args;
                   } else {
                       if (islong)
-                          DebugOut() << (uint64_t)args;
+                          out << (uint64_t)args;
                       else
-                          DebugOut() << (uint32_t)args;
+                          out << (uint32_t)args;
                   }
 
                   if (zero)
-                      DebugOut().fill(' ');
+                      out.fill(' ');
 
                   if (width > 0)
-                      DebugOut().width(0);
+                      out.width(0);
 
-                  DebugOut() << dec;
+                  out << dec;
 
                   ++args;
                 }
@@ -176,11 +177,11 @@ Printk(TheISA::Arguments args)
                         s = "<NULL>";
 
                     if (width > 0)
-                        DebugOut().width(width);
+                        out.width(width);
                     if (leftjustify)
-                        DebugOut().setf(ios::left);
+                        out.setf(ios::left);
 
-                    DebugOut() << s;
+                    out << s;
                     ++args;
                 }
                   break;
@@ -201,7 +202,7 @@ Printk(TheISA::Arguments args)
                     while (width-- > 0) {
                         char c = (char)(num & mask);
                         if (c)
-                            DebugOut() << c;
+                            out << c;
                         num >>= 8;
                     }
 
@@ -211,7 +212,7 @@ Printk(TheISA::Arguments args)
                 case 'b': {
                   uint64_t n = (uint64_t)args++;
                   char *s = (char *)args++;
-                  DebugOut() << s << ": " << n;
+                  out << s << ": " << n;
                 }
                   break;
                 case 'n':
@@ -233,32 +234,32 @@ Printk(TheISA::Arguments args)
                 }
                   break;
                 case '%':
-                  DebugOut() << '%';
+                  out << '%';
                   break;
               }
               ++p;
           }
             break;
           case '\n':
-            DebugOut() << endl;
+            out << endl;
             ++p;
             break;
           case '\r':
             ++p;
             if (*p != '\n')
-                DebugOut() << endl;
+                out << endl;
             break;
 
           default: {
               size_t len = strcspn(p, "%\n\r\0");
-              DebugOut().write(p, len);
+              out.write(p, len);
               p += len;
           }
         }
     }
 
-    DebugOut().flags(saved_flags);
-    DebugOut().fill(old_fill);
-    DebugOut().precision(old_precision);
+    out.flags(saved_flags);
+    out.fill(old_fill);
+    out.precision(old_precision);
 }
 
index 22d2228f078826241baf69cade488c8a136565ac..5ccfbca5dbd4a5cd5602acc68d94ca7331d18a7c 100644 (file)
@@ -50,6 +50,7 @@ void
 DumpMbuf(Arguments args)
 {
     ThreadContext *tc = args.getThreadContext();
+    StringWrap name(tc->getSystemPtr()->name());
     Addr addr = (Addr)args;
     struct mbuf m;
 
@@ -57,16 +58,14 @@ DumpMbuf(Arguments args)
 
     int count = m.m_pkthdr.len;
 
-    ccprintf(DebugOut(), "m=%#lx, m->m_pkthdr.len=%#d\n", addr,
-             m.m_pkthdr.len);
+    DPRINTFN("m=%#lx, m->m_pkthdr.len=%#d\n", addr, m.m_pkthdr.len);
 
     while (count > 0) {
-        ccprintf(DebugOut(), "m=%#lx, m->m_data=%#lx, m->m_len=%d\n",
+        DPRINTFN("m=%#lx, m->m_data=%#lx, m->m_len=%d\n",
                  addr, m.m_data, m.m_len);
         char *buffer = new char[m.m_len];
         CopyOut(tc, buffer, m.m_data, m.m_len);
-        Trace::dataDump(curTick, tc->getSystemPtr()->name(), (uint8_t *)buffer,
-                        m.m_len);
+        DDUMPN((uint8_t *)buffer, m.m_len);
         delete [] buffer;
 
         count -= m.m_len;
index 2c767c4d2f308ef592ccfc2f2f793350d7361271..4245ac6d003a41ce44afd01dbd031cb350bd9e96 100644 (file)
@@ -44,11 +44,13 @@ namespace tru64 {
 void
 Printf(TheISA::Arguments args)
 {
+    std::ostream &out = Trace::output();
+
     char *p = (char *)args++;
 
-    ios::fmtflags saved_flags = DebugOut().flags();
-    char old_fill = DebugOut().fill();
-    int old_precision = DebugOut().precision();
+    ios::fmtflags saved_flags = out.flags();
+    char old_fill = out.fill();
+    int old_precision = out.precision();
 
     while (*p) {
         switch (*p) {
@@ -121,53 +123,53 @@ Printf(TheISA::Arguments args)
                 case 'P':
                 case 'p': {
                   if (hexnum)
-                      DebugOut() << hex;
+                      out << hex;
 
                   if (octal)
-                      DebugOut() << oct;
+                      out << oct;
 
                   if (format) {
                       if (!zero)
-                          DebugOut().setf(ios::showbase);
+                          out.setf(ios::showbase);
                       else {
                           if (hexnum) {
-                              DebugOut() << "0x";
+                              out << "0x";
                               width -= 2;
                           } else if (octal) {
-                              DebugOut() << "0";
+                              out << "0";
                               width -= 1;
                           }
                       }
                   }
 
                   if (zero)
-                      DebugOut().fill('0');
+                      out.fill('0');
 
                   if (width > 0)
-                      DebugOut().width(width);
+                      out.width(width);
 
                   if (leftjustify && !zero)
-                      DebugOut().setf(ios::left);
+                      out.setf(ios::left);
 
                   if (sign) {
                       if (islong)
-                          DebugOut() << (int64_t)args;
+                          out << (int64_t)args;
                       else
-                          DebugOut() << (int32_t)args;
+                          out << (int32_t)args;
                   } else {
                       if (islong)
-                          DebugOut() << (uint64_t)args;
+                          out << (uint64_t)args;
                       else
-                          DebugOut() << (uint32_t)args;
+                          out << (uint32_t)args;
                   }
 
                   if (zero)
-                      DebugOut().fill(' ');
+                      out.fill(' ');
 
                   if (width > 0)
-                      DebugOut().width(0);
+                      out.width(0);
 
-                  DebugOut() << dec;
+                  out << dec;
 
                   ++args;
                 }
@@ -179,11 +181,11 @@ Printf(TheISA::Arguments args)
                         s = "<NULL>";
 
                     if (width > 0)
-                        DebugOut().width(width);
+                        out.width(width);
                     if (leftjustify)
-                        DebugOut().setf(ios::left);
+                        out.setf(ios::left);
 
-                    DebugOut() << s;
+                    out << s;
                     ++args;
                 }
                   break;
@@ -204,7 +206,7 @@ Printf(TheISA::Arguments args)
                     while (width-- > 0) {
                         char c = (char)(num & mask);
                         if (c)
-                            DebugOut() << c;
+                            out << c;
                         num >>= 8;
                     }
 
@@ -214,7 +216,7 @@ Printf(TheISA::Arguments args)
                 case 'b': {
                   uint64_t n = (uint64_t)args++;
                   char *s = (char *)args++;
-                  DebugOut() << s << ": " << n;
+                  out << s << ": " << n;
                 }
                   break;
                 case 'n':
@@ -236,33 +238,33 @@ Printf(TheISA::Arguments args)
                 }
                   break;
                 case '%':
-                  DebugOut() << '%';
+                  out << '%';
                   break;
               }
               ++p;
           }
             break;
           case '\n':
-            DebugOut() << endl;
+            out << endl;
             ++p;
             break;
           case '\r':
             ++p;
             if (*p != '\n')
-                DebugOut() << endl;
+                out << endl;
             break;
 
           default: {
               size_t len = strcspn(p, "%\n\r\0");
-              DebugOut().write(p, len);
+              out.write(p, len);
               p += len;
           }
         }
     }
 
-    DebugOut().flags(saved_flags);
-    DebugOut().fill(old_fill);
-    DebugOut().precision(old_precision);
+    out.flags(saved_flags);
+    out.fill(old_fill);
+    out.precision(old_precision);
 }
 
 } // namespace Tru64
index 851b3a526078748dc41a5b2bc27024cfc41fda55..0ad89f8bd9d3f7860dee7e6c607cd6a4e9e2ca86 100644 (file)
@@ -79,7 +79,8 @@ void
 PrintfEvent::process(ThreadContext *tc)
 {
     if (DTRACE(Printf)) {
-        DebugOut() << curTick << ": " << tc->getCpuPtr()->name() << ": ";
+        StringWrap name(tc->getSystemPtr()->name());
+        DPRINTFN("");
 
         Arguments args(tc);
         tru64::Printf(args);
@@ -90,8 +91,10 @@ void
 DebugPrintfEvent::process(ThreadContext *tc)
 {
     if (DTRACE(DebugPrintf)) {
-        if (!raw)
-            DebugOut() << curTick << ": " << tc->getCpuPtr()->name() << ": ";
+        if (!raw) {
+            StringWrap name(tc->getSystemPtr()->name());
+            DPRINTFN("");
+        }
 
         Arguments args(tc);
         tru64::Printf(args);
index 0bd5b431a5f161b6225662084648499417c42f14..d02bc466b9f234e60d34479af3b3b961590122e1 100644 (file)
@@ -268,7 +268,7 @@ def main():
         internal.debug.schedBreakCycle(int(when))
 
     for flag in options.trace_flags:
-        internal.trace.setFlag(flag)
+        internal.trace.set(flag)
 
     if options.trace_start is not None:
         internal.trace.enabled = False
@@ -276,8 +276,7 @@ def main():
             internal.event.enabled = True
         internal.event.create(enable_trace, options.trace_start)
 
-    #if options.trace_file is not None:
-    #    internal.trace.file(options.trace_file)
+    internal.trace.output(options.trace_file)
 
     for ignore in options.trace_ignore:
         internal.trace.ignore(ignore)
index 5d1669d0299ca35c7f5a9c937ef8cc550580937f..69b44c025957241965e6edad3773055c88af5408 100644 (file)
 %{
 #include "base/trace.hh"
 #include "sim/host.hh"
-#include "sim/trace_control.hh"
+
+inline void
+output(const char *filename)
+{
+    Trace::setOutput(filename);
+}
 
 inline void
 set(const char *flag)
 {
-    setTraceFlag(flag);
+    Trace::changeFlag(flag, true);
 }
 
 inline void
 clear(const char *flag)
 {
-    clearTraceFlag(flag);
+    Trace::changeFlag(flag, false);
 }
 
 inline void
@@ -57,9 +62,10 @@ using Trace::enabled;
 %}
 
 %inline %{
-extern void ignore(const char *expr);
+extern void output(const char *string);
 extern void set(const char *string);
 extern void clear(const char *string);
+extern void ignore(const char *expr);
 extern bool enabled;
 %}
 
index 04dbe1ef43176e0eef6176af3f9eec3e5212ac51..9f9a564506de7e1b9d939e5ce23e0bf8a0f0ab0a 100644 (file)
@@ -111,11 +111,6 @@ void
 abortHandler(int sigtype)
 {
     cerr << "Program aborted at cycle " << curTick << endl;
-
-#if TRACING_ON
-    // dump trace buffer, if there is one
-    Trace::theLog.dump(cerr);
-#endif
 }
 
 int