I want to know the cache information when the replacement algorithm is executed. So I made the following changes in the latest version of gem5. I added a line of DebugFlag('ReplacementInfo')
command to the /home/cuiyujie/workspace/workGem5/gem5/src/mem/cache/replacement_policies/SConscript
file. Then I added the header file #include "debug/ReplacementInfo.hh"
in the /home/cuiyujie/workspace/workGem5/gem5/build/X86/params/RandomRP.cc
file. Then I used DPRINTF(ReplacementInfo, "candidates");
command in this file. But an error occurred during compilation.
build/X86/mem/cache/replacement_policies/random_rp.cc: In member function'virtual ReplaceableEntry* RandomRP::getVictim(const ReplacementCandidates&) const':
build/X86/mem/cache/replacement_policies/random_rp.cc:82:13: error:'ReplacementInfo' was not declared in this scope
DPRINTF(ReplacementInfo, "candidates");
^
build/X86/mem/cache/replacement_policies/random_rp.cc:82:13: note: suggested alternative:
In file included from build/X86/mem/cache/replacement_policies/random_rp.cc:44:0:
build/X86/debug/ReplacementInfo.hh:18:19: note:'Debug::ReplacementInfo'
extern SimpleFlag ReplacementInfo;
^
build/X86/mem/cache/replacement_policies/random_rp.cc:82:42: error:'DPRINTF' was not declared in this scope
DPRINTF(ReplacementInfo, "candidates");
^
scons: *** [build/X86/mem/cache/replacement_policies/random_rp.o] Error 1
scons: building terminated because of errors.
The second error was:
build/X86/mem/cache/replacement_policies/random_rp.cc:82:42: error:'DPRINTF' was not declared in this scope
DPRINTF(ReplacementInfo, "candidates");
which means you also need:
#include "base/trace.hh"
which is where DPRINTF
is defined.
Error order is a bit messed up because GCC must be assuming that DPRINTF
is a function since it did not see the macro definition, so it tries to evaluate arguments first. But DPRINTF
is a macro, and adds the missing Debug::
to Debug::ReplacementInfo
, which it complained about on the first error:
#define DPRINTF(x, ...) do { \
using namespace Debug; \
if (M5_UNLIKELY(DTRACE(x))) { \
Trace::getDebugLogger()->dprintf_flag( \
curTick(), name(), #x, __VA_ARGS__); \
} \
} while (0)