Nathanael Premillieu has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/49671 )

Change subject: misc: sync debug tracing with m5op reset/dump stats
......................................................................

misc: sync debug tracing with m5op reset/dump stats

Add an option to start and stop debug tracing when encountering the m5
pseudo-instruction for resetstats and dumpstats.
When encoutering resetstats the tracing is enabled and
when encountering dumpstats, the tracing is disabled.
The rationale is that reset/dump stats pseudo-instructions are used to
define the Region of Interest (ROI).
It is then useful to be able to do the tracing only on this ROI.

Change-Id: I59e374da4a97413c748f3b6dfe99784f6e859b65
---
M src/base/trace.cc
M src/base/trace.hh
M src/python/m5/main.py
M src/python/m5/trace.py
M src/python/pybind11/debug.cc
M src/sim/pseudo_inst.cc
6 files changed, 43 insertions(+), 2 deletions(-)



diff --git a/src/base/trace.cc b/src/base/trace.cc
index b7a3a44..1d2ab7d 100644
--- a/src/base/trace.cc
+++ b/src/base/trace.cc
@@ -64,6 +64,20 @@
 // directly

 Logger *debug_logger = NULL;
+uint64_t file_size_limit = 0;
+bool with_stats = false;
+
+bool
+getWithStats()
+{
+    return with_stats;
+}
+
+void
+setWithStats(bool b)
+{
+    with_stats = b;
+}

 Logger *
 getDebugLogger()
diff --git a/src/base/trace.hh b/src/base/trace.hh
index 05ad70e..e923d7a 100644
--- a/src/base/trace.hh
+++ b/src/base/trace.hh
@@ -138,6 +138,9 @@
 void enable();
 void disable();

+bool getWithStats();
+void setWithStats(bool b);
+
 } // namespace Trace

 // This silly little class allows us to wrap a string in a functor
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index ab72395..57e53b2 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -142,6 +142,8 @@
         help="Start debug output at TICK")
     option("--debug-end", metavar="TICK", type='int',
         help="End debug output at TICK")
+    option("--debug-with-stats", action="store_true",
+ help="Start debug tracing on resetstats call, end on dumpstats call")
     option("--debug-file", metavar="FILE", default="cout",
help="Sets the output file for debug. Append '.gz' to the name for it"
               " to be compressed automatically [Default: %default]")
@@ -411,14 +413,16 @@
         e = event.create(trace.enable, event.Event.Debug_Enable_Pri)
         event.mainq.schedule(e, options.debug_start)
     else:
-        trace.enable()
+        if not options.debug_with_stats:
+            trace.enable()

     if options.debug_end:
         _check_tracing()
         e = event.create(trace.disable, event.Event.Debug_Enable_Pri)
         event.mainq.schedule(e, options.debug_end)

-    trace.output(options.debug_file)
+    if options.debug_with_stats:
+        trace.setWithStats(True)

     for ignore in options.debug_ignore:
         _check_tracing()
diff --git a/src/python/m5/trace.py b/src/python/m5/trace.py
index 9603914..ee2ca50 100644
--- a/src/python/m5/trace.py
+++ b/src/python/m5/trace.py
@@ -26,3 +26,4 @@

 # Export native methods to Python
 from _m5.trace import output, ignore, disable, enable
+from _m5.trace import  getWithStats, setWithStats
\ No newline at end of file
diff --git a/src/python/pybind11/debug.cc b/src/python/pybind11/debug.cc
index 699de58..65e1e56 100644
--- a/src/python/pybind11/debug.cc
+++ b/src/python/pybind11/debug.cc
@@ -130,6 +130,8 @@
         .def("ignore", &ignore)
         .def("enable", &Trace::enable)
         .def("disable", &Trace::disable)
+        .def("getWithStats", &Trace::getWithStats)
+        .def("setWithStats", &Trace::setWithStats)
         ;
 }

diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index b3c1f4e..67a299a 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -53,6 +53,7 @@

 #include "base/debug.hh"
 #include "base/output.hh"
+#include "base/trace.hh"
 #include "cpu/base.hh"
 #include "cpu/thread_context.hh"
 #include "debug/Loader.hh"
@@ -76,6 +77,10 @@

 using namespace statistics;

+namespace Trace {
+extern bool with_stats;
+}
+
 GEM5_DEPRECATED_NAMESPACE(PseudoInst, pseudo_inst);
 namespace pseudo_inst
 {
@@ -315,6 +320,12 @@
     Tick repeat = period * sim_clock::as_int::ns;

     statistics::schedStatEvent(false, true, when, repeat);
+
+    if (Trace::with_stats) {
+        inform("PseudoInst::resetstats(%i, %i) encountered at tick %llu, "
+               "enabling debug tracing\n", delay, period, curTick());
+        Trace::enable();
+    }
 }

 void
@@ -329,6 +340,12 @@
     Tick repeat = period * sim_clock::as_int::ns;

     statistics::schedStatEvent(true, false, when, repeat);
+
+    if (Trace::with_stats) {
+        inform("PseudoInst::dumpstats(%i, %i) encountered at tick %llu, "
+               "disabling debug tracing\n", delay, period, curTick());
+        Trace::disable();
+    }
 }

 void

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49671
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: I59e374da4a97413c748f3b6dfe99784f6e859b65
Gerrit-Change-Number: 49671
Gerrit-PatchSet: 1
Gerrit-Owner: Nathanael Premillieu <nathanael.premill...@huawei.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