eventq: Add some debugging code to the eventq.
authorNathan Binkert <nate@binkert.org>
Mon, 8 Dec 2008 15:17:48 +0000 (07:17 -0800)
committerNathan Binkert <nate@binkert.org>
Mon, 8 Dec 2008 15:17:48 +0000 (07:17 -0800)
src/sim/eventq.cc
src/sim/eventq.hh

index f3d0eb461be91042dd8444c54b9ff8f5f77cad45..d1f84fcb2d44fb0986901a4c30a7b78e1bca4bfa 100644 (file)
@@ -59,6 +59,7 @@ Counter Event::instanceCounter = 0;
 
 Event::~Event()
 {
+    assert(!scheduled());
 }
 
 const std::string
index a29942d072f6f78a11a6cce74f05a01393779fc9..33bb342524bb2965243c5c7880eee55b2ee00ef2 100644 (file)
@@ -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);