Andreas Sandberg has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/34119 )

Change subject: python: Add the ability to check if a debug flag has been enabled
......................................................................

python: Add the ability to check if a debug flag has been enabled

There is currently no Python API to check if a debug flag is
enabled. Add a new status property that can be read or set to control
the status of a flag. The stat of a flag can also be queried by
converting it to a bool.

For example:

  m5.debug.flags["XBar"].status = True

  if m5.debug.flags["XBar"]:
      print("XBar debugging is on")

Change-Id: I5a50c39ced182ab44e18c061c463d7d9c41ef186
Signed-off-by: Andreas Sandberg <andreas.sandb...@arm.com>
---
M src/python/pybind11/debug.cc
1 file changed, 14 insertions(+), 0 deletions(-)



diff --git a/src/python/pybind11/debug.cc b/src/python/pybind11/debug.cc
index ed2942b..69c497c 100644
--- a/src/python/pybind11/debug.cc
+++ b/src/python/pybind11/debug.cc
@@ -98,6 +98,20 @@
         .def_property_readonly("desc", &Debug::Flag::desc)
         .def("enable", &Debug::Flag::enable)
         .def("disable", &Debug::Flag::disable)
+        .def_property("status",
+                      [](const Debug::Flag *flag) {
+                          return flag->status();
+                      },
+                      [](Debug::Flag *flag, bool state) {
+                          if (state) {
+                              flag->enable();
+                          } else {
+                              flag->disable();
+                          }
+                      })
+        .def("__bool__", [](const Debug::Flag *flag) {
+                return flag->status();
+            })
         ;

     py::class_<Debug::SimpleFlag>(m_debug, "SimpleFlag", c_flag);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34119
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: I5a50c39ced182ab44e18c061c463d7d9c41ef186
Gerrit-Change-Number: 34119
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to