summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/SConscript1
-rw-r--r--src/base/trace.cc209
-rw-r--r--src/base/trace.hh138
-rw-r--r--src/cpu/exetrace.cc14
-rw-r--r--src/cpu/exetrace.hh26
-rw-r--r--src/cpu/o3/commit_impl.hh3
-rw-r--r--src/cpu/simple/base.cc4
-rw-r--r--src/kern/linux/printk.cc61
-rw-r--r--src/kern/tru64/dump_mbuf.cc9
-rw-r--r--src/kern/tru64/printf.cc62
-rw-r--r--src/kern/tru64/tru64_events.cc9
-rw-r--r--src/python/m5/main.py5
-rw-r--r--src/python/swig/trace.i14
-rw-r--r--src/sim/main.cc5
14 files changed, 232 insertions, 328 deletions
diff --git a/src/SConscript b/src/SConscript
index 9037f9634..d6b4c6c8d 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -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('''
diff --git a/src/base/trace.cc b/src/base/trace.cc
index efa76b044..7afb038be 100644
--- a/src/base/trace.cc
+++ b/src/base/trace.cc
@@ -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" */ }
diff --git a/src/base/trace.hh b/src/base/trace.hh
index dbe98a11b..8e380d8e1 100644
--- a/src/base/trace.hh
+++ b/src/base/trace.hh
@@ -32,132 +32,35 @@
#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
diff --git a/src/cpu/exetrace.cc b/src/cpu/exetrace.cc
index 5108d7338..683cb138e 100644
--- a/src/cpu/exetrace.cc
+++ b/src/cpu/exetrace.cc
@@ -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;
diff --git a/src/cpu/exetrace.hh b/src/cpu/exetrace.hh
index a825f6a82..95a142f3c 100644
--- a/src/cpu/exetrace.hh
+++ b/src/cpu/exetrace.hh
@@ -36,22 +36,24 @@
#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());
}
diff --git a/src/cpu/o3/commit_impl.hh b/src/cpu/o3/commit_impl.hh
index f1457922c..18fb2aaa3 100644
--- a/src/cpu/o3/commit_impl.hh
+++ b/src/cpu/o3/commit_impl.hh
@@ -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;
}
diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc
index b8d1f3bed..80b137909 100644
--- a/src/cpu/simple/base.cc
+++ b/src/cpu/simple/base.cc
@@ -427,7 +427,9 @@ BaseSimpleCPU::postExecute()
traceFunctions(thread->readPC());
if (traceData) {
- traceData->finalize();
+ traceData->dump();
+ delete traceData;
+ traceData = NULL;
}
}
diff --git a/src/kern/linux/printk.cc b/src/kern/linux/printk.cc
index ea3d59f19..0e9fd6620 100644
--- a/src/kern/linux/printk.cc
+++ b/src/kern/linux/printk.cc
@@ -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);
}
diff --git a/src/kern/tru64/dump_mbuf.cc b/src/kern/tru64/dump_mbuf.cc
index 22d2228f0..5ccfbca5d 100644
--- a/src/kern/tru64/dump_mbuf.cc
+++ b/src/kern/tru64/dump_mbuf.cc
@@ -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;
diff --git a/src/kern/tru64/printf.cc b/src/kern/tru64/printf.cc
index 2c767c4d2..4245ac6d0 100644
--- a/src/kern/tru64/printf.cc
+++ b/src/kern/tru64/printf.cc
@@ -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
diff --git a/src/kern/tru64/tru64_events.cc b/src/kern/tru64/tru64_events.cc
index 851b3a526..0ad89f8bd 100644
--- a/src/kern/tru64/tru64_events.cc
+++ b/src/kern/tru64/tru64_events.cc
@@ -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);
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index 0bd5b431a..d02bc466b 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -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)
diff --git a/src/python/swig/trace.i b/src/python/swig/trace.i
index 5d1669d02..69b44c025 100644
--- a/src/python/swig/trace.i
+++ b/src/python/swig/trace.i
@@ -33,18 +33,23 @@
%{
#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;
%}
diff --git a/src/sim/main.cc b/src/sim/main.cc
index 04dbe1ef4..9f9a56450 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -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