summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2004-01-30 16:01:26 -0500
committerNathan Binkert <binkertn@umich.edu>2004-01-30 16:01:26 -0500
commit4ae64216c3c27e9f1e35ce93114f932f3d2c3361 (patch)
treefe3ca24667628af7c2e5a94a3bcae585fb492855 /base
parenta0c3e61d320e72bbdddf4cea1413f6638e0faf45 (diff)
parent2f4f7aacf77dea16795a4052613da6092f6efc31 (diff)
downloadgem5-4ae64216c3c27e9f1e35ce93114f932f3d2c3361.tar.xz
Merge
--HG-- extra : convert_revision : 8690e31b64235874d74ea4a1123a408610fb115b
Diffstat (limited to 'base')
-rw-r--r--base/cprintf.cc26
-rw-r--r--base/cprintf.hh1
-rw-r--r--base/loader/elf_object.cc6
-rw-r--r--base/misc.cc40
-rw-r--r--base/statistics.cc57
-rw-r--r--base/trace.cc7
6 files changed, 93 insertions, 44 deletions
diff --git a/base/cprintf.cc b/base/cprintf.cc
index 5796a712b..5cbf0c057 100644
--- a/base/cprintf.cc
+++ b/base/cprintf.cc
@@ -37,9 +37,20 @@ using namespace std;
namespace cp {
+ArgList::~ArgList()
+{
+ while (!objects.empty()) {
+ delete objects.front();
+ objects.pop_front();
+ }
+}
+
void
ArgList::dump(const string &format)
{
+ list_t::iterator iter = objects.begin();
+ list_t::iterator end = objects.end();
+
const char *p = format.c_str();
stream->fill(' ');
@@ -198,22 +209,19 @@ ArgList::dump(const string &format)
}
}
- if (!objects.empty())
+ if (iter != end)
{
- Base *data = objects.front();
- objects.pop_front();
-
ios::fmtflags saved_flags = stream->flags();
char old_fill = stream->fill();
int old_precision = stream->precision();
- data->process(*stream, fmt);
+ (*iter)->process(*stream, fmt);
stream->flags(saved_flags);
stream->fill(old_fill);
stream->precision(old_precision);
- delete data;
+ ++iter;
} else {
*stream << "<missing arg for format>";
}
@@ -241,11 +249,9 @@ ArgList::dump(const string &format)
}
}
- while (!objects.empty()) {
+ while (iter != end) {
*stream << "<extra arg>";
- Base *data = objects.front();
- objects.pop_front();
- delete data;
+ ++iter;
}
}
diff --git a/base/cprintf.hh b/base/cprintf.hh
index ac34cd252..ca5c08b16 100644
--- a/base/cprintf.hh
+++ b/base/cprintf.hh
@@ -89,6 +89,7 @@ class ArgList
public:
ArgList() : stream(&std::cout) {}
+ ~ArgList();
template<class T>
void append(const T &data) {
diff --git a/base/loader/elf_object.cc b/base/loader/elf_object.cc
index 929d455a5..9889b9d4c 100644
--- a/base/loader/elf_object.cc
+++ b/base/loader/elf_object.cc
@@ -30,7 +30,11 @@
// Because of the -Wundef flag we have to do this
#define __LIBELF_INTERNAL__ 0
-#define __LIBELF64_LINUX 1
+// counterintuitive, but the flag below causes libelf to define
+// 64-bit elf types that apparently didn't exist in some older
+// versions of Linux. They seem to be there in 2.4.x, so don't
+// set this now (it causes things to break on 64-bit platforms).
+#define __LIBELF64_LINUX 0
#define __LIBELF_NEED_LINK_H 0
#include <libelf/libelf.h>
diff --git a/base/misc.cc b/base/misc.cc
index 8190caddd..5caf96d40 100644
--- a/base/misc.cc
+++ b/base/misc.cc
@@ -42,7 +42,17 @@ void
__panic(const string &format, cp::ArgList &args, const char *func,
const char *file, int line)
{
- string fmt = "panic: " + format + " @ cycle %d\n[%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);
@@ -63,8 +73,18 @@ void
__fatal(const string &format, cp::ArgList &args, const char *func,
const char *file, int line)
{
- string fmt = "fatal: " + format + " @ cycle %d\n[%s:%s, line %d]\n"
- "Memory Usage: %ld KBytes\n";
+ string fmt = "fatal: " + format;
+
+ switch (fmt[fmt.size() - 1]) {
+ case '\n':
+ case '\r':
+ break;
+ default:
+ fmt += "\n";
+ }
+
+ fmt += " @ cycle %d\n[%s:%s, line %d]\n";
+ fmt += "Memory Usage: %ld KBytes\n";
args.append(curTick);
args.append(func);
@@ -83,16 +103,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 += " @ 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 (outputStream != &cerr && outputStream != &cout)
+ args.dump(*outputStream, fmt);
delete &args;
}
diff --git a/base/statistics.cc b/base/statistics.cc
index 5c9a2bc65..49294ad27 100644
--- a/base/statistics.cc
+++ b/base/statistics.cc
@@ -116,7 +116,7 @@ Data::~Data()
{
if (stream) {
delete py;
- ccprintf(*stream, "if __name__ == '__main__':\n");
+ ccprintf(*stream, "\n\nif __name__ == '__main__':\n");
ccprintf(*stream, " program_display()\n");
stream->close();
delete stream;
@@ -209,30 +209,41 @@ Data::python_dump(const string &name, const string &subname)
++i;
}
}
- py->next();
}
void
Data::python(const string &name, const string &subname, const string &bin)
{
- py->start("collections.append");
- py->start("Collection");
+ py->name("collections.append");
+ py->newline();
+ py->name("Collection");
+ py->newline();
py->qarg(name);
+ py->newline();
py->qarg(subname);
+ py->newline();
py->qarg(bin);
+ py->newline();
py->qarg(hostname());
+ py->newline();
py->qarg(Time::start.date());
- py->startList();
+ py->newline();
+ py->list();
list_t::iterator i = allStats.begin();
list_t::iterator end = allStats.end();
while (i != end) {
StatData *stat = *i;
+ py->newline();
stat->python(*py);
++i;
}
- py->endList();
- py->end();
- py->end();
+ py->newline();
+ py->listEnd();
+ py->newline();
+ py->nameEnd();
+ py->newline();
+ py->nameEnd();
+ py->newline();
}
StatData *
@@ -996,7 +1007,7 @@ VectorDistDataBase::display(ostream &stream, DisplayMode mode) const
void
ScalarDataBase::python(Python &py) const
{
- py.start("Scalar");
+ py.name("Scalar");
py.qarg(name);
py.qqqarg(desc);
py.kwarg("binned", binned());
@@ -1005,7 +1016,7 @@ ScalarDataBase::python(Python &py) const
if (prereq)
py.qkwarg("prereq", prereq->name);
py.kwarg("value", val());
- py.end();
+ py.nameEnd();
}
void
@@ -1013,7 +1024,7 @@ VectorDataBase::python(Python &py) const
{
const_cast<VectorDataBase *>(this)->update();
- py.start("Vector");
+ py.name("Vector");
py.qarg(name);
py.qqqarg(desc);
py.kwarg("binned", binned());
@@ -1026,7 +1037,7 @@ VectorDataBase::python(Python &py) const
py.qkwarg("subnames", subnames);
if (!subdescs.empty())
py.qkwarg("subdescs", subdescs);
- py.end();
+ py.nameEnd();
}
void
@@ -1039,7 +1050,7 @@ DistDataData::python(Python &py, const string &name) const
else
s += "FullDist";
- py.start(s);
+ py.name(s);
py.arg(sum);
py.arg(squares);
py.arg(samples);
@@ -1054,7 +1065,7 @@ DistDataData::python(Python &py, const string &name) const
py.arg(bucket_size);
py.arg(size);
}
- py.end();
+ py.nameEnd();
}
void
@@ -1062,7 +1073,7 @@ FormulaDataBase::python(Python &py) const
{
const_cast<FormulaDataBase *>(this)->update();
- py.start("Formula");
+ py.name("Formula");
py.qarg(name);
py.qqqarg(desc);
py.kwarg("binned", binned());
@@ -1075,7 +1086,7 @@ FormulaDataBase::python(Python &py) const
py.qkwarg("subnames", subnames);
if (!subdescs.empty())
py.qkwarg("subdescs", subdescs);
- py.end();
+ py.nameEnd();
}
void
@@ -1083,7 +1094,7 @@ DistDataBase::python(Python &py) const
{
const_cast<DistDataBase *>(this)->update();
- py.start("Dist");
+ py.name("Dist");
py.qarg(name);
py.qqqarg(desc);
py.kwarg("binned", binned());
@@ -1092,7 +1103,7 @@ DistDataBase::python(Python &py) const
if (prereq)
py.qkwarg("prereq", prereq->name);
data.python(py, "dist");
- py.end();
+ py.nameEnd();
}
void
@@ -1100,7 +1111,7 @@ VectorDistDataBase::python(Python &py) const
{
const_cast<VectorDistDataBase *>(this)->update();
- py.start("VectorDist");
+ py.name("VectorDist");
py.qarg(name);
py.qqqarg(desc);
py.kwarg("binned", binned());
@@ -1121,8 +1132,8 @@ VectorDistDataBase::python(Python &py) const
i->python(py, "");
++i;
}
- py.endTuple();
- py.end();
+ py.tupleEnd();
+ py.nameEnd();
}
void
@@ -1130,7 +1141,7 @@ Vector2dDataBase::python(Python &py) const
{
const_cast<Vector2dDataBase *>(this)->update();
- py.start("Vector2d");
+ py.name("Vector2d");
py.qarg(name);
py.qqqarg(desc);
py.kwarg("binned", binned());
@@ -1149,7 +1160,7 @@ Vector2dDataBase::python(Python &py) const
py.kwarg("x", x);
py.kwarg("y", y);
- py.end();
+ py.nameEnd();
}
void
diff --git a/base/trace.cc b/base/trace.cc
index 99e97e7ea..156110376 100644
--- a/base/trace.cc
+++ b/base/trace.cc
@@ -49,7 +49,7 @@ FlagVec flags(NumFlags, false);
// directly; use DebugOut() (see below) to access this stream for
// output.
//
-ostream *dprintf_stream = NULL;
+ostream *dprintf_stream = &cerr;
int dprintf_ignore_size;
vector<string> dprintf_ignore;
@@ -267,10 +267,7 @@ RawDataRecord::dump(ostream &os)
std::ostream &
DebugOut()
{
- if (Trace::dprintf_stream)
- return *Trace::dprintf_stream;
- else
- return cerr;
+ return *Trace::dprintf_stream;
}
/////////////////////////////////////////////