return flags;
}
+bool SimpleFlag::_active = false;
+
Flag *
findFlag(const std::string &name)
{
// should find and remove flag.
}
+void
+SimpleFlag::enableAll()
+{
+ _active = true;
+ for (auto& i : allFlags())
+ i.second->sync();
+}
+
+void
+SimpleFlag::disableAll()
+{
+ _active = false;
+ for (auto& i : allFlags())
+ i.second->sync();
+}
+
void
CompoundFlag::enable()
{
- SimpleFlag::enable();
- for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::enable));
+ for (auto& k : _kids)
+ k->enable();
}
void
CompoundFlag::disable()
{
- SimpleFlag::disable();
- for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::disable));
+ for (auto& k : _kids)
+ k->disable();
}
struct AllFlags : public Flag
protected:
const char *_name;
const char *_desc;
- std::vector<Flag *> _kids;
public:
Flag(const char *name, const char *desc);
std::string name() const { return _name; }
std::string desc() const { return _desc; }
- std::vector<Flag *> kids() { return _kids; }
+ virtual std::vector<Flag *> kids() { return std::vector<Flag*>(); }
virtual void enable() = 0;
virtual void disable() = 0;
+ virtual void sync() {}
};
class SimpleFlag : public Flag
{
+ static bool _active; // whether debug tracings are enabled
protected:
- bool _status;
+ bool _tracing; // tracing is enabled and flag is on
+ bool _status; // flag status
public:
SimpleFlag(const char *name, const char *desc)
: Flag(name, desc), _status(false)
{ }
- bool status() const { return _status; }
- operator bool() const { return _status; }
- bool operator!() const { return !_status; }
+ bool status() const { return _tracing; }
+ operator bool() const { return _tracing; }
+ bool operator!() const { return !_tracing; }
+
+ void enable() { _status = true; sync(); }
+ void disable() { _status = false; sync(); }
+
+ void sync() { _tracing = _active && _status; }
- void enable() { _status = true; }
- void disable() { _status = false; }
+ static void enableAll();
+ static void disableAll();
};
-class CompoundFlag : public SimpleFlag
+class CompoundFlag : public Flag
{
protected:
+ std::vector<Flag *> _kids;
+
void
addFlag(Flag *f)
{
Flag *f14 = nullptr, Flag *f15 = nullptr,
Flag *f16 = nullptr, Flag *f17 = nullptr,
Flag *f18 = nullptr, Flag *f19 = nullptr)
- : SimpleFlag(name, desc)
+ : Flag(name, desc)
{
addFlag(f00); addFlag(f01); addFlag(f02); addFlag(f03); addFlag(f04);
addFlag(f05); addFlag(f06); addFlag(f07); addFlag(f08); addFlag(f09);
addFlag(f15); addFlag(f16); addFlag(f17); addFlag(f18); addFlag(f19);
}
+ std::vector<Flag *> kids() { return _kids; }
+
void enable();
void disable();
};
#include <sstream>
#include <string>
+#include "base/debug.hh"
#include "base/misc.hh"
#include "base/output.hh"
#include "base/str.hh"
namespace Trace
{
-bool enabled = false;
-
// This variable holds the output logger for debug information. Other
// than setting up/redirecting this logger, do *NOT* reference this
// directly
debug_logger = logger;
}
+void
+enable()
+{
+ Debug::SimpleFlag::enableAll();
+}
+
+void
+disable()
+{
+ Debug::SimpleFlag::disableAll();
+}
+
ObjectMatch ignore;
void
/** Delete the current global logger and assign a new one */
void setDebugLogger(Logger *logger);
-/** Enable debug logging */
-extern bool enabled;
+/** Enable/disable debug logging */
+void enable();
+void disable();
} // namespace Trace
#if TRACING_ON
-#define DTRACE(x) ((Debug::x) && Trace::enabled)
+#define DTRACE(x) (Debug::x)
#define DDUMP(x, data, count) do { \
using namespace Debug; \
if (!Debug::ExecEnable)
return NULL;
- if (!Trace::enabled)
- return NULL;
-
return new ExeTracerRecord(when, tc,
staticInst, pc, macroStaticInst);
}
InstPBTrace::getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr si,
TheISA::PCState pc, const StaticInstPtr mi)
{
- // Only record the trace if Exec debugging in enabled
- if (!Trace::enabled || !Debug::ExecEnable)
+ // Only record the trace if Exec debugging is enabled
+ if (!Debug::ExecEnable)
return NULL;
return new InstPBTraceRecord(*this, when, tc, si, pc, mi);
if (!Debug::ExecEnable)
return NULL;
- if (!Trace::enabled)
- return NULL;
-
return new IntelTraceRecord(when, tc, staticInst, pc, macroStaticInst);
}
};
from internal.trace import output, ignore
def disable():
- internal.trace.cvar.enabled = False
+ internal.trace.disable()
def enable():
- internal.trace.cvar.enabled = True
+ internal.trace.enable()
Trace::getDebugLogger()->setIgnore(ignore);
}
-using Trace::enabled;
+inline void enable() { Trace::enable(); }
+inline void disable() { Trace::disable(); }
%}
extern void output(const char *string);
extern void ignore(const char *expr);
-extern bool enabled;
+extern void enable();
+extern void disable();
Stats::initSimStats();
Stats::registerHandlers(CxxConfig::statsReset, CxxConfig::statsDump);
- Trace::enabled = true;
+ Trace::enable();
setDebugFlag("Terminal");
// setDebugFlag("CxxConfig");
Stats::initSimStats();
Stats::registerHandlers(CxxConfig::statsReset, CxxConfig::statsDump);
- Trace::enabled = true;
+ Trace::enable();
setDebugFlag("Terminal");
checkpoint_restore = false;
Stats::initSimStats();
Stats::registerHandlers(CxxConfig::statsReset, CxxConfig::statsDump);
- Trace::enabled = true;
+ Trace::enable();
config_file = new CxxIniFile();
Stats::initSimStats();
Stats::registerHandlers(CxxConfig::statsReset, CxxConfig::statsDump);
- Trace::enabled = true;
+ Trace::enable();
sim_end = 0;
debug = false;