@@ -2661,6 +2661,51 @@ PyObject *PyFtrace_synth(PyObject *self, PyObject *args,
return py_synth;
}
+#define SYNTH_SYS "synthetic"
+
+static bool enable_synth(PySynthEvent *self, PyObject *args, PyObject *kwargs,
+ bool enable)
+{
+ struct tracefs_instance *instance;
+
+ if (!get_instance_from_arg(args, kwargs, &instance))
+ return NULL;
+
+ return event_enable_disable(instance, SYNTH_SYS,
+ tracefs_synth_get_name(self->ptrObj),
+ enable);
+}
+
+PyObject *PySynthEvent_enable(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs)
+{
+ if (!enable_synth(self, args, kwargs, true))
+ return NULL;
+
+ Py_RETURN_NONE;
+}
+
+PyObject *PySynthEvent_disable(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs)
+{
+ if (!enable_synth(self, args, kwargs, false))
+ return NULL;
+
+ Py_RETURN_NONE;
+}
+
+PyObject *PySynthEvent_is_enabled(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs)
+{
+ struct tracefs_instance *instance;
+
+ if (!get_instance_from_arg(args, kwargs, &instance))
+ return NULL;
+
+ return event_is_enabled(instance, SYNTH_SYS,
+ tracefs_synth_get_name(self->ptrObj));
+}
+
PyObject *PyFtrace_set_ftrace_loglevel(PyObject *self, PyObject *args,
PyObject *kwargs)
{
@@ -143,6 +143,15 @@ PyObject *PySynthEvent_register(PySynthEvent *self);
PyObject *PySynthEvent_unregister(PySynthEvent *self);
+PyObject *PySynthEvent_enable(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs);
+
+PyObject *PySynthEvent_disable(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs);
+
+PyObject *PySynthEvent_is_enabled(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs);
+
PyObject *PyFtrace_dir(PyObject *self);
PyObject *PyFtrace_detach(PyObject *self, PyObject *args, PyObject *kwargs);
@@ -262,6 +262,21 @@ static PyMethodDef PySynthEvent_methods[] = {
METH_NOARGS,
"Unregister synth. event from a trace instance."
},
+ {"enable",
+ (PyCFunction) PySynthEvent_enable,
+ METH_VARARGS | METH_KEYWORDS,
+ "Enable synth. event."
+ },
+ {"disable",
+ (PyCFunction) PySynthEvent_disable,
+ METH_VARARGS | METH_KEYWORDS,
+ "Disable synth. event."
+ },
+ {"is_enabled",
+ (PyCFunction) PySynthEvent_is_enabled,
+ METH_VARARGS | METH_KEYWORDS,
+ "Check if synth. event is enabled."
+ },
{NULL, NULL, 0, NULL}
};
Here we add the following methods to the Python type for synthetic events: enable() disable() is_enabled() The 3 new APIs replicate the APIs available for kpobes. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/ftracepy-utils.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/ftracepy-utils.h | 9 +++++++++ src/ftracepy.c | 15 +++++++++++++++ 3 files changed, 69 insertions(+)