dumpstats not working with gem5 library


Stats dumping does not work when the gem5 library is used inside a SystemC simulation.

I've built the gem5 library

and executed the full system TLM example. When I run "m5 dumpstats" in the simulation a stats file "stats-systemc.txt" is created. This file contains the following lines:

---------- Begin Simulation Statistics ----------

---------- End Simulation Statistics ----------

When I run "m5 dumpstats" again a second pair of begin and end simulation statistics is added. But all the statistic parameters are missing.


Ubuntu 20.04 LTS
gcc 9.3.0
Python 3.8.5
SCons 3.1.2


Jason Lowe-Power
March 31, 2021, 4:02 PM

Makes sense. This is what I was thinking as well. We should leave this issue open, but, to be honest, it isn’t high on our priority list right now. We’d be happy to accept a contribution fixing this, though!

Andreas Sandberg
March 30, 2021, 11:39 AM

It seems like this code needs to be updated to support new-style stats. The Python-side currently does the following:

  • At initialisation: Behind stat groups to mirror the SimObject hierarchy in the stat group hierarchy.

  • At dump: Recursively traverse the StatGroup tree and dump stats for each group.

The CXX runner doesn’t necessarily need to link stat groups to mirror the SimObject hierarchy, the runner could also just traverse the SimObject graph and dump the stats for individual SimObjects (keep in mind that SimObject may contain nested stat groups). It probably makes sense to mirror the hierarchy though since that is likely to make the dump code cleaner (it only needs to care about stat groups in that case).

Jason Lowe-Power
March 29, 2021, 10:25 PM

Ok, I see now! I think this is related to the Stats::Group API change from .

When compiling without python you have to call Stats::registerHandlers(CxxConfig::statsReset, CxxConfig::statsDump); (See util/cxx_config/main.cc:117).

That statsDump function is in util/cxx_config/stats.cc:61. This does not use the normal stats dumping interface. You will probably need to update that function or write your own function to dump stats. Maybe has a better suggestion?

Jason Lowe-Power
March 29, 2021, 10:19 PM

I’m not sure what’s going on… But this might help debug it. In theory, when you call m5 dumpstats it should call the python function m5.stats.dump() found at src/python/m5/stats/__init__.py:368. The way it calls this is a bit convoluted, but trust me .

Can you put some print calls in that function to see if it’s executed or why it wouldn’t dump all of your stats?

Edit: Oh! You’re compiling without python! That’s the problem . I’ll check if there’s a way around using python.

Lukas Steiner
March 29, 2021, 3:16 PM

Running a simple example with the TLM memory could be a good starting point. It will test TLM, SystemC and the library without Python but with CXX configuration.


Hoa Nguyen


Lukas Steiner



Affects versions