summaryrefslogtreecommitdiff
path: root/src/sim/main.cc
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-08-04 20:27:23 -0700
committerGabe Black <gblack@eecs.umich.edu>2007-08-04 20:27:23 -0700
commitcae8d20633c0f43fdae23576adfb894284a7ee86 (patch)
treee9e232684d7fc024900d8a07d6b8a3add1f52e92 /src/sim/main.cc
parent30e777a5d3829975266ecccac965d2297a5f4985 (diff)
parentdf015f17a45b18302565c43d3790d787e1b54c42 (diff)
downloadgem5-cae8d20633c0f43fdae23576adfb894284a7ee86.tar.xz
Merge with head.
--HG-- extra : convert_revision : 3edb9f03353b18b4c9f062bccf11e79cfb3c15f2
Diffstat (limited to 'src/sim/main.cc')
-rw-r--r--src/sim/main.cc38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/sim/main.cc b/src/sim/main.cc
index 5bf4add4b..62ab9445b 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -76,6 +76,39 @@ abortHandler(int sigtype)
}
int
+python_main()
+{
+ PyObject *module;
+ PyObject *dict;
+ PyObject *result;
+
+ module = PyImport_AddModule("__main__");
+ if (module == NULL)
+ fatal("Could not import __main__");
+
+ dict = PyModule_GetDict(module);
+
+ result = PyRun_String("import m5.main", Py_file_input, dict, dict);
+ if (!result) {
+ PyErr_Print();
+ return 1;
+ }
+ Py_DECREF(result);
+
+ result = PyRun_String("m5.main.main()", Py_file_input, dict, dict);
+ if (!result) {
+ PyErr_Print();
+ return 1;
+ }
+ Py_DECREF(result);
+
+ if (Py_FlushLine())
+ PyErr_Clear();
+
+ return 0;
+}
+
+int
main(int argc, char **argv)
{
signal(SIGFPE, SIG_IGN); // may occur on misspeculated paths
@@ -114,9 +147,10 @@ main(int argc, char **argv)
// initialize SWIG modules
init_swig();
- PyRun_SimpleString("import m5.main");
- PyRun_SimpleString("m5.main.main()");
+ int ret = python_main();
// clean up Python intepreter.
Py_Finalize();
+
+ return ret;
}