From f5a803f56e6057a9d908c47aa05fbbfb98a575b5 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Mon, 5 Feb 2007 22:05:00 -0800 Subject: Use an instance counter to give Events repeatable IDs in debugging mode (especially valuable for tracediff). --HG-- extra : convert_revision : 227434a06b5271a8300f2f6861bd06c4ac19e6c4 --- src/sim/eventq.cc | 2 ++ src/sim/eventq.hh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'src') diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc index 6ae838897..de3050d8c 100644 --- a/src/sim/eventq.cc +++ b/src/sim/eventq.cc @@ -53,6 +53,8 @@ using namespace std; // EventQueue mainEventQueue("MainEventQueue"); +Counter Event::instanceCounter = 0; + void EventQueue::insert(Event *event) { diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh index fa65b08af..1aeb26e25 100644 --- a/src/sim/eventq.hh +++ b/src/sim/eventq.hh @@ -75,6 +75,18 @@ class Event : public Serializable, public FastAlloc friend class EventQueue; private: + +#ifndef NDEBUG + /// Global counter to generate unique IDs for Event instances + static Counter instanceCounter; + + /// This event's unique ID. We can also use pointer values for + /// this but they're not consistent across runs making debugging + /// more difficult. Thus we use a global counter value when + /// debugging. + Counter instanceId; +#endif // NDEBUG + /// queue to which this event belongs (though it may or may not be /// scheduled on this queue yet) EventQueue *queue; @@ -173,12 +185,19 @@ class Event : public Serializable, public FastAlloc #endif annotated_value(0) { +#ifndef NDEBUG + instanceId = ++instanceCounter; +#endif } ~Event() {} virtual const std::string name() const { +#ifndef NDEBUG + return csprintf("Event_%d", instanceId); +#else return csprintf("Event_%x", (uintptr_t)this); +#endif } /// Determine if the current event is scheduled -- cgit v1.2.3