Giacomo Travaglini has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/69079?usp=email )

Change subject: misc: Rename DEBUG macro into GEM5_DEBUG
......................................................................

misc: Rename DEBUG macro into GEM5_DEBUG

The DEBUG macro is not part of any compiler standards (differently from
NDEBUG, which elides assertions).

It is only meant to differentiate gem5.debug from .fast and .opt builds.
gem5 developers have used it to insert helper code that is supposed to
aid the debugging process in case anything goes wrong.

This generic name is likely to clash with other libraries linked with
gem5.  This is the case of DRAMSim as an example.

Rather than using undef tricks, we just inject a GEM5_DEBUG macro
for gem5.debug builds.

Change-Id: Ie913ca30da615bd0075277a260bbdbc397b7ec87
Signed-off-by: Giacomo Travaglini <giacomo.travagl...@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69079
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
---
M src/SConscript
M src/base/cast.hh
M src/cpu/o3/cpu.hh
M src/cpu/o3/dyn_inst.cc
M src/cpu/o3/dyn_inst.hh
M src/cpu/o3/iew.cc
M src/cpu/o3/inst_queue.cc
M src/cpu/o3/mem_dep_unit.cc
M src/cpu/o3/mem_dep_unit.hh
M src/cpu/pred/tournament.cc
M src/cpu/pred/tournament.hh
M src/gpu-compute/fetch_unit.cc
M src/mem/dramsim2_wrapper.cc
M src/mem/dramsim3_wrapper.cc
M util/tlm/SConstruct
15 files changed, 24 insertions(+), 42 deletions(-)

Approvals:
  kokoro: Regressions pass
  Daniel Carvalho: Looks good to me, approved
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved




diff --git a/src/SConscript b/src/SConscript
index 3179849..4e9048c 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -649,7 +649,7 @@
     'fast': env.Clone(ENV_LABEL='fast', OBJSUFFIX='.fo'),
 }

-envs['debug'].Append(CPPDEFINES=['DEBUG', 'TRACING_ON=1'])
+envs['debug'].Append(CPPDEFINES=['GEM5_DEBUG', 'TRACING_ON=1'])
 envs['opt'].Append(CCFLAGS=['-g'], CPPDEFINES=['TRACING_ON=1'])
 envs['fast'].Append(CPPDEFINES=['NDEBUG', 'TRACING_ON=0'])

diff --git a/src/base/cast.hh b/src/base/cast.hh
index 01464d9..29eefa9 100644
--- a/src/base/cast.hh
+++ b/src/base/cast.hh
@@ -40,7 +40,7 @@
 // type, but in all cases when we cast it to a derived type, we know
 // by construction that it should work correctly.

-#if defined(DEBUG)
+#if defined(GEM5_DEBUG)

 // In debug builds, do the dynamic cast and assert the result is good

diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh
index 08a1312..76a9060 100644
--- a/src/cpu/o3/cpu.hh
+++ b/src/cpu/o3/cpu.hh
@@ -385,7 +385,7 @@
      */
     std::queue<ListIt> removeList;

-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     /** Debug structure to keep track of the sequence numbers still in
      * flight.
      */
diff --git a/src/cpu/o3/dyn_inst.cc b/src/cpu/o3/dyn_inst.cc
index 94433cf..0f500d8 100644
--- a/src/cpu/o3/dyn_inst.cc
+++ b/src/cpu/o3/dyn_inst.cc
@@ -74,7 +74,7 @@
     ++cpu->instcount;

     if (cpu->instcount > 1500) {
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
         cpu->dumpInsts();
         dumpSNList();
 #endif
@@ -86,7 +86,7 @@
         seqNum, cpu->name(), cpu->instcount);
 #endif

-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     cpu->snList.insert(seqNum);
 #endif

@@ -262,13 +262,13 @@
"DynInst: [sn:%lli] Instruction destroyed. Instcount for %s = %i\n",
         seqNum, cpu->name(), cpu->instcount);
 #endif
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     cpu->snList.erase(seqNum);
 #endif
 };


-#ifdef DEBUG
+#ifdef GEM5_DEBUG
 void
 DynInst::dumpSNList()
 {
diff --git a/src/cpu/o3/dyn_inst.hh b/src/cpu/o3/dyn_inst.hh
index 54c0385..d6df09c 100644
--- a/src/cpu/o3/dyn_inst.hh
+++ b/src/cpu/o3/dyn_inst.hh
@@ -452,7 +452,7 @@
     }

   public:
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     void dumpSNList();
 #endif

diff --git a/src/cpu/o3/iew.cc b/src/cpu/o3/iew.cc
index 7cf6c54..e67bc69 100644
--- a/src/cpu/o3/iew.cc
+++ b/src/cpu/o3/iew.cc
@@ -769,7 +769,7 @@
 IEW::sortInsts()
 {
     int insts_from_rename = fromRename->size;
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     for (ThreadID tid = 0; tid < numThreads; tid++)
         assert(insts[tid].empty());
 #endif
diff --git a/src/cpu/o3/inst_queue.cc b/src/cpu/o3/inst_queue.cc
index ee286fc..b236b75 100644
--- a/src/cpu/o3/inst_queue.cc
+++ b/src/cpu/o3/inst_queue.cc
@@ -165,7 +165,7 @@
 InstructionQueue::~InstructionQueue()
 {
     dependGraph.reset();
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     cprintf("Nodes traversed: %i, removed: %i\n",
             dependGraph.nodesTraversed, dependGraph.nodesRemoved);
 #endif
diff --git a/src/cpu/o3/mem_dep_unit.cc b/src/cpu/o3/mem_dep_unit.cc
index bffbf23..bd74e2b 100644
--- a/src/cpu/o3/mem_dep_unit.cc
+++ b/src/cpu/o3/mem_dep_unit.cc
@@ -46,7 +46,7 @@
 namespace o3
 {

-#ifdef DEBUG
+#ifdef GEM5_DEBUG
 int MemDepUnit::MemDepEntry::memdep_count = 0;
 int MemDepUnit::MemDepEntry::memdep_insert = 0;
 int MemDepUnit::MemDepEntry::memdep_erase = 0;
@@ -83,7 +83,7 @@
         }
     }

-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     assert(MemDepEntry::memdep_count == 0);
 #endif
 }
@@ -196,7 +196,7 @@
     // Add the MemDepEntry to the hash.
     memDepHash.insert(
         std::pair<InstSeqNum, MemDepEntryPtr>(inst->seqNum, inst_entry));
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     MemDepEntry::memdep_insert++;
 #endif

@@ -329,7 +329,7 @@
     // Add the MemDepEntry to the hash.
     memDepHash.insert(
std::pair<InstSeqNum, MemDepEntryPtr>(barr_inst->seqNum, inst_entry));
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     MemDepEntry::memdep_insert++;
 #endif

@@ -419,7 +419,7 @@
     (*hash_it).second = NULL;

     memDepHash.erase(hash_it);
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     MemDepEntry::memdep_erase++;
 #endif
 }
@@ -494,7 +494,7 @@
 MemDepUnit::MemDepEntry::MemDepEntry(const DynInstPtr &new_inst) :
     inst(new_inst)
 {
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     ++memdep_count;

     DPRINTF(MemDepUnit,
@@ -508,7 +508,7 @@
     for (int i = 0; i < dependInsts.size(); ++i) {
         dependInsts[i] = NULL;
     }
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     --memdep_count;

     DPRINTF(MemDepUnit,
@@ -556,7 +556,7 @@
         (*hash_it).second = NULL;

         memDepHash.erase(hash_it);
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
         MemDepEntry::memdep_erase++;
 #endif

@@ -635,7 +635,7 @@

     cprintf("Memory dependence hash size: %i\n", memDepHash.size());

-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     cprintf("Memory dependence entries: %i\n", MemDepEntry::memdep_count);
 #endif
 }
diff --git a/src/cpu/o3/mem_dep_unit.hh b/src/cpu/o3/mem_dep_unit.hh
index 6609f8d..57df492 100644
--- a/src/cpu/o3/mem_dep_unit.hh
+++ b/src/cpu/o3/mem_dep_unit.hh
@@ -210,7 +210,7 @@
         bool squashed = false;

         /** For debugging. */
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
         static int memdep_count;
         static int memdep_insert;
         static int memdep_erase;
diff --git a/src/cpu/pred/tournament.cc b/src/cpu/pred/tournament.cc
index c059b5d..b3a5531 100644
--- a/src/cpu/pred/tournament.cc
+++ b/src/cpu/pred/tournament.cc
@@ -349,7 +349,7 @@
     delete history;
 }

-#ifdef DEBUG
+#ifdef GEM5_DEBUG
 int
 TournamentBP::BPHistory::newCount = 0;
 #endif
diff --git a/src/cpu/pred/tournament.hh b/src/cpu/pred/tournament.hh
index 3f2eb25..018d675 100644
--- a/src/cpu/pred/tournament.hh
+++ b/src/cpu/pred/tournament.hh
@@ -159,7 +159,7 @@
      */
     struct BPHistory
     {
-#ifdef DEBUG
+#ifdef GEM5_DEBUG
         BPHistory()
         { newCount++; }
         ~BPHistory()
diff --git a/src/gpu-compute/fetch_unit.cc b/src/gpu-compute/fetch_unit.cc
index 640e29b..4dadbd3 100644
--- a/src/gpu-compute/fetch_unit.cc
+++ b/src/gpu-compute/fetch_unit.cc
@@ -523,7 +523,7 @@
             wavefront->wfSlotId, wavefront->wfDynId, cur_wave_pc,
             wavefront->pc());

-#ifdef DEBUG
+#ifdef GEM5_DEBUG
     int idx = 0;
     for (const auto &buf_pc : bufferedPCs) {
         DPRINTF(GPUFetch, "PC[%d] = %#x\n", idx, buf_pc.first);
diff --git a/src/mem/dramsim2_wrapper.cc b/src/mem/dramsim2_wrapper.cc
index b9bcf14..b174454 100644
--- a/src/mem/dramsim2_wrapper.cc
+++ b/src/mem/dramsim2_wrapper.cc
@@ -37,15 +37,6 @@

 #include <cassert>

-/**
- * When building the debug binary, we need to undo the command-line
- * definition of DEBUG not to clash with DRAMSim2 print macros that
- * are included for no obvious reason.
- */
-#ifdef DEBUG
-#undef DEBUG
-#endif
-
 #include "mem/dramsim2_wrapper.hh"

 #include <fstream>
diff --git a/src/mem/dramsim3_wrapper.cc b/src/mem/dramsim3_wrapper.cc
index 89e4901..69edfde 100644
--- a/src/mem/dramsim3_wrapper.cc
+++ b/src/mem/dramsim3_wrapper.cc
@@ -38,15 +38,6 @@

 #include <cassert>

-/**
- * When building the debug binary, we need to undo the command-line
- * definition of DEBUG not to clash with DRAMsim3 print macros that
- * are included for no obvious reason.
- */
-#ifdef DEBUG
-#undef DEBUG
-#endif
-
 #include "mem/dramsim3_wrapper.hh"

 #include <fstream>
diff --git a/util/tlm/SConstruct b/util/tlm/SConstruct
index 7fe09d4..c05b70b 100644
--- a/util/tlm/SConstruct
+++ b/util/tlm/SConstruct
@@ -62,7 +62,7 @@
                      ])

 if gem5_variant == 'debug':
-    env.Append(CXXFLAGS=['-g', '-DDEBUG'])
+    env.Append(CXXFLAGS=['-g', '-DGEM5_DEBUG'])

deps = [] # keep track of all dependencies required for building the binaries


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/69079?usp=email 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: Ie913ca30da615bd0075277a260bbdbc397b7ec87
Gerrit-Change-Number: 69079
Gerrit-PatchSet: 2
Gerrit-Owner: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to