Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/44988 )

Change subject: base,arch,dev,mem: Always compile DPRINTFs, even if they're disabled.
......................................................................

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
---
M src/arch/arm/nativetrace.cc
M src/arch/sparc/process.cc
M src/base/remote_gdb.cc
M src/base/trace.hh
M src/dev/net/i8254xGBe.cc
M src/mem/cache/base.cc
M src/mem/cache/cache.cc
7 files changed, 13 insertions(+), 36 deletions(-)



diff --git a/src/arch/arm/nativetrace.cc b/src/arch/arm/nativetrace.cc
index 805c139..d1f6854 100644
--- a/src/arch/arm/nativetrace.cc
+++ b/src/arch/arm/nativetrace.cc
@@ -51,7 +51,6 @@

 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 @@
     "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30",
     "f31", "fpscr"
 };
-#endif

 void
 Trace::ArmNativeTrace::ThreadState::update(NativeTrace *parent)
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc
index 043cce7..51a0b7d 100644
--- a/src/arch/sparc/process.cc
+++ b/src/arch/sparc/process.cc
@@ -286,9 +286,7 @@
     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);
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index efda8e8..fc6813c 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -330,7 +330,6 @@
     GdbAccWp = '4',
 };

-#ifndef NDEBUG
 const char *
 breakType(char c)
 {
@@ -343,7 +342,6 @@
       default: return "unknown breakpoint/watchpoint";
     }
 }
-#endif

 std::map<Addr, HardBreakpoint *> hardBreakMap;

diff --git a/src/base/trace.hh b/src/base/trace.hh
index e0b07fd..21a5ead 100644
--- a/src/base/trace.hh
+++ b/src/base/trace.hh
@@ -166,54 +166,45 @@
  * @{
  */

-#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 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)

-#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 DPRINTFN(...) do {} while (0)
-#define DPRINTFNR(...) do {} while (0)
-
-#endif  // TRACING_ON
-
 /** @} */ // end of api_trace

 #endif // __BASE_TRACE_HH__
diff --git a/src/dev/net/i8254xGBe.cc b/src/dev/net/i8254xGBe.cc
index 5e78bdc..8388b3b 100644
--- a/src/dev/net/i8254xGBe.cc
+++ b/src/dev/net/i8254xGBe.cc
@@ -992,9 +992,7 @@
     }


-#ifndef NDEBUG
     int oldCp = cachePnt;
-#endif

     cachePnt += curFetching;
     assert(cachePnt <= descLen());
@@ -1015,10 +1013,8 @@
 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());
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index e35cace..772dc86 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -1417,9 +1417,7 @@
     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));
diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index 4bec7de..d5c6b55 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -591,9 +591,7 @@
     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));


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44988
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ia95ae229ebcd2fc9828f62e87f037f76b9279819
Gerrit-Change-Number: 44988
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to