[gem5-dev] Change in gem5/gem5[develop]: base: Rename Flag status to enabled

2021-01-15 Thread Daniel Carvalho (Gerrit) via gem5-dev
Daniel Carvalho has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/38711 )


Change subject: base: Rename Flag status to enabled
..

base: Rename Flag status to enabled

The semantic of "The status of a flag is true/false" may be
confusing. Rename `status` to `enabled`, so that queries
become "Is this flag enabled?".

Change-Id: I8cdd76766d80d65007a9f204abcf71b18211ab42
Signed-off-by: Daniel R. Carvalho 
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38711
Tested-by: kokoro 
Reviewed-by: Jason Lowe-Power 
Reviewed-by: Andreas Sandberg 
Maintainer: Jason Lowe-Power 
---
M src/base/debug.cc
M src/base/debug.hh
M src/base/debug.test.cc
M src/python/pybind11/debug.cc
4 files changed, 89 insertions(+), 87 deletions(-)

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



diff --git a/src/base/debug.cc b/src/base/debug.cc
index 83a4461..925c16f 100644
--- a/src/base/debug.cc
+++ b/src/base/debug.cc
@@ -137,13 +137,13 @@
 }

 bool
-CompoundFlag::status() const
+CompoundFlag::enabled() const
 {
 if (_kids.empty())
 return false;

 for (auto& k : _kids) {
-if (!k->status())
+if (!k->enabled())
 return false;
 }

@@ -188,7 +188,7 @@
 FlagsMap::iterator end = allFlags().end();
 for (; i != end; ++i) {
 SimpleFlag *f = dynamic_cast(i->second);
-if (f && f->status())
+if (f && f->enabled())
 cprintf("%s\n", f->name());
 }
 }
diff --git a/src/base/debug.hh b/src/base/debug.hh
index 4226de7..2d46381 100644
--- a/src/base/debug.hh
+++ b/src/base/debug.hh
@@ -70,9 +70,9 @@

 virtual void enable() = 0;
 virtual void disable() = 0;
-virtual bool status() const = 0;
+virtual bool enabled() const = 0;

-operator bool() const { return status(); }
+operator bool() const { return enabled(); }

 static void globalEnable();
 static void globalDisable();
@@ -82,17 +82,17 @@
 {
   protected:
 bool _tracing = false; // tracing is enabled and flag is on
-bool _status = false;  // flag status
+bool _enabled = false; // flag enablement status

-void sync() override { _tracing = _globalEnable && _status; }
+void sync() override { _tracing = _globalEnable && _enabled; }

   public:
 SimpleFlag(const char *name, const char *desc) : Flag(name, desc) {}

-bool status() const override { return _tracing; }
+bool enabled() const override { return _tracing; }

-void enable() override  { _status = true;  sync(); }
-void disable() override { _status = false; sync(); }
+void enable() override  { _enabled = true;  sync(); }
+void disable() override { _enabled = false; sync(); }
 };

 class CompoundFlag : public Flag
@@ -113,7 +113,7 @@

 void enable() override;
 void disable() override;
-bool status() const override;
+bool enabled() const override;
 };

 typedef std::map FlagsMap;
diff --git a/src/base/debug.test.cc b/src/base/debug.test.cc
index b1c0130..3f7b2f4 100644
--- a/src/base/debug.test.cc
+++ b/src/base/debug.test.cc
@@ -61,114 +61,116 @@
 }

 /** Test enabling and disabling simple flags, as well as the global  
enabler. */

-TEST(DebugSimpleFlagTest, Status)
+TEST(DebugSimpleFlagTest, Enabled)
 {
 Debug::Flag::globalDisable();
-Debug::SimpleFlag flag("SimpleFlagStatusTest", "");
+Debug::SimpleFlag flag("SimpleFlagEnabledTest", "");

 // By default flags are initialized disabled
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());

 // Flags must be globally enabled before individual flags are enabled
 flag.enable();
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());
 Debug::Flag::globalEnable();
-ASSERT_TRUE(flag.status());
+ASSERT_TRUE(flag.enabled());

 // Verify that the global enabler works
 Debug::Flag::globalDisable();
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());
 Debug::Flag::globalEnable();
-ASSERT_TRUE(flag.status());
+ASSERT_TRUE(flag.enabled());

 // Test disabling the flag with global enabled
 flag.disable();
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());
 }

 /**
- * Tests that manipulate the status of the compound flag to change the  
status

- * of the kids.
+ * Tests that manipulate the enablement status of the compound flag to  
change

+ * the corresponding status of the kids.
  */
-TEST(DebugCompoundFlagTest, Status)
+TEST(DebugCompoundFlagTest, Enabled)
 {
 Debug::Flag::globalDisable();
-Debug::SimpleFlag flag_a("CompoundFlagStatusTestKidA", "");
-Debug::SimpleFlag flag_b("CompoundFlagStatusTestKidB", "");
-Debug::CompoundFlag flag("CompoundFlagStatusTest", "", {_a,  
_b});

+Debug::SimpleFlag flag_a("CompoundFlagEnabledTestKidA", "");
+

[gem5-dev] Change in gem5/gem5[develop]: base: Rename Flag status to enabled

2020-12-25 Thread Daniel Carvalho (Gerrit) via gem5-dev
Daniel Carvalho has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/38711 )



Change subject: base: Rename Flag status to enabled
..

base: Rename Flag status to enabled

The semantic of "The status of a flag is true/false" may be
confusing. Rename `status` to `enabled`, so that queries
become "Is this flag enabled?".

Change-Id: I8cdd76766d80d65007a9f204abcf71b18211ab42
Signed-off-by: Daniel R. Carvalho 
---
M src/base/debug.cc
M src/base/debug.hh
M src/base/debug.test.cc
M src/python/pybind11/debug.cc
4 files changed, 90 insertions(+), 88 deletions(-)



diff --git a/src/base/debug.cc b/src/base/debug.cc
index 8eaf2c6..dbf92cf 100644
--- a/src/base/debug.cc
+++ b/src/base/debug.cc
@@ -138,13 +138,13 @@
 }

 bool
-CompoundFlag::status() const
+CompoundFlag::enabled() const
 {
 if (_kids.empty())
 return false;

 for (auto& k : _kids) {
-if (!k->status())
+if (!k->enabled())
 return false;
 }

@@ -189,7 +189,7 @@
 FlagsMap::iterator end = allFlags().end();
 for (; i != end; ++i) {
 SimpleFlag *f = dynamic_cast(i->second);
-if (f && f->status())
+if (f && f->enabled())
 cprintf("%s\n", f->name());
 }
 }
diff --git a/src/base/debug.hh b/src/base/debug.hh
index 297c1dd..7b66db0 100644
--- a/src/base/debug.hh
+++ b/src/base/debug.hh
@@ -70,9 +70,9 @@

 virtual void enable() = 0;
 virtual void disable() = 0;
-virtual bool status() const = 0;
+virtual bool enabled() const = 0;

-operator bool() const { return status(); }
+operator bool() const { return enabled(); }

 static void globalEnable();
 static void globalDisable();
@@ -82,19 +82,19 @@
 {
   protected:
 bool _tracing; // tracing is enabled and flag is on
-bool _status;  // flag status
+bool _enabled; // flag enablement status

-void sync() override { _tracing = _globalEnable && _status; }
+void sync() override { _tracing = _globalEnable && _enabled; }

   public:
 SimpleFlag(const char *name, const char *desc)
-: Flag(name, desc), _tracing(false), _status(false)
+: Flag(name, desc), _tracing(false), _enabled(false)
 { }

-bool status() const override { return _tracing; }
+bool enabled() const override { return _tracing; }

-void enable() override  { _status = true;  sync(); }
-void disable() override { _status = false; sync(); }
+void enable() override  { _enabled = true;  sync(); }
+void disable() override { _enabled = false; sync(); }
 };

 class CompoundFlag : public Flag
@@ -115,7 +115,7 @@

 void enable() override;
 void disable() override;
-bool status() const override;
+bool enabled() const override;
 };

 typedef std::map FlagsMap;
diff --git a/src/base/debug.test.cc b/src/base/debug.test.cc
index 2b042ba..7d8f674 100644
--- a/src/base/debug.test.cc
+++ b/src/base/debug.test.cc
@@ -61,114 +61,116 @@
 }

 /** Test enabling and disabling simple flags, as well as the global  
enabler. */

-TEST(SimpleFlagTest, Status)
+TEST(SimpleFlagTest, Enabled)
 {
 Debug::Flag::globalDisable();
-Debug::SimpleFlag flag("SimpleFlagStatusTest", "");
+Debug::SimpleFlag flag("SimpleFlagEnabledTest", "");

 // By default flags are initialized disabled
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());

 // Flags must be globally enabled before individual flags are enabled
 flag.enable();
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());
 Debug::Flag::globalEnable();
-ASSERT_TRUE(flag.status());
+ASSERT_TRUE(flag.enabled());

 // Verify that the global enabler works
 Debug::Flag::globalDisable();
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());
 Debug::Flag::globalEnable();
-ASSERT_TRUE(flag.status());
+ASSERT_TRUE(flag.enabled());

 // Test disabling the flag with global enabled
 flag.disable();
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());
 }

 /**
- * Tests that manipulate the status of the compound flag to change the  
status

- * of the kids.
+ * Tests that manipulate the enablement status of the compound flag to  
change

+ * the corresponding status of the kids.
  */
-TEST(CompoundFlagTest, Status)
+TEST(CompoundFlagTest, Enabled)
 {
 Debug::Flag::globalDisable();
-Debug::SimpleFlag flag_a("CompoundFlagStatusTestKidA", "");
-Debug::SimpleFlag flag_b("CompoundFlagStatusTestKidB", "");
-Debug::CompoundFlag flag("CompoundFlagStatusTest", "", {_a,  
_b});

+Debug::SimpleFlag flag_a("CompoundFlagEnabledTestKidA", "");
+Debug::SimpleFlag flag_b("CompoundFlagEnabledTestKidB", "");
+Debug::CompoundFlag flag("CompoundFlagEnabledTest", "",
+{_a, _b});

 // By default flags are initialized disabled
-ASSERT_FALSE(flag.status());
+ASSERT_FALSE(flag.enabled());

 //