Remove redundant trace-cmd plugin handling logic
v4 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.
All existing plugins are moved from plugins/ to lib/traceevent/plugins directory, as all of them are designed to be used with the traceevent library.
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.
Tzvetomir Stoyanov (1):
trace-cmd: Change plugin install directories
Tzvetomir Stoyanov (VMware) (4):
trace-cmd: Move libtraceevent plugins in its own directory.
trace-cmd: Rename plugin_python to plugin_python_loader.
trace-cmd: Load libtraceevent plugins from build folder, if exists.
trace-cmd: Add initial infrastructure for trace-cmd specific plugins.
.gitignore | 3 +-
Makefile | 83 +++--
include/trace-cmd/trace-cmd.h | 43 +++
include/traceevent/event-parse.h | 3 +
lib/trace-cmd/Makefile | 3 +-
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 | 46 +++
lib/traceevent/event-plugin.c | 44 ++-
{plugins => lib/traceevent/plugins}/Makefile | 16 +-
.../traceevent/plugins}/plugin_blk.c | 0
.../traceevent/plugins}/plugin_cfg80211.c | 0
.../traceevent/plugins}/plugin_function.c | 0
.../traceevent/plugins}/plugin_futex.c | 0
.../traceevent/plugins}/plugin_hrtimer.c | 0
.../traceevent/plugins}/plugin_jbd2.c | 0
.../traceevent/plugins}/plugin_kmem.c | 0
.../traceevent/plugins}/plugin_kvm.c | 0
.../traceevent/plugins}/plugin_mac80211.c | 0
.../traceevent/plugins/plugin_python_loader.c | 0
.../traceevent/plugins}/plugin_sched_switch.c | 0
.../traceevent/plugins}/plugin_scsi.c | 0
.../traceevent/plugins}/plugin_tlb.c | 0
.../traceevent/plugins}/plugin_xen.c | 0
tracecmd/trace-check-events.c | 7 +-
tracecmd/trace-list.c | 14 +-
27 files changed, 569 insertions(+), 71 deletions(-)
create mode 100644 lib/trace-cmd/plugins/Makefile
create mode 100644 lib/trace-cmd/trace-plugin.c
rename {plugins => lib/traceevent/plugins}/Makefile (81%)
rename {plugins => lib/traceevent/plugins}/plugin_blk.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_cfg80211.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_function.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_futex.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_hrtimer.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_jbd2.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_kmem.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_kvm.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_mac80211.c (100%)
rename plugins/plugin_python.c => lib/traceevent/plugins/plugin_python_loader.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_sched_switch.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_scsi.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_tlb.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_xen.c (100%)Signature · 1 line
2.21.0
PATCH v4 1/5 trace-cmd: Move libtraceevent plugins in its own directory.
All existing plugins are moved from plugins/ to plugins/traceevent/ directory, as all of them (except plugin_python) are designed to be used with the traceevent library. This change paves the way for implementing trace-cmd specific plugins.
---
.gitignore | 2 +-
Makefile | 28 +++++++++----------
lib/trace-cmd/Makefile | 2 --
{plugins => lib/traceevent/plugins}/Makefile | 6 ++--
.../traceevent/plugins}/plugin_blk.c | 0
.../traceevent/plugins}/plugin_cfg80211.c | 0
.../traceevent/plugins}/plugin_function.c | 0
.../traceevent/plugins}/plugin_futex.c | 0
.../traceevent/plugins}/plugin_hrtimer.c | 0
.../traceevent/plugins}/plugin_jbd2.c | 0
.../traceevent/plugins}/plugin_kmem.c | 0
.../traceevent/plugins}/plugin_kvm.c | 0
.../traceevent/plugins}/plugin_mac80211.c | 0
.../traceevent/plugins}/plugin_python.c | 0
.../traceevent/plugins}/plugin_sched_switch.c | 0
.../traceevent/plugins}/plugin_scsi.c | 0
.../traceevent/plugins}/plugin_tlb.c | 0
.../traceevent/plugins}/plugin_xen.c | 0
18 files changed, 18 insertions(+), 20 deletions(-)
rename {plugins => lib/traceevent/plugins}/Makefile (93%)
rename {plugins => lib/traceevent/plugins}/plugin_blk.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_cfg80211.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_function.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_futex.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_hrtimer.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_jbd2.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_kmem.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_kvm.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_mac80211.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_python.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_sched_switch.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_scsi.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_tlb.c (100%)
rename {plugins => lib/traceevent/plugins}/plugin_xen.c (100%).gitignore +1 -1
@@ -18,5 +18,5 @@ ctracecmdgui_wrap.c tags TAGS cscope* -trace_plugin_dir +traceevent_plugin_dir trace_python_dir
Makefile +14 -14
@@ -273,16 +273,16 @@ gui: force $(CMD_TARGETS) $(kshark-dir)/build/Makefile trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) $(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@ -$(LIBTRACEEVENT_SHARED): force +$(LIBTRACEEVENT_SHARED): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(Q)$(MAKE) -C $(src)/lib/traceevent $@ -$(LIBTRACEEVENT_STATIC): force +$(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(Q)$(MAKE) -C $(src)/lib/traceevent $@ -$(LIBTRACECMD_STATIC): force $(obj)/plugins/trace_plugin_dir +$(LIBTRACECMD_STATIC): force $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ -$(LIBTRACECMD_SHARED): force $(obj)/plugins/trace_plugin_dir +$(LIBTRACECMD_SHARED): force $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ libtraceevent.so: $(LIBTRACEEVENT_SHARED)
@@ -292,14 +292,14 @@ libtracecmd.so: $(LIBTRACECMD_SHARED) libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED) -plugins: force $(obj)/plugins/trace_plugin_dir $(obj)/plugins/trace_python_dir - $(Q)$(MAKE) -C $(src)/plugins +plugins: force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(obj)/lib/traceevent/plugins/trace_python_dir + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins -$(obj)/plugins/trace_plugin_dir: force - $(Q)$(MAKE) -C $(src)/plugins $@ +$(obj)/lib/traceevent/plugins/traceevent_plugin_dir: force + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ -$(obj)/plugins/trace_python_dir: force - $(Q)$(MAKE) -C $(src)/plugins $@ +$(obj)/lib/traceevent/plugins/trace_python_dir: force + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ show_gui_make: @echo "Note: to build the gui, type \"make gui\""
@@ -325,7 +325,7 @@ cscope: force $(call find_tag_files) | cscope -b -q install_plugins: force - $(Q)$(MAKE) -C $(src)/plugins $@ + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ install_python: force $(Q)$(MAKE) -C $(src)/python $@
@@ -372,7 +372,7 @@ clean: $(RM) tags TAGS cscope* $(MAKE) -C $(src)/lib/traceevent clean $(MAKE) -C $(src)/lib/trace-cmd clean - $(MAKE) -C $(src)/plugins clean + $(MAKE) -C $(src)/lib/traceevent/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
@@ -421,8 +421,8 @@ python-gui: $(PYTHON_GUI) PHONY += python-plugin python-plugin: $(PYTHON_PLUGINS) -plugin_python.so: force $(obj)/plugins/trace_python_dir - $(Q)$(MAKE) -C $(src)/plugins $(obj)/plugins/plugin_python.so +plugin_python.so: force $(obj)/lib/traceevent/plugins/trace_python_dir + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $(obj)/lib/traceevent/plugins/plugin_python.so dist: git archive --format=tar --prefix=trace-cmd-$(TRACECMD_VERSION)/ HEAD \
lib/trace-cmd/Makefile +0 -2
@@ -40,8 +40,6 @@ $(bdir)/libtracecmd.so: $(OBJS) $(bdir)/%.o: %.c $(Q)$(call do_fpic_compile) -$(bdir)/trace-util.o: $(obj)/plugins/trace_plugin_dir - $(DEPS): $(bdir)/.%.d: %.c $(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
lib/traceevent/plugins/Makefile renamed from plugins/Makefile +3 -3
@@ -1,6 +1,6 @@ include $(src)/scripts/utils.mk -bdir:=$(obj)/plugins +bdir:=$(obj)/lib/traceevent/plugins PLUGIN_OBJS = PLUGIN_OBJS += plugin_jbd2.o
@@ -61,7 +61,7 @@ install_plugins: $(PLUGINS_INSTALL) # and $(PYTHON_DIR) change. Without them, a full clean build would necessary # in order to get the binaries updated. -$(bdir)/trace_plugin_dir: $(bdir) force +$(bdir)/traceevent_plugin_dir: $(bdir) force $(Q)$(N)$(call update_dir, 'PLUGIN_DIR=$(PLUGIN_DIR)') $(bdir)/trace_python_dir: $(bdir) force
@@ -75,7 +75,7 @@ ifneq ($(dep_includes),) endif clean: - $(RM) -f $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(bdir)/trace_plugin_dir $(bdir)/trace_python_dir + $(RM) -f $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(bdir)/traceevent_plugin_dir $(bdir)/trace_python_dir force: .PHONY: clean force
lib/traceevent/plugins/plugin_blk.c renamed from plugins/plugin_blk.c +0 -0
lib/traceevent/plugins/plugin_cfg80211.c renamed from plugins/plugin_cfg80211.c +0 -0
lib/traceevent/plugins/plugin_function.c renamed from plugins/plugin_function.c +0 -0
lib/traceevent/plugins/plugin_futex.c renamed from plugins/plugin_futex.c +0 -0
lib/traceevent/plugins/plugin_hrtimer.c renamed from plugins/plugin_hrtimer.c +0 -0
lib/traceevent/plugins/plugin_jbd2.c renamed from plugins/plugin_jbd2.c +0 -0
lib/traceevent/plugins/plugin_kmem.c renamed from plugins/plugin_kmem.c +0 -0
lib/traceevent/plugins/plugin_kvm.c renamed from plugins/plugin_kvm.c +0 -0
lib/traceevent/plugins/plugin_mac80211.c renamed from plugins/plugin_mac80211.c +0 -0
lib/traceevent/plugins/plugin_python.c renamed from plugins/plugin_python.c +0 -0
lib/traceevent/plugins/plugin_sched_switch.c renamed from plugins/plugin_sched_switch.c +0 -0
lib/traceevent/plugins/plugin_scsi.c renamed from plugins/plugin_scsi.c +0 -0
lib/traceevent/plugins/plugin_tlb.c renamed from plugins/plugin_tlb.c +0 -0
lib/traceevent/plugins/plugin_xen.c renamed from plugins/plugin_xen.c +0 -0
Signature · 1 line
2.21.0
PATCH v4 2/5 trace-cmd: Rename plugin_python to plugin_python_loader.
In reply to Tzvetomir Stoyanov (VMware)The plugin_python is renamed to plugin_python_loader, to make the name more closer to the actual plugin role.
---
Makefile | 10 +---------
lib/traceevent/plugins/Makefile | 6 +++---
.../{plugin_python.c => plugin_python_loader.c} | 0
3 files changed, 4 insertions(+), 12 deletions(-)
rename lib/traceevent/plugins/{plugin_python.c => plugin_python_loader.c} (100%)Makefile +1 -9
@@ -116,8 +116,7 @@ PYTHON_PKGCONFIG_VERS ?= $(PYTHON_VERS) # Can build python? ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_PKGCONFIG_VERS) > /dev/null 2>&1 && echo y"), y) - PYTHON_PLUGINS := plugin_python.so - BUILD_PYTHON := $(PYTHON) $(PYTHON_PLUGINS) + BUILD_PYTHON := $(PYTHON) BUILD_PYTHON_WORKS := 1 else BUILD_PYTHON := report_nopythondev
@@ -125,7 +124,6 @@ else endif endif # NO_PYTHON -export PYTHON_PLUGINS export BUILD_PYTHON_WORKS export NO_PYTHON
@@ -418,12 +416,6 @@ python: $(PYTHON) PHONY += python-gui python-gui: $(PYTHON_GUI) -PHONY += python-plugin -python-plugin: $(PYTHON_PLUGINS) - -plugin_python.so: force $(obj)/lib/traceevent/plugins/trace_python_dir - $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $(obj)/lib/traceevent/plugins/plugin_python.so - dist: git archive --format=tar --prefix=trace-cmd-$(TRACECMD_VERSION)/ HEAD \ > ../trace-cmd-$(TRACECMD_VERSION).tar
lib/traceevent/plugins/Makefile +3 -3
@@ -21,7 +21,7 @@ PLUGIN_OBJS := $(PLUGIN_OBJS:%.o=$(bdir)/%.o) PLUGIN_BUILD := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/%.so) PLUGINS := $(PLUGIN_BUILD) ifndef NO_PYTHON -PLUGINS += $(bdir)/plugin_python.so +PLUGINS += $(bdir)/plugin_python_loader.so endif DEPS := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/.%.d)
@@ -44,10 +44,10 @@ $(DEPS): $(bdir)/.%.d: %.c $(PLUGIN_OBJS): $(bdir)/%.o : $(bdir)/.%.d -$(bdir)/plugin_python.o: $(bdir)/%.o : %.c $(bdir)/trace_python_dir +$(bdir)/plugin_python_loader.o: $(bdir)/%.o : %.c $(bdir)/trace_python_dir $(Q)$(do_compile_python_plugin_obj) -$(bdir)/plugin_python.so: $(bdir)/%.so: $(bdir)/%.o +$(bdir)/plugin_python_loader.so: $(bdir)/%.so: $(bdir)/%.o $(Q)$(do_python_plugin_build) PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS))
lib/traceevent/plugins/plugin_python_loader.c renamed from lib/traceevent/plugins/plugin_python.c +0 -0
Signature · 1 line
2.21.0
PATCH v4 3/5 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 ++ include/traceevent/event-parse.h | 3 +++ lib/trace-cmd/trace-input.c | 7 +---- lib/trace-cmd/trace-util.c | 46 ++++++++++++++++++++++++++++++++ lib/traceevent/event-plugin.c | 38 ++++++++++++++++++++++++++ tracecmd/trace-check-events.c | 7 +---- tracecmd/trace-list.c | 14 ++-------- 7 files changed, 93 insertions(+), 24 deletions(-)
include/trace-cmd/trace-cmd.h +2 -0
@@ -25,6 +25,8 @@ void tracecmd_parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigneextern int tracecmd_disable_sys_plugins;extern int tracecmd_disable_plugins; +struct tep_plugin_list *trace_load_tep_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);
include/traceevent/event-parse.h +3 -0
@@ -380,6 +380,9 @@ struct tep_plugin_list;#define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1))struct tep_plugin_list *tep_load_plugins (struct tep_handle *tep); +struct tep_plugin_list *tep_load_plugins_dir (struct tep_handle *tep,char *path); +void tep_plugins_append (struct tep_plugin_list *list1, +struct tep_plugin_list *list2);void tep_unload_plugins (struct tep_plugin_list *plugin_list,struct tep_handle *tep); void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix,
lib/trace-cmd/trace-input.c +1 -6
@@ -2850,15 +2850,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_tep_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 +46 -0
52 lines not on this page · raw message
lib/traceevent/event-plugin.c +38 -0
@@ -599,6 +599,44 @@ tep_load_plugins(struct tep_handle *tep)return list; } +/** +* tep_load_plugins_dir - load traceevent plugins from a directory +* @tep: Trace event handler. +* @path: Path to a directory. All files with extension .so in that +* directory will be loaded as plugins. +* +* Returns a list of loaded plugins +*/ +struct tep_plugin_list * +tep_load_plugins_dir (struct tep_handle *tep,char *path) +{ +struct tep_plugin_list *list =NULL ; + +if (tep && tep->flags &TEP_DISABLE_PLUGINS ) +return NULL ; + +load_plugins_dir (tep,".so" , path, load_plugin, &list); +return list; +} + +/** +* tep_plugins_append - Concatenate two plugin lists. +* @list1: The first plugin list. +* @list2: The second plugin list. +* +* The second plugin list (list2) is appended to the first one (list1). +*/ +void tep_plugins_append (struct tep_plugin_list *list1, +struct tep_plugin_list *list2) +{ +struct tep_plugin_list *list = list1; + +while (list && list->next) + list = list->next; +if (list) + list->next = list2; +} +void tep_unload_plugins (struct tep_plugin_list *plugin_list,struct tep_handle *tep) {
tracecmd/trace-check-events.c +1 -6
@@ -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_tep_plugins (pevent); ret =tracecmd_fill_local_events (tracing, pevent, &parsing_failures);if (ret || parsing_failures) ret =EINVAL ;
tracecmd/trace-list.c +2 -12
@@ -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_tep_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_tep_plugins (pevent);tep_print_plugins (&s," " ,"\n" , list);trace_seq_do_printf (&s);
Signature · 1 line
2.21.0
Re: [PATCH v4 3/5] trace-cmd: Load libtraceevent plugins from build folder, if exists.
Quoted 4 lines · On Fri, 4 Oct 2019 16:36:45 +0300 "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:
Quoted 8 lines
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.
We should probably break this patch up into two. One that adds the new interface to libtraceevent (making it easier to send to upstream libtraceevent), and then one that uses it in trace-cmd.
And we should probably update the man pages when adding the tep_*() patches. That said, I have some comments about this.
Quoted 43 lines
Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>lib/trace-cmd/trace-util.c +31
-0@@ -884,6 +884,52 @@ 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_tep_plugins (struct tep_handle *tep) +{ +struct tep_plugin_list *list_dev; +struct tep_plugin_list *list; +char *path; + +if (tracecmd_disable_plugins) +tep_set_flag (tep,TEP_DISABLE_PLUGINS ); +if (tracecmd_disable_sys_plugins)
lib/trace-cmd/trace-util.c void trace_util_free_plugin_files(char **files) · line 927
Quoted 10 lines
lib/trace-cmd/trace-util.c +10
-0+tep_set_flag (tep,TEP_DISABLE_SYS_PLUGINS ); + + list =tep_load_plugins (tep); + + path =get_source_plugins_dir (); +if (path) { + list_dev =tep_load_plugins_dir (tep, path); +tep_plugins_append (list_dev, list); + list = list_dev; +free (path);
I think it would be better to be able to add paths to the tep, and then call "tep_load_plugins()". That is:
path = get_source_plugins_dir(); if (path) tep_add_plugin_path(tep, path); list = tep_load_plugins(tep);
And have the tep_load_plugins() do all the work, and not have a tep_plugins_append(). That append function is exposing too much of the implementation of the tep code.
-- Steve
Quoted 9 lines
lib/trace-cmd/trace-util.c +5
-0+ } + +return list; +} +char *tracecmd_get_tracing_file (const char *name) {static const char *tracing;
PATCH v4 4/5 trace-cmd: Change plugin install directories
In reply to Tzvetomir Stoyanov (VMware)From: Tzvetomir Stoyanov <[email protected]>
To be compliant with XDG user directory layout, the user's plugin directory is changed from ~/.traceevent/plugins to ~/.local/lib/traceevent/plugins/
Thanks to Patrick McLean:
https://lore.kernel.org/linux-trace-devel/20190313144206.41e75cf8@patrickm/
The system plugin directory is changed from (install_prefix)/lib/trace-cmd/plugins to (install_prefix)/lib/traceevent/plugins This change paves the way for implementing trace-cmd specific plugins.
--- Makefile | 16 ++++++++-------- lib/traceevent/event-plugin.c | 6 +++--- lib/traceevent/plugins/Makefile | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-)
Makefile +8 -8
@@ -56,15 +56,15 @@ export img_install img_install_SQ export DESTDIR DESTDIR_SQ ifeq ($(prefix),$(HOME)) -plugin_dir = $(HOME)/.trace-cmd/plugins +plugin_traceevent_dir = $(HOME)/.local/lib/traceevent/plugins python_dir = $(HOME)/.trace-cmd/python var_dir = $(HOME)/.trace-cmd/ else -plugin_dir = $(libdir)/trace-cmd/plugins +plugin_traceevent_dir = $(libdir)/traceevent/plugins python_dir ?= $(libdir)/trace-cmd/python -PLUGIN_DIR = -DPLUGIN_DIR="$(plugin_dir)" +PLUGIN_DIR_TRACEEVENT = -DPLUGIN_TRACEEVENT_DIR="$(plugin_traceevent_dir)" PYTHON_DIR = -DPYTHON_DIR="$(python_dir)" -PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))' +PLUGIN_DIR_TRACEEVENT_SQ = '$(subst ','\'',$(PLUGIN_DIR_TRACEEVENT))' PYTHON_DIR_SQ = '$(subst ','\'',$(PYTHON_DIR))' var_dir = /var endif
@@ -72,7 +72,7 @@ endif # Shell quotes bindir_SQ = $(subst ','\'',$(bindir)) bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) -plugin_dir_SQ = $(subst ','\'',$(plugin_dir)) +plugin_traceevent_dir_SQ = $(subst ','\'',$(plugin_traceevent_dir)) python_dir_SQ = $(subst ','\'',$(python_dir)) VAR_DIR = -DVAR_DIR="$(var_dir)"
@@ -85,10 +85,10 @@ HELP_DIR_SQ = '$(subst ','\'',$(HELP_DIR))' BASH_COMPLETE_DIR ?= /etc/bash_completion.d -export PLUGIN_DIR +export PLUGIN_DIR_TRACEEVENT export PYTHON_DIR export PYTHON_DIR_SQ -export plugin_dir_SQ +export plugin_traceevent_dir_SQ export python_dir_SQ export var_dir
@@ -239,7 +239,7 @@ LIBS += -laudit endif # Append required CFLAGS -override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR) +override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_TRACEEVENT_SQ) $(VAR_DIR) override CFLAGS += $(udis86-flags) $(blk-flags) override LDFLAGS += $(udis86-ldflags)
lib/traceevent/event-plugin.c +3 -3
@@ -19,7 +19,7 @@#include "event-utils.h" #include "trace-seq.h" -#define LOCAL_PLUGIN_DIR ".traceevent/plugins" +#define LOCAL_PLUGIN_DIR ".local/lib/traceevent/plugins/" static struct registered_plugin_options { struct registered_plugin_options *next;
@@ -557,9 +557,9 @@ void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix,* If a system plugin directory was defined, * check that first. */ -#ifdef PLUGIN_DIR +#ifdef PLUGIN_TRACEEVENT_DIR if (!tep || !(tep->flags &TEP_DISABLE_SYS_PLUGINS )) -load_plugins_dir (tep, suffix,PLUGIN_DIR , +load_plugins_dir (tep, suffix,PLUGIN_TRACEEVENT_DIR , load_plugin, data);#endif
lib/traceevent/plugins/Makefile +2 -2
@@ -53,11 +53,11 @@ $(bdir)/plugin_python_loader.so: $(bdir)/%.so: $(bdir)/%.o PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(PLUGINS_INSTALL): $(bdir)/%.install : $(bdir)/%.so force - $(Q)$(call do_install_data,$<,$(plugin_dir_SQ)) + $(Q)$(call do_install_data,$<,$(plugin_traceevent_dir_SQ)) install_plugins: $(PLUGINS_INSTALL) -# The following targets are necessary to trigger a rebuild when $(PLUGIN_DIR) +# The following targets are necessary to trigger a rebuild when $(PLUGIN_DIR_TRACEEVENT) # and $(PYTHON_DIR) change. Without them, a full clean build would necessary # in order to get the binaries updated.
Signature · 1 line
2.21.0
PATCH v4 5/5 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 | 43 ++++- include/trace-cmd/trace-cmd.h | 41 +++++ lib/trace-cmd/Makefile | 1 + lib/trace-cmd/plugins/Makefile | 58 ++++++ lib/trace-cmd/trace-plugin.c | 313 +++++++++++++++++++++++++++++++++ 6 files changed, 448 insertions(+), 9 deletions(-) create mode 100644 lib/trace-cmd/plugins/Makefile create mode 100644 lib/trace-cmd/trace-plugin.c
.gitignore +1 -0
@@ -20,3 +20,4 @@ TAGS cscope* traceevent_plugin_dir trace_python_dir +tracecmd_plugin_dir
Makefile +34 -9
109 lines not on this page · raw message
include/trace-cmd/trace-cmd.h +41 -0
47 lines not on this page · raw message
lib/trace-cmd/Makefile +1 -0
@@ -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
Quoted 15 lines · On Fri, 4 Oct 2019 16:36:42 +0300 "Tzvetomir Stoyanov (VMware)"…
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.
All existing plugins are moved from plugins/ to
lib/traceevent/pluginsdirectory, as all of them are designed to be used with the traceevent library.An initial infrastructure for trace-cmd specific plugins is added - new
lib/trace-cmd/pluginsdirectory and an initial set of APIs for working with trace-cmd plugins.
Quoted 10 lines
Tzvetomir Stoyanov (1):
trace-cmd: Change plugin install directoriesTzvetomir Stoyanov (VMware) (4):
trace-cmd: Move libtraceevent plugins in its own directory.
trace-cmd: Renameplugin_pythontoplugin_python_loader.
trace-cmd: Load libtraceevent plugins from build folder, if exists.
trace-cmd: Add initial infrastructure for trace-cmd specific plugins.
Hi Tzvetomir,
Not sure if you noticed, but I pulled in parts of this patch series as they were not dependent on the patches is question.
I'll take a look at the patches not yet in the series.
Thanks!
-- Steve
Quoted 30 lines · Steven Rostedt
Quoted 15 lines · On Fri, 4 Oct 2019 16:36:42 +0300 "Tzvetomir Stoyanov (VMware)"…
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.
All existing plugins are moved from plugins/ to
lib/traceevent/pluginsdirectory, as all of them are designed to be used with the traceevent library.An initial infrastructure for trace-cmd specific plugins is added - new
lib/trace-cmd/pluginsdirectory and an initial set of APIs for working with trace-cmd plugins.Quoted 10 lines
Tzvetomir Stoyanov (1):
trace-cmd: Change plugin install directoriesTzvetomir Stoyanov (VMware) (4):
trace-cmd: Move libtraceevent plugins in its own directory.
trace-cmd: Renameplugin_pythontoplugin_python_loader.
trace-cmd: Load libtraceevent plugins from build folder, if exists.
trace-cmd: Add initial infrastructure for trace-cmd specific plugins.
Quoted 7 lines
Hi Tzvetomir,
Not sure if you noticed, but I pulled in parts of this patch series as they were not dependent on the patches is question.
I'll take a look at the patches not yet in the series.
I just noticed it, going to rebase and send the next version of the series today.
Quoted 3 lines
Thanks!
-- Steve
Signature · 2 lines
Tzvetomir (Ceco) Stoyanov VMware Open Source Technology Center