main: return an an exit code of 1 when we exit due to a python exception.
This requires us to not use PyRun_SimpleString, but PyRun_String since the latter actually returns a result --HG-- extra : convert_revision : 3e3916ddd7eef9957569d8e72e73ba4c3160ce20
This commit is contained in:
@@ -75,6 +75,39 @@ abortHandler(int sigtype)
|
||||
ccprintf(cerr, "Program aborted at cycle %d\n", curTick);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user