@@ -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 *
@@ -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
new file mode 100644
@@ -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;
+}
+
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