misc: Rename Debug namespace as debug

As part of recent decisions regarding namespace
naming conventions, all namespaces will be changed
to snake case.

gem5::Debug became gem5::debug.

Change-Id: Ic04606baab3317d2e58ab3ca9b37fc201c406ee8
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47305
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/SConscript b/src/SConscript
index c254269..d5a5b88 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -1154,12 +1154,15 @@
 
     # file header
     code('''
+#include "base/compiler.hh" // For namespace deprecation
 #include "base/debug.hh"
 
 namespace gem5
 {
 
-namespace Debug {
+GEM5_DEPRECATED_NAMESPACE(Debug, debug);
+namespace debug
+{
 
 ''')
 
@@ -1196,7 +1199,7 @@
 
     code.append(comp_code)
     code()
-    code('} // namespace Debug')
+    code('} // namespace debug')
     code('} // namespace gem5')
 
     code.write(str(target[0]))
@@ -1214,10 +1217,14 @@
 #ifndef __DEBUG_${name}_HH__
 #define __DEBUG_${name}_HH__
 
+#include "base/compiler.hh" // For namespace deprecation
+
 namespace gem5
 {
 
-namespace Debug {
+GEM5_DEPRECATED_NAMESPACE(Debug, debug);
+namespace debug
+{
 ''')
 
     if compound:
@@ -1232,7 +1239,7 @@
         code('extern SimpleFlag& $name;')
 
     code('''
-} // namespace Debug
+} // namespace debug
 } // namespace gem5
 
 #endif // __DEBUG_${name}_HH__
diff --git a/src/arch/arm/kvm/arm_cpu.cc b/src/arch/arm/kvm/arm_cpu.cc
index 1661f05..28fa036 100644
--- a/src/arch/arm/kvm/arm_cpu.cc
+++ b/src/arch/arm/kvm/arm_cpu.cc
@@ -679,7 +679,7 @@
         setOneReg(ri->id, value);
     }
 
-    if (Debug::KvmContext)
+    if (debug::KvmContext)
         dumpKvmStateCore();
 }
 
@@ -717,7 +717,7 @@
     }
 
     warned = true;
-    if (Debug::KvmContext)
+    if (debug::KvmContext)
         dumpKvmStateMisc();
 }
 
@@ -823,7 +823,7 @@
     pc.set(getOneRegU32(REG_CORE32(usr_regs.ARM_pc)));
     tc->pcState(pc);
 
-    if (Debug::KvmContext)
+    if (debug::KvmContext)
         dumpKvmStateCore();
 }
 
@@ -856,7 +856,7 @@
 
     warned = true;
 
-    if (Debug::KvmContext)
+    if (debug::KvmContext)
         dumpKvmStateMisc();
 }
 
diff --git a/src/arch/riscv/process.cc b/src/arch/riscv/process.cc
index ce34e3b..bdbb7cc 100644
--- a/src/arch/riscv/process.cc
+++ b/src/arch/riscv/process.cc
@@ -170,7 +170,7 @@
         memState->setStackMin(memState->getStackMin() - (arg.size() + 1));
         initVirtMem->writeString(memState->getStackMin(), arg.c_str());
         argPointers.push_back(memState->getStackMin());
-        if (Debug::Stack) {
+        if (debug::Stack) {
             std::string wrote;
             initVirtMem->readString(wrote, argPointers.back());
             DPRINTFN("Wrote arg \"%s\" to address %p\n",
diff --git a/src/base/debug.cc b/src/base/debug.cc
index 74107fe..8e65e1f 100644
--- a/src/base/debug.cc
+++ b/src/base/debug.cc
@@ -52,7 +52,9 @@
 namespace gem5
 {
 
-namespace Debug {
+GEM5_DEPRECATED_NAMESPACE(Debug, debug);
+namespace debug
+{
 
 //
 // This function will cause the process to signal itself with a
@@ -65,7 +67,7 @@
 #ifndef NDEBUG
     kill(getpid(), SIGTRAP);
 #else
-    cprintf("Debug::breakpoint suppressed, compiled with NDEBUG\n");
+    cprintf("debug::breakpoint suppressed, compiled with NDEBUG\n");
 #endif
 }
 
@@ -154,25 +156,25 @@
     return true;
 }
 
-} // namespace Debug
+} // namespace debug
 
 // add a set of functions that can easily be invoked from gdb
 void
 setDebugFlag(const char *string)
 {
-    Debug::changeFlag(string, true);
+    debug::changeFlag(string, true);
 }
 
 void
 clearDebugFlag(const char *string)
 {
-    Debug::changeFlag(string, false);
+    debug::changeFlag(string, false);
 }
 
 void
 dumpDebugFlags(std::ostream &os)
 {
-    using namespace Debug;
+    using namespace debug;
     FlagsMap::iterator i = allFlags().begin();
     FlagsMap::iterator end = allFlags().end();
     for (; i != end; ++i) {
diff --git a/src/base/debug.hh b/src/base/debug.hh
index c678a25..d2dfee2 100644
--- a/src/base/debug.hh
+++ b/src/base/debug.hh
@@ -48,10 +48,14 @@
 #include <string>
 #include <vector>
 
+#include "base/compiler.hh"
+
 namespace gem5
 {
 
-namespace Debug {
+GEM5_DEPRECATED_NAMESPACE(Debug, debug);
+namespace debug
+{
 
 void breakpoint();
 
@@ -139,7 +143,7 @@
 
 bool changeFlag(const char *s, bool value);
 
-} // namespace Debug
+} // namespace debug
 
 void setDebugFlag(const char *string);
 
@@ -153,8 +157,8 @@
  * @ingroup api_trace
  * @{
  */
-#define DTRACE(x) GEM5_DEPRECATED_MACRO(DTRACE, Debug::x, \
-        "Replace DTRACE(x) with Debug::x.")
+#define DTRACE(x) GEM5_DEPRECATED_MACRO(DTRACE, debug::x, \
+        "Replace DTRACE(x) with debug::x.")
 /** @} */ // end of api_trace
 
 } // namespace gem5
diff --git a/src/base/debug.test.cc b/src/base/debug.test.cc
index 81eb6b7..f3d9e07 100644
--- a/src/base/debug.test.cc
+++ b/src/base/debug.test.cc
@@ -36,15 +36,15 @@
 /** Test assignment of names and descriptions. */
 TEST(DebugFlagTest, NameDesc)
 {
-    Debug::SimpleFlag flag_a("FlagNameDescTestKidA", "Kid A");
+    debug::SimpleFlag flag_a("FlagNameDescTestKidA", "Kid A");
     EXPECT_EQ("FlagNameDescTestKidA", flag_a.name());
     EXPECT_EQ("Kid A", flag_a.desc());
 
-    Debug::SimpleFlag flag_b("FlagNameDescTestKidB", "Kid B");
+    debug::SimpleFlag flag_b("FlagNameDescTestKidB", "Kid B");
     EXPECT_EQ("FlagNameDescTestKidB", flag_b.name());
     EXPECT_EQ("Kid B", flag_b.desc());
 
-    Debug::CompoundFlag compound_flag("FlagNameDescTest", "Compound Flag",
+    debug::CompoundFlag compound_flag("FlagNameDescTest", "Compound Flag",
         {&flag_a, &flag_b});
     EXPECT_EQ("FlagNameDescTest", compound_flag.name());
     EXPECT_EQ("Compound Flag", compound_flag.desc());
@@ -53,9 +53,9 @@
 /** Test that names are unique. */
 TEST(DebugFlagDeathTest, UniqueNames)
 {
-    Debug::SimpleFlag flag("FlagUniqueNamesTest", "A");
+    debug::SimpleFlag flag("FlagUniqueNamesTest", "A");
     gtestLogOutput.str("");
-    EXPECT_ANY_THROW(Debug::SimpleFlag("FlagUniqueNamesTest", "B"));
+    EXPECT_ANY_THROW(debug::SimpleFlag("FlagUniqueNamesTest", "B"));
     const std::string expected = "panic: panic condition !result.second "
         "occurred: Flag FlagUniqueNamesTest already defined!\n";
     std::string actual = gtestLogOutput.str();
@@ -65,19 +65,19 @@
 /** Test format attribute. */
 TEST(DebugFlagTest, IsFormat)
 {
-    Debug::SimpleFlag flag_a("FlagIsFormatTestA", "", true);
+    debug::SimpleFlag flag_a("FlagIsFormatTestA", "", true);
     EXPECT_TRUE(flag_a.isFormat());
-    Debug::SimpleFlag flag_b("FlagIsFormatTestB", "", false);
+    debug::SimpleFlag flag_b("FlagIsFormatTestB", "", false);
     EXPECT_FALSE(flag_b.isFormat());
-    Debug::SimpleFlag flag_c("FlagIsFormatTestC", "");
+    debug::SimpleFlag flag_c("FlagIsFormatTestC", "");
     EXPECT_FALSE(flag_c.isFormat());
 }
 
 /** Test enabling and disabling simple flags, as well as the global enabler. */
 TEST(DebugSimpleFlagTest, Enabled)
 {
-    Debug::Flag::globalDisable();
-    Debug::SimpleFlag flag("SimpleFlagEnabledTest", "");
+    debug::Flag::globalDisable();
+    debug::SimpleFlag flag("SimpleFlagEnabledTest", "");
 
     // By default flags are initialized disabled
     ASSERT_FALSE(flag.tracing());
@@ -85,13 +85,13 @@
     // Flags must be globally enabled before individual flags are enabled
     flag.enable();
     ASSERT_FALSE(flag.tracing());
-    Debug::Flag::globalEnable();
+    debug::Flag::globalEnable();
     ASSERT_TRUE(!TRACING_ON || flag.tracing());
 
     // Verify that the global enabler works
-    Debug::Flag::globalDisable();
+    debug::Flag::globalDisable();
     ASSERT_FALSE(flag.tracing());
-    Debug::Flag::globalEnable();
+    debug::Flag::globalEnable();
     ASSERT_TRUE(!TRACING_ON || flag.tracing());
 
     // Test disabling the flag with global enabled
@@ -105,10 +105,10 @@
  */
 TEST(DebugCompoundFlagTest, Enabled)
 {
-    Debug::Flag::globalDisable();
-    Debug::SimpleFlag flag_a("CompoundFlagEnabledTestKidA", "");
-    Debug::SimpleFlag flag_b("CompoundFlagEnabledTestKidB", "");
-    Debug::CompoundFlag flag("CompoundFlagEnabledTest", "",
+    debug::Flag::globalDisable();
+    debug::SimpleFlag flag_a("CompoundFlagEnabledTestKidA", "");
+    debug::SimpleFlag flag_b("CompoundFlagEnabledTestKidB", "");
+    debug::CompoundFlag flag("CompoundFlagEnabledTest", "",
         {&flag_a, &flag_b});
 
     // By default flags are initialized disabled
@@ -119,7 +119,7 @@
     ASSERT_FALSE(flag_a.tracing());
     ASSERT_FALSE(flag_b.tracing());
     ASSERT_FALSE(flag.tracing());
-    Debug::Flag::globalEnable();
+    debug::Flag::globalEnable();
     for (auto &kid : flag.kids()) {
         ASSERT_TRUE(!TRACING_ON || kid->tracing());
     }
@@ -139,8 +139,8 @@
 /** Test that the conversion operator matches the enablement status. */
 TEST(DebugFlagTest, ConversionOperator)
 {
-    Debug::Flag::globalEnable();
-    Debug::SimpleFlag flag("FlagConversionOperatorTest", "");
+    debug::Flag::globalEnable();
+    debug::SimpleFlag flag("FlagConversionOperatorTest", "");
 
     ASSERT_EQ(flag, flag.tracing());
     flag.enable();
@@ -154,10 +154,10 @@
  */
 TEST(DebugCompoundFlagTest, EnabledKids)
 {
-    Debug::Flag::globalEnable();
-    Debug::SimpleFlag flag_a("CompoundFlagEnabledKidsTestKidA", "");
-    Debug::SimpleFlag flag_b("CompoundFlagEnabledKidsTestKidB", "");
-    Debug::CompoundFlag flag("CompoundFlagEnabledKidsTest", "",
+    debug::Flag::globalEnable();
+    debug::SimpleFlag flag_a("CompoundFlagEnabledKidsTestKidA", "");
+    debug::SimpleFlag flag_b("CompoundFlagEnabledKidsTestKidB", "");
+    debug::CompoundFlag flag("CompoundFlagEnabledKidsTest", "",
         {&flag_a, &flag_b});
 
     // Test enabling only flag A
@@ -187,58 +187,58 @@
 /** Search for existent and non-existent flags. */
 TEST(DebugFlagTest, FindFlag)
 {
-    Debug::Flag::globalEnable();
-    Debug::SimpleFlag flag_a("FlagFindFlagTestA", "");
-    Debug::SimpleFlag flag_b("FlagFindFlagTestB", "");
+    debug::Flag::globalEnable();
+    debug::SimpleFlag flag_a("FlagFindFlagTestA", "");
+    debug::SimpleFlag flag_b("FlagFindFlagTestB", "");
 
     // Enable the found flags and verify that the original flags are
     // enabled too
-    Debug::Flag *flag;
-    EXPECT_TRUE(flag = Debug::findFlag("FlagFindFlagTestA"));
+    debug::Flag *flag;
+    EXPECT_TRUE(flag = debug::findFlag("FlagFindFlagTestA"));
     ASSERT_FALSE(flag_a.tracing());
     flag->enable();
     ASSERT_TRUE(!TRACING_ON || flag_a.tracing());
-    EXPECT_TRUE(flag = Debug::findFlag("FlagFindFlagTestB"));
+    EXPECT_TRUE(flag = debug::findFlag("FlagFindFlagTestB"));
     ASSERT_FALSE(flag_b.tracing());
     flag->enable();
     ASSERT_TRUE(!TRACING_ON || flag_b.tracing());
 
     // Search for a non-existent flag
-    EXPECT_FALSE(Debug::findFlag("FlagFindFlagTestC"));
+    EXPECT_FALSE(debug::findFlag("FlagFindFlagTestC"));
 }
 
 /** Test changing flag enabled. */
 TEST(DebugFlagTest, ChangeFlag)
 {
-    Debug::Flag::globalEnable();
-    Debug::SimpleFlag flag_a("FlagChangeFlagTestA", "");
-    Debug::SimpleFlag flag_b("FlagChangeFlagTestB", "");
+    debug::Flag::globalEnable();
+    debug::SimpleFlag flag_a("FlagChangeFlagTestA", "");
+    debug::SimpleFlag flag_b("FlagChangeFlagTestB", "");
 
     // Enable the found flags and verify that the original flags are
     // enabled too
     ASSERT_FALSE(flag_a.tracing());
-    EXPECT_TRUE(Debug::changeFlag("FlagChangeFlagTestA", true));
+    EXPECT_TRUE(debug::changeFlag("FlagChangeFlagTestA", true));
     ASSERT_TRUE(!TRACING_ON || flag_a.tracing());
-    EXPECT_TRUE(Debug::changeFlag("FlagChangeFlagTestA", false));
+    EXPECT_TRUE(debug::changeFlag("FlagChangeFlagTestA", false));
     ASSERT_FALSE(flag_a.tracing());
 
     // Disable and enable a flag
     ASSERT_FALSE(flag_b.tracing());
-    EXPECT_TRUE(Debug::changeFlag("FlagChangeFlagTestB", false));
+    EXPECT_TRUE(debug::changeFlag("FlagChangeFlagTestB", false));
     ASSERT_FALSE(flag_b.tracing());
-    EXPECT_TRUE(Debug::changeFlag("FlagChangeFlagTestB", true));
+    EXPECT_TRUE(debug::changeFlag("FlagChangeFlagTestB", true));
     ASSERT_TRUE(!TRACING_ON || flag_b.tracing());
 
     // Change a non-existent flag
-    ASSERT_FALSE(Debug::changeFlag("FlagChangeFlagTestC", true));
+    ASSERT_FALSE(debug::changeFlag("FlagChangeFlagTestC", true));
 }
 
 /** Test changing flag enabled with aux functions. */
 TEST(DebugFlagTest, SetClearDebugFlag)
 {
-    Debug::Flag::globalEnable();
-    Debug::SimpleFlag flag_a("FlagSetClearDebugFlagTestA", "");
-    Debug::SimpleFlag flag_b("FlagSetClearDebugFlagTestB", "");
+    debug::Flag::globalEnable();
+    debug::SimpleFlag flag_a("FlagSetClearDebugFlagTestA", "");
+    debug::SimpleFlag flag_b("FlagSetClearDebugFlagTestB", "");
 
     // Enable and disable a flag
     ASSERT_FALSE(flag_a.tracing());
@@ -262,8 +262,8 @@
 /** Test dumping no enabled debug flags. */
 TEST(DebugFlagTest, NoDumpDebugFlags)
 {
-    Debug::Flag::globalEnable();
-    Debug::SimpleFlag flag("FlagDumpDebugFlagTest", "");
+    debug::Flag::globalEnable();
+    debug::SimpleFlag flag("FlagDumpDebugFlagTest", "");
 
     // Verify that the names of the enabled flags are printed
     gtestLogOutput.str("");
@@ -276,15 +276,15 @@
 /** Test dumping enabled debug flags with a larger set of flags. */
 TEST(DebugFlagTest, DumpDebugFlags)
 {
-    Debug::Flag::globalEnable();
-    Debug::SimpleFlag flag_a("FlagDumpDebugFlagTestA", "");
-    Debug::SimpleFlag flag_b("FlagDumpDebugFlagTestB", "");
-    Debug::SimpleFlag flag_c("FlagDumpDebugFlagTestC", "");
-    Debug::SimpleFlag flag_d("FlagDumpDebugFlagTestD", "");
-    Debug::SimpleFlag flag_e("FlagDumpDebugFlagTestE", "");
-    Debug::CompoundFlag compound_flag_a("CompoundFlagDumpDebugFlagTestA", "",
+    debug::Flag::globalEnable();
+    debug::SimpleFlag flag_a("FlagDumpDebugFlagTestA", "");
+    debug::SimpleFlag flag_b("FlagDumpDebugFlagTestB", "");
+    debug::SimpleFlag flag_c("FlagDumpDebugFlagTestC", "");
+    debug::SimpleFlag flag_d("FlagDumpDebugFlagTestD", "");
+    debug::SimpleFlag flag_e("FlagDumpDebugFlagTestE", "");
+    debug::CompoundFlag compound_flag_a("CompoundFlagDumpDebugFlagTestA", "",
         {&flag_d});
-    Debug::CompoundFlag compound_flag_b("CompoundFlagDumpDebugFlagTestB", "",
+    debug::CompoundFlag compound_flag_b("CompoundFlagDumpDebugFlagTestB", "",
         {&flag_e});
 
     // Enable a few flags
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index c3353b7..e57ded7 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -691,8 +691,8 @@
     proxy.readBlob(vaddr, data, size);
 
 #if TRACING_ON
-    if (Debug::GDBRead) {
-        if (Debug::GDBExtra) {
+    if (debug::GDBRead) {
+        if (debug::GDBExtra) {
             char buf[1024];
             mem2hex(buf, data, size);
             DPRINTFNR(": %s\n", buf);
@@ -708,9 +708,9 @@
 bool
 BaseRemoteGDB::write(Addr vaddr, size_t size, const char *data)
 {
-    if (Debug::GDBWrite) {
+    if (debug::GDBWrite) {
         DPRINTFN("write: addr=%#x, size=%d", vaddr, size);
-        if (Debug::GDBExtra) {
+        if (debug::GDBExtra) {
             char buf[1024];
             mem2hex(buf, data, size);
             DPRINTFNR(": %s\n", buf);
diff --git a/src/base/stats/group.cc b/src/base/stats/group.cc
index b31efc9..d5626e6 100644
--- a/src/base/stats/group.cc
+++ b/src/base/stats/group.cc
@@ -72,7 +72,7 @@
         g->regStats();
 
     for (auto &g : statGroups) {
-        if (Debug::Stats) {
+        if (debug::Stats) {
             M5_VAR_USED const Named *named = dynamic_cast<const Named *>(this);
             DPRINTF(Stats, "%s: regStats in group %s\n",
                     named ? named->name() : "?",
diff --git a/src/base/stats/info.cc b/src/base/stats/info.cc
index f7512d2..c7dd5c9 100644
--- a/src/base/stats/info.cc
+++ b/src/base/stats/info.cc
@@ -75,7 +75,7 @@
 {
     id = id_count++;
     if (debug_break_id >= 0 and debug_break_id == id)
-        Debug::breakpoint();
+        debug::breakpoint();
 }
 
 Info::~Info()
diff --git a/src/base/trace.cc b/src/base/trace.cc
index 982bac4..b7a3a44 100644
--- a/src/base/trace.cc
+++ b/src/base/trace.cc
@@ -93,13 +93,13 @@
 void
 enable()
 {
-    Debug::Flag::globalEnable();
+    debug::Flag::globalEnable();
 }
 
 void
 disable()
 {
-    Debug::Flag::globalDisable();
+    debug::Flag::globalDisable();
 }
 
 ObjectMatch ignore;
@@ -152,10 +152,10 @@
     if (!name.empty() && ignore.match(name))
         return;
 
-    if (!Debug::FmtTicksOff && (when != MaxTick))
+    if (!debug::FmtTicksOff && (when != MaxTick))
         ccprintf(stream, "%7d: ", when);
 
-    if (Debug::FmtFlag && !flag.empty())
+    if (debug::FmtFlag && !flag.empty())
         stream << flag << ": ";
 
     if (!name.empty())
@@ -164,7 +164,7 @@
     stream << message;
     stream.flush();
 
-    if (Debug::FmtStackTrace) {
+    if (debug::FmtStackTrace) {
         print_backtrace();
         STATIC_ERR("\n");
     }
diff --git a/src/base/trace.hh b/src/base/trace.hh
index cbdbd0b..05ad70e 100644
--- a/src/base/trace.hh
+++ b/src/base/trace.hh
@@ -158,10 +158,10 @@
  * If you desire that the automatic printing not occur, use DPRINTFR
  * (R for raw)
  *
- * With DPRINTFV it is possible to pass a Debug::SimpleFlag variable
+ * With DPRINTFV it is possible to pass a debug::SimpleFlag variable
  * as first argument. Example:
  *
- * Debug::Flag some_flag = Debug::DMA;
+ * debug::Flag some_flag = debug::DMA;
  * DPRINTFV(some_flag, ...);
  *
  * \def DDUMP(x, data, count)
@@ -178,27 +178,27 @@
  */
 
 #define DDUMP(x, data, count) do {               \
-    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::Debug::x))     \
+    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::debug::x))     \
         ::gem5::Trace::getDebugLogger()->dump(           \
             ::gem5::curTick(), name(), data, count, #x); \
 } while (0)
 
 #define DPRINTF(x, ...) do {                     \
-    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::Debug::x)) {   \
+    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::debug::x)) {   \
         ::gem5::Trace::getDebugLogger()->dprintf_flag(   \
             ::gem5::curTick(), name(), #x, __VA_ARGS__); \
     }                                            \
 } while (0)
 
 #define DPRINTFS(x, s, ...) do {                        \
-    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::Debug::x)) {          \
+    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::debug::x)) {          \
         ::gem5::Trace::getDebugLogger()->dprintf_flag(          \
                 ::gem5::curTick(), (s)->name(), #x, __VA_ARGS__); \
     }                                                   \
 } while (0)
 
 #define DPRINTFR(x, ...) do {                          \
-    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::Debug::x)) {         \
+    if (GEM5_UNLIKELY(TRACING_ON && ::gem5::debug::x)) {         \
         ::gem5::Trace::getDebugLogger()->dprintf_flag(         \
             (::gem5::Tick)-1, std::string(), #x, __VA_ARGS__); \
     }                                                  \
diff --git a/src/base/trace.test.cc b/src/base/trace.test.cc
index 885783e..526e8dd 100644
--- a/src/base/trace.test.cc
+++ b/src/base/trace.test.cc
@@ -50,11 +50,12 @@
 
 namespace gem5
 {
-namespace Debug {
+namespace debug
+{
 /** Debug flag used for the tests in this file. */
 SimpleFlag TraceTestDebugFlag("TraceTestDebugFlag",
     "Exclusive debug flag for the trace tests");
-}
+} // namespace debug
 } // namespace gem5
 
 /** @return The ostream as a std::string. */
@@ -127,7 +128,7 @@
     ASSERT_EQ(getString(&logger), "    100: Foo: Test message");
 
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("FmtTicksOff", true));
+    EXPECT_TRUE(debug::changeFlag("FmtTicksOff", true));
 
     logger.logMessage(Tick(200), "Foo", "", "Test message");
 #if TRACING_ON
@@ -136,7 +137,7 @@
     ASSERT_EQ(getString(&logger), "    200: Foo: Test message");
 #endif
 
-    Debug::changeFlag("FmtTicksOff", false);
+    debug::changeFlag("FmtTicksOff", false);
     Trace::disable();
 
     logger.logMessage(Tick(300), "Foo", "", "Test message");
@@ -152,7 +153,7 @@
     std::stringstream ss;
     Trace::OstreamLogger logger(ss);
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
 
     logger.logMessage(Tick(100), "Foo", "Bar", "Test message");
 #if TRACING_ON
@@ -161,7 +162,7 @@
     ASSERT_EQ(getString(&logger), "    100: Foo: Test message");
 #endif
 
-    Debug::changeFlag("FmtFlag", false);
+    debug::changeFlag("FmtFlag", false);
     Trace::disable();
 }
 
@@ -246,7 +247,7 @@
     Trace::OstreamLogger logger(ss);
 
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     std::string message = "Test message";
     logger.dump(Tick(100), "Foo", message.c_str(), message.size(), "Bar");
 #if TRACING_ON
@@ -270,7 +271,7 @@
         // 1 space + 12 chars + \n
         " Test message\n");
 #endif
-    Debug::changeFlag("FmtFlag", false);
+    debug::changeFlag("FmtFlag", false);
     Trace::disable();
 }
 
@@ -383,14 +384,14 @@
     Trace::OstreamLogger logger(ss);
 
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     logger.dprintf_flag(Tick(100), "Foo", "Bar", "Test %s", "message");
 #if TRACING_ON
     ASSERT_EQ(getString(&logger), "    100: Bar: Foo: Test message");
 #else
     ASSERT_EQ(getString(&logger), "    100: Foo: Test message");
 #endif
-    Debug::changeFlag("FmtFlag", false);
+    debug::changeFlag("FmtFlag", false);
     Trace::disable();
 }
 
@@ -413,10 +414,10 @@
     Trace::OstreamLogger logger(ss);
 
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     logger.dprintf(Tick(100), "Foo", "Test %s", "message");
     ASSERT_EQ(getString(&logger), "    100: Foo: Test message");
-    Debug::changeFlag("FmtFlag", false);
+    debug::changeFlag("FmtFlag", false);
     Trace::disable();
 }
 
@@ -442,8 +443,8 @@
 
     // Flag enabled
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", true));
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     DDUMP(TraceTestDebugFlag, message.c_str(), message.size());
 #if TRACING_ON
     ASSERT_EQ(getString(Trace::output()),
@@ -455,7 +456,7 @@
 
     // Flag disabled
     Trace::disable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", false));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", false));
     DDUMP(TraceTestDebugFlag, message.c_str(), message.size());
     ASSERT_EQ(getString(Trace::output()), "");
 }
@@ -467,8 +468,8 @@
 
     // Flag enabled
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", true));
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     DPRINTF(TraceTestDebugFlag, "Test message");
 #if TRACING_ON
     ASSERT_EQ(getString(Trace::output()),
@@ -479,7 +480,7 @@
 
     // Flag disabled
     Trace::disable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", false));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", false));
     DPRINTF(TraceTestDebugFlag, "Test message");
     ASSERT_EQ(getString(Trace::output()), "");
 }
@@ -494,8 +495,8 @@
 
     // Flag enabled
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", true));
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
 #if TRACING_ON
     DPRINTFS(TraceTestDebugFlag, named_ptr, "Test message");
     ASSERT_EQ(getString(Trace::output()),
@@ -504,7 +505,7 @@
 
     // Flag disabled
     Trace::disable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", false));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", false));
 #if TRACING_ON
     DPRINTFS(TraceTestDebugFlag, named_ptr, "Test message");
     ASSERT_EQ(getString(Trace::output()), "");
@@ -516,8 +517,8 @@
 {
     // Flag enabled
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", true));
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     DPRINTFR(TraceTestDebugFlag, "Test message");
 #if TRACING_ON
     ASSERT_EQ(getString(Trace::output()), "TraceTestDebugFlag: Test message");
@@ -527,7 +528,7 @@
 
     // Flag disabled
     Trace::disable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", false));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", false));
     DPRINTFR(TraceTestDebugFlag, "Test message");
     ASSERT_EQ(getString(Trace::output()), "");
 }
@@ -562,8 +563,8 @@
 
     // Flag enabled
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", true));
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     DPRINTF_UNCONDITIONAL(TraceTestDebugFlag, "Test message");
 #if TRACING_ON
     ASSERT_EQ(getString(Trace::output()),
@@ -574,7 +575,7 @@
 
     // Flag disabled
     Trace::disable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", false));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", false));
     DPRINTF_UNCONDITIONAL(TraceTestDebugFlag, "Test message");
 #if TRACING_ON
     ASSERT_EQ(getString(Trace::output()), "      0: Foo: Test message");
@@ -591,8 +592,8 @@
 {
     // Flag enabled
     Trace::enable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", true));
-    EXPECT_TRUE(Debug::changeFlag("FmtFlag", true));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", true));
+    EXPECT_TRUE(debug::changeFlag("FmtFlag", true));
     DPRINTF(TraceTestDebugFlag, "Test message");
 #if TRACING_ON
     ASSERT_EQ(getString(Trace::output()),
@@ -603,7 +604,7 @@
 
     // Flag disabled
     Trace::disable();
-    EXPECT_TRUE(Debug::changeFlag("TraceTestDebugFlag", false));
+    EXPECT_TRUE(debug::changeFlag("TraceTestDebugFlag", false));
     DPRINTF(TraceTestDebugFlag, "Test message");
     ASSERT_EQ(getString(Trace::output()), "");
 }
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index 2585ce8..0b7ef88 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -583,7 +583,7 @@
         /* This code no longer works since the zero register (e.g.,
          * r31 on Alpha) doesn't necessarily contain zero at this
          * point.
-           if (Debug::Context)
+           if (debug::Context)
             ThreadContext::compare(oldTC, newTC);
         */
 
diff --git a/src/cpu/exetrace.cc b/src/cpu/exetrace.cc
index 2ac6d32..6c129b9 100644
--- a/src/cpu/exetrace.cc
+++ b/src/cpu/exetrace.cc
@@ -63,23 +63,23 @@
     std::stringstream outs;
 
     const bool in_user_mode = thread->getIsaPtr()->inUserMode();
-    if (in_user_mode && !Debug::ExecUser)
+    if (in_user_mode && !debug::ExecUser)
         return;
-    if (!in_user_mode && !Debug::ExecKernel)
+    if (!in_user_mode && !debug::ExecKernel)
         return;
 
-    if (Debug::ExecAsid) {
+    if (debug::ExecAsid) {
         outs << "A" << std::dec <<
             thread->getIsaPtr()->getExecutingAsid() << " ";
     }
 
-    if (Debug::ExecThread)
+    if (debug::ExecThread)
         outs << "T" << thread->threadId() << " : ";
 
     Addr cur_pc = pc.instAddr();
     loader::SymbolTable::const_iterator it;
     ccprintf(outs, "%#x", cur_pc);
-    if (Debug::ExecSymbol && (!FullSystem || !in_user_mode) &&
+    if (debug::ExecSymbol && (!FullSystem || !in_user_mode) &&
             (it = loader::debugSymbolTable.findNearest(cur_pc)) !=
                 loader::debugSymbolTable.end()) {
         Addr delta = cur_pc - it->address;
@@ -107,15 +107,15 @@
     if (ran) {
         outs << " : ";
 
-        if (Debug::ExecOpClass) {
+        if (debug::ExecOpClass) {
             outs << enums::OpClassStrings[inst->opClass()] << " : ";
         }
 
-        if (Debug::ExecResult && !predicate) {
+        if (debug::ExecResult && !predicate) {
             outs << "Predicated False";
         }
 
-        if (Debug::ExecResult && data_status != DataInvalid) {
+        if (debug::ExecResult && data_status != DataInvalid) {
             switch (data_status) {
               case DataVec:
                 ccprintf(outs, " D=%s", *data.as_vec);
@@ -129,16 +129,16 @@
             }
         }
 
-        if (Debug::ExecEffAddr && getMemValid())
+        if (debug::ExecEffAddr && getMemValid())
             outs << " A=0x" << std::hex << addr;
 
-        if (Debug::ExecFetchSeq && fetch_seq_valid)
+        if (debug::ExecFetchSeq && fetch_seq_valid)
             outs << "  FetchSeq=" << std::dec << fetch_seq;
 
-        if (Debug::ExecCPSeq && cp_seq_valid)
+        if (debug::ExecCPSeq && cp_seq_valid)
             outs << "  CPSeq=" << std::dec << cp_seq;
 
-        if (Debug::ExecFlags) {
+        if (debug::ExecFlags) {
             outs << "  flags=(";
             inst->printFlags(outs, "|");
             outs << ")";
@@ -166,14 +166,14 @@
      * finishes. Macroops then behave like regular instructions and don't
      * complete/print when they fault.
      */
-    if (Debug::ExecMacro && staticInst->isMicroop() &&
-        ((Debug::ExecMicro &&
+    if (debug::ExecMacro && staticInst->isMicroop() &&
+        ((debug::ExecMicro &&
             macroStaticInst && staticInst->isFirstMicroop()) ||
-            (!Debug::ExecMicro &&
+            (!debug::ExecMicro &&
              macroStaticInst && staticInst->isLastMicroop()))) {
         traceInst(macroStaticInst, false);
     }
-    if (Debug::ExecMicro || !staticInst->isMicroop()) {
+    if (debug::ExecMicro || !staticInst->isMicroop()) {
         traceInst(staticInst, true);
     }
 }
diff --git a/src/cpu/exetrace.hh b/src/cpu/exetrace.hh
index 5c93f15..5dc3ff7 100644
--- a/src/cpu/exetrace.hh
+++ b/src/cpu/exetrace.hh
@@ -71,7 +71,7 @@
             const StaticInstPtr staticInst, TheISA::PCState pc,
             const StaticInstPtr macroStaticInst = NULL)
     {
-        if (!Debug::ExecEnable)
+        if (!debug::ExecEnable)
             return NULL;
 
         return new ExeTracerRecord(when, tc,
diff --git a/src/cpu/inst_pb_trace.cc b/src/cpu/inst_pb_trace.cc
index 0a34cd2..fbb7470 100644
--- a/src/cpu/inst_pb_trace.cc
+++ b/src/cpu/inst_pb_trace.cc
@@ -124,7 +124,7 @@
                            TheISA::PCState pc, const StaticInstPtr mi)
 {
     // Only record the trace if Exec debugging is enabled
-    if (!Debug::ExecEnable)
+    if (!debug::ExecEnable)
         return NULL;
 
     return new InstPBTraceRecord(*this, when, tc, si, pc, mi);
diff --git a/src/cpu/inteltrace.hh b/src/cpu/inteltrace.hh
index 0f09c9f..16e0620 100644
--- a/src/cpu/inteltrace.hh
+++ b/src/cpu/inteltrace.hh
@@ -68,7 +68,7 @@
             const StaticInstPtr staticInst, TheISA::PCState pc,
             const StaticInstPtr macroStaticInst = NULL)
     {
-        if (!Debug::ExecEnable)
+        if (!debug::ExecEnable)
             return NULL;
 
         return new IntelTraceRecord(when, tc, staticInst, pc, macroStaticInst);
diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc
index d4cddfc..fa5ff99 100644
--- a/src/cpu/kvm/base.cc
+++ b/src/cpu/kvm/base.cc
@@ -288,7 +288,7 @@
 void
 BaseKvmCPU::serializeThread(CheckpointOut &cp, ThreadID tid) const
 {
-    if (Debug::Checkpoint) {
+    if (debug::Checkpoint) {
         DPRINTF(Checkpoint, "KVM: Serializing thread %i:\n", tid);
         dump();
     }
diff --git a/src/cpu/kvm/x86_cpu.cc b/src/cpu/kvm/x86_cpu.cc
index 6b4e2ef..7097470 100644
--- a/src/cpu/kvm/x86_cpu.cc
+++ b/src/cpu/kvm/x86_cpu.cc
@@ -687,7 +687,7 @@
     updateKvmStateMSRs();
 
     DPRINTF(KvmContext, "X86KvmCPU::updateKvmState():\n");
-    if (Debug::KvmContext)
+    if (debug::KvmContext)
         dump();
 }
 
@@ -951,7 +951,7 @@
     getSpecialRegisters(sregs);
 
     DPRINTF(KvmContext, "X86KvmCPU::updateThreadContext():\n");
-    if (Debug::KvmContext)
+    if (debug::KvmContext)
         dump();
 
     updateThreadContextRegs(regs, sregs);
diff --git a/src/cpu/minor/execute.cc b/src/cpu/minor/execute.cc
index 39a652d..793ed7e 100644
--- a/src/cpu/minor/execute.cc
+++ b/src/cpu/minor/execute.cc
@@ -783,7 +783,7 @@
         if (issued) {
             /* Generate MinorTrace's MinorInst lines.  Do this at commit
              *  to allow better instruction annotation? */
-            if (Debug::MinorTrace && !inst->isBubble()) {
+            if (debug::MinorTrace && !inst->isBubble()) {
                 inst->minorTraceInst(*this,
                         cpu.threads[0]->getIsaPtr()->regClasses());
             }
@@ -989,7 +989,7 @@
 
         if (fault != NoFault) {
             if (inst->traceData) {
-                if (Debug::ExecFaulting) {
+                if (debug::ExecFaulting) {
                     inst->traceData->setFaulting(true);
                 } else {
                     delete inst->traceData;
@@ -1393,7 +1393,7 @@
 
             /* Don't show no cost instructions as having taken a commit
              *  slot */
-            if (Debug::MinorTrace && !is_no_cost_inst)
+            if (debug::MinorTrace && !is_no_cost_inst)
                 ex_info.instsBeingCommitted.insts[num_insts_committed] = inst;
 
             if (!is_no_cost_inst)
diff --git a/src/cpu/minor/fetch1.cc b/src/cpu/minor/fetch1.cc
index db5488b..198ed52 100644
--- a/src/cpu/minor/fetch1.cc
+++ b/src/cpu/minor/fetch1.cc
@@ -258,7 +258,7 @@
                 response->request->getPaddr() : 0),
             response->request->getVaddr());
 
-        if (Debug::MinorTrace)
+        if (debug::MinorTrace)
             minorTraceResponseLine(name(), response);
     } else {
         DPRINTF(Fetch, "Got ITLB response\n");
@@ -427,7 +427,7 @@
     numFetchesInMemorySystem--;
     fetch_request->state = FetchRequest::Complete;
 
-    if (Debug::MinorTrace)
+    if (debug::MinorTrace)
         minorTraceResponseLine(name(), fetch_request);
 
     if (response->isError()) {
diff --git a/src/cpu/minor/fetch2.cc b/src/cpu/minor/fetch2.cc
index e588e21..a28018e 100644
--- a/src/cpu/minor/fetch2.cc
+++ b/src/cpu/minor/fetch2.cc
@@ -491,7 +491,7 @@
 
                 /* Output MinorTrace instruction info for
                  *  pre-microop decomposition macroops */
-                if (Debug::MinorTrace && !dyn_inst->isFault() &&
+                if (debug::MinorTrace && !dyn_inst->isFault() &&
                     dyn_inst->staticInst->isMacroop())
                 {
                     dyn_inst->minorTraceInst(*this,
diff --git a/src/cpu/minor/func_unit.cc b/src/cpu/minor/func_unit.cc
index 17b7a0e..428a8b3 100644
--- a/src/cpu/minor/func_unit.cc
+++ b/src/cpu/minor/func_unit.cc
@@ -109,7 +109,7 @@
     for (unsigned int i = 0; i < description.timings.size(); i++) {
         MinorFUTiming &timing = *(description.timings[i]);
 
-        if (Debug::MinorTiming) {
+        if (debug::MinorTiming) {
             std::ostringstream lats;
 
             unsigned int num_lats = timing.srcRegsRelativeLats.size();
diff --git a/src/cpu/minor/pipeline.cc b/src/cpu/minor/pipeline.cc
index db936e4..358f4dfa 100644
--- a/src/cpu/minor/pipeline.cc
+++ b/src/cpu/minor/pipeline.cc
@@ -136,7 +136,7 @@
     fetch2.evaluate();
     fetch1.evaluate();
 
-    if (Debug::MinorTrace)
+    if (debug::MinorTrace)
         minorTrace();
 
     /* Update the time buffers after the stages */
diff --git a/src/cpu/minor/scoreboard.cc b/src/cpu/minor/scoreboard.cc
index af359ef..b957c3d 100644
--- a/src/cpu/minor/scoreboard.cc
+++ b/src/cpu/minor/scoreboard.cc
@@ -264,7 +264,7 @@
         src_index++;
     }
 
-    if (Debug::MinorTiming) {
+    if (debug::MinorTiming) {
         if (ret && num_srcs > num_relative_latencies &&
             num_relative_latencies != 0)
         {
diff --git a/src/cpu/o3/commit.cc b/src/cpu/o3/commit.cc
index 9d70647..f7c6127 100644
--- a/src/cpu/o3/commit.cc
+++ b/src/cpu/o3/commit.cc
@@ -1264,7 +1264,7 @@
         if (head_inst->traceData) {
             // We ignore ReExecution "faults" here as they are not real
             // (architectural) faults but signal flush/replays.
-            if (Debug::ExecFaulting
+            if (debug::ExecFaulting
                 && dynamic_cast<ReExec*>(inst_fault.get()) == nullptr) {
 
                 head_inst->traceData->setFaulting(true);
@@ -1314,7 +1314,7 @@
     rob->retireHead(tid);
 
 #if TRACING_ON
-    if (Debug::O3PipeView) {
+    if (debug::O3PipeView) {
         head_inst->commitTick = curTick() - head_inst->fetchTick;
     }
 #endif
diff --git a/src/cpu/o3/decode.cc b/src/cpu/o3/decode.cc
index 64aa9ce..21bac40 100644
--- a/src/cpu/o3/decode.cc
+++ b/src/cpu/o3/decode.cc
@@ -688,7 +688,7 @@
         --insts_available;
 
 #if TRACING_ON
-        if (Debug::O3PipeView) {
+        if (debug::O3PipeView) {
             inst->decodeTick = curTick() - inst->fetchTick;
         }
 #endif
diff --git a/src/cpu/o3/dyn_inst.cc b/src/cpu/o3/dyn_inst.cc
index bb7cf18..1bd37cc 100644
--- a/src/cpu/o3/dyn_inst.cc
+++ b/src/cpu/o3/dyn_inst.cc
@@ -98,7 +98,7 @@
 DynInst::~DynInst()
 {
 #if TRACING_ON
-    if (Debug::O3PipeView) {
+    if (debug::O3PipeView) {
         Tick fetch = this->fetchTick;
         // fetchTick can be -1 if the instruction fetched outside the trace
         // window.
diff --git a/src/cpu/o3/fetch.cc b/src/cpu/o3/fetch.cc
index e45511e..5bbdc03 100644
--- a/src/cpu/o3/fetch.cc
+++ b/src/cpu/o3/fetch.cc
@@ -1277,7 +1277,7 @@
             numInst++;
 
 #if TRACING_ON
-            if (Debug::O3PipeView) {
+            if (debug::O3PipeView) {
                 instruction->fetchTick = curTick();
             }
 #endif
diff --git a/src/cpu/o3/iew.cc b/src/cpu/o3/iew.cc
index f21fc74..7cdc8d8 100644
--- a/src/cpu/o3/iew.cc
+++ b/src/cpu/o3/iew.cc
@@ -1566,7 +1566,7 @@
     iewStats.executedInstStats.numInsts++;
 
 #if TRACING_ON
-    if (Debug::O3PipeView) {
+    if (debug::O3PipeView) {
         inst->completeTick = curTick() - inst->fetchTick;
     }
 #endif
diff --git a/src/cpu/o3/lsq_unit.cc b/src/cpu/o3/lsq_unit.cc
index 4102bd3..5394e4f 100644
--- a/src/cpu/o3/lsq_unit.cc
+++ b/src/cpu/o3/lsq_unit.cc
@@ -1181,7 +1181,7 @@
             store_inst->seqNum, store_idx.idx() - 1, storeQueue.head() - 1);
 
 #if TRACING_ON
-    if (Debug::O3PipeView) {
+    if (debug::O3PipeView) {
         store_inst->storeTick =
             curTick() - store_inst->fetchTick;
     }
diff --git a/src/cpu/o3/mem_dep_unit.cc b/src/cpu/o3/mem_dep_unit.cc
index 42e8471..6bb3a13 100644
--- a/src/cpu/o3/mem_dep_unit.cc
+++ b/src/cpu/o3/mem_dep_unit.cc
@@ -164,7 +164,7 @@
     if (barr_inst->isWriteBarrier() || barr_inst->isHtmCmd())
         storeBarrierSNs.insert(barr_sn);
 
-    if (Debug::MemDepUnit) {
+    if (debug::MemDepUnit) {
         const char *barrier_type = nullptr;
         if (barr_inst->isReadBarrier() && barr_inst->isWriteBarrier())
             barrier_type = "memory";
@@ -439,7 +439,7 @@
         assert(hasLoadBarrier());
         loadBarrierSNs.erase(barr_sn);
     }
-    if (Debug::MemDepUnit) {
+    if (debug::MemDepUnit) {
         const char *barrier_type = nullptr;
         if (inst->isWriteBarrier() && inst->isReadBarrier())
             barrier_type = "Memory";
diff --git a/src/cpu/o3/rename.cc b/src/cpu/o3/rename.cc
index ff052d3..50f057a 100644
--- a/src/cpu/o3/rename.cc
+++ b/src/cpu/o3/rename.cc
@@ -798,7 +798,7 @@
         const DynInstPtr &inst = fromDecode->insts[i];
         insts[inst->threadNumber].push_back(inst);
 #if TRACING_ON
-        if (Debug::O3PipeView) {
+        if (debug::O3PipeView) {
             inst->renameTick = curTick() - inst->fetchTick;
         }
 #endif
diff --git a/src/cpu/pc_event.cc b/src/cpu/pc_event.cc
index e797849..33b8e91 100644
--- a/src/cpu/pc_event.cc
+++ b/src/cpu/pc_event.cc
@@ -125,7 +125,7 @@
 {
     StringWrap name("break_event");
     DPRINTFN("break event %s triggered\n", descr());
-    Debug::breakpoint();
+    debug::breakpoint();
     if (remove)
         delete this;
 }
diff --git a/src/cpu/profile.hh b/src/cpu/profile.hh
index efdfbfb..a5e16d6 100644
--- a/src/cpu/profile.hh
+++ b/src/cpu/profile.hh
@@ -90,7 +90,7 @@
 
     const std::vector<Addr> &getstack() const { return stack; }
 
-    void dprintf() { if (Debug::Stack) dump(); }
+    void dprintf() { if (debug::Stack) dump(); }
 
     // This function can be overridden so that special addresses which don't
     // actually refer to PCs can be translated into special names. For
diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc
index 135094f..2047158 100644
--- a/src/cpu/simple/base.cc
+++ b/src/cpu/simple/base.cc
@@ -246,7 +246,7 @@
 void
 BaseSimpleCPU::traceFault()
 {
-    if (Debug::ExecFaulting) {
+    if (debug::ExecFaulting) {
         traceData->setFaulting(true);
     } else {
         delete traceData;
diff --git a/src/cpu/trace/trace_cpu.cc b/src/cpu/trace/trace_cpu.cc
index d62e856..b8bf7da 100644
--- a/src/cpu/trace/trace_cpu.cc
+++ b/src/cpu/trace/trace_cpu.cc
@@ -267,7 +267,7 @@
             depGraph.size());
 
     // Print readyList
-    if (Debug::TraceCPUData) {
+    if (debug::TraceCPUData) {
         printReadyList();
     }
     auto free_itr = readyList.begin();
@@ -519,7 +519,7 @@
     } // end of while loop
 
     // Print readyList, sizes of queues and resource status after updating
-    if (Debug::TraceCPUData) {
+    if (debug::TraceCPUData) {
         printReadyList();
         DPRINTF(TraceCPUData, "Execute end occupancy:\n");
         DPRINTFR(TraceCPUData, "\tdepGraph = %d, readyList = %d, "
@@ -723,7 +723,7 @@
         depGraph.erase(graph_itr);
     }
 
-    if (Debug::TraceCPUData) {
+    if (debug::TraceCPUData) {
         printReadyList();
     }
 
diff --git a/src/dev/net/i8254xGBe.cc b/src/dev/net/i8254xGBe.cc
index 12057b1..7e9549a 100644
--- a/src/dev/net/i8254xGBe.cc
+++ b/src/dev/net/i8254xGBe.cc
@@ -1802,7 +1802,7 @@
         tsoPrevSeq = tsoUsedLen;
     }
 
-    if (Debug::EthernetDesc) {
+    if (debug::EthernetDesc) {
         IpPtr ip(pktPtr);
         if (ip)
             DPRINTF(EthernetDesc, "Proccesing Ip packet with Id=%d\n",
@@ -2295,7 +2295,7 @@
 
 
     if (etherInt->sendPacket(txFifo.front())) {
-        if (Debug::EthernetSM) {
+        if (debug::EthernetSM) {
             IpPtr ip(txFifo.front());
             if (ip)
                 DPRINTF(EthernetSM, "Transmitting Ip packet with Id=%d\n",
diff --git a/src/dev/net/ns_gige.cc b/src/dev/net/ns_gige.cc
index b89a6d3..b8c3705 100644
--- a/src/dev/net/ns_gige.cc
+++ b/src/dev/net/ns_gige.cc
@@ -1166,7 +1166,7 @@
             rxPacketBufPtr = rxPacket->data;
 
 #if TRACING_ON
-            if (Debug::Ethernet) {
+            if (debug::Ethernet) {
                 IpPtr ip(rxPacket);
                 if (ip) {
                     DPRINTF(Ethernet, "ID is %d\n", ip->id());
@@ -1363,7 +1363,7 @@
             txFifo.size());
     if (interface->sendPacket(txFifo.front())) {
 #if TRACING_ON
-        if (Debug::Ethernet) {
+        if (debug::Ethernet) {
             IpPtr ip(txFifo.front());
             if (ip) {
                 DPRINTF(Ethernet, "ID is %d\n", ip->id());
@@ -1607,7 +1607,7 @@
                             udp->sum(cksum(udp));
                             etherDeviceStats.txUdpChecksums++;
                         } else {
-                            Debug::breakpoint();
+                            debug::breakpoint();
                             warn_once("UDPPKT set, but not UDP!\n");
                         }
                     } else if (extsts & EXTSTS_TCPPKT) {
diff --git a/src/dev/net/sinic.cc b/src/dev/net/sinic.cc
index 5b45b5e..ef3259c 100644
--- a/src/dev/net/sinic.cc
+++ b/src/dev/net/sinic.cc
@@ -721,7 +721,7 @@
 
     switch (rxState) {
       case rxFifoBlock:
-        if (Debug::EthernetSM) {
+        if (debug::EthernetSM) {
             PacketFifo::iterator end = rxFifo.end();
             int size = virtualRegs.size();
             for (int i = 0; i < size; ++i) {
@@ -976,7 +976,7 @@
 
     txFifo.pop();
 #if TRACING_ON
-    if (Debug::Ethernet) {
+    if (debug::Ethernet) {
         IpPtr ip(packet);
         if (ip) {
             DPRINTF(Ethernet, "ID is %d\n", ip->id());
diff --git a/src/dev/serial/terminal.cc b/src/dev/serial/terminal.cc
index feb0e09..52dbb9e 100644
--- a/src/dev/serial/terminal.cc
+++ b/src/dev/serial/terminal.cc
@@ -327,7 +327,7 @@
 Terminal::writeData(uint8_t c)
 {
 #if TRACING_ON == 1
-    if (Debug::Terminal) {
+    if (debug::Terminal) {
         static char last = '\0';
 
         if ((c != '\n' && c != '\r') || (last != '\n' && last != '\r')) {
diff --git a/src/dev/virtio/base.cc b/src/dev/virtio/base.cc
index 7fe08095..f528cea 100644
--- a/src/dev/virtio/base.cc
+++ b/src/dev/virtio/base.cc
@@ -108,7 +108,7 @@
 void
 VirtDescriptor::dump() const
 {
-    if (!Debug::VIO)
+    if (!debug::VIO)
         return;
 
     DPRINTF(VIO, "Descriptor[%i]: "
@@ -125,7 +125,7 @@
 void
 VirtDescriptor::dumpChain() const
 {
-    if (!Debug::VIO)
+    if (!debug::VIO)
         return;
 
     const VirtDescriptor *desc(this);
@@ -317,7 +317,7 @@
 void
 VirtQueue::dump() const
 {
-    if (!Debug::VIO)
+    if (!debug::VIO)
         return;
 
     for (const VirtDescriptor &d : descriptors)
diff --git a/src/dev/virtio/fs9p.cc b/src/dev/virtio/fs9p.cc
index dc893f6..c0cad7c 100644
--- a/src/dev/virtio/fs9p.cc
+++ b/src/dev/virtio/fs9p.cc
@@ -198,7 +198,7 @@
 VirtIO9PBase::dumpMsg(const P9MsgHeader &header, const uint8_t *data, size_t size)
 {
 #ifndef NDEBUG
-    if (!Debug::VIO9P)
+    if (!debug::VIO9P)
         return;
 
     const P9MsgInfoMap::const_iterator it_msg(p9_msg_info.find(header.type));
@@ -390,7 +390,7 @@
 
         // Start diod
         execlp(p.diod.c_str(), p.diod.c_str(),
-               "-d", Debug::VIO9P ? "1" : "0", // show debug output
+               "-d", debug::VIO9P ? "1" : "0", // show debug output
                "-f", // start in foreground
                "-r", diod_rfd_s.c_str(), // setup read FD
                "-w", diod_wfd_s.c_str(), // setup write FD
diff --git a/src/gpu-compute/exec_stage.cc b/src/gpu-compute/exec_stage.cc
index da8f2b6..730992c 100644
--- a/src/gpu-compute/exec_stage.cc
+++ b/src/gpu-compute/exec_stage.cc
@@ -154,7 +154,7 @@
 ExecStage::exec()
 {
     initStatistics();
-    if (Debug::GPUSched) {
+    if (debug::GPUSched) {
         dumpDispList();
     }
     for (int unitId = 0; unitId < computeUnit.numExeUnits(); ++unitId) {
diff --git a/src/kern/linux/events.hh b/src/kern/linux/events.hh
index 3884c77..7549209 100644
--- a/src/kern/linux/events.hh
+++ b/src/kern/linux/events.hh
@@ -69,7 +69,7 @@
     void
     process(ThreadContext *tc) override
     {
-        if (Debug::DebugPrintf) {
+        if (debug::DebugPrintf) {
             std::string str;
             std::function<int(ThreadContext *, Addr, PrintkVarArgs)> func =
                 [&str](ThreadContext *tc, Addr format_ptr,
diff --git a/src/mem/external_slave.cc b/src/mem/external_slave.cc
index 6ed739b..21eec9a 100644
--- a/src/mem/external_slave.cc
+++ b/src/mem/external_slave.cc
@@ -100,7 +100,7 @@
 Tick
 StubSlavePort::recvAtomic(PacketPtr packet)
 {
-    if (Debug::ExternalPort) {
+    if (debug::ExternalPort) {
         GEM5_VAR_USED unsigned int size = packet->getSize();
 
         DPRINTF(ExternalPort, "StubSlavePort: recvAtomic a: 0x%x size: %d"
diff --git a/src/mem/qos/mem_sink.cc b/src/mem/qos/mem_sink.cc
index f49ca7b..04d230e 100644
--- a/src/mem/qos/mem_sink.cc
+++ b/src/mem/qos/mem_sink.cc
@@ -228,7 +228,7 @@
             "%s DUMPING %s queues status\n", __func__,
             (busState == WRITE ? "WRITE" : "READ"));
 
-    if (Debug::QOS) {
+    if (debug::QOS) {
         for (uint8_t i = 0; i < numPriorities(); ++i) {
             std::string plist = "";
             for (auto& e : (busState == WRITE ? writeQueue[i]: readQueue[i])) {
diff --git a/src/python/pybind11/debug.cc b/src/python/pybind11/debug.cc
index e594176..699de58 100644
--- a/src/python/pybind11/debug.cc
+++ b/src/python/pybind11/debug.cc
@@ -45,6 +45,7 @@
 #include <map>
 #include <vector>
 
+#include "base/compiler.hh"
 #include "base/debug.hh"
 #include "base/output.hh"
 #include "base/trace.hh"
@@ -55,9 +56,11 @@
 namespace gem5
 {
 
-namespace Debug {
+GEM5_DEPRECATED_NAMESPACE(Debug, debug);
+namespace debug
+{
 extern int allFlagsVersion;
-}
+} // namespace debug
 
 static void
 output(const char *filename)
@@ -84,40 +87,40 @@
     py::module_ m_debug = m_native.def_submodule("debug");
 
     m_debug
-        .def("getAllFlagsVersion", []() { return Debug::allFlagsVersion; })
-        .def("allFlags", &Debug::allFlags, py::return_value_policy::reference)
+        .def("getAllFlagsVersion", []() { return debug::allFlagsVersion; })
+        .def("allFlags", &debug::allFlags, py::return_value_policy::reference)
 
         .def("schedBreak", &schedBreak)
         .def("setRemoteGDBPort", &setRemoteGDBPort)
         ;
 
-    py::class_<Debug::Flag> c_flag(m_debug, "Flag");
+    py::class_<debug::Flag> c_flag(m_debug, "Flag");
     c_flag
-        .def_property_readonly("name", &Debug::Flag::name)
-        .def_property_readonly("desc", &Debug::Flag::desc)
-        .def("enable", &Debug::Flag::enable)
-        .def("disable", &Debug::Flag::disable)
+        .def_property_readonly("name", &debug::Flag::name)
+        .def_property_readonly("desc", &debug::Flag::desc)
+        .def("enable", &debug::Flag::enable)
+        .def("disable", &debug::Flag::disable)
         .def_property("tracing",
-                      [](const Debug::Flag *flag) {
+                      [](const debug::Flag *flag) {
                           return flag->tracing();
                       },
-                      [](Debug::Flag *flag, bool state) {
+                      [](debug::Flag *flag, bool state) {
                           if (state) {
                               flag->enable();
                           } else {
                               flag->disable();
                           }
                       })
-        .def("__bool__", [](const Debug::Flag *flag) {
+        .def("__bool__", [](const debug::Flag *flag) {
                 return (bool)*flag;
             })
         ;
 
-    py::class_<Debug::SimpleFlag>(m_debug, "SimpleFlag", c_flag)
-        .def_property_readonly("isFormat", &Debug::SimpleFlag::isFormat)
+    py::class_<debug::SimpleFlag>(m_debug, "SimpleFlag", c_flag)
+        .def_property_readonly("isFormat", &debug::SimpleFlag::isFormat)
         ;
-    py::class_<Debug::CompoundFlag>(m_debug, "CompoundFlag", c_flag)
-        .def("kids", &Debug::CompoundFlag::kids)
+    py::class_<debug::CompoundFlag>(m_debug, "CompoundFlag", c_flag)
+        .def("kids", &debug::CompoundFlag::kids)
         ;
 
 
diff --git a/src/sim/debug.cc b/src/sim/debug.cc
index 6b9d873..85bfb97 100644
--- a/src/sim/debug.cc
+++ b/src/sim/debug.cc
@@ -68,7 +68,7 @@
 void
 DebugBreakEvent::process()
 {
-    Debug::breakpoint();
+    debug::breakpoint();
 }
 
 
diff --git a/src/sim/drain.cc b/src/sim/drain.cc
index b15cdb6..88de3ec 100644
--- a/src/sim/drain.cc
+++ b/src/sim/drain.cc
@@ -73,7 +73,7 @@
     _state = DrainState::Draining;
     for (auto *obj : _allDrainable) {
         DrainState status = obj->dmDrain();
-        if (Debug::Drain && status != DrainState::Drained) {
+        if (debug::Drain && status != DrainState::Drained) {
             Named *temp = dynamic_cast<Named*>(obj);
             if (temp)
                 DPRINTF(Drain, "Failed to drain %s\n", temp->name());
diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc
index 7afafa5..66d0385 100644
--- a/src/sim/eventq.cc
+++ b/src/sim/eventq.cc
@@ -218,7 +218,7 @@
     if (!event->squashed()) {
         // forward current cycle to the time when this event occurs.
         setCurTick(event->when());
-        if (Debug::Event)
+        if (debug::Event)
             event->trace("executed");
         event->process();
         if (event->isExitEvent()) {
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 3e146e3..a7226ff 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -784,7 +784,7 @@
         event->flags.set(Event::Scheduled);
         event->acquire();
 
-        if (Debug::Event)
+        if (debug::Event)
             event->trace("scheduled");
     }
 
@@ -805,7 +805,7 @@
         event->flags.clear(Event::Squashed);
         event->flags.clear(Event::Scheduled);
 
-        if (Debug::Event)
+        if (debug::Event)
             event->trace("descheduled");
 
         event->release();
@@ -836,7 +836,7 @@
         event->flags.clear(Event::Squashed);
         event->flags.set(Event::Scheduled);
 
-        if (Debug::Event)
+        if (debug::Event)
             event->trace("rescheduled");
     }
 
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index 6a39ceb..4332b16 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -444,7 +444,7 @@
 debugbreak(ThreadContext *tc)
 {
     DPRINTF(PseudoInst, "pseudo_inst::debugbreak()\n");
-    Debug::breakpoint();
+    debug::breakpoint();
 }
 
 void