1a2,4
> * Copyright (c) 2014 ARM Limited
> * All rights reserved
> *
29a33
> * Andrew Bardsley
34a39
> #include <sstream>
42c47,49
< using namespace std;
---
> const std::string &name()
> {
> static const std::string default_name("global");
44c51,52
< namespace Trace {
---
> return default_name;
> }
46c54,56
< const string DefaultName("global");
---
> namespace Trace
> {
>
49,56c59,75
< //
< // This variable holds the output stream for debug information. Other
< // than setting up/redirecting this stream, do *NOT* reference this
< // directly; use DebugOut() (see below) to access this stream for
< // output.
< //
< ostream *dprintf_stream = &cerr;
< ostream &
---
> // This variable holds the output logger for debug information. Other
> // than setting up/redirecting this logger, do *NOT* reference this
> // directly
>
> Logger *debug_logger = NULL;
>
> Logger *
> getDebugLogger()
> {
> /* Set a default logger to cerr when no other logger is set */
> if (!debug_logger)
> debug_logger = new OstreamLogger(std::cerr);
>
> return debug_logger;
> }
>
> std::ostream &
59c78
< return *dprintf_stream;
---
> return getDebugLogger()->getOstream();
63c82
< setOutput(const string &filename)
---
> setDebugLogger(Logger *logger)
65,67c84,87
< dprintf_stream = simout.find(filename);
< if (!dprintf_stream)
< dprintf_stream = simout.create(filename);
---
> if (!logger)
> warn("Trying to set debug logger to NULL\n");
> else
> debug_logger = logger;
72,74c92,93
<
< bool
< __dprintf_prologue(Tick when, const std::string &name)
---
> void
> Logger::dump(Tick when, const std::string &name, const void *d, int len)
77c96
< return false;
---
> return;
79,92d97
< std::ostream &os = *dprintf_stream;
<
< if (when != MaxTick)
< ccprintf(os, "%7d: ", when);
<
< if (!name.empty())
< os << name << ": ";
<
< return true;
< }
<
< void
< dump(Tick when, const std::string &name, const void *d, int len)
< {
94d98
< std::ostream &os = *dprintf_stream;
98,99c102
< if (!__dprintf_prologue(when, name))
< return;
---
> std::ostringstream line;
101c104
< ccprintf(os, "%08x ", i);
---
> ccprintf(line, "%08x ", i);
106c109
< ccprintf(os, "%02x ", data[i + j] & 0xff);
---
> ccprintf(line, "%02x ", data[i + j] & 0xff);
108c111
< ccprintf(os, " ");
---
> ccprintf(line, " ");
112,113c115,116
< ccprintf(os, " ");
< ccprintf(os, " ");
---
> ccprintf(line, " ");
> ccprintf(line, " ");
117c120
< ccprintf(os, "%c", (char)(isprint(ch) ? ch : ' '));
---
> ccprintf(line, "%c", (char)(isprint(ch) ? ch : ' '));
120c123,124
< ccprintf(os, "\n");
---
> ccprintf(line, "\n");
> logMessage(when, name, line.str());
126a131,147
> void
> OstreamLogger::logMessage(Tick when, const std::string &name,
> const std::string &message)
> {
> if (!name.empty() && ignore.match(name))
> return;
>
> if (when != MaxTick)
> ccprintf(stream, "%7d: ", when);
>
> if (!name.empty())
> stream << name << ": ";
>
> stream << message;
> stream.flush();
> }
>