commit e75f80d759f42a24f564952dd393568c5a83b529
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Fri Jan 13 19:05:53 2012 -0500
allow registration of callbacks on gcc.PLUGIN_GGC_{START,MARKING,FINISH}
gcc-python-callbacks.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/gcc-python-callbacks.c b/gcc-python-callbacks.c
index c7296e4..d4bca14 100644
--- a/gcc-python-callbacks.c
+++ b/gcc-python-callbacks.c
@@ -253,6 +253,41 @@ gcc_python_callback_for_FINISH_UNIT(void *gcc_data, void *user_data)
user_data);
}
+static void
+gcc_python_callback_for_GGC_START(void *gcc_data, void *user_data)
+{
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+
+ gcc_python_finish_invoking_callback(gstate,
+ 0, NULL,
+ user_data);
+}
+
+static void
+gcc_python_callback_for_GGC_MARKING(void *gcc_data, void *user_data)
+{
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+
+ gcc_python_finish_invoking_callback(gstate,
+ 0, NULL,
+ user_data);
+}
+
+static void
+gcc_python_callback_for_GGC_END(void *gcc_data, void *user_data)
+{
+ PyGILState_STATE gstate;
+
+ gstate = PyGILState_Ensure();
+
+ gcc_python_finish_invoking_callback(gstate,
+ 0, NULL,
+ user_data);
+}
PyObject*
@@ -318,6 +353,25 @@ gcc_python_register_callback(PyObject *self, PyObject *args, PyObject *kwargs)
closure);
break;
+ case PLUGIN_GGC_START:
+ register_callback("python", // FIXME
+ (enum plugin_event)event,
+ gcc_python_callback_for_GGC_START,
+ closure);
+ break;
+ case PLUGIN_GGC_MARKING:
+ register_callback("python", // FIXME
+ (enum plugin_event)event,
+ gcc_python_callback_for_GGC_MARKING,
+ closure);
+ break;
+ case PLUGIN_GGC_END:
+ register_callback("python", // FIXME
+ (enum plugin_event)event,
+ gcc_python_callback_for_GGC_END,
+ closure);
+ break;
+
default:
PyErr_Format(PyExc_ValueError, "event type %i invalid (or not wired up yet)", event);
return NULL;