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 05/10] trace-cruncher: APIs for enabling synth. events
Date: Mon, 24 Jan 2022 10:56:20 +0200 [thread overview]
Message-ID: <20220124085625.92297-6-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:
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(+)
diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c
index 244bff9..8a0c3c3 100644
--- a/src/ftracepy-utils.c
+++ b/src/ftracepy-utils.c
@@ -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)
{
diff --git a/src/ftracepy-utils.h b/src/ftracepy-utils.h
index 40b41d8..daf1a19 100644
--- a/src/ftracepy-utils.h
+++ b/src/ftracepy-utils.h
@@ -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);
diff --git a/src/ftracepy.c b/src/ftracepy.c
index 0314aa1..62c6de0 100644
--- a/src/ftracepy.c
+++ b/src/ftracepy.c
@@ -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}
};
--
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 ` Yordan Karadzhov (VMware) [this message]
2022-01-24 8:56 ` [PATCH 06/10] trace-cryncher: Add static methods for manipulating filters Yordan Karadzhov (VMware)
2022-01-24 8:56 ` [PATCH 07/10] trace-cruncher: APIs for filtering synth. events Yordan Karadzhov (VMware)
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-6-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).