@@ -2739,6 +2739,62 @@ PyObject *PySynthEvent_is_enabled(PySynthEvent *self, PyObject *args,
tracefs_synth_get_name(self->ptrObj));
}
+struct tep_event *synth_get_event(PySynthEvent *event, struct tep_handle **tep_ptr)
+{
+ struct tep_event *tep_evt;
+ struct tep_handle *tep;
+
+ tep = get_tep(NULL, NULL);
+ if (!tep)
+ return NULL;
+
+ tep_evt = tracefs_synth_get_event(tep, event->ptrObj);
+ if (!tep_evt) {
+ TfsError_setstr(NULL, "Failed to get synth. event.");
+ return NULL;
+ }
+
+ if (tep_ptr)
+ *tep_ptr = tep;
+
+ return tep_evt;
+}
+
+PyObject *PySynthEvent_set_filter(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs)
+{
+ struct tep_handle *tep;
+ struct tep_event *evt;
+
+ evt = synth_get_event(self, &tep);
+ if (!evt)
+ return NULL;
+
+ return set_filter(args, kwargs, tep, evt);
+}
+
+PyObject *PySynthEvent_get_filter(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs)
+{
+ struct tep_event *evt = synth_get_event(self, NULL);
+
+ if (!evt)
+ return NULL;
+
+ return get_filter(args, kwargs, SYNTH_SYS, evt->name);
+}
+
+PyObject *PySynthEvent_clear_filter(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs)
+{
+ struct tep_event *evt = synth_get_event(self, NULL);
+
+ if (!evt)
+ return NULL;
+
+ return clear_filter(args, kwargs, evt);
+}
+
PyObject *PyFtrace_set_ftrace_loglevel(PyObject *self, PyObject *args,
PyObject *kwargs)
{
@@ -152,6 +152,15 @@ PyObject *PySynthEvent_disable(PySynthEvent *self, PyObject *args,
PyObject *PySynthEvent_is_enabled(PySynthEvent *self, PyObject *args,
PyObject *kwargs);
+PyObject *PySynthEvent_set_filter(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs);
+
+PyObject *PySynthEvent_get_filter(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs);
+
+PyObject *PySynthEvent_clear_filter(PySynthEvent *self, PyObject *args,
+ PyObject *kwargs);
+
PyObject *PyFtrace_dir(PyObject *self);
PyObject *PyFtrace_detach(PyObject *self, PyObject *args, PyObject *kwargs);
@@ -277,6 +277,21 @@ static PyMethodDef PySynthEvent_methods[] = {
METH_VARARGS | METH_KEYWORDS,
"Check if synth. event is enabled."
},
+ {"set_filter",
+ (PyCFunction) PySynthEvent_set_filter,
+ METH_VARARGS | METH_KEYWORDS,
+ "Define a filter for a synthetic event."
+ },
+ {"get_filter",
+ (PyCFunction) PySynthEvent_get_filter,
+ METH_VARARGS | METH_KEYWORDS,
+ "Get the filter of a synthetic event."
+ },
+ {"clear_filter",
+ (PyCFunction) PySynthEvent_clear_filter,
+ METH_VARARGS | METH_KEYWORDS,
+ "Clear the filter of a synthetic event."
+ },
{NULL, NULL, 0, NULL}
};
Here we add the following methods to the Python type for synthetic events: set_filter() get_filter() clear_filter() The new APIs allow for easy manipulation of the filters associated with a given synthetic event. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/ftracepy-utils.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ src/ftracepy-utils.h | 9 +++++++ src/ftracepy.c | 15 ++++++++++++ 3 files changed, 80 insertions(+)