summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-12-08 07:17:48 -0800
committerNathan Binkert <nate@binkert.org>2008-12-08 07:17:48 -0800
commitd0c0c25ebc082576d29257c51e4aee96b378f0c6 (patch)
tree7bf28b68d0080b76b48fc7de3486e120b90ccb50
parent19273164da50011d59b7f362026f8e80260807d4 (diff)
downloadgem5-d0c0c25ebc082576d29257c51e4aee96b378f0c6.tar.xz
eventq: Add some debugging code to the eventq.
-rw-r--r--src/sim/eventq.cc1
-rw-r--r--src/sim/eventq.hh13
2 files changed, 14 insertions, 0 deletions
diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc
index f3d0eb461..d1f84fcb2 100644
--- a/src/sim/eventq.cc
+++ b/src/sim/eventq.cc
@@ -59,6 +59,7 @@ Counter Event::instanceCounter = 0;
Event::~Event()
{
+ assert(!scheduled());
}
const std::string
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index a29942d07..33bb34252 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -77,6 +77,9 @@ class Event : public Serializable, public FastAlloc
static const FlagsType AutoSerialize = 0x0008;
static const FlagsType IsExitEvent = 0x0010;
static const FlagsType IsMainQueue = 0x0020;
+#ifdef EVENTQ_DEBUG
+ static const FlagsType Initialized = 0xf000;
+#endif
private:
// The event queue is now a linked list of linked lists. The
@@ -245,6 +248,7 @@ class Event : public Serializable, public FastAlloc
queue = NULL;
#endif
#ifdef EVENTQ_DEBUG
+ flags.set(Initialized);
whenCreated = curTick;
whenScheduled = 0;
#endif
@@ -469,6 +473,9 @@ EventQueue::schedule(Event *event, Tick when)
{
assert(when >= curTick);
assert(!event->scheduled());
+#ifdef EVENTQ_DEBUG
+ assert((event->flags & Event::Initialized) == Event::Initialized);
+#endif
event->setWhen(when, this);
insert(event);
@@ -486,6 +493,9 @@ inline void
EventQueue::deschedule(Event *event)
{
assert(event->scheduled());
+#ifdef EVENTQ_DEBUG
+ assert((event->flags & Event::Initialized) == Event::Initialized);
+#endif
remove(event);
@@ -504,6 +514,9 @@ EventQueue::reschedule(Event *event, Tick when, bool always)
{
assert(when >= curTick);
assert(always || event->scheduled());
+#ifdef EVENTQ_DEBUG
+ assert((event->flags & Event::Initialized) == Event::Initialized);
+#endif
if (event->scheduled())
remove(event);