From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org, y.karadz@gmail.com
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v7 13/15] libtracefs: Introduce eprobe API
Date: Mon, 15 Nov 2021 12:45:54 +0200 [thread overview]
Message-ID: <20211115104556.121359-14-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20211115104556.121359-1-tz.stoyanov@gmail.com>
Recently a new type of dynamic trace events was added in the Linux
kernel - event probes. Tracefs library should have APIs to work with
that event. As this is a dynamic event, all tracefs_dynevent_* APIs can
be used to control event probes. Only one new API is proposed:
tracefs_eprobe_alloc()
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
include/tracefs.h | 4 ++++
src/Makefile | 1 +
src/tracefs-eprobes.c | 56 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+)
create mode 100644 src/tracefs-eprobes.c
diff --git a/include/tracefs.h b/include/tracefs.h
index 7b3f92b..4431ec7 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -261,6 +261,10 @@ enum tracefs_dynevent_type
tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system,
char **event, char **prefix, char **addr, char **format);
+struct tracefs_dynevent *
+tracefs_eprobe_alloc(const char *system, const char *event,
+ const char *target_system, const char *target_event, const char *fetchargs);
+
struct tracefs_dynevent *
tracefs_kprobe_alloc(const char *system, const char *event, const char *addr, const char *format);
struct tracefs_dynevent *
diff --git a/src/Makefile b/src/Makefile
index 99cd7da..cda0a0c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -12,6 +12,7 @@ OBJS += tracefs-kprobes.o
OBJS += tracefs-hist.o
OBJS += tracefs-filter.o
OBJS += tracefs-dynevents.o
+OBJS += tracefs-eprobes.o
# Order matters for the the three below
OBJS += sqlhist-lex.o
diff --git a/src/tracefs-eprobes.c b/src/tracefs-eprobes.c
new file mode 100644
index 0000000..cc25f8e
--- /dev/null
+++ b/src/tracefs-eprobes.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: LGPL-2.1
+/*
+ * Copyright (C) 2021, VMware, Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
+ *
+ */
+#include <stdlib.h>
+#include <errno.h>
+
+#include "tracefs.h"
+#include "tracefs-local.h"
+
+#define EPROBE_DEFAULT_GROUP "eprobes"
+
+/**
+ * tracefs_eprobe_alloc - Allocate new eprobe
+ * @system: The system name (NULL for the default eprobes)
+ * @event: The name of the event to create
+ * @target_system: The system of the target event
+ * @target_event: The name of the target event
+ * @fetchargs: String with arguments, that will be fetched from @target_event
+ *
+ * Allocate an eprobe context that will be in the @system group (or eprobes if
+ * @system is NULL). Have the name of @event. The new eprobe will be attached to
+ * given @target_event which is in the given @target_system. The arguments
+ * described in @fetchargs will fetched from the @target_event.
+ *
+ * The eprobe is not created in the system.
+ *
+ * Return a pointer to a eprobe context on success, or NULL on error.
+ * The returned pointer must be freed with tracefs_dynevent_free()
+ *
+ */
+struct tracefs_dynevent *
+tracefs_eprobe_alloc(const char *system, const char *event,
+ const char *target_system, const char *target_event, const char *fetchargs)
+{
+ struct tracefs_dynevent *kp;
+ char *target;
+
+ if (!event || !target_system || !target_event) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (!system)
+ system = EPROBE_DEFAULT_GROUP;
+
+ if (asprintf(&target, "%s.%s", target_system, target_event) < 0)
+ return NULL;
+
+ kp = dynevent_alloc(TRACEFS_DYNEVENT_EPROBE, system, event, target, fetchargs);
+ free(target);
+
+ return kp;
+}
+
--
2.33.1
next prev parent reply other threads:[~2021-11-15 10:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 10:45 [PATCH v7 00/15] libtracefs dynamic events support Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 01/15] libtracefs: New APIs for dynamic events Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 02/15] libtracefs: New APIs for kprobe allocation Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 03/15] libtracefs: Remove redundant kprobes APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 04/15] libtracefs: Reimplement kprobe raw APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 05/15] libtracefs: Extend kprobes unit test Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 06/15] libtracefs: Rename tracefs_synth_init API Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 07/15] libtracefs: Use the internal dynamic events API when creating synthetic events Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 08/15] libtracefs: Remove instance parameter from synthetic events APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 09/15] libtracefs: Add unit test for synthetic events Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 10/15] libtracefs: Update kprobes man pages Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 11/15] libtracefs: Document dynamic events APIs Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 12/15] libtracefs: Do not clean sqlhist man page source Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` Tzvetomir Stoyanov (VMware) [this message]
2021-11-15 10:45 ` [PATCH v7 14/15] libtracefs: Add utest for event probes Tzvetomir Stoyanov (VMware)
2021-11-15 10:45 ` [PATCH v7 15/15] libtracefs: Document eprobe 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=20211115104556.121359-14-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.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).