From 48ae255762126d96bc1918d6ffaaa0199eb24051 Mon Sep 17 00:00:00 2001 From: Yan Lee Date: Mon, 15 May 2023 00:32:32 -0700 Subject: [PATCH] sim,python: add activate option and method With --debug-activate option, user can add the target names into activate list of debug log. For example, with "--debug-activate=system.AAA.bus --debug-flags=IOXBar" We can enable the logs of a specified bus. Change-Id: I89ce87d784ae9736708bbc976a6bad58732bd5da Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70618 Reviewed-by: Bobby Bruce Reviewed-by: Jason Lowe-Power Tested-by: kokoro Maintainer: Jason Lowe-Power --- src/python/m5/main.py | 11 +++++++++++ src/python/m5/trace.py | 2 +- src/python/pybind11/debug.cc | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/python/m5/main.py b/src/python/m5/main.py index b4a3472187..a68279b633 100644 --- a/src/python/m5/main.py +++ b/src/python/m5/main.py @@ -275,6 +275,13 @@ def parse_options(): help="Sets the output file for debug. Append '.gz' to the name for it" " to be compressed automatically [Default: %default]", ) + option( + "--debug-activate", + metavar="EXPR[,EXPR]", + action="append", + split=",", + help="Activate EXPR sim objects", + ) option( "--debug-ignore", metavar="EXPR", @@ -557,6 +564,10 @@ def main(): trace.output(options.debug_file) + for activate in options.debug_activate: + _check_tracing() + trace.activate(activate) + for ignore in options.debug_ignore: _check_tracing() trace.ignore(ignore) diff --git a/src/python/m5/trace.py b/src/python/m5/trace.py index 9603914ca8..759f96e5bf 100644 --- a/src/python/m5/trace.py +++ b/src/python/m5/trace.py @@ -25,4 +25,4 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Export native methods to Python -from _m5.trace import output, ignore, disable, enable +from _m5.trace import output, activate, ignore, disable, enable diff --git a/src/python/pybind11/debug.cc b/src/python/pybind11/debug.cc index 313ca81e6e..0087ffadd4 100644 --- a/src/python/pybind11/debug.cc +++ b/src/python/pybind11/debug.cc @@ -67,6 +67,14 @@ output(const char *filename) trace::setDebugLogger(new trace::OstreamLogger(*file_stream->stream())); } +static void +activate(const char *expr) +{ + ObjectMatch activate(expr); + + trace::getDebugLogger()->addActivate(activate); +} + static void ignore(const char *expr) { @@ -121,6 +129,7 @@ pybind_init_debug(py::module_ &m_native) py::module_ m_trace = m_native.def_submodule("trace"); m_trace .def("output", &output) + .def("activate", &activate) .def("ignore", &ignore) .def("enable", &trace::enable) .def("disable", &trace::disable)