When gem5 is a slave to another simulator and the Python is only used
to initialize the configuration (and not perform actual simulation), a
"debug start" (--debug-start) event will get freed during or immediately
after the initial Python frame's execution rather than remaining in the
event queue. This tricky patch fixes the GC issue causing this.
}
}
+%typemap(out) PythonEvent* {
+ result->object = $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PythonEvent, SWIG_POINTER_NEW);
+}
+
%ignore EventQueue::schedule;
%ignore EventQueue::deschedule;
#include "sim/async.hh"
#include "sim/eventq.hh"
-PythonEvent::PythonEvent(PyObject *obj, Priority priority)
- : Event(priority), object(obj)
+PythonEvent::PythonEvent(PyObject *code, Priority priority)
+ : Event(priority), eventCode(code)
{
- if (object == NULL)
+ if (code == NULL)
panic("Passed in invalid object");
}
PythonEvent::process()
{
PyObject *args = PyTuple_New(0);
- PyObject *result = PyObject_Call(object, args, NULL);
+ PyObject *result = PyObject_Call(eventCode, args, NULL);
Py_DECREF(args);
if (result) {
class PythonEvent : public Event
{
private:
- PyObject *object;
-
+ PyObject *eventCode; // PyObject to call to perform event
public:
+ PyObject *object; // PyObject wrapping this PythonEvent
+
PythonEvent(PyObject *obj, Event::Priority priority);
~PythonEvent();