From: Ciro Santilli Date: Fri, 22 Nov 2019 16:14:50 +0000 (+0000) Subject: sim: print --debug-flag Event execution and instance ID X-Git-Tag: v20.0.0.0~459 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0aafbd422a54169777443310b35c37c6e145c8fa;p=gem5.git sim: print --debug-flag Event execution and instance ID This makes it much easier to determine what event is causing something to happen, especially when there are multiple events happening at the same time. Change-Id: I17378e16bd3de1d98e936a6252aab2cd8c303b23 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25383 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc index 6141380a1..25131b3f6 100644 --- a/src/sim/eventq.cc +++ b/src/sim/eventq.cc @@ -81,11 +81,7 @@ Event::~Event() const std::string Event::name() const { -#ifndef NDEBUG - return csprintf("Event_%d", instance); -#else - return csprintf("Event_%x", (uintptr_t)this); -#endif + return csprintf("Event_%s", instanceString()); } @@ -220,7 +216,8 @@ EventQueue::serviceOne() if (!event->squashed()) { // forward current cycle to the time when this event occurs. setCurTick(event->when()); - + if (DTRACE(Event)) + event->trace("executed"); event->process(); if (event->isExitEvent()) { assert(!event->flags.isSet(Event::Managed) || @@ -388,8 +385,18 @@ Event::trace(const char *action) // more informative message in the trace, override this method on // the particular subclass where you have the information that // needs to be printed. - DPRINTF_UNCONDITIONAL(Event, "%s event %s @ %d\n", - description(), action, when()); + DPRINTF_UNCONDITIONAL(Event, "%s %s %s @ %d\n", + description(), instanceString(), action, when()); +} + +const std::string +Event::instanceString() const +{ +#ifndef NDEBUG + return csprintf("%d", instance); +#else + return csprintf("%#x", (uintptr_t)this); +#endif } void diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh index a703363ab..2976e11cb 100644 --- a/src/sim/eventq.hh +++ b/src/sim/eventq.hh @@ -284,6 +284,9 @@ class Event : public EventBase, public Serializable // This function isn't really useful if TRACING_ON is not defined virtual void trace(const char *action); //!< trace event activity + /// Return the instance number as a string. + const std::string instanceString() const; + protected: /* Memory management */ /** * @{