trace-cmd: Load trace-cmd plugins from build folder, if exists
PATCH 1/1 trace-cmd: Load trace-cmd plugins from build folder, if exists
When a development version of trace-cmd is built and run on the machine, by default it loads all plugins from predefined drierctories :
(install_preffix)/lib/traceevent/plugins
~/.traceevent/plugins
the path specified in TRACEEVENT_PLUGIN_DIR environment variable.
In case there is a legacy trace-cmd version already installed, there will be a collision with the development version. Wrong, incompatible plugins will be loaded. To simplify the development process, a new logic is added:
On trace-cmd build stage, the full build path is stored in the trace-cmd binary. When the application is started, it checks if this build directory exists and loads only plugins from it.
Signed-off-by Tzvetomir Stoyanov <[email protected]>
--- Makefile | 2 ++ lib/trace-cmd/trace-util.c | 10 ++++++++++ 2 files changed, 12 insertions(+)
Makefile +2 -0
@@ -207,6 +207,8 @@ LDFLAGS ?= export CFLAGS export INCLUDES +override CFLAGS += -DBUILD_PLUGIN_PATH="\"$(shell $(shell which pwd))/plugins"\" + # Required CFLAGS override CFLAGS += -D_GNU_SOURCE
lib/trace-cmd/trace-util.c +10 -0
@@ -1374,11 +1374,21 @@ int trace_util_load_plugins(struct tep_handle *pevent, const char *suffix,char *home;char *path;char *envdir; +struct stat sb;int ret;if (tracecmd_disable_plugins)return -EBUSY ; +#ifdef BUILD_PLUGIN_PATH +if (stat (BUILD_PLUGIN_PATH , &sb) ==0 &&S_ISDIR (sb.st_mode)) { +trace_util_load_plugins_dir (pevent, suffix,BUILD_PLUGIN_PATH , + load_plugin, data); +return 0 ; + } +#endif + +/* If a system plugin directory was defined, check that first */ #ifdef PLUGIN_DIR if (!tracecmd_disable_sys_plugins)
Signature · 1 line
2.20.1