help='Update test reference outputs')
AddLocalOption('--verbose', dest='verbose', action='store_true',
help='Print full tool command lines')
+AddLocalOption('--without-python', dest='without_python',
+ action='store_true',
+ help='Build without Python configuration support')
termcap = get_termcap(GetOption('use_colors'))
print 'Using build cache located at', main['M5_BUILD_CACHE']
CacheDir(main['M5_BUILD_CACHE'])
-# Find Python include and library directories for embedding the
-# interpreter. We rely on python-config to resolve the appropriate
-# includes and linker flags. ParseConfig does not seem to understand
-# the more exotic linker flags such as -Xlinker and -export-dynamic so
-# we add them explicitly below. If you want to link in an alternate
-# version of python, see above for instructions on how to invoke
-# scons with the appropriate PATH set.
-#
-# First we check if python2-config exists, else we use python-config
-python_config = readCommand(['which', 'python2-config'], exception='').strip()
-if not os.path.exists(python_config):
- python_config = readCommand(['which', 'python-config'],
+if not GetOption('without_python'):
+ # Find Python include and library directories for embedding the
+ # interpreter. We rely on python-config to resolve the appropriate
+ # includes and linker flags. ParseConfig does not seem to understand
+ # the more exotic linker flags such as -Xlinker and -export-dynamic so
+ # we add them explicitly below. If you want to link in an alternate
+ # version of python, see above for instructions on how to invoke
+ # scons with the appropriate PATH set.
+ #
+ # First we check if python2-config exists, else we use python-config
+ python_config = readCommand(['which', 'python2-config'],
exception='').strip()
-py_includes = readCommand([python_config, '--includes'],
- exception='').split()
-# Strip the -I from the include folders before adding them to the
-# CPPPATH
-main.Append(CPPPATH=map(lambda inc: inc[2:], py_includes))
-
-# Read the linker flags and split them into libraries and other link
-# flags. The libraries are added later through the call the CheckLib.
-py_ld_flags = readCommand([python_config, '--ldflags'], exception='').split()
-py_libs = []
-for lib in py_ld_flags:
- if not lib.startswith('-l'):
- main.Append(LINKFLAGS=[lib])
- else:
- lib = lib[2:]
- if lib not in py_libs:
- py_libs.append(lib)
-
-# verify that this stuff works
-if not conf.CheckHeader('Python.h', '<>'):
- print "Error: can't find Python.h header in", py_includes
- print "Install Python headers (package python-dev on Ubuntu and RedHat)"
- Exit(1)
-
-for lib in py_libs:
- if not conf.CheckLib(lib):
- print "Error: can't find library %s required by python" % lib
+ if not os.path.exists(python_config):
+ python_config = readCommand(['which', 'python-config'],
+ exception='').strip()
+ py_includes = readCommand([python_config, '--includes'],
+ exception='').split()
+ # Strip the -I from the include folders before adding them to the
+ # CPPPATH
+ main.Append(CPPPATH=map(lambda inc: inc[2:], py_includes))
+
+ # Read the linker flags and split them into libraries and other link
+ # flags. The libraries are added later through the call the CheckLib.
+ py_ld_flags = readCommand([python_config, '--ldflags'],
+ exception='').split()
+ py_libs = []
+ for lib in py_ld_flags:
+ if not lib.startswith('-l'):
+ main.Append(LINKFLAGS=[lib])
+ else:
+ lib = lib[2:]
+ if lib not in py_libs:
+ py_libs.append(lib)
+
+ # verify that this stuff works
+ if not conf.CheckHeader('Python.h', '<>'):
+ print "Error: can't find Python.h header in", py_includes
+ print "Install Python headers (package python-dev on Ubuntu and RedHat)"
Exit(1)
+ for lib in py_libs:
+ if not conf.CheckLib(lib):
+ print "Error: can't find library %s required by python" % lib
+ Exit(1)
+
# On Solaris you need to use libsocket for socket ops
if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
# false). Current filters are:
# main -- specifies the gem5 main() function
# skip_lib -- do not put this file into the gem5 library
+# skip_no_python -- do not put this file into a no_python library
+# as it embeds compiled Python
# <unittest> -- unit tests use filters based on the unit test name
#
# A parent can now be specified for a source file and default filter
def __init__(self, package, source, **guards):
'''Specify the python package, the source file, and any guards'''
- super(SwigSource, self).__init__(source, **guards)
+ super(SwigSource, self).__init__(source, skip_no_python=True, **guards)
modname,ext = self.extname
assert ext == 'i'
cc_file = joinpath(self.dirname, modname + '_wrap.cc')
py_file = joinpath(self.dirname, modname + '.py')
- self.cc_source = Source(cc_file, swig=True, parent=self)
- self.py_source = PySource(package, py_file, parent=self)
+ self.cc_source = Source(cc_file, swig=True, parent=self, **guards)
+ self.py_source = PySource(package, py_file, parent=self, **guards)
class ProtoBuf(SourceFile):
'''Add a Protocol Buffer to build'''
code.write(str(target[0]))
for source in PySource.all:
- env.Command(source.cpp, source.tnode,
+ env.Command(source.cpp, source.tnode,
MakeAction(embedPyFile, Transform("EMBED PY")))
- Source(source.cpp)
+ Source(source.cpp, skip_no_python=True)
########################################################################
#
return obj
- static_objs = \
- [ make_obj(s, True) for s in Source.get(main=False, skip_lib=False) ]
- shared_objs = \
- [ make_obj(s, False) for s in Source.get(main=False, skip_lib=False) ]
+ lib_guards = {'main': False, 'skip_lib': False}
+
+ # Without Python, leave out all SWIG and Python content from the
+ # library builds. The option doesn't affect gem5 built as a program
+ if GetOption('without_python'):
+ lib_guards['skip_no_python'] = False
+
+ static_objs = [ make_obj(s, True) for s in Source.get(**lib_guards) ]
+ shared_objs = [ make_obj(s, False) for s in Source.get(**lib_guards) ]
static_date = make_obj(date_source, static=True, extra_deps=static_objs)
static_objs.append(static_date)
-
+
shared_date = make_obj(date_source, static=False, extra_deps=shared_objs)
shared_objs.append(shared_date)
return root ? root->str() : "";
}
+Handler resetHandler = NULL;
+Handler dumpHandler = NULL;
+
+void
+registerHandlers(Handler reset_handler, Handler dump_handler)
+{
+ resetHandler = reset_handler;
+ dumpHandler = dump_handler;
+}
+
CallbackQueue dumpQueue;
CallbackQueue resetQueue;
+void
+processResetQueue()
+{
+ resetQueue.process();
+}
+
+void
+processDumpQueue()
+{
+ dumpQueue.process();
+}
+
void
registerResetCallback(Callback *cb)
{
_enabled = true;
}
+void
+dump()
+{
+ if (dumpHandler)
+ dumpHandler();
+ else
+ fatal("No registered Stats::dump handler");
+}
+
+void
+reset()
+{
+ if (resetHandler)
+ resetHandler();
+ else
+ fatal("No registered Stats::reset handler");
+}
+
void
registerDumpCallback(Callback *cb)
{
void enable();
bool enabled();
+/**
+ * Register reset and dump handlers. These are the functions which
+ * will actually perform the whole statistics reset/dump actions
+ * including processing the reset/dump callbacks
+ */
+typedef void (*Handler)();
+
+void registerHandlers(Handler reset_handler, Handler dump_handler);
+
/**
* Register a callback that should be called whenever statistics are
* reset
*/
void registerDumpCallback(Callback *cb);
+/**
+ * Process all the callbacks in the reset callbacks queue
+ */
+void processResetQueue();
+
+/**
+ * Process all the callbacks in the dump callbacks queue
+ */
+void processDumpQueue();
+
std::list<Info *> &statsList();
typedef std::map<const void *, Info *> MapType;
Import('*')
-Source('swig/pyevent.cc')
-Source('swig/pyobject.cc')
+Source('swig/pyevent.cc', skip_no_python=True)
+Source('swig/pyobject.cc', skip_no_python=True)
PySource('', 'importer.py')
PySource('m5', 'm5/__init__.py')
def initSimStats():
internal.stats.initSimStats()
+ internal.stats.registerPythonStatsHandlers()
names = []
stats_dict = {}
// these in sim/main.cc as well that are handled without this define.
#define PCC(s) const_cast<char *>(s)
+/** Single instance of PythonSimObjectResolver as its action is effectively
+ * static but SimObjectResolver can use a non-persistent object */
+PythonSimObjectResolver pythonSimObjectResolver;
SimObject *
-resolveSimObject(const string &name)
+PythonSimObjectResolver::resolveSimObject(const string &name)
{
PyObject *module = PyImport_ImportModule(PCC("m5.SimObject"));
if (module == NULL)
return obj;
}
+
+Checkpoint *
+getCheckpoint(const std::string &cpt_dir)
+{
+ return new Checkpoint(cpt_dir, pythonSimObjectResolver);
+}
#include "sim/sim_object.hh"
extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
-SimObject *resolveSimObject(const std::string &name);
+
+/** Resolve a SimObject name using the Python configuration */
+class PythonSimObjectResolver : public SimObjectResolver
+{
+ SimObject *resolveSimObject(const std::string &name);
+};
EtherInt * lookupEthPort(SimObject *so, const std::string &name, int i);
Serializable::serializeAll(cpt_dir);
}
-inline Checkpoint *
-getCheckpoint(const std::string &cpt_dir)
-{
- return new Checkpoint(cpt_dir);
-}
+Checkpoint *
+getCheckpoint(const std::string &cpt_dir);
inline void
unserializeGlobals(Checkpoint *cp)
#include "base/statistics.hh"
#include "sim/core.hh"
#include "sim/stat_control.hh"
+#include "sim/stat_register.hh"
namespace Stats {
template <class T>
info->flags = flags;
}
-inline void
-processResetQueue()
-{
- extern CallbackQueue resetQueue;
- resetQueue.process();
-}
-
-inline void
-processDumpQueue()
-{
- extern CallbackQueue dumpQueue;
- dumpQueue.process();
-}
-
inline char *
PCC(const char *string)
{
}
void
-dump()
+pythonDump()
{
call_module_function("m5.stats", "dump");
}
void
-reset()
+pythonReset()
{
call_module_function("m5.stats", "reset");
}
void initSimStats();
Output *initText(const std::string &filename, bool desc);
+void registerPythonStatsHandlers();
+
void schedStatEvent(bool dump, bool reset,
Tick when = curTick(), Tick repeat = 0);
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')
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')
* Steve Reinhardt
*/
-#include <Python.h>
-
#include <string>
#include <vector>
}
}
-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
*/
void eventqDump();
-void py_interact();
-
int getRemoteGDBPort();
// Remote gdb base port. 0 disables remote gdb.
void setRemoteGDBPort(int port);
#include <marshal.h>
#include <zlib.h>
-#include <csignal>
#include <iostream>
#include <list>
#include <string>
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))
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);
--- /dev/null
+/*
+ * 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);
+}
+
--- /dev/null
+/*
+ * 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__
#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
--- /dev/null
+/*
+ * 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);
+}
+
--- /dev/null
+/*
+ * 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__
using namespace std;
-extern SimObject *resolveSimObject(const string &);
-
//
// The base implementations use to_number for parsing and '<<' for
// displaying, suitable for integer types.
}
-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)) {
if (!db->find(section, entry, path))
return false;
- value = resolveSimObject(path);
+ value = objNameResolver.resolveSimObject(path);
return true;
}
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;
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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__