Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/49412 )

Change subject: sim: Eliminate m5MainCommands and simplify calling m5.main.
......................................................................

sim: Eliminate m5MainCommands and simplify calling m5.main.

m5MainCommands had been a way to override the python code which would
get the python side of gem5 started, used by some "unit" tests which
were really tests of all of gem5 but focus on a particular area. Those
tests have either been converted into real unit tests or eliminated,
and so that mechanism is no longer needed.

This change eliminates that mechanism, and also uses pybind11 to
significantly simplify the code that calls m5.main().

Change-Id: I553ae17074cd5389708f1b7313630a13a6946d76
---
M src/sim/init.cc
1 file changed, 1 insertion(+), 32 deletions(-)



diff --git a/src/sim/init.cc b/src/sim/init.cc
index 589d2f0..5e04e3c 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -215,16 +215,6 @@
 }

 /*
- * Make the commands array weak so that they can be overridden (used
- * by unit tests to specify a different python main function.
- */
-GEM5_WEAK const char *m5MainCommands[] = {
-    "import m5",
-    "m5.main()",
-    0 // sentinel is required
-};
-
-/*
  * Start up the M5 simulator.  This mostly vectors into the python
  * main function.
  */
@@ -253,28 +243,7 @@

     PySys_SetArgv(argc, argv);

-    // We have to set things up in the special __main__ module
-    PyObject *module = PyImport_AddModule(PyCC("__main__"));
-    if (module == NULL)
-        panic("Could not import __main__");
-    PyObject *dict = PyModule_GetDict(module);
-
-    // import the main m5 module
-    PyObject *result;
-    const char **command = m5MainCommands;
-
-    // evaluate each command in the m5MainCommands array (basically a
-    // bunch of python statements.
-    while (*command) {
-        result = PyRun_String(*command, Py_file_input, dict, dict);
-        if (!result) {
-            PyErr_Print();
-            return 1;
-        }
-        Py_DECREF(result);
-
-        command++;
-    }
+    py::module_::import("m5").attr("main")();

 #if HAVE_PROTOBUF
     google::protobuf::ShutdownProtobufLibrary();

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49412
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I553ae17074cd5389708f1b7313630a13a6946d76
Gerrit-Change-Number: 49412
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to