summaryrefslogtreecommitdiff
path: root/src/sim/sim_object.hh
diff options
context:
space:
mode:
authorMatt Horsnell <matt.horsnell@ARM.com>2014-01-24 15:29:30 -0600
committerMatt Horsnell <matt.horsnell@ARM.com>2014-01-24 15:29:30 -0600
commit739c6df94ea0030fea04065e6b8d8a1e232752a0 (patch)
tree6f0101f3d32c84125f75b1b48623056755da79c2 /src/sim/sim_object.hh
parent4de69821e630576f40c55a26355ed1064c6a233c (diff)
downloadgem5-739c6df94ea0030fea04065e6b8d8a1e232752a0.tar.xz
base: add support for probe points and common probes
The probe patch is motivated by the desire to move analytical and trace code away from functional code. This is achieved by the probe interface which is essentially a glorified observer model. What this means to users: * add a probe point and a "notify" call at the source of an "event" * add an isolated module, that is being used to carry out *your* analysis (e.g. generate a trace) * register that module as a probe listener Note: an example is given for reference in src/cpu/o3/simple_trace.[hh|cc] and src/cpu/SimpleTrace.py What is happening under the hood: * every SimObject maintains has a ProbeManager. * during initialization (src/python/m5/simulate.py) first regProbePoints and the regProbeListeners is called on each SimObject. this hooks up the probe point notify calls with the listeners. FAQs: Why did you develop probe points: * to remove trace, stats gathering, analytical code out of the functional code. * the belief that probes could be generically useful. What is a probe point: * a probe point is used to notify upon a given event (e.g. cpu commits an instruction) What is a probe listener: * a class that handles whatever the user wishes to do when they are notified about an event. What can be passed on notify: * probe points are templates, and so the user can generate probes that pass any type of argument (by const reference) to a listener. What relationships can be generated (1:1, 1:N, N:M etc): * there isn't a restriction. You can hook probe points and listeners up in a 1:1, 1:N, N:M relationship. They become useful when a number of modules listen to the same probe points. The idea being that you can add a small number of probes into the source code and develop a larger number of useful analysis modules that use information passed by the probes. Can you give examples: * adding a probe point to the cpu's commit method allows you to build a trace module (outputting assembler), you could re-use this to gather instruction distribution (arithmetic, load/store, conditional, control flow) stats. Why is the probe interface currently restricted to passing a const reference: * the desire, initially at least, is to allow an interface to observe functionality, but not to change functionality. * of course this can be subverted by const-casting. What is the performance impact of adding probes: * when nothing is actively listening to the probes they should have a relatively minor impact. Profiling has suggested even with a large number of probes (60) the impact of them (when not active) is very minimal (<1%).
Diffstat (limited to 'src/sim/sim_object.hh')
-rw-r--r--src/sim/sim_object.hh20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/sim/sim_object.hh b/src/sim/sim_object.hh
index 1cb06d777..e4526e773 100644
--- a/src/sim/sim_object.hh
+++ b/src/sim/sim_object.hh
@@ -51,7 +51,7 @@
class BaseCPU;
class Event;
-
+class ProbeManager;
/**
* Abstract superclass for simulation objects. Represents things that
* correspond to physical components and can be specified via the
@@ -90,6 +90,9 @@ class SimObject : public EventManager, public Serializable, public Drainable
/** List of all instantiated simulation objects. */
static SimObjectList simObjectList;
+ /** Manager coordinates hooking up probe points with listeners. */
+ ProbeManager *probeManager;
+
protected:
/** Cached copy of the object parameters. */
const SimObjectParams *_params;
@@ -143,6 +146,21 @@ class SimObject : public EventManager, public Serializable, public Drainable
virtual void resetStats();
/**
+ * Register probe points for this object.
+ */
+ virtual void regProbePoints();
+
+ /**
+ * Register probe listeners for this object.
+ */
+ virtual void regProbeListeners();
+
+ /**
+ * Get the probe manager for this object.
+ */
+ ProbeManager *getProbeManager();
+
+ /**
* startup() is the final initialization call before simulation.
* All state is initialized (including unserialized state, if any,
* such as the curTick() value), so this is the appropriate place to