Skip to contentSkip to conversation

Remove redundant trace-cmd plugin handling logic

PATCH In review Tzvetomir Stoyanov (VMware) 2 participants 6 messages Oct 7, 2019 – Dec 2, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

v6 cover Remove redundant trace-cmd plugin handling logic

Currently there are no trace-cmd related plugins, all of them are designed to be used with libtraceeevnt. As both libtraceevent and trace-cmd have logic for managing plugins, the one in trace-cmd is redundant. Those redundant code is removed and replaced with calls to libtraceeevnt plugin APIs. When trace-cmd has to load any plugins, it uses libtraceeevnt to do the job.

A new libtraceevent API is introduced, which can be used to define custom plugin directories. It is used by trace-cmd to load development plugins, if any.

An initial infrastructure for trace-cmd specific plugins is added - new lib/trace-cmd/plugins directory and an initial set of APIs for working with trace-cmd plugins.

[
v6 changes:
- Introduced new libtraceevent API for adding custom plugin directories.

v5 changes:
- Removed accepted patches from the patch set.
- Moved logic which loads traceevent development plugins from libtraceevent to trace-cmd application.
]

Tzvetomir Stoyanov (VMware) (3):
trace-cmd: Introduced new traceevent API, for adding new plugins
directories.
trace-cmd: Load libtraceevent plugins from build folder, if exists.
trace-cmd: Add initial infrastructure for trace-cmd specific plugins.

 .gitignore                         |   1 +
 Makefile                           |  40 +++-
 include/trace-cmd/trace-cmd.h      |  42 ++++
 include/traceevent/event-parse.h   |   7 +
 lib/trace-cmd/Makefile             |   1 +
 lib/trace-cmd/plugins/Makefile     |  58 ++++++
 lib/trace-cmd/trace-input.c        |   7 +-
 lib/trace-cmd/trace-plugin.c       | 313 +++++++++++++++++++++++++++++
 lib/trace-cmd/trace-util.c         |  42 ++++
 lib/traceevent/event-parse-local.h |   5 +-
 lib/traceevent/event-parse.c       |   1 +
 lib/traceevent/event-plugin.c      |  70 +++++++
 tracecmd/trace-check-events.c      |   7 +-
 tracecmd/trace-list.c              |  14 +-
 14 files changed, 575 insertions(+), 33 deletions(-)
 create mode 100644 lib/trace-cmd/plugins/Makefile
 create mode 100644 lib/trace-cmd/trace-plugin.c
Signature · 1 line
2.21.0
#1 lore raw

PATCH v6 1/3 trace-cmd: Introduced new traceevent API, for adding new plugins directories.

Implement new traceevent plugin API, which can be used to add new plugins directories:
enum tep_plugin_load_priority {
TEP_PLUGIN_FIRST,
TEP_PLUGIN_LAST,
};
int tep_add_plugin_path(struct tep_handle *tep, char *path,

			enum tep_plugin_load_priority prio);

It adds the "path" as new plugin directory, in the context of the handler "tep". The tep_load_plugins() API searches for plugins in this new location. Depending of the priority "prio", the plugins from this directory are loaded before (TEP_PLUGIN_FIRST) or after (TEP_PLUGIN_LAST) the ordinary libtraceevent plugin locations.

---
 include/traceevent/event-parse.h   |  7 +++
 lib/traceevent/event-parse-local.h |  5 ++-
 lib/traceevent/event-parse.c       |  1 +
 lib/traceevent/event-plugin.c      | 70 ++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 1 deletion(-)
include/traceevent/event-parse.h +7 -0
index 5dff952..d66647b 100644
@@ -379,6 +379,13 @@ struct tep_plugin_list;
 
 #define INVALID_PLUGIN_LIST_OPTION	((char **)((unsigned long)-1))
 
+enum tep_plugin_load_priority {
+	TEP_PLUGIN_FIRST,
+	TEP_PLUGIN_LAST,
+};
+
+int tep_add_plugin_path(struct tep_handle *tep, char *path,
+			enum tep_plugin_load_priority prio);
 struct tep_plugin_list *tep_load_plugins(struct tep_handle *tep);
 void tep_unload_plugins(struct tep_plugin_list *plugin_list,
 			struct tep_handle *tep);
lib/traceevent/event-parse-local.h +4 -1
index 6e58ee1..abaeadf 100644
@@ -13,6 +13,7 @@ struct func_map;
 struct func_list;
 struct event_handler;
 struct func_resolver;
+struct tep_plugins_dir;
 
 struct tep_handle {
 	int ref_count;
@@ -47,7 +48,6 @@ struct tep_handle {
 	struct printk_list *printklist;
 	unsigned int printk_count;
 
-
 	struct tep_event **events;
 	int nr_events;
 	struct tep_event **sort_events;
@@ -83,10 +83,13 @@ struct tep_handle {
 	struct tep_event *last_event;
 
 	char *trace_clock;
+
+	struct tep_plugins_dir *plugins_dir;
 };
 
 void tep_free_event(struct tep_event *event);
 void tep_free_format_field(struct tep_format_field *field);
+void tep_free_plugin_paths(struct tep_handle *tep);
 
 unsigned short tep_data2host2(struct tep_handle *tep, unsigned short data);
 unsigned int tep_data2host4(struct tep_handle *tep, unsigned int data);
lib/traceevent/event-parse.c +1 -0
index 7fbbbcc..b92e52c 100644
@@ -7063,6 +7063,7 @@ void tep_free(struct tep_handle *tep)
 	free(tep->events);
 	free(tep->sort_events);
 	free(tep->func_resolver);
+	tep_free_plugin_paths(tep);
 
 	free(tep);
 }
lib/traceevent/event-plugin.c +70 -0

100 lines not on this page · raw message

Signature · 1 line
2.21.0
#2 lore raw

PATCH v6 2/3 trace-cmd: Load libtraceevent plugins from build folder, if exists.

In reply to Tzvetomir Stoyanov (VMware)

When a development version of trace-cmd is built and run on the machine, by default it loads only installed plugins, from system directories. Thus, the development plugins will not be loaded. To simplify the development process, a new logic is added:
At plugins load time, check the location of trace-cmd application and look for "plugins" directory around it. If found, load plugins from it. Those plugins will be loaded last, so in case of duplication the "development" plugins win.
A two new APIs are introduced to libtraceevent, in order to accomplish this logic:
tep_load_plugins_dir() - loads tep plugins from a specific directory. tep_plugins_append() - Append two plugin lists.

---
 include/trace-cmd/trace-cmd.h |  2 ++
 lib/trace-cmd/trace-input.c   |  7 +-----
 lib/trace-cmd/trace-util.c    | 42 +++++++++++++++++++++++++++++++++++
 tracecmd/trace-check-events.c |  7 +-----
 tracecmd/trace-list.c         | 14 ++----------
 5 files changed, 48 insertions(+), 24 deletions(-)
include/trace-cmd/trace-cmd.h +2 -0
index 4090eba..d1aaef8 100644
@@ -24,6 +24,8 @@ void tracecmd_parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigne
 extern int tracecmd_disable_sys_plugins;
 extern int tracecmd_disable_plugins;
 
+struct tep_plugin_list *trace_load_plugins(struct tep_handle *tep);
+
 char **tracecmd_event_systems(const char *tracing_dir);
 char **tracecmd_system_events(const char *tracing_dir, const char *system);
 struct tep_handle *tracecmd_local_events(const char *tracing_dir);
lib/trace-cmd/trace-input.c +1 -6
index 6102eb3..28da455 100644
@@ -2886,15 +2886,10 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd)
 	if (!handle->pevent)
 		goto failed_read;
 
-	if (tracecmd_disable_plugins)
-		tep_set_flag(handle->pevent, TEP_DISABLE_PLUGINS);
-	if (tracecmd_disable_sys_plugins)
-		tep_set_flag(handle->pevent, TEP_DISABLE_SYS_PLUGINS);
-
 	/* register default ftrace functions first */
 	tracecmd_ftrace_overrides(handle, &handle->finfo);
 
-	handle->plugin_list = tep_load_plugins(handle->pevent);
+	handle->plugin_list = trace_load_plugins(handle->pevent);
 
 	tep_set_file_bigendian(handle->pevent, buf[0]);
 	tep_set_local_bigendian(handle->pevent, tracecmd_host_bigendian());
lib/trace-cmd/trace-util.c +42 -0

48 lines not on this page · raw message

tracecmd/trace-check-events.c +1 -6
index b09fcd0..ffaae27 100644
@@ -43,12 +43,7 @@ void trace_check_events(int argc, char **argv)
 	if (!pevent)
 		exit(EINVAL);
 
-	if (tracecmd_disable_plugins)
-		tep_set_flag(pevent, TEP_DISABLE_PLUGINS);
-	if (tracecmd_disable_sys_plugins)
-		tep_set_flag(pevent, TEP_DISABLE_SYS_PLUGINS);
-
-	list = tep_load_plugins(pevent);
+	list = trace_load_plugins(pevent);
 	ret = tracecmd_fill_local_events(tracing, pevent, &parsing_failures);
 	if (ret || parsing_failures)
 		ret = EINVAL;
tracecmd/trace-list.c +2 -12
index 65099a5..6b59117 100644
@@ -317,14 +317,9 @@ static void show_plugin_options(void)
 	if (!pevent)
 		die("Can not allocate pevent\n");
 
-	if (tracecmd_disable_plugins)
-		tep_set_flag(pevent, TEP_DISABLE_PLUGINS);
-	if (tracecmd_disable_sys_plugins)
-		tep_set_flag(pevent, TEP_DISABLE_SYS_PLUGINS);
-
 	trace_seq_init(&s);
 
-	list = tep_load_plugins(pevent);
+	list = trace_load_plugins(pevent);
 	tep_plugin_print_options(&s);
 	trace_seq_do_printf(&s);
 	tep_unload_plugins(list, pevent);
@@ -348,14 +343,9 @@ static void show_plugins(void)
 	if (!pevent)
 		die("Can not allocate pevent\n");
 
-	if (tracecmd_disable_plugins)
-		tep_set_flag(pevent, TEP_DISABLE_PLUGINS);
-	if (tracecmd_disable_sys_plugins)
-		tep_set_flag(pevent, TEP_DISABLE_SYS_PLUGINS);
-
 	trace_seq_init(&s);
 
-	list = tep_load_plugins(pevent);
+	list = trace_load_plugins(pevent);
 	tep_print_plugins(&s, "  ", "\n", list);
 
 	trace_seq_do_printf(&s);
Signature · 1 line
2.21.0
#3 lore raw

Re: [PATCH v6 2/3] trace-cmd: Load libtraceevent plugins from build folder, if exists.

Ping.

I think this will be useful in avoiding problems like
https://bugzilla.kernel.org/show_bug.cgi?id=205643

Signature · 6 lines
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center



On Mon, Oct 7, 2019 at 2:49 PM Tzvetomir Stoyanov (VMware)
Quoted 165 lines · <[email protected]> wrote:

When a development version of trace-cmd is built and run on the machine, by default it loads only installed plugins, from system directories. Thus, the development plugins will not be loaded. To simplify the development process, a new logic is added:
At plugins load time, check the location of trace-cmd application and look for "plugins" directory around it. If found, load plugins from it. Those plugins will be loaded last, so in case of duplication the "development" plugins win.
A two new APIs are introduced to libtraceevent, in order to accomplish this logic:
tep_load_plugins_dir() - loads tep plugins from a specific directory. tep_plugins_append() - Append two plugin lists.

---
 include/trace-cmd/trace-cmd.h |  2 ++
 lib/trace-cmd/trace-input.c   |  7 +-----
 lib/trace-cmd/trace-util.c    | 42 +++++++++++++++++++++++++++++++++++
 tracecmd/trace-check-events.c |  7 +-----
 tracecmd/trace-list.c         | 14 ++----------
 5 files changed, 48 insertions(+), 24 deletions(-)
include/trace-cmd/trace-cmd.h +2 -0
index 4090eba..d1aaef8 100644
@@ -24,6 +24,8 @@ void tracecmd_parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigne
 extern int tracecmd_disable_sys_plugins;
 extern int tracecmd_disable_plugins;
 
+struct tep_plugin_list *trace_load_plugins(struct tep_handle *tep);
+
 char **tracecmd_event_systems(const char *tracing_dir);
 char **tracecmd_system_events(const char *tracing_dir, const char *system);
 struct tep_handle *tracecmd_local_events(const char *tracing_dir);
lib/trace-cmd/trace-input.c +1 -6
index 6102eb3..28da455 100644
@@ -2886,15 +2886,10 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd)
        if (!handle->pevent)
                goto failed_read;
 
-       if (tracecmd_disable_plugins)
-               tep_set_flag(handle->pevent, TEP_DISABLE_PLUGINS);
-       if (tracecmd_disable_sys_plugins)
-               tep_set_flag(handle->pevent, TEP_DISABLE_SYS_PLUGINS);
-
        /* register default ftrace functions first */
        tracecmd_ftrace_overrides(handle, &handle->finfo);
 
-       handle->plugin_list = tep_load_plugins(handle->pevent);
+       handle->plugin_list = trace_load_plugins(handle->pevent);
 
        tep_set_file_bigendian(handle->pevent, buf[0]);
        tep_set_local_bigendian(handle->pevent, tracecmd_host_bigendian());
lib/trace-cmd/trace-util.c +42 -0
index 8aa3b6c..690a135 100644
@@ -860,6 +860,48 @@ void trace_util_free_plugin_files(char **files)
        free(files);
 }
 
+static char *get_source_plugins_dir(void)
+{
+       char *p, path[PATH_MAX+1];
+       int ret;
+
+       ret = readlink("/proc/self/exe", path, PATH_MAX);
+       if (ret > PATH_MAX || ret < 0)
+               return NULL;
+
+       dirname(path);
+       p = strrchr(path, '/');
+       if (!p)
+               return NULL;
+       /* Check if we are in the the source tree */
+       if (strcmp(p, "/tracecmd") != 0)
+               return NULL;
+
+       strcpy(p, "/lib/traceevent/plugins");
+       return strdup(path);
+}
+
+struct tep_plugin_list*
+trace_load_plugins(struct tep_handle *tep)
+{
+       struct tep_plugin_list *list;
+       char *path;
+
+       if (tracecmd_disable_plugins)
+               tep_set_flag(tep, TEP_DISABLE_PLUGINS);
+       if (tracecmd_disable_sys_plugins)
+               tep_set_flag(tep, TEP_DISABLE_SYS_PLUGINS);
+
+       path = get_source_plugins_dir();
+       if (path)
+               tep_add_plugin_path(tep, path, TEP_PLUGIN_LAST);
+       free(path);
+
+       list = tep_load_plugins(tep);
+
+       return list;
+}
+
 char *tracecmd_get_tracing_file(const char *name)
 {
        static const char *tracing;
tracecmd/trace-check-events.c +1 -6
index b09fcd0..ffaae27 100644
@@ -43,12 +43,7 @@ void trace_check_events(int argc, char **argv)
        if (!pevent)
                exit(EINVAL);
 
-       if (tracecmd_disable_plugins)
-               tep_set_flag(pevent, TEP_DISABLE_PLUGINS);
-       if (tracecmd_disable_sys_plugins)
-               tep_set_flag(pevent, TEP_DISABLE_SYS_PLUGINS);
-
-       list = tep_load_plugins(pevent);
+       list = trace_load_plugins(pevent);
        ret = tracecmd_fill_local_events(tracing, pevent, &parsing_failures);
        if (ret || parsing_failures)
                ret = EINVAL;
tracecmd/trace-list.c +2 -13
index 65099a5..6b59117 100644
@@ -317,14 +317,9 @@ static void show_plugin_options(void)
        if (!pevent)
                die("Can not allocate pevent\n");
 
-       if (tracecmd_disable_plugins)
-               tep_set_flag(pevent, TEP_DISABLE_PLUGINS);
-       if (tracecmd_disable_sys_plugins)
-               tep_set_flag(pevent, TEP_DISABLE_SYS_PLUGINS);
-
        trace_seq_init(&s);
 
-       list = tep_load_plugins(pevent);
+       list = trace_load_plugins(pevent);
        tep_plugin_print_options(&s);
        trace_seq_do_printf(&s);
        tep_unload_plugins(list, pevent);
@@ -348,14 +343,9 @@ static void show_plugins(void)
        if (!pevent)
                die("Can not allocate pevent\n");
 
-       if (tracecmd_disable_plugins)
-               tep_set_flag(pevent, TEP_DISABLE_PLUGINS);
-       if (tracecmd_disable_sys_plugins)
-               tep_set_flag(pevent, TEP_DISABLE_SYS_PLUGINS);
-
        trace_seq_init(&s);
 
-       list = tep_load_plugins(pevent);
+       list = trace_load_plugins(pevent);
        tep_print_plugins(&s, "  ", "\n", list);
 
        trace_seq_do_printf(&s);
--
Quoted 2 lines

2.21.0

--
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

#5 lore raw

PATCH v6 3/3 trace-cmd: Add initial infrastructure for trace-cmd specific plugins.

In reply to Tzvetomir Stoyanov (VMware)

Create a new directory lib/trace-cmd/plugins, where the libtracecmd plugins will be placed. Plugins compilation is integrated in
the trace-cmd build process. New plugins are installed in $(HOME)/.local/lib/trace-cmd/plugins or $(libdir)/trace-cmd/plugins directories. Current python_plugin.so is part of libtraceevent plugins, so the python plugins path is changed from
$(HOME)/.trace-cmd/python to $(HOME)/.local/lib/traceevent/python and
$(libdir)/trace-cmd/python to $(libdir)/traceevent/python

Added an initial set of APIs for working with trace-cmd plugins.

---
 .gitignore                     |   1 +
 Makefile                       |  40 ++++-
 include/trace-cmd/trace-cmd.h  |  40 +++++
 lib/trace-cmd/Makefile         |   1 +
 lib/trace-cmd/plugins/Makefile |  58 ++++++
 lib/trace-cmd/trace-plugin.c   | 313 +++++++++++++++++++++++++++++++++
 6 files changed, 445 insertions(+), 8 deletions(-)
 create mode 100644 lib/trace-cmd/plugins/Makefile
 create mode 100644 lib/trace-cmd/trace-plugin.c
.gitignore +1 -0
index 20bb5a3..6759e51 100644
@@ -20,3 +20,4 @@ TAGS
 cscope*
 traceevent_plugin_dir
 trace_python_dir
+tracecmd_plugin_dir
Makefile +32 -8
index bbdf15e..ab76f1f 100644
@@ -57,14 +57,17 @@ export DESTDIR DESTDIR_SQ
 
 ifeq ($(prefix),$(HOME))
 plugin_traceevent_dir = $(HOME)/.local/lib/traceevent/plugins
-python_dir = $(HOME)/.trace-cmd/python
+plugin_tracecmd_dir = $(libdir)/trace-cmd/plugins
+python_dir ?= $(libdir)/traceevent/python
 var_dir = $(HOME)/.trace-cmd/
 else
 plugin_traceevent_dir = $(libdir)/traceevent/plugins
 python_dir ?= $(libdir)/trace-cmd/python
 PLUGIN_DIR_TRACEEVENT = -DPLUGIN_TRACEEVENT_DIR="$(plugin_traceevent_dir)"
+PLUGIN_DIR_TRACECMD = -DPLUGIN_TRACECMD_DIR="$(plugin_tracecmd_dir)"
 PYTHON_DIR = -DPYTHON_DIR="$(python_dir)"
 PLUGIN_DIR_TRACEEVENT_SQ = '$(subst ','\'',$(PLUGIN_DIR_TRACEEVENT))'
+PLUGIN_DIR_TRACECMD_SQ = '$(subst ','\'',$(PLUGIN_DIR_TRACECMD))'
 PYTHON_DIR_SQ = '$(subst ','\'',$(PYTHON_DIR))'
 var_dir = /var
 endif
@@ -73,6 +76,7 @@ endif
 bindir_SQ = $(subst ','\'',$(bindir))
 bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
 plugin_traceevent_dir_SQ = $(subst ','\'',$(plugin_traceevent_dir))
+plugin_tracecmd_dir_SQ = $(subst ','\'',$(plugin_tracecmd_dir))
 python_dir_SQ = $(subst ','\'',$(python_dir))
 
 VAR_DIR = -DVAR_DIR="$(var_dir)"
@@ -86,9 +90,11 @@ HELP_DIR_SQ = '$(subst ','\'',$(HELP_DIR))'
 BASH_COMPLETE_DIR ?= /etc/bash_completion.d
 
 export PLUGIN_DIR_TRACEEVENT
+export PLUGIN_DIR_TRACECMD
 export PYTHON_DIR
 export PYTHON_DIR_SQ
 export plugin_traceevent_dir_SQ
+export plugin_tracecmd_dir_SQ
 export python_dir_SQ
 export var_dir
 
@@ -239,7 +245,8 @@ LIBS += -laudit
 endif
 
 # Append required CFLAGS
-override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_TRACEEVENT_SQ) $(VAR_DIR)
+override CFLAGS += $(INCLUDES) $(VAR_DIR)
+override CFLAGS += $(PLUGIN_DIR_TRACEEVENT_SQ) $(PLUGIN_DIR_TRACECMD_SQ)
 override CFLAGS += $(udis86-flags) $(blk-flags)
 override LDFLAGS += $(udis86-ldflags)
 
@@ -268,13 +275,16 @@ gui: force $(CMD_TARGETS) $(kshark-dir)/build/Makefile
 	@echo "gui build complete"
 	@echo "  kernelshark located at $(kshark-dir)/bin"
 
-trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC)
+trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) \
+	force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir
 	$(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@
 
-$(LIBTRACEEVENT_SHARED): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir
+$(LIBTRACEEVENT_SHARED): force $(obj)/lib/traceevent/plugins/trace_python_dir \
+			 $(obj)/lib/traceevent/plugins/traceevent_plugin_dir
 	$(Q)$(MAKE) -C $(src)/lib/traceevent $@
 
-$(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir
+$(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/trace_python_dir \
+			 $(obj)/lib/traceevent/plugins/traceevent_plugin_dir
 	$(Q)$(MAKE) -C $(src)/lib/traceevent $@
 
 $(LIBTRACECMD_STATIC): force
@@ -290,12 +300,21 @@ libtracecmd.so: $(LIBTRACECMD_SHARED)
 
 libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED)
 
-plugins: force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(obj)/lib/traceevent/plugins/trace_python_dir
+plugins_traceevent: force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir \
+		   $(obj)/lib/traceevent/plugins/trace_python_dir
 	$(Q)$(MAKE) -C $(src)/lib/traceevent/plugins
 
+plugins_tracecmd: force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir
+	$(Q)$(MAKE) -C $(src)/lib/trace-cmd/plugins
+
+plugins: plugins_traceevent plugins_tracecmd
+
 $(obj)/lib/traceevent/plugins/traceevent_plugin_dir: force
 	$(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@
 
+$(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir: force
+	$(Q)$(MAKE) -C $(src)/lib/trace-cmd/plugins $@
+
 $(obj)/lib/traceevent/plugins/trace_python_dir: force
 	$(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@
 
@@ -322,8 +341,12 @@ cscope: force
 	$(RM) cscope*
 	$(call find_tag_files) | cscope -b -q
 
-install_plugins: force
-	$(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@
+install_plugins_traceevent: force
+	$(Q)$(MAKE) -C $(src)/lib/traceevent/plugins install_plugins
+install_plugins_tracecmd: force
+	$(Q)$(MAKE) -C $(src)/lib/trace-cmd/plugins install_plugins
+
+install_plugins: install_plugins_traceevent install_plugins_tracecmd
 
 install_python: force
 	$(Q)$(MAKE) -C $(src)/python $@
@@ -371,6 +394,7 @@ clean:
 	$(MAKE) -C $(src)/lib/traceevent clean
 	$(MAKE) -C $(src)/lib/trace-cmd clean
 	$(MAKE) -C $(src)/lib/traceevent/plugins clean
+	$(MAKE) -C $(src)/lib/trace-cmd/plugins clean
 	$(MAKE) -C $(src)/python clean
 	$(MAKE) -C $(src)/tracecmd clean
 	if [ -f $(kshark-dir)/build/Makefile ]; then $(MAKE) -C $(kshark-dir)/build clean; fi
include/trace-cmd/trace-cmd.h +40 -0
index d1aaef8..092a80c 100644
@@ -54,6 +54,46 @@ struct tracecmd_output;
 struct tracecmd_recorder;
 struct hook_list;
 
+/* --- tracecmd plugins --- */
+
+extern int tracecmd_disable_sys_plugins;
+extern int tracecmd_disable_plugins;
+
+enum tracecmd_context {
+	TRACECMD_INPUT,
+	TRACECMD_OUTPUT,
+};
+
+enum tracecmd_plugin_flag {
+	TRACECMD_DISABLE_SYS_PLUGINS	= 1,
+	TRACECMD_DISABLE_PLUGINS	= 1 << 1,
+};
+
+struct trace_plugin_context;
+
+struct trace_plugin_context *
+tracecmd_plugin_context_create(enum tracecmd_context context, void *data);
+
+void tracecmd_plugin_set_flag(struct trace_plugin_context *context,
+			      enum tracecmd_plugin_flag flag);
+
+#define TRACECMD_PLUGIN_LOADER tracecmd_plugin_loader
+#define TRACECMD_PLUGIN_UNLOADER tracecmd_plugin_unloader
+#define TRACECMD_PLUGIN_ALIAS tracecmd_plugin_alias
+#define _MAKE_STR(x)	#x
+#define MAKE_STR(x)	_MAKE_STR(x)
+#define TRACECMD_PLUGIN_LOADER_NAME MAKE_STR(TRACECMD_PLUGIN_LOADER)
+#define TRACECMD_PLUGIN_UNLOADER_NAME MAKE_STR(TRACECMD_PLUGIN_UNLOADER)
+#define TRACECMD_PLUGIN_ALIAS_NAME MAKE_STR(TRACECMD_PLUGIN_ALIAS)
+
+typedef int (*tracecmd_plugin_load_func)(struct trace_plugin_context *trace);
+typedef int (*tracecmd_plugin_unload_func)(struct trace_plugin_context *trace);
+
+struct tracecmd_input *
+tracecmd_plugin_context_input(struct trace_plugin_context *trace_context);
+struct tracecmd_output *
+tracecmd_plugin_context_output(struct trace_plugin_context *trace_context);
+
 void tracecmd_set_quiet(struct tracecmd_output *handle, bool set_quiet);
 bool tracecmd_get_quiet(struct tracecmd_output *handle);
 
lib/trace-cmd/Makefile +1 -0
index 3b4b5aa..6f3e6b1 100644
@@ -15,6 +15,7 @@ OBJS += trace-recorder.o
 OBJS += trace-util.o
 OBJS += trace-filter-hash.o
 OBJS += trace-msg.o
+OBJS += trace-plugin.o
 
 # Additional util objects
 OBJS += trace-blk-hack.o
lib/trace-cmd/plugins/Makefile new file +58 -0

58 lines not on this page · raw message

lib/trace-cmd/trace-plugin.c new file +313 -0

313 lines not on this page · raw message

Signature · 1 line
2.21.0