From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: y.karadz@gmail.com
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v2 1/2] trace-cruncher: Add support for event probes
Date: Thu, 27 Jan 2022 08:09:53 +0200 [thread overview]
Message-ID: <20220127060954.22927-2-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20220127060954.22927-1-tz.stoyanov@gmail.com>
Event probe (eprobe) is a new type of ftrace dynamic events, introduced
in the Linux kernel 5.15 version. It is useful to have support for it in
trace-cruncher, as it allows more flexibility when printing event's
data.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
src/ftracepy-utils.c | 32 ++++++++++++++++++++++++++++++++
src/ftracepy-utils.h | 2 ++
src/ftracepy.c | 5 +++++
3 files changed, 39 insertions(+)
diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c
index 8c46590..053b659 100644
--- a/src/ftracepy-utils.c
+++ b/src/ftracepy-utils.c
@@ -2315,6 +2315,38 @@ struct tep_event *dynevent_get_event(PyDynevent *event,
return tep_evt;
}
+PyObject *PyFtrace_eprobe(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = {"event", "target_system", "target_event", "fetchargs", NULL};
+ const char *event, *target_system, *target_event, *fetchargs;
+ struct tracefs_dynevent *eprobe;
+
+ if (!PyArg_ParseTupleAndKeywords(args,
+ kwargs,
+ "ssss",
+ kwlist,
+ &event,
+ &target_system,
+ &target_event,
+ &fetchargs)) {
+ return NULL;
+ }
+
+ eprobe = tracefs_eprobe_alloc(TC_SYS, event, target_system, target_event, fetchargs);
+ if (!eprobe) {
+ MEM_ERROR;
+ return NULL;
+ }
+
+ if (tracefs_dynevent_create(eprobe) < 0) {
+ TfsError_fmt(NULL, "Failed to create eprobe '%s'", event);
+ tracefs_dynevent_free(eprobe);
+ return NULL;
+ }
+
+ return PyDynevent_New(eprobe);
+}
+
static PyObject *set_filter(PyObject *args, PyObject *kwargs,
struct tep_handle *tep,
struct tep_event *event)
diff --git a/src/ftracepy-utils.h b/src/ftracepy-utils.h
index 7612df6..c96fd85 100644
--- a/src/ftracepy-utils.h
+++ b/src/ftracepy-utils.h
@@ -251,6 +251,8 @@ PyObject *PyFtrace_register_kprobe(PyObject *self, PyObject *args,
PyObject *PyFtrace_register_kretprobe(PyObject *self, PyObject *args,
PyObject *kwargs);
+PyObject *PyFtrace_eprobe(PyObject *self, PyObject *args, PyObject *kwargs);
+
PyObject *PyFtrace_hist(PyObject *self, PyObject *args,
PyObject *kwargs);
diff --git a/src/ftracepy.c b/src/ftracepy.c
index 3f71b5e..0c9f795 100644
--- a/src/ftracepy.c
+++ b/src/ftracepy.c
@@ -460,6 +460,11 @@ static PyMethodDef ftracepy_methods[] = {
METH_VARARGS | METH_KEYWORDS,
"Define a kretprobe."
},
+ {"register_eprobe",
+ (PyCFunction) PyFtrace_eprobe,
+ METH_VARARGS | METH_KEYWORDS,
+ "Define an eprobe."
+ },
{"hist",
(PyCFunction) PyFtrace_hist,
METH_VARARGS | METH_KEYWORDS,
--
2.34.1
next prev parent reply other threads:[~2022-01-27 6:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 6:09 [PATCH v2 0/2] trace-cruncher: Add support for event probes Tzvetomir Stoyanov (VMware)
2022-01-27 6:09 ` Tzvetomir Stoyanov (VMware) [this message]
2022-01-27 6:09 ` [PATCH v2 2/2] trace-cruncher: Unit test for event probes API Tzvetomir Stoyanov (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=20220127060954.22927-2-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=y.karadz@gmail.com \
/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).