From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 07/10] trace-cruncher: APIs for filtering synth. events
Date: Mon, 24 Jan 2022 10:56:22 +0200 [thread overview]
Message-ID: <20220124085625.92297-8-y.karadz@gmail.com> (raw)
In-Reply-To: <20220124085625.92297-1-y.karadz@gmail.com>
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(+)
diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c
index af73784..43c0f07 100644
--- a/src/ftracepy-utils.c
+++ b/src/ftracepy-utils.c
@@ -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)
{
diff --git a/src/ftracepy-utils.h b/src/ftracepy-utils.h
index daf1a19..f31b330 100644
--- a/src/ftracepy-utils.h
+++ b/src/ftracepy-utils.h
@@ -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);
diff --git a/src/ftracepy.c b/src/ftracepy.c
index 62c6de0..50675c0 100644
--- a/src/ftracepy.c
+++ b/src/ftracepy.c
@@ -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}
};
--
2.32.0
next prev parent reply other threads:[~2022-01-24 8:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 8:56 [PATCH 00/10] trace-cruncher: Synthetic events Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 01/10] trace-cruncher: Define Python type for synthetic events Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 02/10] trace-cruncher: APIs for adding start/end fields to synth. event Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 03/10] trace-cruncher: APIs for adding arithmetic fields to synth. events Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 04/10] trace-cruncher: APIs for registering/unregistering " Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 05/10] trace-cruncher: APIs for enabling " Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 06/10] trace-cryncher: Add static methods for manipulating filters Yordan Karadzhov (VMware)
2022-01-24 8:56 ` Yordan Karadzhov (VMware) [this message]
2022-01-24 8:56 ` [PATCH 08/10] trace-cruncher: API to show descriptor of the synth. event Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 09/10] trace-cruncher: Add synthetic event example Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 10/10] trace-cruncher: Add synth. events tests Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220124085625.92297-8-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).