Clean up tracing stuff more, get rid of the trace log since
its not all that useful. Fix a few bugs with python/C++ integration. --HG-- extra : convert_revision : a706512f7dc8b0c88f1ff96fe35ab8fbf9548b78
This commit is contained in:
parent
63a8240059
commit
184decd196
|
@ -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('''
|
||||
|
|
|
@ -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,121 +56,40 @@ bool enabled = true;
|
|||
// output.
|
||||
//
|
||||
ostream *dprintf_stream = &cerr;
|
||||
ostream &
|
||||
output()
|
||||
{
|
||||
return *dprintf_stream;
|
||||
}
|
||||
|
||||
void
|
||||
setOutput(const string &filename)
|
||||
{
|
||||
dprintf_stream = simout.find(filename);
|
||||
}
|
||||
|
||||
ObjectMatch ignore;
|
||||
|
||||
Log theLog;
|
||||
|
||||
Log::Log()
|
||||
{
|
||||
size = 0;
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Log::init(int _size)
|
||||
dprintf(Tick when, const std::string &name, const char *format,
|
||||
CPRINTF_DEFINITION)
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
for (int i = 0; i < size; ++i) {
|
||||
delete buffer[i];
|
||||
}
|
||||
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// no buffering: justget rid of it now
|
||||
if (buffer == NULL) {
|
||||
delete rec;
|
||||
if (!name.empty() && ignore.match(name))
|
||||
return;
|
||||
}
|
||||
|
||||
Record *oldRec = *nextRecPtr;
|
||||
std::ostream &os = *dprintf_stream;
|
||||
|
||||
if (oldRec != NULL) {
|
||||
// log has wrapped: overwrite
|
||||
delete oldRec;
|
||||
}
|
||||
|
||||
*nextRecPtr = rec;
|
||||
|
||||
if (++nextRecPtr == wrapRecPtr) {
|
||||
nextRecPtr = &buffer[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Log::dump(ostream &os)
|
||||
{
|
||||
if (buffer == NULL) {
|
||||
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()
|
||||
{}
|
||||
|
||||
void
|
||||
PrintfRecord::dump(ostream &os)
|
||||
{
|
||||
string fmt = "";
|
||||
CPrintfArgsList args(VARARGS_ALLARGS);
|
||||
|
||||
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;
|
||||
|
@ -178,26 +98,32 @@ PrintfRecord::dump(ostream &os)
|
|||
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)
|
||||
dump(Tick when, const std::string &name, const void *d, int len)
|
||||
{
|
||||
int c, i, j;
|
||||
if (!name.empty() && ignore.match(name))
|
||||
return;
|
||||
|
||||
std::ostream &os = *dprintf_stream;
|
||||
|
||||
string fmt = "";
|
||||
CPrintfArgsList args;
|
||||
|
||||
if (!name.empty()) {
|
||||
fmt = "%s: " + fmt;
|
||||
args.push_front(name);
|
||||
}
|
||||
|
||||
if (when != (Tick)-1) {
|
||||
fmt = "%7d: " + fmt;
|
||||
args.push_front(when);
|
||||
}
|
||||
|
||||
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" */ }
|
||||
|
|
|
@ -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;
|
||||
std::ostream &output();
|
||||
void setOutput(const std::string &filename);
|
||||
|
||||
extern FlagVec flags;
|
||||
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();
|
||||
|
||||
extern std::ostream *dprintf_stream;
|
||||
extern ObjectMatch ignore;
|
||||
extern const std::string DefaultName;
|
||||
|
||||
inline bool
|
||||
IsOn(int t)
|
||||
{
|
||||
return flags[t];
|
||||
}
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
public:
|
||||
DataRecord(Tick cycle, const std::string &name,
|
||||
const void *_data, int _len);
|
||||
virtual ~DataRecord();
|
||||
|
||||
virtual void dump(std::ostream &);
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ®s);
|
||||
|
||||
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 ®s)
|
|||
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -427,7 +427,9 @@ BaseSimpleCPU::postExecute()
|
|||
traceFunctions(thread->readPC());
|
||||
|
||||
if (traceData) {
|
||||
traceData->finalize();
|
||||
traceData->dump();
|
||||
delete traceData;
|
||||
traceData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
%}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue