base,arch,dev,mem: Always compile DPRINTFs, even if they're disabled.
The code in the body of a DPRINTF will always be compiled, even if it's disabled. If TRACING_ON is false, the if around it will short circuit to false without actually running any code to check the specified condition, and the body of the if will be elided by the compiler as unreachable code. This creates a more consistent environment whether TRACING_ON is on or not, so that variables which are only used in DPRINTF don't have to be guarded by their own TRACING_ON #ifs at the call site. It also ensures that the code inside DPRINTF is always checked to be valid code, even if the DPRINTF itself will never go off. This helps avoid syntax errors, etc, which aren't found because of the configuration of the build being tested with. Change-Id: Ia95ae229ebcd2fc9828f62e87f037f76b9279819 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44988 Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
This commit is contained in:
@@ -51,7 +51,6 @@ using namespace ArmISA;
|
||||
|
||||
namespace Trace {
|
||||
|
||||
#if TRACING_ON
|
||||
static const char *regNames[] = {
|
||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
||||
"r8", "r9", "r10", "fp", "r12", "sp", "lr", "pc",
|
||||
@@ -61,7 +60,6 @@ static const char *regNames[] = {
|
||||
"f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30",
|
||||
"f31", "fpscr"
|
||||
};
|
||||
#endif
|
||||
|
||||
void
|
||||
Trace::ArmNativeTrace::ThreadState::update(NativeTrace *parent)
|
||||
|
||||
@@ -286,9 +286,7 @@ SparcProcess::argsInit(int pageSize)
|
||||
IntType envp_array_base = auxv_array_base - envp_array_size;
|
||||
IntType argv_array_base = envp_array_base - argv_array_size;
|
||||
IntType argc_base = argv_array_base - argc_size;
|
||||
#if TRACING_ON
|
||||
IntType window_save_base = argc_base - window_save_size;
|
||||
#endif
|
||||
|
||||
DPRINTF(Stack, "The addresses of items on the initial stack:\n");
|
||||
DPRINTF(Stack, "%#x - sentry NULL\n", sentry_base);
|
||||
|
||||
@@ -332,7 +332,6 @@ enum GdbBreakpointType
|
||||
GdbAccWp = '4',
|
||||
};
|
||||
|
||||
#ifndef NDEBUG
|
||||
const char *
|
||||
breakType(char c)
|
||||
{
|
||||
@@ -345,7 +344,6 @@ breakType(char c)
|
||||
default: return "unknown breakpoint/watchpoint";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
std::map<Addr, HardBreakpoint *> hardBreakMap;
|
||||
|
||||
|
||||
@@ -173,72 +173,62 @@ const std::string &name();
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if TRACING_ON
|
||||
|
||||
#define DDUMP(x, data, count) do { \
|
||||
if (M5_UNLIKELY(DTRACE(x))) \
|
||||
if (M5_UNLIKELY(TRACING_ON && DTRACE(x))) \
|
||||
Trace::getDebugLogger()->dump( \
|
||||
curTick(), name(), data, count, #x); \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTF(x, ...) do { \
|
||||
if (M5_UNLIKELY(DTRACE(x))) { \
|
||||
if (M5_UNLIKELY(TRACING_ON && DTRACE(x))) { \
|
||||
Trace::getDebugLogger()->dprintf_flag( \
|
||||
curTick(), name(), #x, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTFS(x, s, ...) do { \
|
||||
if (M5_UNLIKELY(DTRACE(x))) { \
|
||||
if (M5_UNLIKELY(TRACING_ON && DTRACE(x))) { \
|
||||
Trace::getDebugLogger()->dprintf_flag( \
|
||||
curTick(), s->name(), #x, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTFR(x, ...) do { \
|
||||
if (M5_UNLIKELY(DTRACE(x))) { \
|
||||
if (M5_UNLIKELY(TRACING_ON && DTRACE(x))) { \
|
||||
Trace::getDebugLogger()->dprintf_flag( \
|
||||
(Tick)-1, std::string(), #x, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTFV(x, ...) do { \
|
||||
if (M5_UNLIKELY(x)) { \
|
||||
if (M5_UNLIKELY(TRACING_ON && (x))) { \
|
||||
Trace::getDebugLogger()->dprintf_flag( \
|
||||
curTick(), name(), x.name(), __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTFN(...) do { \
|
||||
Trace::getDebugLogger()->dprintf(curTick(), name(), __VA_ARGS__); \
|
||||
#define DPRINTFN(...) do { \
|
||||
if (TRACING_ON) { \
|
||||
Trace::getDebugLogger()->dprintf(curTick(), name(), __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTFNR(...) do { \
|
||||
Trace::getDebugLogger()->dprintf((Tick)-1, std::string(), __VA_ARGS__); \
|
||||
#define DPRINTFNR(...) do { \
|
||||
if (TRACING_ON) { \
|
||||
Trace::getDebugLogger()->dprintf((Tick)-1, "", __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTF_UNCONDITIONAL(x, ...) \
|
||||
GEM5_DEPRECATED_MACRO_STMT(DPRINTF_UNCONDITIONAL, \
|
||||
do { Trace::getDebugLogger()->dprintf_flag( \
|
||||
curTick(), name(), #x, __VA_ARGS__); \
|
||||
} while (0), \
|
||||
#define DPRINTF_UNCONDITIONAL(x, ...) \
|
||||
GEM5_DEPRECATED_MACRO_STMT(DPRINTF_UNCONDITIONAL, \
|
||||
do { \
|
||||
if (TRACING_ON) { \
|
||||
Trace::getDebugLogger()->dprintf_flag( \
|
||||
curTick(), name(), #x, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0), \
|
||||
"Use DPRINTFN or DPRINTF with a debug flag instead.")
|
||||
|
||||
#else // !TRACING_ON
|
||||
|
||||
#define DDUMP(x, data, count) do {} while (0)
|
||||
#define DPRINTF(x, ...) do {} while (0)
|
||||
#define DPRINTFS(x, ...) do {} while (0)
|
||||
#define DPRINTFR(...) do {} while (0)
|
||||
#define DPRINTFV(...) do {} while (0)
|
||||
#define DPRINTFN(...) do {} while (0)
|
||||
#define DPRINTFNR(...) do {} while (0)
|
||||
#define DPRINTF_UNCONDITIONAL(x, ...) \
|
||||
GEM5_DEPRECATED_MACRO_STMT(DPRINTF_UNCONDITIONAL, do {} while (0), \
|
||||
"Use DPRINTFN or DPRINTF with a debug flag instead.")
|
||||
|
||||
#endif // TRACING_ON
|
||||
|
||||
/** @} */ // end of api_trace
|
||||
|
||||
#endif // __BASE_TRACE_HH__
|
||||
|
||||
@@ -992,9 +992,7 @@ IGbE::DescCache<T>::fetchComplete()
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
int oldCp = cachePnt;
|
||||
#endif
|
||||
|
||||
cachePnt += curFetching;
|
||||
assert(cachePnt <= descLen());
|
||||
@@ -1015,10 +1013,8 @@ void
|
||||
IGbE::DescCache<T>::wbComplete()
|
||||
{
|
||||
|
||||
long curHead = descHead();
|
||||
#ifndef NDEBUG
|
||||
long curHead = descHead();
|
||||
long oldHead = curHead;
|
||||
#endif
|
||||
|
||||
for (int x = 0; x < wbOut; x++) {
|
||||
assert(usedCache.size());
|
||||
|
||||
2
src/mem/cache/base.cc
vendored
2
src/mem/cache/base.cc
vendored
@@ -1417,9 +1417,7 @@ BaseCache::handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks,
|
||||
Addr addr = pkt->getAddr();
|
||||
bool is_secure = pkt->isSecure();
|
||||
const bool has_old_data = blk && blk->isValid();
|
||||
#if TRACING_ON
|
||||
const std::string old_state = blk ? blk->print() : "";
|
||||
#endif
|
||||
|
||||
// When handling a fill, we should have no writes to this line.
|
||||
assert(addr == pkt->getBlockAddr(blkSize));
|
||||
|
||||
2
src/mem/cache/cache.cc
vendored
2
src/mem/cache/cache.cc
vendored
@@ -591,9 +591,7 @@ Cache::handleAtomicReqMiss(PacketPtr pkt, CacheBlk *&blk,
|
||||
DPRINTF(Cache, "%s: Sending an atomic %s\n", __func__,
|
||||
bus_pkt->print());
|
||||
|
||||
#if TRACING_ON
|
||||
const std::string old_state = blk ? blk->print() : "";
|
||||
#endif
|
||||
|
||||
Cycles latency = ticksToCycles(memSidePort.sendAtomic(bus_pkt));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user