What does "global" mean in certain gem5 DPRINTF log messages where I expect a SimObject name instead?

Viewed 81

While debugging a problem with --debug-flag Cache, I noticed that this printf:

bool
MSHR::handleSnoop(PacketPtr pkt, Counter _order)
{
    DPRINTF(Cache, "%s for %s\n", __func__, pkt->print());

prints as:

7306617000: Cache: global: handleSnoop for WriteReq [80a70800:80a70803] UC D=110e0000

which was a bit confusing since most DPRINTF lines have the full path to a simobject as in the system.cpu5.dcache for:

7306617000: Cache: system.cpu5.dcache: sendWriteQueuePacket: write WriteReq [80a70800:80a70803] UC D=110e0000

What does this global mean?

Tested in gem5 3ca404da175a66e0b958165ad75eb5f54cb5e772.

1 Answers

global just means that the DPRINTF is being called from neither a SimObject, nor from a class that does implements the name() method.

By expanding the definition of DPRINTF we see that it calls name():

#define DPRINTF(x, ...) do {                     \
    using namespace Debug;                       \
    if (DTRACE(x)) {                             \
        Trace::getDebugLogger()->dprintf_flag(   \
            curTick(), name(), #x, __VA_ARGS__); \
    }                                            \
} while (0)

and name() is defined on the SimObject base class:

    virtual const std::string name() const { return params()->name; }

However, if a class does not derive from SimObject nor implement a custom name(), it just resolves to the global name() declared in src/base/trace.hh:

// Return the global context name "global".  This function gets called when
// the DPRINTF macros are used in a context without a visible name() function
const std::string &name();

which is implemented as:

const std::string &name()
{
    static const std::string default_name("global");

    return default_name;
}

So on the above example, MSHR is not a SimObject, but Cache is.

Related