summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorAndrew Bardsley <Andrew.Bardsley@arm.com>2014-10-16 05:49:32 -0400
committerAndrew Bardsley <Andrew.Bardsley@arm.com>2014-10-16 05:49:32 -0400
commitd8502ee46d356830698d7b96b29e4b27906a2d79 (patch)
treec7d052a7e276126bd1630658b386ac715f75238d /src/sim
parenta63ba6c7b7fe6620478c0d8d7812661c6a36d55a (diff)
downloadgem5-d8502ee46d356830698d7b96b29e4b27906a2d79.tar.xz
config: Add a --without-python option to build process
Add the ability to build libgem5 without embedded Python or the ability to configure with Python. This is a prelude to a patch to allow config.ini files to be loaded into libgem5 using only C++ which would make embedding gem5 within other simulation systems easier. This adds a few registration interfaces to things which cross between Python and C++. Namely: stats dumping and SimObject resolving
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/SConscript5
-rw-r--r--src/sim/debug.cc18
-rw-r--r--src/sim/debug.hh2
-rw-r--r--src/sim/init.cc85
-rw-r--r--src/sim/init.hh5
-rw-r--r--src/sim/init_signals.cc138
-rw-r--r--src/sim/init_signals.hh40
-rw-r--r--src/sim/main.cc1
-rw-r--r--src/sim/py_interact.cc51
-rw-r--r--src/sim/py_interact.hh40
-rw-r--r--src/sim/serialize.cc8
-rw-r--r--src/sim/serialize.hh16
-rw-r--r--src/sim/stat_register.cc53
-rw-r--r--src/sim/stat_register.hh57
14 files changed, 402 insertions, 117 deletions
diff --git a/src/sim/SConscript b/src/sim/SConscript
index 7d75a9439..7987afa00 100644
--- a/src/sim/SConscript
+++ b/src/sim/SConscript
@@ -44,9 +44,11 @@ Source('arguments.cc')
Source('async.cc')
Source('core.cc')
Source('debug.cc')
+Source('py_interact.cc', skip_no_python=True)
Source('eventq.cc')
Source('global_event.cc')
-Source('init.cc')
+Source('init.cc', skip_no_python=True)
+Source('init_signals.cc')
Source('main.cc', main=True, skip_lib=True)
Source('root.cc')
Source('serialize.cc')
@@ -57,6 +59,7 @@ Source('sub_system.cc')
Source('ticked_object.cc')
Source('simulate.cc')
Source('stat_control.cc')
+Source('stat_register.cc', skip_no_python=True)
Source('clock_domain.cc')
Source('voltage_domain.cc')
Source('system.cc')
diff --git a/src/sim/debug.cc b/src/sim/debug.cc
index 0dd16a88d..dd504778c 100644
--- a/src/sim/debug.cc
+++ b/src/sim/debug.cc
@@ -29,8 +29,6 @@
* Steve Reinhardt
*/
-#include <Python.h>
-
#include <string>
#include <vector>
@@ -108,22 +106,6 @@ eventqDump()
}
}
-void
-py_interact()
-{
- PyObject *globals;
- PyObject *locals;
-
- globals = PyEval_GetGlobals();
- Py_INCREF(globals);
- locals = PyDict_New();
- PyRun_String("import code", Py_file_input, globals, locals);
- PyRun_String("code.interact(local=globals())", Py_file_input,
- globals, locals);
- Py_DECREF(globals);
- Py_DECREF(locals);
-}
-
int remote_gdb_base_port = 7000;
int
diff --git a/src/sim/debug.hh b/src/sim/debug.hh
index c29251a1e..fc9f0f55e 100644
--- a/src/sim/debug.hh
+++ b/src/sim/debug.hh
@@ -53,8 +53,6 @@ void takeCheckpoint(Tick when);
*/
void eventqDump();
-void py_interact();
-
int getRemoteGDBPort();
// Remote gdb base port. 0 disables remote gdb.
void setRemoteGDBPort(int port);
diff --git a/src/sim/init.cc b/src/sim/init.cc
index 042448e41..0a15c384d 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -46,7 +46,6 @@
#include <marshal.h>
#include <zlib.h>
-#include <csignal>
#include <iostream>
#include <list>
#include <string>
@@ -65,90 +64,6 @@
using namespace std;
-/// Stats signal handler.
-void
-dumpStatsHandler(int sigtype)
-{
- async_event = true;
- async_statdump = true;
-}
-
-void
-dumprstStatsHandler(int sigtype)
-{
- async_event = true;
- async_statdump = true;
- async_statreset = true;
-}
-
-/// Exit signal handler.
-void
-exitNowHandler(int sigtype)
-{
- async_event = true;
- async_exit = true;
-}
-
-/// Abort signal handler.
-void
-abortHandler(int sigtype)
-{
- ccprintf(cerr, "Program aborted at tick %d\n", curTick());
-}
-
-// Handle SIGIO
-static void
-ioHandler(int sigtype)
-{
- async_event = true;
- async_io = true;
-}
-
-static void
-installSignalHandler(int signal, void (*handler)(int sigtype))
-{
- struct sigaction sa;
-
- memset(&sa, 0, sizeof(sa));
- sigemptyset(&sa.sa_mask);
- sa.sa_handler = handler;
- sa.sa_flags = SA_RESTART;
-
- if (sigaction(signal, &sa, NULL) == -1)
- panic("Failed to setup handler for signal %i\n", signal);
-}
-
-/*
- * M5 can do several special things when various signals are sent.
- * None are mandatory.
- */
-void
-initSignals()
-{
- // Floating point exceptions may happen on misspeculated paths, so
- // ignore them
- signal(SIGFPE, SIG_IGN);
-
- // We use SIGTRAP sometimes for debugging
- signal(SIGTRAP, SIG_IGN);
-
- // Dump intermediate stats
- installSignalHandler(SIGUSR1, dumpStatsHandler);
-
- // Dump intermediate stats and reset them
- installSignalHandler(SIGUSR2, dumprstStatsHandler);
-
- // Exit cleanly on Interrupt (Ctrl-C)
- installSignalHandler(SIGINT, exitNowHandler);
-
- // Print out cycle number on abort
- installSignalHandler(SIGABRT, abortHandler);
-
- // Install a SIGIO handler to handle asynchronous file IO. See the
- // PollQueue class.
- installSignalHandler(SIGIO, ioHandler);
-}
-
// The python library is totally messed up with respect to constness,
// so make a simple macro to make life a little easier
#define PyCC(x) (const_cast<char *>(x))
diff --git a/src/sim/init.hh b/src/sim/init.hh
index 325fc8e6f..766cb4365 100644
--- a/src/sim/init.hh
+++ b/src/sim/init.hh
@@ -76,11 +76,6 @@ struct EmbeddedSwig
static void initAll();
};
-void dumpStatsHandler(int sigtype);
-void dumprstStatsHandler(int sigtype);
-void exitNowHandler(int sigtype);
-void abortHandler(int sigtype);
-void initSignals();
int initM5Python();
int m5Main(int argc, char **argv);
PyMODINIT_FUNC initm5(void);
diff --git a/src/sim/init_signals.cc b/src/sim/init_signals.cc
new file mode 100644
index 000000000..705a154e8
--- /dev/null
+++ b/src/sim/init_signals.cc
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Copyright (c) 2000-2005 The Regents of The University of Michigan
+ * Copyright (c) 2008 The Hewlett-Packard Development Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Nathan Binkert
+ */
+
+#include <csignal>
+#include <iostream>
+#include <string>
+
+#include "base/cprintf.hh"
+#include "sim/async.hh"
+#include "sim/core.hh"
+#include "sim/init_signals.hh"
+
+using namespace std;
+
+/// Stats signal handler.
+void
+dumpStatsHandler(int sigtype)
+{
+ async_event = true;
+ async_statdump = true;
+}
+
+void
+dumprstStatsHandler(int sigtype)
+{
+ async_event = true;
+ async_statdump = true;
+ async_statreset = true;
+}
+
+/// Exit signal handler.
+void
+exitNowHandler(int sigtype)
+{
+ async_event = true;
+ async_exit = true;
+}
+
+/// Abort signal handler.
+void
+abortHandler(int sigtype)
+{
+ ccprintf(cerr, "Program aborted at cycle %d\n", curTick());
+}
+
+// Handle SIGIO
+static void
+ioHandler(int sigtype)
+{
+ async_event = true;
+ async_io = true;
+}
+
+static void
+installSignalHandler(int signal, void (*handler)(int sigtype))
+{
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sigemptyset(&sa.sa_mask);
+ sa.sa_handler = handler;
+ sa.sa_flags = SA_RESTART;
+
+ if (sigaction(signal, &sa, NULL) == -1)
+ panic("Failed to setup handler for signal %i\n", signal);
+}
+
+/*
+ * M5 can do several special things when various signals are sent.
+ * None are mandatory.
+ */
+void
+initSignals()
+{
+ // Floating point exceptions may happen on misspeculated paths, so
+ // ignore them
+ signal(SIGFPE, SIG_IGN);
+
+ // We use SIGTRAP sometimes for debugging
+ signal(SIGTRAP, SIG_IGN);
+
+ // Dump intermediate stats
+ installSignalHandler(SIGUSR1, dumpStatsHandler);
+
+ // Dump intermediate stats and reset them
+ installSignalHandler(SIGUSR2, dumprstStatsHandler);
+
+ // Exit cleanly on Interrupt (Ctrl-C)
+ installSignalHandler(SIGINT, exitNowHandler);
+
+ // Print out cycle number on abort
+ installSignalHandler(SIGABRT, abortHandler);
+
+ // Install a SIGIO handler to handle asynchronous file IO. See the
+ // PollQueue class.
+ installSignalHandler(SIGIO, ioHandler);
+}
+
diff --git a/src/sim/init_signals.hh b/src/sim/init_signals.hh
new file mode 100644
index 000000000..7285f51ce
--- /dev/null
+++ b/src/sim/init_signals.hh
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2008 The Hewlett-Packard Development Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Nathan Binkert
+ */
+
+#ifndef __SIM_INIT_SIGNALS_HH__
+#define __SIM_INIT_SIGNALS_HH__
+
+void dumpStatsHandler(int sigtype);
+void dumprstStatsHandler(int sigtype);
+void exitNowHandler(int sigtype);
+void abortHandler(int sigtype);
+void initSignals();
+
+#endif // __SIM_INIT_SIGNALS_HH__
diff --git a/src/sim/main.cc b/src/sim/main.cc
index d674e0cff..48b159263 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -31,6 +31,7 @@
#include <Python.h>
#include "sim/init.hh"
+#include "sim/init_signals.hh"
// main() is now pretty stripped down and just sets up python and then
// calls initM5Python which loads the various embedded python modules
diff --git a/src/sim/py_interact.cc b/src/sim/py_interact.cc
new file mode 100644
index 000000000..7e6527e81
--- /dev/null
+++ b/src/sim/py_interact.cc
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2003-2005 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Nathan Binkert
+ * Steve Reinhardt
+ */
+
+#include <Python.h>
+
+#include "sim/py_interact.hh"
+
+void
+py_interact()
+{
+ PyObject *globals;
+ PyObject *locals;
+
+ globals = PyEval_GetGlobals();
+ Py_INCREF(globals);
+ locals = PyDict_New();
+ PyRun_String("import code", Py_file_input, globals, locals);
+ PyRun_String("code.interact(local=globals())", Py_file_input,
+ globals, locals);
+ Py_DECREF(globals);
+ Py_DECREF(locals);
+}
+
diff --git a/src/sim/py_interact.hh b/src/sim/py_interact.hh
new file mode 100644
index 000000000..bb27b4ef5
--- /dev/null
+++ b/src/sim/py_interact.hh
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2003-2005 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Nathan Binkert
+ */
+
+#ifndef __SIM_PY_INTERACT_HH__
+#define __SIM_PY_INTERACT_HH__
+
+/** @file This file provides py_interact useful for interacting with the
+ * embedded Python content in a debugger such as gdb.
+ */
+
+void py_interact();
+
+#endif // __SIM_PY_INTERACT_HH__
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index 27bf87254..99426b5a6 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -58,8 +58,6 @@
using namespace std;
-extern SimObject *resolveSimObject(const string &);
-
//
// The base implementations use to_number for parsing and '<<' for
// displaying, suitable for integer types.
@@ -600,8 +598,8 @@ Checkpoint::dir()
}
-Checkpoint::Checkpoint(const string &cpt_dir)
- : db(new IniFile), cptDir(setDir(cpt_dir))
+Checkpoint::Checkpoint(const string &cpt_dir, SimObjectResolver &resolver)
+ : db(new IniFile), objNameResolver(resolver), cptDir(setDir(cpt_dir))
{
string filename = cptDir + "/" + Checkpoint::baseFilename;
if (!db->load(filename)) {
@@ -630,7 +628,7 @@ Checkpoint::findObj(const string &section, const string &entry,
if (!db->find(section, entry, path))
return false;
- value = resolveSimObject(path);
+ value = objNameResolver.resolveSimObject(path);
return true;
}
diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index d3c9bb40b..18efa2a26 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -255,14 +255,28 @@ class SerializableClass
SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \
OBJ_CLASS::createForUnserialize);
+// Base class to wrap object resolving functionality. This can be
+// provided to Checkpoint to allow it to map object names onto
+// object C++ objects in which to unserialize
+class SimObjectResolver
+{
+ public:
+ virtual ~SimObjectResolver() { }
+
+ // Find a SimObject given a full path name
+ virtual SimObject *resolveSimObject(const std::string &name) = 0;
+};
+
class Checkpoint
{
private:
IniFile *db;
+ SimObjectResolver &objNameResolver;
+
public:
- Checkpoint(const std::string &cpt_dir);
+ Checkpoint(const std::string &cpt_dir, SimObjectResolver &resolver);
~Checkpoint();
const std::string cptDir;
diff --git a/src/sim/stat_register.cc b/src/sim/stat_register.cc
new file mode 100644
index 000000000..ef7ff8216
--- /dev/null
+++ b/src/sim/stat_register.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2014 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Andrew Bardsley
+ */
+
+#include "sim/stat_register.hh"
+
+namespace Stats
+{
+
+extern void pythonDump();
+extern void pythonReset();
+
+void registerPythonStatsHandlers()
+{
+ registerHandlers(pythonReset, pythonDump);
+}
+
+} // namespace Stats
diff --git a/src/sim/stat_register.hh b/src/sim/stat_register.hh
new file mode 100644
index 000000000..7f8c3bcd9
--- /dev/null
+++ b/src/sim/stat_register.hh
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Andrew Bardsley
+ */
+
+/* Provide a mechanism to register the Python stats reset/dump functions
+ * defined in src/swig/python/stats.i with the mechanisms in namespace
+ * Stats */
+
+#ifndef __SIM_STAT_REGISTER_H__
+#define __SIM_STAT_REGISTER_H__
+
+#include "base/statistics.hh"
+
+namespace Stats
+{
+
+/** Register py_... functions as the statistics handlers */
+void registerPythonStatsHandlers();
+
+} // namespace Stats
+
+#endif // __SIM_STAT_REGISTER_H__